Add reload button to service context menu

This commit is contained in:
Alice Gaudon 2020-01-10 15:11:34 +01:00
parent 37931f7351
commit 6615f59af7

View File

@ -43,7 +43,7 @@
const icons = [];
let services = [];
let selectedService = 0;
let selectedService = null;
let forwardButton;
let backButton;
let addButton;
@ -51,6 +51,11 @@
// Service context menu
const serviceContextMenu = new Menu();
serviceContextMenu.append(new MenuItem({
label: 'Reload', click: () => {
reloadService(serviceContextMenu.serviceId);
}
}));
serviceContextMenu.append(new MenuItem({
label: 'Close', click: () => {
unloadService(serviceContextMenu.serviceId);
@ -267,6 +272,10 @@
updateNavigation();
service.li.classList.add('loaded');
service.viewReady = true;
if (selectedService === null) {
setActiveService(serviceId);
}
});
// Load favicon
@ -311,6 +320,16 @@
}
}
function reloadService(serviceId) {
const service = services[serviceId];
if (service.view && service.viewReady) {
document.querySelector('#services > .loader').classList.remove('hidden');
service.view.reload();
} else if (!service.view && !service.viewReady) {
loadService(serviceId, service);
}
}
function updateNavigation() {
console.debug('Updating navigation');
// Update active list element