From 97cb83733cebd48a2249e83f0a05944eb2c408d6 Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 20 Nov 2023 12:56:38 -0700 Subject: [PATCH] Tweak collectibles logic to await data writing --- ios/Runner.xcodeproj/project.pbxproj | 4 ++-- lib/logic/collectibles_logic.dart | 12 ++++++------ pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 2d5075ca..1e9d1359 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -640,14 +640,14 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = "Wonderous WidgetExtension.entitlements"; + CODE_SIGN_ENTITLEMENTS = "WonderousWidgetExtension.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = S3TL5AY6Y3; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = "Wonderous Widget/Info.plist"; + INFOPLIST_FILE = "WonderousWidget/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = "Wonderous Widget"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; IPHONEOS_DEPLOYMENT_TARGET = 16.4; diff --git a/lib/logic/collectibles_logic.dart b/lib/logic/collectibles_logic.dart index 5319f68e..cff1bddb 100644 --- a/lib/logic/collectibles_logic.dart +++ b/lib/logic/collectibles_logic.dart @@ -38,6 +38,8 @@ class CollectiblesLogic with ThrottledSaveLoadMixin { void setState(String id, int state) { Map states = Map.of(statesById.value); + states[id] = state; + statesById.value = states; if (state == CollectibleState.discovered) { final data = fromId(id)!; _updateHomeWidgetTextData( @@ -46,8 +48,6 @@ class CollectiblesLogic with ThrottledSaveLoadMixin { imageUrl: data.imageUrlSmall, ); } - states[id] = state; - statesById.value = states; scheduleSave(); } @@ -99,14 +99,14 @@ class CollectiblesLogic with ThrottledSaveLoadMixin { Future _updateHomeWidgetTextData({String title = '', String id = '', String imageUrl = ''}) async { // Save title - HomeWidget.saveWidgetData('lastDiscoveredTitle', title); + await HomeWidget.saveWidgetData('lastDiscoveredTitle', title); // Subtitle String subTitle = ''; if(id.isNotEmpty){ final artifactData = await artifactLogic.getArtifactByID(id); subTitle = artifactData?.date ?? ''; } - HomeWidget.saveWidgetData('lastDiscoveredSubTitle', subTitle); + await HomeWidget.saveWidgetData('lastDiscoveredSubTitle', subTitle); // Image, // Download, convert to base64 string and write to shared widget data String imageBase64 = ''; @@ -115,8 +115,8 @@ class CollectiblesLogic with ThrottledSaveLoadMixin { imageBase64 = base64Encode(bytes); debugPrint('Saving base64 bytes: $imageBase64'); } - HomeWidget.saveWidgetData('lastDiscoveredImageData', imageBase64); - HomeWidget.updateWidget(iOSName: _appName); + await HomeWidget.saveWidgetData('lastDiscoveredImageData', imageBase64); + await HomeWidget.updateWidget(iOSName: _appName); } @override diff --git a/pubspec.yaml b/pubspec.yaml index 4a89bd44..d7aeb2b6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: wonders description: Explore the famous wonders of the world. publish_to: "none" -version: 2.1.0 +version: 2.1.1 environment: sdk: ">=2.17.0 <3.0.0"