2020-10-20 23:25:34 +02:00
|
|
|
|
/**
|
|
|
|
|
* @name ReadAllNotificationsButton
|
|
|
|
|
* @authorId 278543574059057154
|
|
|
|
|
* @invite Jx3TjNS
|
|
|
|
|
* @donate https://www.paypal.me/MircoWittrien
|
|
|
|
|
* @patreon https://www.patreon.com/MircoWittrien
|
|
|
|
|
* @website https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ReadAllNotificationsButton
|
|
|
|
|
* @source https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js
|
2020-11-12 17:30:48 +01:00
|
|
|
|
* @updateUrl https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js
|
2020-10-20 23:25:34 +02:00
|
|
|
|
*/
|
2018-10-11 10:21:26 +02:00
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
module.exports = (_ => {
|
2020-10-09 21:09:35 +02:00
|
|
|
|
const config = {
|
2020-09-19 20:49:33 +02:00
|
|
|
|
"info": {
|
|
|
|
|
"name": "ReadAllNotificationsButton",
|
|
|
|
|
"author": "DevilBro",
|
2020-12-15 13:27:07 +01:00
|
|
|
|
"version": "1.6.4",
|
2020-10-16 10:25:30 +02:00
|
|
|
|
"description": "Add a button to clear all notifications"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
}
|
|
|
|
|
};
|
2020-11-13 19:47:44 +01:00
|
|
|
|
|
2020-10-09 21:09:35 +02:00
|
|
|
|
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
|
2020-09-19 20:49:33 +02:00
|
|
|
|
getName () {return config.info.name;}
|
|
|
|
|
getAuthor () {return config.info.author;}
|
|
|
|
|
getVersion () {return config.info.version;}
|
|
|
|
|
getDescription () {return config.info.description;}
|
|
|
|
|
|
2020-10-09 21:09:35 +02:00
|
|
|
|
load() {
|
2020-11-19 16:51:14 +01:00
|
|
|
|
if (!window.BDFDB_Global || !Array.isArray(window.BDFDB_Global.pluginQueue)) window.BDFDB_Global = Object.assign({}, window.BDFDB_Global, {pluginQueue: []});
|
2020-09-19 20:49:33 +02:00
|
|
|
|
if (!window.BDFDB_Global.downloadModal) {
|
|
|
|
|
window.BDFDB_Global.downloadModal = true;
|
|
|
|
|
BdApi.showConfirmationModal("Library Missing", `The library plugin needed for ${config.info.name} is missing. Please click "Download Now" to install it.`, {
|
|
|
|
|
confirmText: "Download Now",
|
|
|
|
|
cancelText: "Cancel",
|
|
|
|
|
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
|
2020-09-20 08:15:13 +02:00
|
|
|
|
onConfirm: _ => {
|
|
|
|
|
delete window.BDFDB_Global.downloadModal;
|
|
|
|
|
require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (e, r, b) => {
|
2020-10-20 23:25:34 +02:00
|
|
|
|
if (!e && b && b.indexOf(`* @name BDFDB`) > -1) require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), b, _ => {});
|
2020-09-20 08:15:13 +02:00
|
|
|
|
else BdApi.alert("Error", "Could not download BDFDB library plugin, try again some time later.");
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-09-19 20:49:33 +02:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
|
2020-10-09 21:09:35 +02:00
|
|
|
|
}
|
|
|
|
|
start() {this.load();}
|
|
|
|
|
stop() {}
|
2020-11-28 23:12:09 +01:00
|
|
|
|
getSettingsPanel() {
|
|
|
|
|
let template = document.createElement("template");
|
|
|
|
|
template.innerHTML = `<div style="color: var(--header-primary); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The library plugin needed for ${config.info.name} is missing.\nPlease click <a style="font-weight: 500;">Download Now</a> to install it.</div>`;
|
|
|
|
|
template.content.firstElementChild.querySelector("a").addEventListener("click", _ => {
|
|
|
|
|
require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (e, r, b) => {
|
|
|
|
|
if (!e && b && b.indexOf(`* @name BDFDB`) > -1) require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), b, _ => {});
|
|
|
|
|
else BdApi.alert("Error", "Could not download BDFDB library plugin, try again some time later.");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
return template.content.firstElementChild;
|
|
|
|
|
}
|
2020-10-09 21:09:35 +02:00
|
|
|
|
} : (([Plugin, BDFDB]) => {
|
2020-09-19 20:49:33 +02:00
|
|
|
|
var blacklist, clearing;
|
|
|
|
|
var settings = {};
|
2020-03-19 14:14:56 +01:00
|
|
|
|
|
2020-10-09 21:09:35 +02:00
|
|
|
|
return class ReadAllNotificationsButton extends Plugin {
|
2020-09-19 20:49:33 +02:00
|
|
|
|
onLoad() {
|
|
|
|
|
this.defaults = {
|
|
|
|
|
settings: {
|
2020-11-19 16:51:14 +01:00
|
|
|
|
addClearButton: {value: true, inner: false, description: "Add a 'Clear Mentions' button to the recent mentions popout"},
|
|
|
|
|
confirmClear: {value: false, inner: false, description: "Ask for your confirmation before clearing reads"},
|
|
|
|
|
includeGuilds: {value: true, inner: true, description: "unread Servers"},
|
|
|
|
|
includeMuted: {value: false, inner: true, description: "muted unread Servers"},
|
|
|
|
|
includeDMs: {value: false, inner: true, description: "unread DMs"}
|
2020-09-19 20:49:33 +02:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.patchedModules = {
|
|
|
|
|
after: {
|
|
|
|
|
Guilds: "render",
|
2020-11-20 16:52:10 +01:00
|
|
|
|
RecentMentions: "default",
|
2020-09-19 20:49:33 +02:00
|
|
|
|
RecentsHeader: "default"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.css = `
|
|
|
|
|
${BDFDB.dotCN.messagespopouttabbar} {
|
|
|
|
|
flex: 1 0 auto;
|
|
|
|
|
}
|
|
|
|
|
${BDFDB.dotCN.messagespopouttabbar} ~ * {
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
}
|
|
|
|
|
${BDFDB.dotCN._readallnotificationsbuttonframe} {
|
2020-10-30 16:12:46 +01:00
|
|
|
|
height: 24px;
|
2020-09-19 20:49:33 +02:00
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
${BDFDB.dotCN._readallnotificationsbuttonframe}:active {
|
|
|
|
|
transform: translateY(1px);
|
|
|
|
|
}
|
2020-10-30 16:12:46 +01:00
|
|
|
|
${BDFDB.dotCN._readallnotificationsbuttoninner} {
|
|
|
|
|
height: 24px;
|
|
|
|
|
}
|
2020-09-19 20:49:33 +02:00
|
|
|
|
${BDFDB.dotCN._readallnotificationsbuttonbutton} {
|
|
|
|
|
border-radius: 4px;
|
2020-10-30 16:12:46 +01:00
|
|
|
|
height: 24px;
|
2020-09-19 20:49:33 +02:00
|
|
|
|
font-size: 12px;
|
|
|
|
|
line-height: 1.3;
|
|
|
|
|
white-space: nowrap;
|
2020-10-30 16:12:46 +01:00
|
|
|
|
cursor: pointer;
|
2020-09-19 20:49:33 +02:00
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
}
|
2020-04-19 20:39:58 +02:00
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
onStart() {
|
|
|
|
|
let loadedBlacklist = BDFDB.DataUtils.load(this, "blacklist");
|
|
|
|
|
this.saveBlacklist(!BDFDB.ArrayUtils.is(loadedBlacklist) ? [] : loadedBlacklist);
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
this.forceUpdateAll();
|
|
|
|
|
}
|
2020-02-04 08:20:40 +01:00
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
onStop() {
|
|
|
|
|
this.forceUpdateAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getSettingsPanel (collapseStates = {}) {
|
|
|
|
|
let settingsPanel, settingsItems = [];
|
|
|
|
|
|
|
|
|
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
|
|
|
|
title: "Settings",
|
|
|
|
|
collapseStates: collapseStates,
|
|
|
|
|
children: Object.keys(settings).filter(key => !this.defaults.settings[key].inner).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
2020-03-19 14:14:56 +01:00
|
|
|
|
type: "Switch",
|
|
|
|
|
plugin: this,
|
|
|
|
|
keys: ["settings", key],
|
|
|
|
|
label: this.defaults.settings[key].description,
|
|
|
|
|
value: settings[key]
|
2020-12-15 10:35:30 +01:00
|
|
|
|
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
2020-09-19 20:49:33 +02:00
|
|
|
|
title: "When left clicking the 'read all' button mark following Elements as read:",
|
2020-12-15 13:27:07 +01:00
|
|
|
|
first: false,
|
|
|
|
|
last: true,
|
2020-09-19 20:49:33 +02:00
|
|
|
|
children: Object.keys(settings).filter(key => this.defaults.settings[key].inner).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
|
|
|
|
type: "Switch",
|
|
|
|
|
plugin: this,
|
|
|
|
|
keys: ["settings", key],
|
|
|
|
|
label: this.defaults.settings[key].description,
|
|
|
|
|
value: settings[key]
|
|
|
|
|
}))
|
2020-03-19 14:14:56 +01:00
|
|
|
|
}))
|
2020-09-19 20:49:33 +02:00
|
|
|
|
}));
|
2020-03-19 14:14:56 +01:00
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
|
|
|
|
title: "Server Black List",
|
|
|
|
|
collapseStates: collapseStates,
|
|
|
|
|
children: [
|
|
|
|
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsGuildList, {
|
|
|
|
|
className: BDFDB.disCN.marginbottom20,
|
|
|
|
|
disabled: BDFDB.DataUtils.load(this, "blacklist"),
|
|
|
|
|
onClick: disabledGuilds => {
|
|
|
|
|
this.saveBlacklist(disabledGuilds);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
|
|
|
|
type: "Button",
|
|
|
|
|
color: BDFDB.LibraryComponents.Button.Colors.GREEN,
|
|
|
|
|
label: "Enable for all Servers",
|
|
|
|
|
onClick: _ => {
|
|
|
|
|
this.batchSetGuilds(settingsPanel, collapseStates, true);
|
|
|
|
|
},
|
|
|
|
|
children: BDFDB.LanguageUtils.LanguageStrings.ENABLE
|
|
|
|
|
}),
|
|
|
|
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
|
|
|
|
type: "Button",
|
|
|
|
|
color: BDFDB.LibraryComponents.Button.Colors.PRIMARY,
|
|
|
|
|
label: "Disable for all Servers",
|
|
|
|
|
onClick: _ => {
|
|
|
|
|
this.batchSetGuilds(settingsPanel, collapseStates, false);
|
|
|
|
|
},
|
|
|
|
|
children: BDFDB.LanguageUtils.LanguageStrings.DISABLE
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
|
2020-02-04 08:20:40 +01:00
|
|
|
|
}
|
2018-10-11 10:21:26 +02:00
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
onSettingsClosed () {
|
|
|
|
|
if (this.SettingsUpdated) {
|
|
|
|
|
delete this.SettingsUpdated;
|
|
|
|
|
this.forceUpdateAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
forceUpdateAll () {
|
|
|
|
|
settings = BDFDB.DataUtils.get(this, "settings");
|
2020-02-04 08:20:40 +01:00
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
BDFDB.PatchUtils.forceAllUpdates(this);
|
2020-02-04 08:20:40 +01:00
|
|
|
|
}
|
2020-10-30 16:12:46 +01:00
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
processGuilds (e) {
|
2020-10-30 16:12:46 +01:00
|
|
|
|
if (typeof e.returnvalue.props.children == "function") {
|
|
|
|
|
let childrenRender = e.returnvalue.props.children;
|
|
|
|
|
e.returnvalue.props.children = (...args) => {
|
2020-11-16 09:59:51 +01:00
|
|
|
|
let children = childrenRender(...args);
|
|
|
|
|
this.checkTree(children);
|
|
|
|
|
return children;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else this.checkTree(e.returnvalue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkTree (returnvalue) {
|
|
|
|
|
let tree = BDFDB.ReactUtils.findChild(returnvalue, {filter: n => n && n.props && typeof n.props.children == "function"});
|
|
|
|
|
if (tree) {
|
|
|
|
|
let childrenRender = tree.props.children;
|
|
|
|
|
tree.props.children = (...args) => {
|
2020-10-30 16:12:46 +01:00
|
|
|
|
let children = childrenRender(...args);
|
|
|
|
|
this.injectButton(children);
|
|
|
|
|
return children;
|
|
|
|
|
};
|
|
|
|
|
}
|
2020-11-16 09:59:51 +01:00
|
|
|
|
else this.injectButton(returnvalue);
|
2020-10-30 16:12:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
injectButton (returnvalue) {
|
|
|
|
|
let [children, index] = BDFDB.ReactUtils.findParent(returnvalue, {name: "ConnectedUnreadDMs"});
|
2020-09-19 20:49:33 +02:00
|
|
|
|
if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement("div", {
|
|
|
|
|
className: BDFDB.disCNS.guildouter + BDFDB.disCN._readallnotificationsbuttonframe,
|
|
|
|
|
children: BDFDB.ReactUtils.createElement("div", {
|
|
|
|
|
className: BDFDB.disCNS.guildiconwrapper + BDFDB.disCN._readallnotificationsbuttoninner,
|
|
|
|
|
children: BDFDB.ReactUtils.createElement("div", {
|
|
|
|
|
className: BDFDB.disCNS.guildiconchildwrapper + BDFDB.disCN._readallnotificationsbuttonbutton,
|
|
|
|
|
children: "read all",
|
|
|
|
|
onClick: _ => {
|
|
|
|
|
let clear = _ => {
|
|
|
|
|
if (settings.includeGuilds) this.markGuildsAsRead(settings.includeMuted ? BDFDB.GuildUtils.getAll() : BDFDB.GuildUtils.getUnread());
|
|
|
|
|
if (settings.includeDMs) BDFDB.DMUtils.markAsRead(BDFDB.DMUtils.getAll());
|
|
|
|
|
};
|
|
|
|
|
if (!settings.confirmClear) clear();
|
|
|
|
|
else BDFDB.ModalUtils.confirm(this, `Are you sure you want to mark all Notifications as read?`, clear);
|
|
|
|
|
},
|
|
|
|
|
onContextMenu: event => {
|
|
|
|
|
BDFDB.ContextMenuUtils.open(this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
|
|
|
|
|
children: [
|
|
|
|
|
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
label: this.labels.context_unreadguilds,
|
2020-09-19 20:49:33 +02:00
|
|
|
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "mark-unread-read"),
|
|
|
|
|
action: event2 => {
|
|
|
|
|
this.markGuildsAsRead(BDFDB.GuildUtils.getUnread());
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
label: this.labels.context_pingedguilds,
|
2020-09-19 20:49:33 +02:00
|
|
|
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "mark-pinged-read"),
|
|
|
|
|
action: event2 => {
|
|
|
|
|
this.markGuildsAsRead(BDFDB.GuildUtils.getPinged());
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
label: this.labels.context_mutedguilds,
|
2020-09-19 20:49:33 +02:00
|
|
|
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "mark-muted-read"),
|
|
|
|
|
action: event2 => {
|
|
|
|
|
this.markGuildsAsRead(BDFDB.GuildUtils.getMuted());
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
label: this.labels.context_guilds,
|
2020-09-19 20:49:33 +02:00
|
|
|
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "mark-all-read"),
|
|
|
|
|
action: event2 => {
|
|
|
|
|
this.addPinnedRecent(instance.props.channel.id);
|
|
|
|
|
this.markGuildsAsRead(BDFDB.GuildUtils.getAll());
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
label: this.labels.context_dms,
|
2020-09-19 20:49:33 +02:00
|
|
|
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "mark-dms-read"),
|
|
|
|
|
action: event2 => {
|
|
|
|
|
BDFDB.DMUtils.markAsRead(BDFDB.DMUtils.getAll());
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
})
|
2020-02-04 08:20:40 +01:00
|
|
|
|
})
|
2020-09-19 20:49:33 +02:00
|
|
|
|
}));
|
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2020-11-20 16:52:10 +01:00
|
|
|
|
processRecentMentions (e) {
|
|
|
|
|
if (e.instance.props.header && e.instance.props.header.props) e.instance.props.header.props.messages = e.returnvalue.props.messages;
|
2020-02-04 08:20:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
processRecentsHeader (e) {
|
|
|
|
|
if (settings.addClearButton && e.instance.props.tab == "Recent Mentions") e.returnvalue.props.children.push(BDFDB.ReactUtils.createElement("div", {
|
|
|
|
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
|
|
|
|
text: `${BDFDB.LanguageUtils.LanguageStrings.CLOSE} (${BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL})`,
|
|
|
|
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
|
|
|
|
|
className: BDFDB.disCNS.messagespopoutbutton + BDFDB.disCN.messagespopoutbuttonsecondary,
|
|
|
|
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
|
|
|
|
nativeClass: true,
|
|
|
|
|
name: BDFDB.LibraryComponents.SvgIcon.Names.CLOSE,
|
|
|
|
|
width: 16,
|
|
|
|
|
height: 16
|
|
|
|
|
}),
|
|
|
|
|
onClick: _ => {
|
|
|
|
|
let clear = _ => {
|
|
|
|
|
if (clearing) return BDFDB.NotificationUtils.toast("Already clearing some recent mentions, please wait...", {type: "error"});
|
2020-11-18 17:59:44 +01:00
|
|
|
|
let messages = [].concat(e.instance.props.messages).filter(n => n);
|
2020-09-19 20:49:33 +02:00
|
|
|
|
if (messages.length) {
|
|
|
|
|
clearing = true;
|
2020-11-19 16:51:14 +01:00
|
|
|
|
let toast = BDFDB.NotificationUtils.toast("Clearing all recent mentions, please wait...", {timeout: 0});
|
2020-09-19 20:49:33 +02:00
|
|
|
|
for (let i = 0; i < messages.length; i++) BDFDB.TimeUtils.timeout(_ => {
|
|
|
|
|
BDFDB.LibraryModules.RecentMentionUtils.deleteRecentMention(messages[i].id);
|
|
|
|
|
if (i == messages.length - 1) {
|
|
|
|
|
clearing = false;
|
|
|
|
|
toast.close();
|
|
|
|
|
BDFDB.NotificationUtils.toast("Cleared all recent mentions.", {type: "success"});
|
|
|
|
|
}
|
|
|
|
|
}, i * 1000);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
if (settings.confirmClear) BDFDB.ModalUtils.confirm(this, `Are you sure you want to mark all mentions as read?`, clear);
|
|
|
|
|
else clear();
|
|
|
|
|
}
|
|
|
|
|
})
|
2020-04-19 20:39:58 +02:00
|
|
|
|
})
|
2020-09-19 20:49:33 +02:00
|
|
|
|
}));
|
2020-03-19 14:14:56 +01:00
|
|
|
|
}
|
2020-06-09 10:14:35 +02:00
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
markGuildsAsRead (guilds) {
|
|
|
|
|
BDFDB.GuildUtils.markAsRead(guilds.filter(g => g && g.id && !blacklist.includes(g.id)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
batchSetGuilds (settingsPanel, collapseStates, value) {
|
|
|
|
|
if (!value) {
|
|
|
|
|
for (let id of BDFDB.LibraryModules.FolderStore.getFlattenedGuildIds()) blacklist.push(id);
|
|
|
|
|
this.saveBlacklist(BDFDB.ArrayUtils.removeCopies(blacklist));
|
|
|
|
|
}
|
|
|
|
|
else this.saveBlacklist([]);
|
|
|
|
|
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveBlacklist (savedBlacklist) {
|
|
|
|
|
blacklist = savedBlacklist;
|
|
|
|
|
BDFDB.DataUtils.save(savedBlacklist, this, "blacklist");
|
2020-02-04 08:20:40 +01:00
|
|
|
|
}
|
2020-07-26 16:39:51 +02:00
|
|
|
|
|
2020-09-19 20:49:33 +02:00
|
|
|
|
setLabelsByLanguage () {
|
|
|
|
|
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "bg": // Bulgarian
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Директно съобщение",
|
|
|
|
|
context_guilds: "Всички сървъри",
|
|
|
|
|
context_mutedguilds: "Приглушени сървъри",
|
|
|
|
|
context_pingedguilds: "Pinged сървъри",
|
|
|
|
|
context_unreadguilds: "Непрочетени сървъри"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "da": // Danish
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Direkte beskeder",
|
|
|
|
|
context_guilds: "Alle servere",
|
|
|
|
|
context_mutedguilds: "Dæmpede servere",
|
|
|
|
|
context_pingedguilds: "Pingede servere",
|
|
|
|
|
context_unreadguilds: "Ulæste servere"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "de": // German
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Direktnachrichten",
|
|
|
|
|
context_guilds: "Alle Server",
|
|
|
|
|
context_mutedguilds: "Stummgeschaltete Server",
|
|
|
|
|
context_pingedguilds: "Gepingte Server",
|
|
|
|
|
context_unreadguilds: "Ungelesene Server"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "el": // Greek
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Αμεσα μηνύματα",
|
|
|
|
|
context_guilds: "Όλοι οι διακομιστές",
|
|
|
|
|
context_mutedguilds: "Σίγαση διακομιστών",
|
|
|
|
|
context_pingedguilds: "Διακομιστές Ping",
|
|
|
|
|
context_unreadguilds: "Μη αναγνωσμένοι διακομιστές"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "es": // Spanish
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Mensajes directos",
|
|
|
|
|
context_guilds: "Todos los servidores",
|
|
|
|
|
context_mutedguilds: "Servidores silenciados",
|
|
|
|
|
context_pingedguilds: "Servidores con ping",
|
|
|
|
|
context_unreadguilds: "Servidores no leídos"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "fi": // Finnish
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Suorat viestit",
|
|
|
|
|
context_guilds: "Kaikki palvelimet",
|
|
|
|
|
context_mutedguilds: "Mykistetyt palvelimet",
|
|
|
|
|
context_pingedguilds: "Pinged-palvelimet",
|
|
|
|
|
context_unreadguilds: "Lukemattomat palvelimet"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "fr": // French
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Messages directs",
|
|
|
|
|
context_guilds: "Tous les serveurs",
|
|
|
|
|
context_mutedguilds: "Serveurs muets",
|
|
|
|
|
context_pingedguilds: "Serveurs ping",
|
|
|
|
|
context_unreadguilds: "Serveurs non lus"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "hr": // Croatian
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Direktna poruka",
|
|
|
|
|
context_guilds: "Svi poslužitelji",
|
|
|
|
|
context_mutedguilds: "Prigušeni poslužitelji",
|
|
|
|
|
context_pingedguilds: "Pingirani poslužitelji",
|
|
|
|
|
context_unreadguilds: "Nepročitani poslužitelji"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "hu": // Hungarian
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Közvetlen üzenet",
|
|
|
|
|
context_guilds: "Minden szerver",
|
|
|
|
|
context_mutedguilds: "Némított szerverek",
|
|
|
|
|
context_pingedguilds: "Pingelt szerverek",
|
|
|
|
|
context_unreadguilds: "Olvasatlan szerverek"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "it": // Italian
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Messaggi diretti",
|
|
|
|
|
context_guilds: "Tutti i server",
|
|
|
|
|
context_mutedguilds: "Server disattivati",
|
|
|
|
|
context_pingedguilds: "Server sottoposti a ping",
|
|
|
|
|
context_unreadguilds: "Server non letti"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "ja": // Japanese
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "ダイレクトメッセージ",
|
|
|
|
|
context_guilds: "すべてのサーバー",
|
|
|
|
|
context_mutedguilds: "ミュートされたサーバー",
|
|
|
|
|
context_pingedguilds: "pingされたサーバー",
|
|
|
|
|
context_unreadguilds: "未読サーバー"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "ko": // Korean
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "쪽지",
|
|
|
|
|
context_guilds: "모든 서버",
|
|
|
|
|
context_mutedguilds: "음소거 된 서버",
|
|
|
|
|
context_pingedguilds: "핑된 서버",
|
|
|
|
|
context_unreadguilds: "읽지 않은 서버"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "lt": // Lithuanian
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Tiesioginiai pranešimai",
|
|
|
|
|
context_guilds: "Visi serveriai",
|
|
|
|
|
context_mutedguilds: "Nutildyti serveriai",
|
|
|
|
|
context_pingedguilds: "„Pinged“ serveriai",
|
|
|
|
|
context_unreadguilds: "Neskaityti serveriai"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "nl": // Dutch
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Directe berichten",
|
|
|
|
|
context_guilds: "Alle servers",
|
|
|
|
|
context_mutedguilds: "Gedempte servers",
|
|
|
|
|
context_pingedguilds: "Gepingde servers",
|
|
|
|
|
context_unreadguilds: "Ongelezen servers"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "no": // Norwegian
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Direktemeldinger",
|
|
|
|
|
context_guilds: "Alle servere",
|
|
|
|
|
context_mutedguilds: "Dempede servere",
|
|
|
|
|
context_pingedguilds: "Pingede servere",
|
|
|
|
|
context_unreadguilds: "Uleste servere"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "pl": // Polish
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Bezpośrednie wiadomości",
|
|
|
|
|
context_guilds: "Wszystkie serwery",
|
|
|
|
|
context_mutedguilds: "Wyciszone serwery",
|
|
|
|
|
context_pingedguilds: "Serwery pingowane",
|
|
|
|
|
context_unreadguilds: "Nieprzeczytane serwery"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "pt-BR": // Portuguese (Brazil)
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Mensagens diretas",
|
|
|
|
|
context_guilds: "Todos os servidores",
|
|
|
|
|
context_mutedguilds: "Servidores Silenciados",
|
|
|
|
|
context_pingedguilds: "Servidores com ping",
|
|
|
|
|
context_unreadguilds: "Servidores não lidos"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "ro": // Romanian
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Mesaje directe",
|
|
|
|
|
context_guilds: "Toate serverele",
|
|
|
|
|
context_mutedguilds: "Servere mutate",
|
|
|
|
|
context_pingedguilds: "Servere pinged",
|
|
|
|
|
context_unreadguilds: "Servere necitite"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "ru": // Russian
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Прямые сообщения",
|
|
|
|
|
context_guilds: "Все серверы",
|
|
|
|
|
context_mutedguilds: "Отключенные серверы",
|
|
|
|
|
context_pingedguilds: "Проверенные серверы",
|
|
|
|
|
context_unreadguilds: "Непрочитанные серверы"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "sv": // Swedish
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "Direktmeddelanden",
|
|
|
|
|
context_guilds: "Alla servrar",
|
|
|
|
|
context_mutedguilds: "Dämpade servrar",
|
|
|
|
|
context_pingedguilds: "Pingade servrar",
|
|
|
|
|
context_unreadguilds: "Olästa servrar"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
2020-12-21 19:56:36 +01:00
|
|
|
|
case "th": // Thai
|
2020-09-19 20:49:33 +02:00
|
|
|
|
return {
|
2020-12-21 19:56:36 +01:00
|
|
|
|
context_dms: "ข้อความโดยตรง",
|
|
|
|
|
context_guilds: "เซิร์ฟเวอร์ทั้งหมด",
|
|
|
|
|
context_mutedguilds: "เซิร์ฟเวอร์ที่ปิดเสียง",
|
|
|
|
|
context_pingedguilds: "เซิร์ฟเวอร์ Pinged",
|
|
|
|
|
context_unreadguilds: "เซิร์ฟเวอร์ที่ยังไม่ได้อ่าน"
|
|
|
|
|
};
|
|
|
|
|
case "tr": // Turkish
|
|
|
|
|
return {
|
|
|
|
|
context_dms: "Direkt Mesajlar",
|
|
|
|
|
context_guilds: "Tüm Sunucular",
|
|
|
|
|
context_mutedguilds: "Sessiz Sunucular",
|
|
|
|
|
context_pingedguilds: "Ping Gönderilen Sunucular",
|
|
|
|
|
context_unreadguilds: "Okunmamış Sunucular"
|
|
|
|
|
};
|
|
|
|
|
case "uk": // Ukrainian
|
|
|
|
|
return {
|
|
|
|
|
context_dms: "Прямі повідомлення",
|
|
|
|
|
context_guilds: "Усі сервери",
|
|
|
|
|
context_mutedguilds: "Приглушені сервери",
|
|
|
|
|
context_pingedguilds: "Pinged сервери",
|
|
|
|
|
context_unreadguilds: "Непрочитані сервери"
|
|
|
|
|
};
|
|
|
|
|
case "vi": // Vietnamese
|
|
|
|
|
return {
|
|
|
|
|
context_dms: "Tin nhắn trực tiếp",
|
|
|
|
|
context_guilds: "Tất cả máy chủ",
|
|
|
|
|
context_mutedguilds: "Máy chủ bị tắt tiếng",
|
|
|
|
|
context_pingedguilds: "Máy chủ Pinged",
|
|
|
|
|
context_unreadguilds: "Máy chủ chưa đọc"
|
|
|
|
|
};
|
|
|
|
|
case "zh": // Chinese
|
|
|
|
|
return {
|
|
|
|
|
context_dms: "直接讯息",
|
|
|
|
|
context_guilds: "所有服务器",
|
|
|
|
|
context_mutedguilds: "静音服务器",
|
|
|
|
|
context_pingedguilds: "绑定服务器",
|
|
|
|
|
context_unreadguilds: "未读服务器"
|
|
|
|
|
};
|
|
|
|
|
case "zh-TW": // Chinese (Traditional)
|
|
|
|
|
return {
|
|
|
|
|
context_dms: "直接訊息",
|
|
|
|
|
context_guilds: "所有服務器",
|
|
|
|
|
context_mutedguilds: "靜音服務器",
|
|
|
|
|
context_pingedguilds: "綁定服務器",
|
|
|
|
|
context_unreadguilds: "未讀服務器"
|
|
|
|
|
};
|
|
|
|
|
default: // English
|
|
|
|
|
return {
|
|
|
|
|
context_dms: "Direct Messages",
|
|
|
|
|
context_guilds: "All Servers",
|
|
|
|
|
context_mutedguilds: "Muted Servers",
|
|
|
|
|
context_pingedguilds: "Pinged Servers",
|
|
|
|
|
context_unreadguilds: "Unread Servers"
|
2020-09-19 20:49:33 +02:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-10-09 21:09:35 +02:00
|
|
|
|
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
|
2020-09-19 20:49:33 +02:00
|
|
|
|
})();
|