stuff
This commit is contained in:
parent
a0b46ec046
commit
115e2921cb
File diff suppressed because one or more lines are too long
|
@ -1727,18 +1727,18 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins ? BDFDB.myPlugins : {}, BDv2Api
|
|||
BDFDB.createSettingsPanel = function (plugin, children) {
|
||||
if (!BDFDB.isObject(plugin) || !children || (!BDFDB.React.isValidElement(children) && !Array.isArray(children)) || (Array.isArray(children) && !children.length)) return;
|
||||
var settingspanel = BDFDB.htmlToElement(`<div class="${plugin.name}-settings BDFDB-settings"></div>`);
|
||||
BDFDB.React.render(BDFDB.React.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
direction: BDFDB.LibraryComponents.Flex.Direction.VERTICAL,
|
||||
BDFDB.React.render(BDFDB.React.createElement(LibraryComponents.Flex, {
|
||||
direction: LibraryComponents.Flex.Direction.VERTICAL,
|
||||
grow: 1,
|
||||
children: [
|
||||
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
|
||||
BDFDB.React.createElement(LibraryComponents.FormComponents.FormTitle, {
|
||||
className: BDFDB.disCNS.marginbottom20 + "BDFDB-settings-title",
|
||||
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H2,
|
||||
tag: LibraryComponents.FormComponents.FormTitle.Tags.H2,
|
||||
children: plugin.name
|
||||
}),
|
||||
BDFDB.React.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
BDFDB.React.createElement(LibraryComponents.Flex, {
|
||||
className: "BDFDB-settings-inner",
|
||||
direction: BDFDB.LibraryComponents.Flex.Direction.VERTICAL,
|
||||
direction: LibraryComponents.Flex.Direction.VERTICAL,
|
||||
grow: 1,
|
||||
children: settingsitems
|
||||
})
|
||||
|
@ -3391,7 +3391,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins ? BDFDB.myPlugins : {}, BDv2Api
|
|||
}
|
||||
if (config.children) {
|
||||
let selectedtab, tabs = [];
|
||||
for (let child of (Array.isArray(config.children) ? config.children : Array.from(config.children))) if (LibraryModules.React.isValidElement(child)) {
|
||||
for (let child of (Array.isArray(config.children) ? config.children : Array.of(config.children))) if (LibraryModules.React.isValidElement(child)) {
|
||||
if (child.type == LibraryComponents.ModalTabContent) {
|
||||
if (!tabs.length) child.props.open = true;
|
||||
else delete child.props.open;
|
||||
|
@ -5858,6 +5858,8 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins ? BDFDB.myPlugins : {}, BDv2Api
|
|||
LibraryComponents.TextElement = BDFDB.WebModules.findByName('Text');
|
||||
LibraryComponents.TextInput = reactInitialized ? class TextInput extends LibraryModules.React.Component {
|
||||
handleChange(e) {
|
||||
this.props.value = e;
|
||||
this.forceUpdate();
|
||||
if (typeof this.props.onChange == 'function') this.props.onChange(e, this);
|
||||
}
|
||||
render() {return BDFDB.React.createElement(NativeSubComponents.TextInput, Object.assign({}, this.props, {onChange: this.handleChange.bind(this)}));}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class EditChannels {
|
||||
getName () {return "EditChannels";}
|
||||
|
||||
getVersion () {return "4.0.3";}
|
||||
getVersion () {return "4.0.4";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -90,8 +90,7 @@ class EditChannels {
|
|||
onClick: _ => {
|
||||
BDFDB.openConfirmModal(this, "Are you sure you want to reset all channels?", () => {
|
||||
BDFDB.removeAllData(this, "channels");
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
this.forceUpdateAll();
|
||||
});
|
||||
},
|
||||
children: BDFDB.LanguageStrings.RESET
|
||||
|
@ -142,9 +141,8 @@ class EditChannels {
|
|||
|
||||
var observer = new MutationObserver(() => {this.changeAppTitle();});
|
||||
BDFDB.addObserver(this, document.head.querySelector("title"), {name:"appTitleObserver",instance:observer}, {childList:true});
|
||||
this.changeAppTitle();
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
this.forceUpdateAll();
|
||||
}
|
||||
else {
|
||||
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
|
||||
|
@ -155,7 +153,7 @@ class EditChannels {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
let data = BDFDB.loadAllData(this, "channels");
|
||||
BDFDB.removeAllData(this, "channels");
|
||||
try {BDFDB.WebModules.forceAllUpdates(this);} catch (err) {}
|
||||
try {this.forceUpdateAll();} catch (err) {}
|
||||
BDFDB.saveAllData(data, this, "channels");
|
||||
|
||||
BDFDB.removeEles(".autocompleteEditChannels", ".autocompleteEditChannelsRow");
|
||||
|
@ -194,8 +192,7 @@ class EditChannels {
|
|||
action: e => {
|
||||
BDFDB.closeContextMenu(menu);
|
||||
BDFDB.removeData(instance.props.channel.id, this, "channels");
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
this.forceUpdateAll();
|
||||
}
|
||||
})
|
||||
]
|
||||
|
@ -208,8 +205,13 @@ class EditChannels {
|
|||
}
|
||||
}
|
||||
|
||||
forceUpdateAll () {
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
showChannelSettings (info) {
|
||||
var {name,color,inheritColor} = BDFDB.loadData(info.id, this, "channels") || {};
|
||||
var data = BDFDB.loadData(info.id, this, "channels") || {};
|
||||
|
||||
BDFDB.openModal(this, {
|
||||
size: "MEDIUM",
|
||||
|
@ -221,7 +223,7 @@ class EditChannels {
|
|||
className: BDFDB.disCN.marginbottom20 + " input-channelname",
|
||||
children: [
|
||||
BDFDB.React.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||
value: name,
|
||||
value: data.name,
|
||||
placeholder: info.name,
|
||||
autoFocus: true
|
||||
}),
|
||||
|
@ -235,7 +237,7 @@ class EditChannels {
|
|||
className: BDFDB.disCN.marginbottom20,
|
||||
children: [
|
||||
BDFDB.React.createElement(BDFDB.LibraryComponents.ColorSwatches, {
|
||||
color: color,
|
||||
color: data.color,
|
||||
number: 1
|
||||
})
|
||||
]
|
||||
|
@ -244,7 +246,7 @@ class EditChannels {
|
|||
type: "Switch",
|
||||
className: BDFDB.disCN.marginbottom20 + " input-inheritcolor",
|
||||
label: this.labels.modal_inheritcolor_text,
|
||||
value: info.type == 4 && inheritColor,
|
||||
value: info.type == 4 && data.inheritColor,
|
||||
disabled: info.type != 4
|
||||
})
|
||||
],
|
||||
|
@ -256,20 +258,20 @@ class EditChannels {
|
|||
let channelnameinput = modal.querySelector(".input-channelname " + BDFDB.dotCN.input);
|
||||
let inheritcolorinput = modal.querySelector(".input-inheritcolor " + BDFDB.dotCN.switchinner);
|
||||
|
||||
name = channelnameinput.value.trim() || null;
|
||||
data.name = channelnameinput.value.trim() || null;
|
||||
|
||||
color = BDFDB.getSwatchColor(modal, 1);
|
||||
if (color != null && !BDFDB.isObject(color)) {
|
||||
if (color[0] < 30 && color[1] < 30 && color[2] < 30) color = BDFDB.colorCHANGE(color, 30);
|
||||
else if (color[0] > 225 && color[1] > 225 && color[2] > 225) color = BDFDB.colorCHANGE(color, -30);
|
||||
data.color = BDFDB.getSwatchColor(modal, 1);
|
||||
if (data.color != null && !BDFDB.isObject(data.color)) {
|
||||
if (data.color[0] < 30 && data.color[1] < 30 && data.color[2] < 30) data.color = BDFDB.colorCHANGE(data.color, 30);
|
||||
else if (data.color[0] > 225 && data.color[1] > 225 && data.color[2] > 225) data.color = BDFDB.colorCHANGE(data.color, -30);
|
||||
}
|
||||
|
||||
inheritColor = inheritcolorinput.checked;
|
||||
data.inheritColor = inheritcolorinput.checked;
|
||||
|
||||
if (name == null && color == null) BDFDB.removeData(info.id, this, "channels");
|
||||
else BDFDB.saveData(info.id, {name,color,inheritColor}, this, "channels");
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
let changed = false;
|
||||
if (Object.keys(data).every(key => data[key] == null || data[key] == false) && (changed = true)) BDFDB.removeData(info.id, this, "channels");
|
||||
else if (!BDFDB.equals(olddata, data) && (changed = true)) BDFDB.saveData(info.id, data, this, "channels");
|
||||
if (changed) this.forceUpdateAll();
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
@ -422,8 +424,7 @@ class EditChannels {
|
|||
processStandardSidebarView (instance, wrapper, returnvalue) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
this.forceUpdateAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,7 +3,7 @@
|
|||
class EditUsers {
|
||||
getName () {return "EditUsers";}
|
||||
|
||||
getVersion () {return "3.6.2";}
|
||||
getVersion () {return "3.6.3";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -11,7 +11,7 @@ class EditUsers {
|
|||
|
||||
constructor () {
|
||||
this.changelog = {
|
||||
"fixed":[["Profile Pictures","Fixed places where profile pictures weren't changed properly"]]
|
||||
"improved":[["Switching to React","Using React to create settings and modals, faster and more less likely to break"]]
|
||||
};
|
||||
|
||||
this.labels = {};
|
||||
|
@ -136,14 +136,13 @@ class EditUsers {
|
|||
onClick: _ => {
|
||||
BDFDB.openConfirmModal(this, "Are you sure you want to reset all users?", () => {
|
||||
BDFDB.removeAllData(this, "users");
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
this.forceUpdateAll();
|
||||
});
|
||||
},
|
||||
children: BDFDB.LanguageStrings.RESET
|
||||
}));
|
||||
|
||||
return BDFDB.createSettingsPanel(plugin, settingsitems);
|
||||
return BDFDB.createSettingsPanel(this, settingsitems);
|
||||
}
|
||||
|
||||
//legacy
|
||||
|
@ -188,9 +187,8 @@ class EditUsers {
|
|||
|
||||
var observer = new MutationObserver(() => {this.changeAppTitle();});
|
||||
BDFDB.addObserver(this, document.head.querySelector("title"), {name:"appTitleObserver",instance:observer}, {childList:true});
|
||||
this.changeAppTitle();
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
this.forceUpdateAll();
|
||||
}
|
||||
else {
|
||||
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
|
||||
|
@ -202,10 +200,7 @@ class EditUsers {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
let data = BDFDB.loadAllData(this, "users");
|
||||
BDFDB.removeAllData(this, "users");
|
||||
try {
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
} catch (err) {}
|
||||
try {this.forceUpdateAll();} catch (err) {}
|
||||
BDFDB.saveAllData(data, this, "users");
|
||||
|
||||
BDFDB.removeEles(".autocompleteEditUsers", ".autocompleteEditUsersRow");
|
||||
|
@ -244,8 +239,7 @@ class EditUsers {
|
|||
action: e => {
|
||||
BDFDB.closeContextMenu(menu);
|
||||
BDFDB.removeData(instance.props.user.id, this, "users");
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
this.forceUpdateAll();
|
||||
}
|
||||
})
|
||||
]
|
||||
|
@ -258,6 +252,11 @@ class EditUsers {
|
|||
}
|
||||
}
|
||||
|
||||
forceUpdateAll () {
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
showUserSettings (info) {
|
||||
let data = BDFDB.loadData(info.id, this, "users") || {};
|
||||
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {};
|
||||
|
@ -292,7 +291,7 @@ class EditUsers {
|
|||
}),
|
||||
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||
title: this.labels.modal_useravatar_text,
|
||||
className: BDFDB.disCN.marginbottom20 + " input-useravatar",
|
||||
className: BDFDB.disCN.marginbottom8 + " input-useravatar",
|
||||
children: [
|
||||
BDFDB.React.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||
inputClassName: !data.removeIcon && data.url ? BDFDB.disCN.inputsuccess : null,
|
||||
|
@ -303,27 +302,7 @@ class EditUsers {
|
|||
this.createNoticeTooltip(e.target);
|
||||
},
|
||||
onChange: (value, instance) => {
|
||||
let input = BDFDB.React.findDOMNodeSafe(instance).firstElementChild;
|
||||
clearTimeout(instance.checkTimeout);
|
||||
if (value == null || !value.trim()) {
|
||||
if (input) BDFDB.removeEles(input.tooltip);
|
||||
instance.props.inputClassName = null;
|
||||
instance.forceUpdate();
|
||||
}
|
||||
else instance.checkTimeout = setTimeout(() => {
|
||||
BDFDB.LibraryRequires.request(value.trim(), (error, response, result) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") != -1) {
|
||||
if (input) BDFDB.removeEles(input.tooltip);
|
||||
instance.props.inputClassName = BDFDB.disCN.inputsuccess;
|
||||
}
|
||||
else {
|
||||
this.createNoticeTooltip(input, true);
|
||||
instance.props.inputClassName = BDFDB.disCN.inputerror;
|
||||
}
|
||||
delete instance.checkTimeout;
|
||||
instance.forceUpdate();
|
||||
});
|
||||
}, 1000);
|
||||
this.checkUrl(value, instance);
|
||||
}
|
||||
})
|
||||
]
|
||||
|
@ -341,7 +320,7 @@ class EditUsers {
|
|||
avatarinputins.forceUpdate();
|
||||
}
|
||||
}
|
||||
}),
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.React.createElement(BDFDB.LibraryComponents.ModalTabContent, {
|
||||
|
@ -416,7 +395,6 @@ class EditUsers {
|
|||
click: modal => {
|
||||
let olddata = Object.assign({}, data);
|
||||
|
||||
let channelnameinput = modal.querySelector(".input-channelname " + BDFDB.dotCN.input);
|
||||
let usernameinput = modal.querySelector(".input-username " + BDFDB.dotCN.input);
|
||||
let usertaginput = modal.querySelector(".input-usertag " + BDFDB.dotCN.input);
|
||||
let useravatarinput = modal.querySelector(".input-useravatar " + BDFDB.dotCN.input);
|
||||
|
@ -425,9 +403,9 @@ class EditUsers {
|
|||
|
||||
data.name = usernameinput.value.trim() || null;
|
||||
data.tag = usertaginput.value.trim() || null;
|
||||
data.url = (!data.removeIcon && BDFDB.containsClass(useravatarinput, BDFDB.disCN.inputsuccess) ? useravatarinput.value.trim() : null) || null;
|
||||
data.removeIcon = removeiconinput.checked;
|
||||
data.ignoreTagColor = ignoretagcolorinput.checked;
|
||||
data.url = (!data.removeIcon && BDFDB.containsClass(useravatarinput, BDFDB.disCN.inputsuccess) ? useravatarinput.value.trim() : null) || null;
|
||||
|
||||
data.color1 = BDFDB.getSwatchColor(modal, 1);
|
||||
data.color2 = BDFDB.getSwatchColor(modal, 2);
|
||||
|
@ -437,10 +415,7 @@ class EditUsers {
|
|||
let changed = false;
|
||||
if (Object.keys(data).every(key => data[key] == null || data[key] == false) && (changed = true)) BDFDB.removeData(info.id, this, "users");
|
||||
else if (!BDFDB.equals(olddata, data) && (changed = true)) BDFDB.saveData(info.id, data, this, "users");
|
||||
if (changed) {
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
if (changed) this.forceUpdateAll();
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
@ -755,11 +730,34 @@ class EditUsers {
|
|||
processStandardSidebarView (instance, wrapper, returnvalue) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
this.changeAppTitle();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
this.forceUpdateAll();
|
||||
}
|
||||
}
|
||||
|
||||
checkUrl (url, instance) {
|
||||
let input = BDFDB.React.findDOMNode(instance).firstElementChild;
|
||||
clearTimeout(instance.checkTimeout);
|
||||
if (url == null || !url.trim()) {
|
||||
if (input) BDFDB.removeEles(input.tooltip);
|
||||
instance.props.inputClassName = null;
|
||||
instance.forceUpdate();
|
||||
}
|
||||
else instance.checkTimeout = setTimeout(() => {
|
||||
BDFDB.LibraryRequires.request(url.trim(), (error, response, result) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") != -1) {
|
||||
if (input) BDFDB.removeEles(input.tooltip);
|
||||
instance.props.inputClassName = BDFDB.disCN.inputsuccess;
|
||||
}
|
||||
else {
|
||||
this.createNoticeTooltip(input, true);
|
||||
instance.props.inputClassName = BDFDB.disCN.inputerror;
|
||||
}
|
||||
delete instance.checkTimeout;
|
||||
instance.forceUpdate();
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
createNoticeTooltip (input, isinvalid = false) {
|
||||
if (!input) return;
|
||||
BDFDB.removeEles(input.tooltip);
|
||||
|
|
Loading…
Reference in New Issue