Couldn't stand the challenge, you could do something similar as I suggested here. Added the catch block to detect connection drops:
const nativeFetch = window.fetch;
window.fetch = function (...args) {
console.trace('detected fetch call');
const prom = nativeFetch.apply(window, args);
prom.then(response => {
if (response.status == 401) {
alert("Your session expired, goodbye!");
}
}).catch(error => {
console.error("Fetch failed:", error);
// Here you can add code to handle the failed fetch due to internet connection drop
// For example, you can show an alert or perform some other action.
alert("Fetch failed due to internet connection drop!");
});
return prom;
};
In the widget mobile features: https://marketplace.mendix.com/link/component/48902 you have this option:
Custom body classes:
May be you can use this to show a warning to the user that the person is currently offline.
Regards,
Ronald