Fix newly created service failing to load on client
This commit is contained in:
parent
6a822c97f3
commit
c89f12e691
@ -119,27 +119,34 @@ ipcRenderer.on('data', (event, appData, brandIcons, solidIcons, actualServices,
|
|||||||
emptyPage = emptyUrl;
|
emptyPage = emptyUrl;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function removeServiceFeatures(id) {
|
||||||
|
const nav = document.querySelector('#service-selector');
|
||||||
|
|
||||||
|
// Remove nav
|
||||||
|
const oldNavButton = nav.querySelector('li:nth-of-type(' + (id + 1) + ')');
|
||||||
|
if (oldNavButton) {
|
||||||
|
nav.removeChild(oldNavButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove webview
|
||||||
|
if (services[id] && services[id].view) {
|
||||||
|
const serviceContainer = document.querySelector('#services');
|
||||||
|
serviceContainer.removeChild(services[id].view);
|
||||||
|
}
|
||||||
|
|
||||||
|
return oldNavButton;
|
||||||
|
}
|
||||||
|
|
||||||
ipcRenderer.on('updateService', (e, id, data) => {
|
ipcRenderer.on('updateService', (e, id, data) => {
|
||||||
if (id === null) {
|
if (id === null) {
|
||||||
services.push(data);
|
services.push(data);
|
||||||
createService(services.length - 1);
|
createService(services.length - 1);
|
||||||
} else {
|
} else {
|
||||||
const nav = document.querySelector('#service-selector');
|
const oldNavButton = removeServiceFeatures(id);
|
||||||
|
|
||||||
// Remove nav
|
|
||||||
const oldNavButton = nav.querySelector('li:nth-of-type(' + (id + 1) + ')');
|
|
||||||
const nextNavButton = oldNavButton.nextSibling;
|
|
||||||
nav.removeChild(oldNavButton);
|
|
||||||
|
|
||||||
// Remove webview
|
|
||||||
if (services[id].view) {
|
|
||||||
const serviceContainer = document.querySelector('#services');
|
|
||||||
serviceContainer.removeChild(services[id].view);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create new service
|
// Create new service
|
||||||
services[id] = data;
|
services[id] = data;
|
||||||
createService(id, nextNavButton);
|
createService(id, oldNavButton ? oldNavButton.nextSibling : null);
|
||||||
if (parseInt(selectedService) === id) {
|
if (parseInt(selectedService) === id) {
|
||||||
setActiveService(id);
|
setActiveService(id);
|
||||||
}
|
}
|
||||||
@ -172,19 +179,7 @@ ipcRenderer.on('reorderService', (e, serviceId, targetId) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcRenderer.on('deleteService', (e, id) => {
|
ipcRenderer.on('deleteService', (e, id) => {
|
||||||
const nav = document.querySelector('#service-selector');
|
removeServiceFeatures(id);
|
||||||
|
|
||||||
// Remove nav
|
|
||||||
const navButton = nav.querySelector('li:nth-of-type(' + (id + 1) + ')');
|
|
||||||
if (navButton) {
|
|
||||||
nav.removeChild(navButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove webview
|
|
||||||
if (services[id].view) {
|
|
||||||
const serviceContainer = document.querySelector('#services');
|
|
||||||
serviceContainer.removeChild(services[id].view);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parseInt(selectedService) === id) {
|
if (parseInt(selectedService) === id) {
|
||||||
setActiveService(0);
|
setActiveService(0);
|
||||||
|
@ -144,6 +144,7 @@ function createWindow() {
|
|||||||
config.services[id] = newService;
|
config.services[id] = newService;
|
||||||
} else {
|
} else {
|
||||||
config.services.push(newService);
|
config.services.push(newService);
|
||||||
|
id = config.services.indexOf(newService);
|
||||||
}
|
}
|
||||||
config.save();
|
config.save();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user