diff --git a/src/store/storeWp.ts b/src/store/storeWp.ts index e70e920..4d6895b 100644 --- a/src/store/storeWp.ts +++ b/src/store/storeWp.ts @@ -88,7 +88,7 @@ const useWpStore = defineStore("wp", { this.userLogin = await store.get("userLogin"); this.userToken = await store.get("userToken"); }, - createInAppBrowser(url = '',extraParams = 'location=no,fullscreen=no,zoom=no') { + createInAppBrowser(url = '',extraParams = 'location=yes,hideurlbar=yes,fullscreen=no,zoom=no,hardwareback=no,toolbarcolor=#ffffff') { let tainacanAdminUrl = this.userSiteUrl + "/wp-admin/admin.php?page=tainacan_admin&mobileAppMode=true&itemEditionMode=true" + url; if (!this.userIsLoggedIn && this.authorizationURL) tainacanAdminUrl = this.authorizationURL + "?app_name=TainacanMobileApp&success_url=" + tainacanAdminUrl; @@ -99,15 +99,19 @@ const useWpStore = defineStore("wp", { openInAppBrowser(url: string) { if (!this.inAppBrowser || !this.inAppBrowser.executeScript) - this.createInAppBrowser('#' + url, 'hidden=yes,location=no,fullscreen=no,zoom=no'); + this.createInAppBrowser('#' + url, 'hidden=yes,location=yes,hideurlbar=yes,fullscreen=no,zoom=no,hardwareback=no,toolbarcolor=#ffffff'); else { const urlRedirectionScript = ` + try { window.history.replaceState( null, null, '${this.userSiteUrl}/wp-admin/admin.php?page=tainacan_admin&mobileAppMode=true&itemEditionMode=true#${url}' ); window.history.go(0); + } catch(err){ + console.log('catch', err); + } `; this.inAppBrowser.executeScript({ code: urlRedirectionScript }); } @@ -119,6 +123,9 @@ const useWpStore = defineStore("wp", { }, listenEventInAppBrowser(event: any) { this.inAppBrowser.on('message').subscribe(event); + this.inAppBrowser.on('exit').subscribe((anEvent: any) => { + delete this.inAppBrowser; + }) } }, });