-
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: App review in the "scan card" (#4450)
* App review in the "scan card" * Add a keep alive to prevent many requests * Add a missing call to super (for the KeepAlive mixin) * Don't really understand what happened with this file 🤨
- Loading branch information
Showing
48 changed files
with
401 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
packages/smooth_app/lib/data_models/preferences/migration/user_preferences_migration.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
part of '../user_preferences.dart'; | ||
|
||
/// When we add/remove entries in the [UserPreferences] class, we need to | ||
/// add a new level and ensure we do a proper migration | ||
class UserPreferencesMigrationTool { | ||
const UserPreferencesMigrationTool._(); | ||
|
||
static final Iterable<UserPreferencesMigration> _versions = | ||
<UserPreferencesMigration>[ | ||
const _UserPreferencesMigrationV1(), | ||
const _UserPreferencesMigrationV2(), | ||
const _UserPreferencesMigrationV3(), | ||
]; | ||
|
||
static Future<void> onUpgrade( | ||
UserPreferences preferences, | ||
int? oldVersion, | ||
int newVersion, | ||
) async { | ||
if (oldVersion == newVersion) { | ||
return; | ||
} | ||
|
||
for (final UserPreferencesMigration migration in _versions) { | ||
if ((oldVersion ?? 0) >= migration.version) { | ||
continue; | ||
} | ||
|
||
await migration.onUpgrade(preferences, oldVersion, newVersion); | ||
} | ||
} | ||
} | ||
|
||
abstract interface class UserPreferencesMigration { | ||
const UserPreferencesMigration(); | ||
|
||
Future<void> onUpgrade( | ||
UserPreferences preferences, | ||
int? oldVersion, | ||
int newVersion, | ||
); | ||
|
||
int get version; | ||
} | ||
|
||
class _UserPreferencesMigrationV1 extends UserPreferencesMigration { | ||
const _UserPreferencesMigrationV1(); | ||
|
||
@override | ||
Future<void> onUpgrade( | ||
UserPreferences preferences, | ||
int? oldVersion, | ||
int newVersion, | ||
) async { | ||
final bool? crashReporting = preferences._sharedPreferences | ||
.getBool(UserPreferences._TAG_CRASH_REPORTS); | ||
if (crashReporting != null) { | ||
await preferences.setUserTracking(crashReporting); | ||
} | ||
} | ||
|
||
@override | ||
int get version => 1; | ||
} | ||
|
||
class _UserPreferencesMigrationV2 extends UserPreferencesMigration { | ||
const _UserPreferencesMigrationV2(); | ||
|
||
@override | ||
Future<void> onUpgrade( | ||
UserPreferences preferences, | ||
int? oldVersion, | ||
int newVersion, | ||
) async { | ||
/// With version == null and 1, [_TAG_USER_GROUP] is missing | ||
if (preferences._sharedPreferences | ||
.getInt(UserPreferences._TAG_USER_GROUP) == | ||
null) { | ||
await preferences._sharedPreferences.setInt( | ||
UserPreferences._TAG_USER_GROUP, | ||
Random().nextInt(10), | ||
); | ||
} | ||
} | ||
|
||
@override | ||
int get version => 2; | ||
} | ||
|
||
class _UserPreferencesMigrationV3 extends UserPreferencesMigration { | ||
const _UserPreferencesMigrationV3(); | ||
|
||
@override | ||
Future<void> onUpgrade( | ||
UserPreferences preferences, | ||
int? oldVersion, | ||
int newVersion, | ||
) async { | ||
if (preferences._sharedPreferences.getBool('_TAG_IS_FIRST_SCAN') ?? false) { | ||
await preferences.incrementScanCount(); | ||
} | ||
} | ||
|
||
@override | ||
int get version => 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_card.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/smooth_app/lib/knowledge_panel/knowledge_panels_builder.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/smooth_app/lib/pages/onboarding/onboarding_flow_navigator.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/smooth_app/lib/pages/preferences/abstract_user_preferences.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.