Update PinDMs.plugin.js

This commit is contained in:
Mirco Wittrien 2021-01-29 18:39:02 +01:00
parent 3fbfee0b9d
commit 3e47da9576
1 changed files with 18 additions and 17 deletions

View File

@ -14,12 +14,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "PinDMs", "name": "PinDMs",
"author": "DevilBro", "author": "DevilBro",
"version": "1.7.8", "version": "1.7.9",
"description": "Allow you to pin DMs, making them appear at the top of your DMs/Server-List" "description": "Allow you to pin DMs, making them appear at the top of your DMs/Server-List"
}, },
"changeLog": { "changeLog": {
"added": { "improved": {
"Predefined Categories": "Added the option to enable predefined categories for the channel list in the settings that will automatically add the dms fitting the category topic" "Canary Changes": "Preparing Plugins for the changes that are already done on Discord Canary"
} }
} }
}; };
@ -880,7 +880,10 @@ module.exports = (_ => {
} }
openCategorySettingsModal (data, type, isNew) { openCategorySettingsModal (data, type, isNew) {
if (BDFDB.ObjectUtils.is(data) && type) BDFDB.ModalUtils.open(this, { if (!BDFDB.ObjectUtils.is(data) || !type) return;
let newData = Object.assign({}, data);
BDFDB.ModalUtils.open(this, {
size: "MEDIUM", size: "MEDIUM",
header: BDFDB.LanguageUtils.LanguageStrings.CATEGORY_SETTINGS, header: BDFDB.LanguageUtils.LanguageStrings.CATEGORY_SETTINGS,
subHeader: data.name, subHeader: data.name,
@ -892,7 +895,8 @@ module.exports = (_ => {
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
value: data.name, value: data.name,
placeholder: data.name, placeholder: data.name,
autoFocus: true autoFocus: true,
onChange: value => {newData.name = value}
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.dividerdefault className: BDFDB.disCN.dividerdefault
@ -905,7 +909,7 @@ module.exports = (_ => {
children: [ children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
color: data.color, color: data.color,
number: 1 onColorChange: value => {newData.color = value}
}) })
] ]
}) })
@ -914,16 +918,13 @@ module.exports = (_ => {
contents: isNew ? BDFDB.LanguageUtils.LanguageStrings.CREATE : BDFDB.LanguageUtils.LanguageStrings.SAVE, contents: isNew ? BDFDB.LanguageUtils.LanguageStrings.CREATE : BDFDB.LanguageUtils.LanguageStrings.SAVE,
color: "BRAND", color: "BRAND",
close: true, close: true,
onClick: modal => { onClick: _ => {
data.name = modal.querySelector(".input-categoryname " + BDFDB.dotCN.input).value.trim() || data.name; if (newData.color != null && !BDFDB.ObjectUtils.is(newData.color)) {
if (newData.color[0] < 30 && newData.color[1] < 30 && newData.color[2] < 30) newData.color = BDFDB.ColorUtils.change(newData.color, 30);
data.color = BDFDB.ColorUtils.getSwatchColor(modal, 1); else if (newData.color[0] > 225 && newData.color[1] > 225 && newData.color[2] > 225) newData.color = BDFDB.ColorUtils.change(newData.color, -30);
if (data.color != null && !BDFDB.ObjectUtils.is(data.color)) {
if (data.color[0] < 30 && data.color[1] < 30 && data.color[2] < 30) data.color = BDFDB.ColorUtils.change(data.color, 30);
else if (data.color[0] > 225 && data.color[1] > 225 && data.color[2] > 225) data.color = BDFDB.ColorUtils.change(data.color, -30);
} }
BDFDB.DataUtils.save(data, this, type, data.id); BDFDB.DataUtils.save(newData, this, type, data.id);
this.updateContainer(type); this.updateContainer(type);
} }
@ -931,11 +932,11 @@ module.exports = (_ => {
}); });
} }
addPin (newid, type) { addPin (newId, type) {
if (!newid) return; if (!newId) return;
let pinnedDMs = BDFDB.DataUtils.load(this, type); let pinnedDMs = BDFDB.DataUtils.load(this, type);
for (let id in pinnedDMs) pinnedDMs[id] = pinnedDMs[id] + 1; for (let id in pinnedDMs) pinnedDMs[id] = pinnedDMs[id] + 1;
pinnedDMs[newid] = 0; pinnedDMs[newId] = 0;
BDFDB.DataUtils.save(pinnedDMs, this, type); BDFDB.DataUtils.save(pinnedDMs, this, type);
this.updateContainer(type); this.updateContainer(type);
} }