fix: navigating to the config pages allways loads, not only on the first attempt.

This commit is contained in:
redxef 2025-01-21 22:51:25 +01:00
parent 2f07efd215
commit eef2f32e14
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
3 changed files with 61 additions and 60 deletions

View file

@ -21,23 +21,26 @@ function initial_load() {
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
} }
document.querySelector('#LispPlaygroundConfigPage') export default function (view, params) {
.addEventListener('viewshow', function() { view.addEventListener('viewshow', function() {
initial_load(); initial_load(null);
}); });
view.addEventListener('viewhide', function (_e) {});
view.addEventListener('viewdestroy', function (_e) {});
document.querySelector('#LispPlaygroundConfigPage') document.querySelector('#LispPlaygroundConfigPage')
.addEventListener('pageshow', function() { .addEventListener('pageshow', function() {
initial_load(); initial_load();
});
document.querySelector('#LispPlaygroundConfigForm')
.addEventListener('submit', function (e) {
e.preventDefault();
Dashboard.showLoadingMsg();
const editProgram = document.querySelector('#LispPlaygroundEditProgram');
ApiClient.runLispProgram(editProgram.value).then(function (r) {
fillForm(r);
Dashboard.hideLoadingMsg();
}); });
});
document.querySelector('#LispPlaygroundConfigForm')
.addEventListener('submit', function (e) {
e.preventDefault();
Dashboard.showLoadingMsg();
const editProgram = document.querySelector('#LispPlaygroundEditProgram');
ApiClient.runLispProgram(editProgram.value).then(function (r) {
fillForm(r);
Dashboard.hideLoadingMsg();
});
});
}

View file

@ -88,29 +88,28 @@ function initial_load(selectedId) {
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}); });
} }
document.querySelector('#SmartCollectionConfigPage')
.addEventListener('viewshow', function() { export default function (view, params) {
view.addEventListener('viewshow', function() {
initial_load(null); initial_load(null);
}); });
view.addEventListener('viewhide', function (_e) {});
view.addEventListener('viewdestroy', function (_e) {});
document.querySelector('#SmartCollectionConfigPage') document.querySelector('#SmartcollectionSelection')
.addEventListener('pageshow', function() { .addEventListener('change', function() {
initial_load(null); const selection = document.querySelector('#SmartcollectionSelection');
}); fillForm(COLLECTIONS[selection.selectedIndex]);
document.querySelector('#SmartcollectionSelection')
.addEventListener('change', function() {
const selection = document.querySelector('#SmartcollectionSelection');
fillForm(COLLECTIONS[selection.selectedIndex]);
});
document.querySelector('#SmartCollectionConfigForm')
.addEventListener('submit', function (e) {
Dashboard.showLoadingMsg();
const selection = document.querySelector('#SmartcollectionSelection');
const selectedId = COLLECTIONS[selection.selectedIndex].Id;
ApiClient.setSmartCollection(jsonFromForm(COLLECTIONS[selection.selectedIndex].CollectionId)).then(function () {
initial_load(selectedId);
}); });
e.preventDefault();
}); document.querySelector('#SmartCollectionConfigForm')
.addEventListener('submit', function (e) {
Dashboard.showLoadingMsg();
const selection = document.querySelector('#SmartcollectionSelection');
const selectedId = COLLECTIONS[selection.selectedIndex].Id;
ApiClient.setSmartCollection(jsonFromForm(COLLECTIONS[selection.selectedIndex].CollectionId)).then(function () {
initial_load(selectedId);
});
e.preventDefault();
});
}

View file

@ -116,28 +116,27 @@ function initial_load(selectedId) {
}); });
} }
document.querySelector('#SmartPlaylistConfigPage') export default function (view, params) {
.addEventListener('viewshow', function() { view.addEventListener('viewshow', function() {
initial_load(null);
});
document.querySelector('#SmartPlaylistConfigPage')
.addEventListener('pageshow', function() {
initial_load(null); initial_load(null);
}); });
view.addEventListener('viewhide', function (_e) {});
view.addEventListener('viewdestroy', function (_e) {});
document.querySelector('#SmartplaylistSelection') document.querySelector('#SmartplaylistSelection')
.addEventListener('change', function() { .addEventListener('change', function() {
const selection = document.querySelector('#SmartplaylistSelection'); const selection = document.querySelector('#SmartplaylistSelection');
fillForm(PLAYLISTS[selection.selectedIndex], USERS); fillForm(PLAYLISTS[selection.selectedIndex], USERS);
});
document.querySelector('#SmartPlaylistConfigForm')
.addEventListener('submit', function (e) {
Dashboard.showLoadingMsg();
const selection = document.querySelector('#SmartplaylistSelection');
const selectedId = PLAYLISTS[selection.selectedIndex].Id;
ApiClient.setSmartPlaylist(jsonFromForm()).then(function () {
initial_load(selectedId);
}); });
e.preventDefault();
}); document.querySelector('#SmartPlaylistConfigForm')
.addEventListener('submit', function (e) {
Dashboard.showLoadingMsg();
const selection = document.querySelector('#SmartplaylistSelection');
const selectedId = PLAYLISTS[selection.selectedIndex].Id;
ApiClient.setSmartPlaylist(jsonFromForm()).then(function () {
initial_load(selectedId);
});
e.preventDefault();
});
}