Fix offline app exception handling, optimize patch

This commit is contained in:
2024-01-27 07:25:30 +05:30
parent c5c95499af
commit f16738fe60
2 changed files with 12 additions and 29 deletions

View File

@@ -34,7 +34,7 @@ class GlobalModel extends ChangeNotifier {
} else {
return "";
}
} on SocketException catch (exce) {
} on (ClientException, SocketException, HttpException) catch (exce) {
print("Unable to download hash");
print(exce);
return "";

View File

@@ -1,15 +1,13 @@
--- menu/build/web/flutter_service_worker.js 2024-01-26 14:59:42.195084752 +0530
+++ in/flutter_service_worker.pat.js 2024-01-26 15:07:37.253097455 +0530
@@ -2,6 +2,7 @@
--- flutter_service_worker.js.orig 2024-01-27 06:21:03.225353652 +0530
+++ flutter_service_worker.js 2024-01-27 06:56:23.531689565 +0530
@@ -1,4 +1,5 @@
'use strict';
+const BaseHREF = 'HREFREPLACE';
const MANIFEST = 'flutter-app-manifest';
const TEMP = 'flutter-temp-cache';
const CACHE_NAME = 'flutter-app-cache';
+const BaseHREF = 'HREFREPLACE';
const RESOURCES = {
"version.json": "d7fbd41faace5a7a02bb5da13e6049ec",
@@ -37,10 +38,7 @@
};
@@ -36,10 +37,7 @@
"version.json": "d7fbd41faace5a7a02bb5da13e6049ec"};
// The application shell files that are downloaded before a service worker can
// start.
-const CORE = ["main.dart.js",
@@ -19,28 +17,12 @@
+const CORE = Object.keys(RESOURCES);
// During install, the TEMP cache is populated with the application shell files.
self.addEventListener("install", (event) =>
@@ -139,13 +137,30 @@
{
self.addEventListener("install", (event) => {
@@ -123,12 +121,13 @@
if (key.indexOf('?v=') != -1) {
key = key.split('?v=')[0];
}
- if (event.request.url == origin || event.request.url.startsWith(origin + '/#') || key == '') {
+ if (key.endsWith("chromium/canvaskit.js"))
+ {
+ key = "canvaskit/chromium/canvaskit.js"
+ }
+ if (key.endsWith("chromium/canvaskit.wasm"))
+ {
+ key = "canvaskit/chromium/canvaskit.wasm"
+ }
+ if (key.endsWith("canvaskit.js"))
+ {
+ key = "canvaskit/canvaskit.js"
+ }
+ if (key.endsWith("canvaskit.wasm"))
+ {
+ key = "canvaskit/canvaskit.wasm"
+ }
+ if (event.request.url == origin || event.request.url.startsWith(origin + '/#') || key == '' || key == BaseHREF) {
key = '/';
}
@@ -51,3 +33,4 @@
+ if (!RESOURCES[resKey]) {
return;
}
// If the URL is the index.html, perform an online-first request.