Skip to content

Commit

Permalink
feat: ✨ control over notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
coldenate committed Apr 30, 2023
1 parent 52202e0 commit dc9beed
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/widgets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ async function onActivate(plugin: ReactRNPlugin) {
defaultValue: false,
});

await plugin.settings.registerBooleanSetting({
id: 'notifs',
title: 'Should RemCord show notifications?',
defaultValue: true,
});

await plugin.settings.registerBooleanSetting({
id: 'idle-check',
title: 'Should RemCord check for idle?',
Expand Down Expand Up @@ -218,26 +224,28 @@ async function onActivate(plugin: ReactRNPlugin) {
await pullSettings();

// Show a toast notification to the user.
await plugin.app.toast(
`RemCord v${pluginVersion} Loaded!\nRemCord Helper ${await getHelperVersion()}`
);

if (Math.floor(Math.random() * 7) === 0) {
await plugin.app.toast('Fun Fact: You can disable these notifications in settings!');
}

if ((await getHelperVersion()) !== DESIRED_VERSIION_HELPER) {
if (await plugin.settings.getSetting('notifs')) {
await plugin.app.toast(
`RemCord Helper is out of date! Please update to ${DESIRED_VERSIION_HELPER}\nVisit the Github. Delete the old helper. \nDownload the New One!`
`RemCord v${pluginVersion} Loaded!\nRemCord Helper ${await getHelperVersion()}`
);

if (Math.floor(Math.random() * 7) === 0) {
await plugin.app.toast('Fun Fact: You can disable these notifications in settings!');
}

if ((await getHelperVersion()) !== DESIRED_VERSIION_HELPER) {
await plugin.app.toast(
`RemCord Helper is out of date! Please update to ${DESIRED_VERSIION_HELPER}\nVisit the Github. Delete the old helper. \nDownload the New One!`
);
}
}

async function pullSettings() {
allowedIdleTime = await plugin.settings.getSetting('idle-time');
idleCheck = await plugin.settings.getSetting('idle-check');
}
sendHeartbeat();
setIdle(plugin);
setIdle();
}

async function setAsQueue(plugin: ReactRNPlugin) {
Expand Down

0 comments on commit dc9beed

Please sign in to comment.