add some comments and consistent structure
This commit is contained in:
parent
62b7679408
commit
6a5f185c80
|
@ -15,15 +15,21 @@ const twelveHour = new RegExp(`([0-9]{1,2}):([0-9]{1,2})\\s(AM|PM)`);
|
|||
|
||||
export default new class TwentyFourHour extends BuiltinModule {
|
||||
|
||||
get settingPath() { return ['ui', 'default', '24-hour'] }
|
||||
/* Getters */
|
||||
get moduleName() { return 'TwentyFourHour' }
|
||||
|
||||
get settingPath() { return ['ui', 'default', '24-hour'] }
|
||||
|
||||
/* Patches */
|
||||
applyPatches() {
|
||||
if (this.patches.length) return;
|
||||
const { TimeFormatter } = Reflection.modules;
|
||||
this.patch(TimeFormatter, 'calendarFormat', this.convertTimeStamps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert 12 hours timestamps to 24 hour timestamps
|
||||
*/
|
||||
convertTimeStamps(that, args, returnValue) {
|
||||
const matched = returnValue.match(twelveHour);
|
||||
if (!matched || matched.length !== 4) return;
|
||||
|
|
|
@ -13,9 +13,11 @@ import { Reflection } from 'modules';
|
|||
|
||||
export default new class BlockedMessages extends BuiltinModule {
|
||||
|
||||
get settingPath() { return ['ui', 'default', 'blocked-messages'] }
|
||||
/* Getters */
|
||||
get moduleName() { return 'BlockedMessages' }
|
||||
|
||||
get settingPath() { return ['ui', 'default', 'blocked-messages'] }
|
||||
|
||||
async enabled(e) {
|
||||
const MessageListComponents = Reflection.module.byProps('BlockedMessageGroup');
|
||||
MessageListComponents.OriginalBlockedMessageGroup = MessageListComponents.BlockedMessageGroup;
|
||||
|
@ -30,17 +32,22 @@ export default new class BlockedMessages extends BuiltinModule {
|
|||
if (this.cancelBlockedMessages) this.cancelBlockedMessages();
|
||||
}
|
||||
|
||||
/* Methods */
|
||||
static isBlocked(id) {
|
||||
const { RelationshipStore } = Reflection.modules;
|
||||
return RelationshipStore.isBlocked(id);
|
||||
}
|
||||
|
||||
/* Patches */
|
||||
applyPatches() {
|
||||
if (this.patches.length) return;
|
||||
const { MessageActions } = Reflection.modules;
|
||||
this.patch(MessageActions, 'receiveMessage', this.processMessage, 'instead');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore blocked messages completely
|
||||
*/
|
||||
processMessage(that, args, originalFunction) {
|
||||
if (args[1] && args[1].author && args[1].author.id && BlockedMessages.isBlocked(args[1].author.id)) return;
|
||||
return originalFunction(...args);
|
||||
|
|
|
@ -15,6 +15,7 @@ import { Settings, Patcher, MonkeyPatch, Reflection, ReactComponents, DiscordApi
|
|||
|
||||
export default new class ColoredText extends BuiltinModule {
|
||||
|
||||
/* Getters */
|
||||
get moduleName() { return 'ColoredText' }
|
||||
|
||||
get settingPath() { return ['ui', 'default', 'colored-text'] }
|
||||
|
@ -41,10 +42,12 @@ export default new class ColoredText extends BuiltinModule {
|
|||
this.intensitySetting.off('setting-updated', this._intensityUpdated);
|
||||
}
|
||||
|
||||
/* Methods */
|
||||
_intensityUpdated() {
|
||||
this.MessageContent.forceUpdateAll();
|
||||
}
|
||||
|
||||
/* Patches */
|
||||
async applyPatches() {
|
||||
if (this.patches.length) return;
|
||||
this.MessageContent = await ReactComponents.getComponent('MessageContent', { selector: Reflection.resolve('container', 'containerCozy', 'containerCompact', 'edited').selector });
|
||||
|
@ -52,6 +55,9 @@ export default new class ColoredText extends BuiltinModule {
|
|||
this.MessageContent.forceUpdateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set markup text colour to match role colour
|
||||
*/
|
||||
injectColoredText(thisObject, args, returnValue) {
|
||||
const { TinyColor } = Reflection.modules;
|
||||
const markup = Utils.findInReactTree(returnValue, m => m && m.props && m.props.className && m.props.className.includes('da-markup'));
|
||||
|
|
Loading…
Reference in New Issue