@saltcorn/mobile-app 0.9.0-beta.8 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@saltcorn/mobile-app",
3
3
  "displayName": "Saltcorn mobile app",
4
- "version": "0.9.0-beta.8",
4
+ "version": "0.9.0",
5
5
  "description": "Apache Cordova application with @saltcorn/markup",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -168,6 +168,8 @@ function addScriptToIframeHead(iframeDoc, script) {
168
168
  async function replaceIframeInnerContent(content) {
169
169
  const iframe = document.getElementById("content-iframe");
170
170
  const iframeDocument = iframe.contentWindow.document;
171
+ const modal = iframeDocument.getElementById("scmodal");
172
+ if (modal) modal.remove();
171
173
  const innerContentDiv = iframeDocument.getElementById("page-inner-content");
172
174
  innerContentDiv.innerHTML = content;
173
175
  const scripts = innerContentDiv.getElementsByTagName("script");
@@ -290,22 +292,37 @@ async function reload() {
290
292
  async function goBack(steps = 1, exitOnFirstPage = false) {
291
293
  const { inLoadState } = saltcorn.data.state.getState().mobileConfig;
292
294
  if (inLoadState) return;
295
+ const iframe = document.getElementById("content-iframe");
293
296
  if (
294
297
  routingHistory.length === 0 ||
295
298
  (exitOnFirstPage && routingHistory.length === 1)
296
299
  ) {
297
300
  navigator.app.exitApp();
298
301
  } else if (routingHistory.length <= steps) {
299
- routingHistory = [];
300
- await handleRoute("/");
302
+ try {
303
+ if (iframe?.contentWindow?.showLoadSpinner)
304
+ iframe.contentWindow.showLoadSpinner();
305
+ routingHistory = [];
306
+ await handleRoute("/");
307
+ } finally {
308
+ if (iframe?.contentWindow?.removeLoadSpinner)
309
+ iframe.contentWindow.removeLoadSpinner();
310
+ }
301
311
  } else {
302
- routingHistory = routingHistory.slice(0, routingHistory.length - steps);
303
- // don't repeat a post
304
- if (routingHistory[routingHistory.length - 1].route.startsWith("post/")) {
305
- routingHistory.pop();
312
+ try {
313
+ if (iframe?.contentWindow?.showLoadSpinner)
314
+ iframe.contentWindow.showLoadSpinner();
315
+ routingHistory = routingHistory.slice(0, routingHistory.length - steps);
316
+ // don't repeat a post
317
+ if (routingHistory[routingHistory.length - 1].route.startsWith("post/")) {
318
+ routingHistory.pop();
319
+ }
320
+ const newCurrent = routingHistory.pop();
321
+ await handleRoute(newCurrent.route, newCurrent.query);
322
+ } finally {
323
+ if (iframe?.contentWindow?.removeLoadSpinner)
324
+ iframe.contentWindow.removeLoadSpinner();
306
325
  }
307
- const newCurrent = routingHistory.pop();
308
- await handleRoute(newCurrent.route, newCurrent.query);
309
326
  }
310
327
  }
311
328