Skip to content

Commit

Permalink
Update main window
Browse files Browse the repository at this point in the history
Shows toast with information when themes are not loaded instead of constantly reloading the frontend.
  • Loading branch information
amanharwara committed Apr 8, 2019
1 parent 809dbde commit 0d999ff
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/windows/main/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
33 changes: 27 additions & 6 deletions src/windows/main/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ let themes = new Store({
name: 'themes'
});

$('.dropdown').dropdown();
$('.dropdown').dropdown({
values: generateThemeNames()
});

function loadTabsFromStorage() {

let storedTabs = tabs.get('instances');
Expand Down Expand Up @@ -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: [
['<button>Reload</button>', (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;
Expand Down

0 comments on commit 0d999ff

Please sign in to comment.