This commit is contained in:
Mirco Wittrien 2020-11-23 20:56:13 +01:00
parent 668d6d6c82
commit c88d662332
3 changed files with 553 additions and 529 deletions

View File

@ -14,12 +14,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "ChatAliases", "name": "ChatAliases",
"author": "DevilBro", "author": "DevilBro",
"version": "2.1.9", "version": "2.2.0",
"description": "Allow the user to configure their own chat-aliases which will automatically be replaced before the message is being sent" "description": "Allow the user to configure their own chat-aliases which will automatically be replaced before the message is being sent"
}, },
"changeLog": { "changeLog": {
"fixed": { "fixed": {
"Autocomplete Menu": "Works again" "New Settings Menu": "Fixed for new settings menu"
} }
} }
}; };
@ -207,7 +207,12 @@ module.exports = (_ => {
} }
getSettingsPanel (collapseStates = {}) { getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = []; let settingsPanel;
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
collapseStates: collapseStates,
children: _ => {
let settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings", title: "Settings",
collapseStates: collapseStates, collapseStates: collapseStates,
@ -241,6 +246,7 @@ module.exports = (_ => {
})) }))
})) }))
})); }));
let values = {wordvalue: "", replacevalue: ""}; let values = {wordvalue: "", replacevalue: ""};
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Add new alias", title: "Add new alias",
@ -253,13 +259,14 @@ module.exports = (_ => {
disabled: !Object.keys(values).every(valuename => values[valuename]), disabled: !Object.keys(values).every(valuename => values[valuename]),
children: BDFDB.LanguageUtils.LanguageStrings.ADD, children: BDFDB.LanguageUtils.LanguageStrings.ADD,
onClick: _ => { onClick: _ => {
this.saveWord(values.wordvalue, values.replacevalue, settingsPanel.querySelector(".input-replacevalue input[type='file']")); this.saveWord(values.wordvalue, values.replacevalue, settingsPanel.props._node.querySelector(".input-replacevalue input[type='file']"));
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates); BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
} }
}), }),
this.createInputs(values) this.createInputs(values)
].flat(10).filter(n => n) ].flat(10).filter(n => n)
})); }));
if (!BDFDB.ObjectUtils.isEmpty(aliases)) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { if (!BDFDB.ObjectUtils.isEmpty(aliases)) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Added aliases", title: "Added aliases",
collapseStates: collapseStates, collapseStates: collapseStates,
@ -307,12 +314,12 @@ module.exports = (_ => {
} }
}) })
})); }));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Remove All", title: "Remove All",
collapseStates: collapseStates, collapseStates: collapseStates,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button", type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED, color: BDFDB.LibraryComponents.Button.Colors.RED,
label: "Remove all added aliases", label: "Remove all added aliases",
onClick: _ => { onClick: _ => {
@ -326,6 +333,7 @@ module.exports = (_ => {
children: BDFDB.LanguageUtils.LanguageStrings.REMOVE children: BDFDB.LanguageUtils.LanguageStrings.REMOVE
}) })
})); }));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Config Guide", title: "Config Guide",
collapseStates: collapseStates, collapseStates: collapseStates,
@ -334,19 +342,21 @@ module.exports = (_ => {
"Not Case: Will replace words while ignoring lowercase/uppercase. apple => apple, APPLE and AppLe", "Not Case: Will replace words while ignoring lowercase/uppercase. apple => apple, APPLE and AppLe",
"Exact: Will replace words that are exactly the replaceword. apple to pear => applepie stays applepie", "Exact: Will replace words that are exactly the replaceword. apple to pear => applepie stays applepie",
"Not Exact: Will replace words anywhere they appear. apple to pear => applepieapple to pearpiepear", "Not Exact: Will replace words anywhere they appear. apple to pear => applepieapple to pearpiepear",
"Autoc: Will appear in the Autocomplete Menu (if enabled).", "Autoc: Will appear in the Autocomplete Menu (if enabled)",
[ [
"Regex: Will treat the entered wordvalue as a regular expression. ", "Regex: Will treat the entered wordvalue as a regular expression - ",
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {href: "https://regexr.com/", children: BDFDB.LanguageUtils.LanguageStrings.HELP + "?"}) BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {href: "https://regexr.com/", children: BDFDB.LanguageUtils.LanguageStrings.HELP + "?"})
], ],
"File: If the replacevalue is a filepath it will try to upload the file located at the filepath." "File: If the replacevalue is a filepath it will try to upload the file located at the filepath"
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, { ].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION, type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string children: string
})) }))
})); }));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems); return settingsItems;
}
});
} }
onSettingsClosed () { onSettingsClosed () {

View File

@ -14,12 +14,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "FriendNotifications", "name": "FriendNotifications",
"author": "DevilBro", "author": "DevilBro",
"version": "1.5.3", "version": "1.5.4",
"description": "Get a notification when a Friend or a User you choose to observe changes their online status, can be configured individually in the settings" "description": "Get a notification when a Friend or a User you choose to observe changes their online status, can be configured individually in the settings"
}, },
"changeLog": { "changeLog": {
"fixed": { "fixed": {
"Works again": "Can discord stop messing with the server list, jeez" "New Settings Menu": "Fixed for new settings menu"
} }
} }
}; };
@ -154,10 +154,10 @@ module.exports = (_ => {
} }
getSettingsPanel (collapseStates = {}) { getSettingsPanel (collapseStates = {}) {
let changeNotificationType = (type, userId, desktopon, disableon) => { let changeNotificationType = (type, userId, desktopOn, disableOn) => {
let data = BDFDB.DataUtils.load(this, type, userId) || this.createDefaultConfig(); let data = BDFDB.DataUtils.load(this, type, userId) || this.createDefaultConfig();
data.desktop = desktopon; data.desktop = desktopOn;
data.disabled = disableon; data.disabled = disableOn;
BDFDB.DataUtils.save(data, this, type, userId); BDFDB.DataUtils.save(data, this, type, userId);
this.SettingsUpdated = true; this.SettingsUpdated = true;
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates); BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
@ -263,6 +263,10 @@ module.exports = (_ => {
}); });
}; };
let settingsPanel;
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
collapseStates: collapseStates,
children: _ => {
let settings = BDFDB.DataUtils.get(this, "settings"); let settings = BDFDB.DataUtils.get(this, "settings");
let amounts = BDFDB.DataUtils.get(this, "amounts"); let amounts = BDFDB.DataUtils.get(this, "amounts");
let notificationStrings = BDFDB.DataUtils.get(this, "notificationstrings"); let notificationStrings = BDFDB.DataUtils.get(this, "notificationstrings");
@ -272,7 +276,7 @@ module.exports = (_ => {
let friendsData = BDFDB.DataUtils.load(this, "friends"), nonFriendsData = BDFDB.DataUtils.load(this, "nonfriends"); let friendsData = BDFDB.DataUtils.load(this, "friends"), nonFriendsData = BDFDB.DataUtils.load(this, "nonfriends");
let friends = [], nonFriends = []; let friends = [], nonFriends = [];
let settingsPanel, settingsItems = [], innerItems = []; let settingsItems = [], innerItems = [];
for (let id of friendIds) { for (let id of friendIds) {
let user = BDFDB.LibraryModules.UserStore.getUser(id); let user = BDFDB.LibraryModules.UserStore.getUser(id);
@ -342,7 +346,7 @@ module.exports = (_ => {
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
onClick: _ => { onClick: _ => {
let userId = settingsPanel.querySelector(`.input-newstranger ` + BDFDB.dotCN.input).value.trim(); let userId = settingsPanel.props._node.querySelector(`.input-newstranger ` + BDFDB.dotCN.input).value.trim();
if (userId == BDFDB.UserUtils.me.id) BDFDB.NotificationUtils.toast("Are you seriously trying to stalk yourself?", {type: "error"}); if (userId == BDFDB.UserUtils.me.id) BDFDB.NotificationUtils.toast("Are you seriously trying to stalk yourself?", {type: "error"});
else if (friendIds.includes(userId)) BDFDB.NotificationUtils.toast("User is already a friend of yours, please use the 'Friend-List' area to configure them", {type: "error"}); else if (friendIds.includes(userId)) BDFDB.NotificationUtils.toast("User is already a friend of yours, please use the 'Friend-List' area to configure them", {type: "error"});
else if (Object.keys(nonFriends).includes(userId)) BDFDB.NotificationUtils.toast("User is already being observed as a 'Stranger'", {type: "error"}); else if (Object.keys(nonFriends).includes(userId)) BDFDB.NotificationUtils.toast("User is already being observed as a 'Stranger'", {type: "error"});
@ -448,7 +452,7 @@ module.exports = (_ => {
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
onClick: _ => { onClick: _ => {
let source = settingsPanel.querySelector(`.input-${key}src ` + BDFDB.dotCN.input).value.trim(); let source = settingsPanel.props._node.querySelector(`.input-${key}src ` + BDFDB.dotCN.input).value.trim();
if (!source.length) { if (!source.length) {
BDFDB.NotificationUtils.toast(`Sound file was removed.`, {type: "warn"}); BDFDB.NotificationUtils.toast(`Sound file was removed.`, {type: "warn"});
successSavedAudio(key, source, source); successSavedAudio(key, source, source);
@ -475,7 +479,9 @@ module.exports = (_ => {
]).flat(10).filter(n => n) ]).flat(10).filter(n => n)
})); }));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems); return settingsItems;
}
});
} }
onSettingsClosed () { onSettingsClosed () {

View File

@ -14,12 +14,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "NotificationSounds", "name": "NotificationSounds",
"author": "DevilBro", "author": "DevilBro",
"version": "3.5.6", "version": "3.5.7",
"description": "Allow you to replace the native sounds of Discord with your own" "description": "Allow you to replace the native sounds of Discord with your own"
}, },
"changeLog": { "changeLog": {
"fixed": { "fixed": {
"Local Sounds not playing": "Fixed issue with newly added local sounds not playing" "New Settings Menu": "Fixed for new settings menu"
} }
} }
}; };
@ -425,7 +425,11 @@ module.exports = (_ => {
}; };
let settingsPanel, settingsItems = []; let settingsPanel;
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
collapseStates: collapseStates,
children: _ => {
let settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings", title: "Settings",
@ -489,10 +493,10 @@ module.exports = (_ => {
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
style: {marginBottom: 1}, style: {marginBottom: 1},
onClick: _ => { onClick: _ => {
for (let input of settingsPanel.querySelectorAll(".input-newsound " + BDFDB.dotCN.input)) if (!input.value || input.value.length == 0 || input.value.trim().length == 0) return BDFDB.NotificationUtils.toast("Fill out all fields to add a new sound", {type: "danger"}); for (let input of settingsPanel.props._node.querySelectorAll(".input-newsound " + BDFDB.dotCN.input)) if (!input.value || input.value.length == 0 || input.value.trim().length == 0) return BDFDB.NotificationUtils.toast("Fill out all fields to add a new sound", {type: "danger"});
let category = settingsPanel.querySelector(".input-category " + BDFDB.dotCN.input).value.trim(); let category = settingsPanel.props._node.querySelector(".input-category " + BDFDB.dotCN.input).value.trim();
let sound = settingsPanel.querySelector(".input-sound " + BDFDB.dotCN.input).value.trim(); let sound = settingsPanel.props._node.querySelector(".input-sound " + BDFDB.dotCN.input).value.trim();
let source = settingsPanel.querySelector(".input-source " + BDFDB.dotCN.input).value.trim(); let source = settingsPanel.props._node.querySelector(".input-source " + BDFDB.dotCN.input).value.trim();
if (source.indexOf("http") == 0) BDFDB.LibraryRequires.request(source, (error, response, result) => { if (source.indexOf("http") == 0) BDFDB.LibraryRequires.request(source, (error, response, result) => {
if (response) { if (response) {
let type = response.headers["content-type"]; let type = response.headers["content-type"];
@ -511,11 +515,13 @@ module.exports = (_ => {
}) })
] ]
})); }));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Implemented Sounds", title: "Implemented Sounds",
collapseStates: collapseStates, collapseStates: collapseStates,
children: Object.keys(BDFDB.ObjectUtils.filter(types, typedata => typedata.implemented)).map(type => createSoundCard(type)).flat(10).filter(n => n) children: Object.keys(BDFDB.ObjectUtils.filter(types, typedata => typedata.implemented)).map(type => createSoundCard(type)).flat(10).filter(n => n)
})); }));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Unimplemented Sounds", title: "Unimplemented Sounds",
collapseStates: collapseStates, collapseStates: collapseStates,
@ -609,7 +615,9 @@ module.exports = (_ => {
}) })
})); }));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems); return settingsItems;
}
});
} }
onSettingsClosed () { onSettingsClosed () {