mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 07:25:10 +00:00
Use settings instead of localstore
This commit is contained in:
parent
6ef0c0232d
commit
d880ad8872
1 changed files with 10 additions and 5 deletions
|
@ -9,7 +9,6 @@ import { Notifications } from "@api/index";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getCurrentChannel } from "@utils/discord";
|
import { getCurrentChannel } from "@utils/discord";
|
||||||
import { localStorage } from "@utils/localStorage";
|
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { ChannelStore, Menu, MessageStore, NavigationRouter, PresenceStore, PrivateChannelsStore, UserStore, WindowStore } from "@webpack/common";
|
import { ChannelStore, Menu, MessageStore, NavigationRouter, PresenceStore, PrivateChannelsStore, UserStore, WindowStore } from "@webpack/common";
|
||||||
|
@ -33,7 +32,7 @@ function Icon(enabled: boolean) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getBypassed = (source: Sources) =>
|
const getBypassed = (source: Sources) =>
|
||||||
(JSON.parse(localStorage.getItem("vc-bypass-dnd") ?? '{"guild": [], "user": [], "channel": []}') as Record<Sources, string[]>)[source];
|
(JSON.parse(settings.store.bypasseds) as Record<Sources, string[]>)[source];
|
||||||
|
|
||||||
const getAllBypassed = () => ({
|
const getAllBypassed = () => ({
|
||||||
guild: getBypassed("guild"),
|
guild: getBypassed("guild"),
|
||||||
|
@ -42,7 +41,7 @@ const getAllBypassed = () => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
function setLists(source: Sources, value: string[]) {
|
function setLists(source: Sources, value: string[]) {
|
||||||
localStorage.setItem("vc-bypass-dnd", JSON.stringify({ ...getAllBypassed(), [source]: value }));
|
settings.store.bypasseds = JSON.stringify({ ...getAllBypassed(), [source]: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showNotification(message: Message, guildId: string | undefined) {
|
async function showNotification(message: Message, guildId: string | undefined) {
|
||||||
|
@ -85,7 +84,7 @@ const ContextCallback = (name: Sources): NavContextMenuPatchCallback => (childre
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
children.splice(-1, 0, (
|
children.splice(-1, 0,
|
||||||
<Menu.MenuGroup>
|
<Menu.MenuGroup>
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id={`dnd-${name}-bypass`}
|
id={`dnd-${name}-bypass`}
|
||||||
|
@ -97,7 +96,7 @@ const ContextCallback = (name: Sources): NavContextMenuPatchCallback => (childre
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Menu.MenuGroup>
|
</Menu.MenuGroup>
|
||||||
));
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
|
@ -108,6 +107,12 @@ const settings = definePluginSettings({
|
||||||
notificationSound: {
|
notificationSound: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Whether the notification sound should be played",
|
description: "Whether the notification sound should be played",
|
||||||
|
},
|
||||||
|
bypasseds: {
|
||||||
|
type: OptionType.STRING,
|
||||||
|
description: "Bypassed users, channels and guilds",
|
||||||
|
default: '{"guild": [], "user": [], "channel": []}',
|
||||||
|
hidden: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue