From 0d999ff397be973b4bbab2ee89abffe3f15bb054 Mon Sep 17 00:00:00 2001 From: ShadyThGod Date: Mon, 8 Apr 2019 13:42:32 +0530 Subject: [PATCH] Update main window Shows toast with information when themes are not loaded instead of constantly reloading the frontend. --- src/windows/main/css/main.css | 3 ++- src/windows/main/js/main.js | 33 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/windows/main/css/main.css b/src/windows/main/css/main.css index 4f48cd3a..661fc78d 100644 --- a/src/windows/main/css/main.css +++ b/src/windows/main/css/main.css @@ -99,6 +99,7 @@ body { background: linear-gradient(to right, #11998e, #2aaa5b) !important; } -.error-toast { +.error-toast, +.themes-not-loaded-toast { background: linear-gradient(to right, #f12711, #a37510) !important; } \ No newline at end of file diff --git a/src/windows/main/js/main.js b/src/windows/main/js/main.js index e4a8c9af..2a57ed9e 100644 --- a/src/windows/main/js/main.js +++ b/src/windows/main/js/main.js @@ -39,11 +39,6 @@ let themes = new Store({ name: 'themes' }); -$('.dropdown').dropdown(); -$('.dropdown').dropdown({ - values: generateThemeNames() -}); - function loadTabsFromStorage() { let storedTabs = tabs.get('instances'); @@ -136,7 +131,33 @@ function generateThemeNames() { nameList.push(themeJSON); }); } else { - window.location.reload(); + Toast.show({ + position: 'center', + class: `themes-not-loaded-toast`, + id: `toast-${generateId()}`, + title: 'Themes Not Loaded!', + message: 'You may not be able to use any themes as they are not loaded. Click the Reload button to reload the window or click the button to close this notification.', + timeout: false, + progressBar: false, + theme: 'dark', + buttons: [ + ['', (i, t) => { + window.location.reload(); + i.hide({}, t) + }, false] + ], + onOpening: (elem) => { + console.log(elem) + let tArray = []; + document.querySelectorAll('.themes-not-loaded-toast').forEach(e => tArray.push(e)); + console.log(tArray); + let prevTs = tArray.filter(i => i.id !== elem.id); + prevTs.forEach(el => { + Toast.hide({}, el); + }); + }, + overlay: true, + }); } return nameList;