Return to material 2, cleanup patch

This commit is contained in:
2024-03-12 12:44:18 +05:30
parent e417622210
commit 531699a8bb
3 changed files with 14 additions and 25 deletions

View File

@@ -18,9 +18,10 @@ class MainApp extends StatelessWidget {
lazy: false, lazy: false,
create: (context) => GlobalModel(), create: (context) => GlobalModel(),
builder: (BuildContext context, child) { builder: (BuildContext context, child) {
return const MaterialApp( return MaterialApp(
title: "IIITB Menu", title: "IIITB Menu",
home: HomePage(), home: const HomePage(),
theme: ThemeData(useMaterial3: false),
); );
}, },
); );

View File

@@ -16,7 +16,7 @@ class GlobalModel extends ChangeNotifier {
DataStatus menuAvailable = DataStatus.Loading; DataStatus menuAvailable = DataStatus.Loading;
GlobalModel() { GlobalModel() {
print("In constructor"); // print("In constructor");
GlobalModel.loadData().then((value) { GlobalModel.loadData().then((value) {
mainData = value; mainData = value;
if (this.mainData["dates"].keys.contains(this.date)) { if (this.mainData["dates"].keys.contains(this.date)) {
@@ -58,12 +58,12 @@ class GlobalModel extends ChangeNotifier {
String? rawData; String? rawData;
String rawHash; String rawHash;
rawData = prefs.getString(storageKey); rawData = prefs.getString(storageKey);
print(rawData); // print(rawData);
if (rawData != null) { if (rawData != null) {
print("data found"); // print("data found");
rawHash = md5.convert(utf8.encode(rawData)).toString(); rawHash = md5.convert(utf8.encode(rawData)).toString();
print("Hash of Raw Data:"); // print("Hash of Raw Data:");
print(rawHash); // print(rawHash);
returnData = jsonDecode(rawData); returnData = jsonDecode(rawData);
} else { } else {
print("Data Not Found"); print("Data Not Found");

View File

@@ -1,35 +1,23 @@
--- flutter_service_worker.js.orig 2024-01-27 06:21:03.225353652 +0530 --- flutter_service_worker.js.bak 2024-01-28 17:40:14.621116939 +0530
+++ flutter_service_worker.js 2024-01-27 06:56:23.531689565 +0530 +++ flutter_service_worker.js 2024-01-28 17:41:33.479719944 +0530
@@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
'use strict'; 'use strict';
+const BaseHREF = 'HREFREPLACE'; +const BASE_HREF = "IIITB_Menu/";
const MANIFEST = 'flutter-app-manifest'; const MANIFEST = 'flutter-app-manifest';
const TEMP = 'flutter-temp-cache'; const TEMP = 'flutter-temp-cache';
const CACHE_NAME = 'flutter-app-cache'; const CACHE_NAME = 'flutter-app-cache';
@@ -36,10 +37,7 @@ @@ -123,12 +124,13 @@
"version.json": "d7fbd41faace5a7a02bb5da13e6049ec"};
// The application shell files that are downloaded before a service worker can
// start.
-const CORE = ["main.dart.js",
-"index.html",
-"assets/AssetManifest.json",
-"assets/FontManifest.json"];
+const CORE = Object.keys(RESOURCES);
// During install, the TEMP cache is populated with the application shell files.
self.addEventListener("install", (event) => {
@@ -123,12 +121,13 @@
if (key.indexOf('?v=') != -1) { if (key.indexOf('?v=') != -1) {
key = key.split('?v=')[0]; key = key.split('?v=')[0];
} }
- if (event.request.url == origin || event.request.url.startsWith(origin + '/#') || key == '') { - if (event.request.url == origin || event.request.url.startsWith(origin + '/#') || key == '') {
+ if (event.request.url == origin || event.request.url.startsWith(origin + '/#') || key == '' || key == BaseHREF) { + if (event.request.url == origin || event.request.url.startsWith(origin + '/#') || key == '' || key == BASE_HREF) {
key = '/'; key = '/';
} }
// If the URL is not the RESOURCE list then return to signal that the // If the URL is not the RESOURCE list then return to signal that the
// browser should take over. // browser should take over.
- if (!RESOURCES[key]) { - if (!RESOURCES[key]) {
+ var resKey = key.replace(BaseHREF, ""); + var resKey = key.replace(BASE_HREF, "");
+ if (!RESOURCES[resKey]) { + if (!RESOURCES[resKey]) {
return; return;
} }