Fixes toasts on non-chat screens

Hopefully fixes Travis deploy as well.
This commit is contained in:
Zack Rauen 2020-08-16 01:40:46 -04:00
parent 5d9de576aa
commit 30c4653b20
4 changed files with 80 additions and 34 deletions

View File

@ -18,6 +18,7 @@ script:
- npm run test
- npm run lint
before_deploy: "echo 'node_modules' > .gitignore"
deploy:
provider: pages
skip_cleanup: true

70
package-lock.json generated
View File

@ -5860,9 +5860,9 @@
}
},
"mocha": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-8.0.1.tgz",
"integrity": "sha512-vefaXfdYI8+Yo8nPZQQi0QO2o+5q9UIMX1jZ1XMmK3+4+CQjc7+B0hPdUeglXiTlr8IHMVRo63IhO9Mzt6fxOg==",
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-8.1.1.tgz",
"integrity": "sha512-p7FuGlYH8t7gaiodlFreseLxEmxTgvyG9RgPHODFPySNhwUehu8NIb0vdSt3WFckSneswZ0Un5typYcWElk7HQ==",
"dev": true,
"requires": {
"ansi-colors": "4.1.1",
@ -5881,7 +5881,7 @@
"ms": "2.1.2",
"object.assign": "4.1.0",
"promise.allsettled": "1.0.2",
"serialize-javascript": "3.0.0",
"serialize-javascript": "4.0.0",
"strip-json-comments": "3.0.1",
"supports-color": "7.1.0",
"which": "2.0.2",
@ -5889,7 +5889,7 @@
"workerpool": "6.0.0",
"yargs": "13.3.2",
"yargs-parser": "13.1.2",
"yargs-unparser": "1.6.0"
"yargs-unparser": "1.6.1"
},
"dependencies": {
"ansi-colors": {
@ -6069,10 +6069,13 @@
}
},
"serialize-javascript": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.0.0.tgz",
"integrity": "sha512-skZcHYw2vEX4bw90nAr2iTTsz6x2SrHEnfxgKYmZlvJYBEZrvbKtobJWlQ20zczKb3bsHHXXTYt48zBA7ni9cw==",
"dev": true
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
"integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
"dev": true,
"requires": {
"randombytes": "^2.1.0"
}
},
"strip-json-comments": {
"version": "3.0.1",
@ -9656,14 +9659,53 @@
}
},
"yargs-unparser": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.0.tgz",
"integrity": "sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==",
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.1.tgz",
"integrity": "sha512-qZV14lK9MWsGCmcr7u5oXGH0dbGqZAIxTDrWXZDo5zUr6b6iUmelNKO6x6R1dQT24AH3LgRxJpr8meWy2unolA==",
"dev": true,
"requires": {
"camelcase": "^5.3.1",
"decamelize": "^1.2.0",
"flat": "^4.1.0",
"lodash": "^4.17.15",
"yargs": "^13.3.0"
"is-plain-obj": "^1.1.0",
"yargs": "^14.2.3"
},
"dependencies": {
"is-plain-obj": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
"integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=",
"dev": true
},
"yargs": {
"version": "14.2.3",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.3.tgz",
"integrity": "sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg==",
"dev": true,
"requires": {
"cliui": "^5.0.0",
"decamelize": "^1.2.0",
"find-up": "^3.0.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^3.0.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^15.0.1"
}
},
"yargs-parser": {
"version": "15.0.1",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.1.tgz",
"integrity": "sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw==",
"dev": true,
"requires": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
}
}
}
}
}

View File

@ -8,12 +8,10 @@
"watch": "webpack --progress --colors --watch",
"build-prod": "webpack --progress --colors --mode production -o dist/remote.js --devtool none",
"lint-js": "eslint --ext .jsx,.js src/",
"build-css": "gulp build-css",
"watch-css": "gulp watch-css",
"build-prod-css": "gulp minify-css",
"lint-css": "stylelint src/styles/*.css && stylelint src/styles/**/*.css",
"prod": "npm run build-prod && npm run build-prod-css",
"lint": "npm run lint-js && npm run lint-css",
"test": "mocha --require @babel/register --recursive \"./tests/*.js\"",
@ -41,7 +39,7 @@
"gulp": "^4.0.2",
"gulp-postcss": "^8.0.0",
"gulp-rename": "^2.0.0",
"mocha": "^8.0.1",
"mocha": "^8.1.1",
"postcss-csso": "^4.0.0",
"postcss-easy-import": "^3.0.0",
"stylelint": "^13.6.1",

View File

@ -1,4 +1,4 @@
import {WebpackModules, Settings, DOMManager} from "modules";
import {WebpackModules, Settings, DOMManager, Logger} from "modules";
export default class Toasts {
@ -33,28 +33,33 @@ export default class Toasts {
* @param {boolean} [options.forceShow=false] Whether to force showing the toast and ignore the bd setting
*/
static show(content, options = {}) {
const {type = "", icon = true, timeout = 3000, forceShow = false} = options;
if (!this.shouldShowToasts && !forceShow) return;
this.ensureContainer();
const toastElem = document.createElement("div");
toastElem.classList.add("bd-toast");
if (type) toastElem.classList.add("toast-" + type);
if (type && icon) toastElem.classList.add("icon");
toastElem.innerText = content;
document.querySelector(".bd-toasts").appendChild(toastElem);
setTimeout(() => {
toastElem.classList.add("closing");
try {
const {type = "", icon = true, timeout = 3000, forceShow = false} = options;
if (!this.shouldShowToasts && !forceShow) return;
this.ensureContainer();
const toastElem = document.createElement("div");
toastElem.classList.add("bd-toast");
if (type) toastElem.classList.add("toast-" + type);
if (type && icon) toastElem.classList.add("icon");
toastElem.innerText = content;
document.querySelector(".bd-toasts").appendChild(toastElem);
setTimeout(() => {
toastElem.remove();
if (!document.querySelectorAll(".bd-toasts .bd-toast").length) document.querySelector(".bd-toasts").remove();
}, 300);
}, timeout);
toastElem.classList.add("closing");
setTimeout(() => {
toastElem.remove();
if (!document.querySelectorAll(".bd-toasts .bd-toast").length) document.querySelector(".bd-toasts").remove();
}, 300);
}, timeout);
}
catch (err) {
Logger.stacktrace("Toasts", "Unable to show toast", err);
}
}
static ensureContainer() {
if (document.querySelector(".bd-toasts")) return;
const container = document.querySelector(`.${this.ChannelsClass} + div`);
const memberlist = container.querySelector(`.${this.MembersWrapClass}`);
const memberlist = container ? container.querySelector(`.${this.MembersWrapClass}`) : null;
const form = container ? container.querySelector("form") : null;
const left = container ? container.getBoundingClientRect().left : 310;
const right = memberlist ? memberlist.getBoundingClientRect().left : 0;