This commit is contained in:
Mirco Wittrien 2022-04-29 14:52:56 +02:00
parent 0d71b49d6e
commit 0c66862c37
8 changed files with 82 additions and 81 deletions

View File

@ -1648,11 +1648,13 @@ module.exports = (_ => {
}
else BDFDB.DOMUtils.addClass(data.toast, type);
let loadingInterval;
let disableInteractions = data.config.disableInteractions && typeof data.config.onClick != "function";
let timeout = typeof data.config.timeout == "number" && !disableInteractions ? data.config.timeout : 3000;
timeout = (timeout > 0 ? timeout : 600000) + 300;
if (data.config.ellipsis && typeof data.children == "string") loadingInterval = BDFDB.TimeUtils.interval(_ => data.toast.update(data.children.endsWith(".....") ? data.children.slice(0, -5) : data.children + "."), 500);
let progressInterval, closeTimeout = BDFDB.TimeUtils.timeout(_ => data.toast.close(), timeout);
let closeTimeout = BDFDB.TimeUtils.timeout(_ => data.toast.close(), timeout);
data.toast.close = _ => {
BDFDB.TimeUtils.clear(closeTimeout);
if (document.contains(data.toast)) {
@ -1660,6 +1662,7 @@ module.exports = (_ => {
data.toast.style.setProperty("pointer-events", "none", "important");
BDFDB.TimeUtils.timeout(_ => {
if (typeof data.config.onClose == "function") data.config.onClose();
BDFDB.TimeUtils.clear(loadingInterval);
BDFDB.ArrayUtils.remove(Toasts, id);
BDFDB.DOMUtils.removeLocalStyle("BDFDBcustomToast" + id);
data.toast.remove();
@ -1710,7 +1713,7 @@ module.exports = (_ => {
componentDidMount() {
data.toast.update = newChildren => {
if (!newChildren) return;
this.props.children = newChildren;
data.children = newChildren;
BDFDB.ReactUtils.forceUpdate(this);
};
}
@ -1731,7 +1734,7 @@ module.exports = (_ => {
}),
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.toasttext, data.config.textClassName),
children: this.props.children
children: data.children
}),
!disableInteractions && BDFDB.ReactUtils.createElement(Internal.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.toastcloseicon,
@ -1751,7 +1754,7 @@ module.exports = (_ => {
]
});
}
}, {children: data.children}), data.toast);
}, {}), data.toast);
ToastQueues[position].full = (BDFDB.ArrayUtils.sum(Array.from(toasts.childNodes).map(c => {
let height = BDFDB.DOMUtils.getRects(c).height;

View File

@ -438,26 +438,40 @@ module.exports = (_ => {
installed: this.props.data.state == pluginStates.INSTALLED,
outdated: this.props.data.state == pluginStates.OUTDATED,
onDownload: _ => {
if (this.props.downloading) return;
this.props.downloading = true;
let loadingToast = BDFDB.NotificationUtils.toast(`${BDFDB.LanguageUtils.LibraryStringsFormat("loading", this.props.data.name)} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {timeout: 0, ellipsis: true});
BDFDB.LibraryRequires.request(this.props.data.rawSourceUrl, (error, response, body) => {
if (error) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("download_fail", `Plugin "${this.props.data.name}"`), {type: "danger"});
else BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), this.props.data.rawSourceUrl.split("/").pop()), body, error2 => {
if (error2) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_fail", `Plugin "${this.props.data.name}"`), {type: "danger"});
else {
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_success", `Plugin "${this.props.data.name}"`), {type: "success"});
if (_this.settings.general.rnmStart) BDFDB.TimeUtils.timeout(_ => {
if (this.props.data.state == pluginStates.INSTALLED && BDFDB.BDUtils.isPluginEnabled(this.props.data.name) == false) {
BDFDB.BDUtils.enablePlugin(this.props.data.name, false);
BDFDB.LogUtils.log(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_started", this.props.data.name), _this);
}
}, 3000);
this.props.data.state = pluginStates.INSTALLED;
BDFDB.ReactUtils.forceUpdate(this);
}
})
})
if (error) {
delete this.props.downloading;
loadingToast.close();
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("download_fail", `Plugin "${this.props.data.name}"`), {type: "danger"});
}
else {
BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), this.props.data.rawSourceUrl.split("/").pop()), body, error2 => {
delete this.props.downloading;
loadingToast.close();
if (error2) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_fail", `Plugin "${this.props.data.name}"`), {type: "danger"});
else {
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_success", `Plugin "${this.props.data.name}"`), {type: "success"});
if (_this.settings.general.rnmStart) BDFDB.TimeUtils.timeout(_ => {
if (this.props.data.state == pluginStates.INSTALLED && BDFDB.BDUtils.isPluginEnabled(this.props.data.name) == false) {
BDFDB.BDUtils.enablePlugin(this.props.data.name, false);
BDFDB.LogUtils.log(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_started", this.props.data.name), _this);
}
}, 3000);
this.props.data.state = pluginStates.INSTALLED;
BDFDB.ReactUtils.forceUpdate(this);
}
});
}
});
},
onDelete: _ => {
if (this.props.deleting) return;
this.props.deleting = true;
BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), this.props.data.rawSourceUrl.split("/").pop()), error => {
delete this.props.deleting;
if (error) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("delete_fail", `Plugin "${this.props.data.name}"`), {type: "danger"});
else {
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("delete_success", `Plugin "${this.props.data.name}"`));

View File

@ -235,26 +235,20 @@ module.exports = (_ => {
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsGuildList, {
className: BDFDB.disCN.marginbottom20,
disabled: BDFDB.DataUtils.load(this, "blacklist"),
onClick: disabledGuilds => {
this.saveBlacklist(disabledGuilds);
}
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);
},
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);
},
onClick: _ => this.batchSetGuilds(settingsPanel, collapseStates, false),
children: BDFDB.LanguageUtils.LanguageStrings.DISABLE
})
]
@ -303,17 +297,7 @@ module.exports = (_ => {
let messages = [].concat(mentionedMessages).filter(n => n);
if (messages.length) {
clearing = true;
let toastInterval;
let loadingString = `${this.labels.toast_clearing} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`;
let currentLoadingString = loadingString;
let toast = BDFDB.NotificationUtils.toast(currentLoadingString, {
timeout: 0,
onClose: _ => {BDFDB.TimeUtils.clear(toastInterval);}
});
toastInterval = BDFDB.TimeUtils.interval(_ => {
currentLoadingString = currentLoadingString.endsWith(".....") ? loadingString : currentLoadingString + ".";
toast.update(currentLoadingString);
}, 500);
let toast = BDFDB.NotificationUtils.toast(`${this.labels.toast_clearing} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {timeout: 0, ellipsis: true});
for (let i = 0; i < messages.length; i++) BDFDB.TimeUtils.timeout(_ => {
BDFDB.LibraryModules.RecentMentionUtils.deleteRecentMention(messages[i].id);
if (i == messages.length - 1) {

View File

@ -119,7 +119,7 @@ module.exports = (_ => {
BDFDB.DOMUtils.remove(BDFDB.dotCN._spellcheckoverlay);
for (let key in languageToasts) this.killLanguageToast(key);
for (let key in languageToasts) languageToasts[key] && languageToasts[key].close();
}
getSettingsPanel (collapseStates = {}) {
@ -334,26 +334,17 @@ module.exports = (_ => {
}
setDictionary (key, lang) {
this.killLanguageToast(key);
languageToasts[key] && languageToasts[key].close();
if (languages[lang]) {
let ownDictionary = BDFDB.DataUtils.load(this, "owndics", lang) || [];
let loadingString = `${this.labels.toast_dictionary.replace("{{var0}}", this.getLanguageName(languages[lang]))} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`;
let currentLoadingString = loadingString;
languageToasts[key] = BDFDB.NotificationUtils.toast(loadingString, {
timeout: 0,
position: "center"
});
languageToasts[key].interval = BDFDB.TimeUtils.interval(_ => {
currentLoadingString = currentLoadingString.endsWith(".....") ? loadingString : currentLoadingString + ".";
languageToasts[key].update(currentLoadingString);
}, 500);
languageToasts[key] = BDFDB.NotificationUtils.toast(`${this.labels.toast_dictionary.replace("{{var0}}", this.getLanguageName(languages[lang]))} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {timeout: 0, ellipsis: true, position: "center"});
languageToasts[key].lang = lang
const folder = BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), "dictionaries");
const filePath = BDFDB.LibraryRequires.path.join(folder, lang + ".dic");
const parse = (error, response, body, download) => {
this.killLanguageToast(key);
languageToasts[key].close();
if (error || (response && body.toLowerCase().indexOf("<!doctype html>") > -1)) {
BDFDB.NotificationUtils.toast(this.labels.toast_dictionary_fail.replace("{{var0}}", this.getLanguageName(languages[lang])), {
type: "danger",
@ -398,13 +389,6 @@ module.exports = (_ => {
}, {});
}
killLanguageToast (key) {
if (languageToasts[key]) {
BDFDB.TimeUtils.clear(languageToasts[key].interval);
languageToasts[key].close();
}
}
isWordNotInDictionary (unformatedWord) {
let wordLow = unformatedWord.toLowerCase();
let wordWithoutSymbols = wordLow.replace(/[0-9\µ\@\$\£\€\¥\¢\²\³\>\<\|\,\;\.\:\-\_\#\+\*\~\?\¿\\\´\`\}\=\]\)\[\(\{\/\&\%\§\"\!\¡\^\°\n\t\r]/g, "");

View File

@ -339,7 +339,10 @@ module.exports = (_ => {
}
createThemeFile(name, filename, body) {
return new Promise(callback => BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getThemesFolder(), filename), body, error => {
if (error) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_fail", `Theme "${name}"`), {type: "danger"});
if (error) {
callback(true);
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_fail", `Theme "${name}"`), {type: "danger"});
}
else {
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_success", `Theme "${name}"`), {type: "success"});
if (_this.settings.general.rnmStart) BDFDB.TimeUtils.timeout(_ => {
@ -869,16 +872,30 @@ module.exports = (_ => {
installed: this.props.data.state == themeStates.INSTALLED,
outdated: this.props.data.state == themeStates.OUTDATED,
onDownload: _ => {
list && BDFDB.LibraryRequires.request(this.props.data.rawSourceUrl, (error, response, body) => {
if (error) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("download_fail", `Theme "${this.props.data.name}"`), {type: "danger"});
else list.createThemeFile(this.props.data.name, this.props.data.rawSourceUrl.split("/").pop(), body).then(_ => {
this.props.data.state = themeStates.INSTALLED;
BDFDB.ReactUtils.forceUpdate(this);
if (!list || this.props.downloading) return;
this.props.downloading = true;
let loadingToast = BDFDB.NotificationUtils.toast(`${BDFDB.LanguageUtils.LibraryStringsFormat("loading", this.props.data.name)} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {timeout: 0, ellipsis: true});
BDFDB.LibraryRequires.request(this.props.data.rawSourceUrl, (error, response, body) => {
if (error) {
delete this.props.downloading;
loadingToast.close();
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("download_fail", `Theme "${this.props.data.name}"`), {type: "danger"});
}
else list.createThemeFile(this.props.data.name, this.props.data.rawSourceUrl.split("/").pop(), body).then(error2 => {
delete this.props.downloading;
loadingToast.close();
if (!error2) {
this.props.data.state = themeStates.INSTALLED;
BDFDB.ReactUtils.forceUpdate(this);
}
});
});
},
onDelete: _ => {
if (this.props.deleting) return;
this.props.deleting = true;
BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getThemesFolder(), this.props.data.rawSourceUrl.split("/").pop()), error => {
delete this.props.deleting;
if (error) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("delete_fail", `Theme "${this.props.data.name}"`), {type: "danger"});
else {
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("delete_success", `Theme "${this.props.data.name}"`));

View File

@ -840,7 +840,6 @@ module.exports = (_ => {
let toast = null, toastInterval, finished = false, finishTranslation = translation => {
isTranslating = false;
if (toast) toast.close();
BDFDB.TimeUtils.clear(toastInterval);
if (finished) return;
finished = true;
@ -875,25 +874,19 @@ module.exports = (_ => {
if (toast) toast.close();
BDFDB.TimeUtils.clear(toastInterval);
let loadingString = `${this.labels.toast_translating} (${translationEngines[engine].name}) - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`;
let currentLoadingString = loadingString;
toast = BDFDB.NotificationUtils.toast(loadingString, {
toast = BDFDB.NotificationUtils.toast(`${this.labels.toast_translating} (${translationEngines[engine].name}) - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {
timeout: 0,
ellipsis: true,
position: "center",
onClose: _ => BDFDB.TimeUtils.clear(toastInterval)
});
toastInterval = BDFDB.TimeUtils.interval((_, count) => {
if (count > 40) {
finishTranslation("");
BDFDB.NotificationUtils.toast(`${this.labels.toast_translating_failed} (${translationEngines[engine].name}) - ${this.labels.toast_translating_tryanother}`, {
type: "danger",
position: "center"
});
}
else {
currentLoadingString = currentLoadingString.endsWith(".....") ? loadingString : currentLoadingString + ".";
toast.update(currentLoadingString);
}
if (count < 40) return;
finishTranslation("");
BDFDB.NotificationUtils.toast(`${this.labels.toast_translating_failed} (${translationEngines[engine].name}) - ${this.labels.toast_translating_tryanother}`, {
type: "danger",
position: "center"
});
}, 500);
};
if (this.validTranslator(this.settings.engines.translator, input, output, specialCase)) {

View File

@ -7,6 +7,9 @@
.supporter-Z3FfwL.hasBadge-4rT8_u .mask-1FEkla {
-webkit-mask: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><path fill="white" d="M 0,0 H 1 V 1 H 0.29565217 V 0.8 c 0,-0.1 -0.0347826,-0.14 -0.12173913,-0.14 H 0 Z"/></svg>') center/cover no-repeat;
}
.avatar-2e8lTP.supporter-Z3FfwL.hasBadge-4rT8_u > img {
-webkit-mask: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><path fill="white" d="M 0,0 H 1 V 1 H 0.34565217 V 0.82 c 0,-0.1 -0.0347826,-0.14 -0.12173913,-0.14 H 0 Z"/></svg>') center/cover no-repeat;
}
.supporter-Z3FfwL.hasBadge-4rT8_u ~ .avatarHint-k7pYop {
-webkit-mask: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><path fill="white" d="M 0,0 H 1 V 1 H 0.34 V 0.8 C 0.34,0.72 0.3,0.7 0.2,0.7 H 0 Z"/></svg>') center/cover no-repeat;
}

View File

@ -7,6 +7,9 @@
.dev-A7f2Rx.hasBadge-4rT8_u .mask-1FEkla {
-webkit-mask: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><path fill="white" d="M 0,0 H 1 V 1 H 0.29565217 V 0.8 c 0,-0.1 -0.0347826,-0.14 -0.12173913,-0.14 H 0 Z"/></svg>') center/cover no-repeat;
}
.avatar-2e8lTP.dev-A7f2Rx.hasBadge-4rT8_u > img {
-webkit-mask: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><path fill="white" d="M 0,0 H 1 V 1 H 0.34565217 V 0.82 c 0,-0.1 -0.0347826,-0.14 -0.12173913,-0.14 H 0 Z"/></svg>') center/cover no-repeat;
}
.dev-A7f2Rx.hasBadge-4rT8_u ~ .avatarHint-k7pYop {
-webkit-mask: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><path fill="white" d="M 0,0 H 1 V 1 H 0.34 V 0.8 C 0.34,0.72 0.3,0.7 0.2,0.7 H 0 Z"/></svg>') center/cover no-repeat;
}