summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js35
1 files changed, 21 insertions, 14 deletions
diff --git a/index.js b/index.js
index 1d8caf8..0ef539a 100644
--- a/index.js
+++ b/index.js
@@ -7,25 +7,33 @@ const {
uninject
} = require('powercord/injector');
const { lookup } = require('./tz');
-
+const {
+ PLUGIN_ID,
+ SETTINGS_INDEV_VERSION,
+ INJECTION_ID_MESSAGE_RENDER,
+ SETTINGS_TIMEZONE
+} = require('./constants');
const { transformMessageArray } = require('./transformation.jsx');
-const PLUGIN_ID = 'timezone-powercord';
-const INJECTION_ID_MESSAGE_RENDER = PLUGIN_ID + '-message-render';
-
const MessageContent = getModule((m) => m.type && m.type.displayName === 'MessageContent', false);
-
module.exports = class TimezonePowercord extends Plugin {
async startPlugin () {
- inject(INJECTION_ID_MESSAGE_RENDER, MessageContent, 'type', (args) => {
- return transformMessageArray(
- () => lookup(this.settings.get('timezone', 'GMT')))(args);
- }, true);
- powercord.api.notices.sendAnnouncement('timezone-request-tz', {
- color: 'green',
- message: 'Timezone Powercord Plugin has been loaded.'
- });
+ inject(INJECTION_ID_MESSAGE_RENDER, MessageContent, 'type',
+ transformMessageArray(() => lookup(this.settings.get(SETTINGS_TIMEZONE, 'GMT'))), true);
+
+ if (this.settings.get(SETTINGS_INDEV_VERSION, '0') !== manifest.version) {
+ powercord.api.notices.sendAnnouncement('timezone-request-tz', {
+ color: 'green',
+ message: 'This version of Timezone Powercord Plugin is still in development.',
+ button: {
+ text: 'Don\'t show again.',
+ onClick: async () => {
+ this.settings.set(SETTINGS_INDEV_VERSION, manifest.version);
+ }
+ }
+ });
+ }
powercord.api.settings.registerSettings(PLUGIN_ID, {
category: this.entityID,
label: 'Timezone Powercord Plugin',
@@ -37,5 +45,4 @@ module.exports = class TimezonePowercord extends Plugin {
uninject(INJECTION_ID_MESSAGE_RENDER);
powercord.api.settings.unregisterSettings(this.entityID);
}
-
};