Compare commits

...

2 Commits

Author SHA1 Message Date
Alex Tran
e04d25d8f5 chore(mobile): better second to first assets shown 2024-06-12 16:58:58 -05:00
Alex
c642150b85 chore(mobile): post release task (#10228) 2024-06-12 14:17:58 -05:00
8 changed files with 67 additions and 31 deletions

View File

@@ -5,17 +5,17 @@
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000218"> <testcase classname="fastlane.lanes" name="0: default_platform" time="0.000381">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="1: bundleRelease" time="58.982292"> <testcase classname="fastlane.lanes" name="1: bundleRelease" time="52.832426">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="2: upload_to_play_store" time="31.253303"> <testcase classname="fastlane.lanes" name="2: upload_to_play_store" time="27.616558">
</testcase> </testcase>

View File

@@ -383,7 +383,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 159; CURRENT_PROJECT_VERSION = 160;
DEVELOPMENT_TEAM = 2F67MQ8R79; DEVELOPMENT_TEAM = 2F67MQ8R79;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -525,7 +525,7 @@
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 159; CURRENT_PROJECT_VERSION = 160;
DEVELOPMENT_TEAM = 2F67MQ8R79; DEVELOPMENT_TEAM = 2F67MQ8R79;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -553,7 +553,7 @@
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 159; CURRENT_PROJECT_VERSION = 160;
DEVELOPMENT_TEAM = 2F67MQ8R79; DEVELOPMENT_TEAM = 2F67MQ8R79;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;

View File

@@ -58,11 +58,11 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.106.1</string> <string>1.106.3</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>159</string> <string>160</string>
<key>FLTEnableImpeller</key> <key>FLTEnableImpeller</key>
<true /> <true />
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>

View File

@@ -5,32 +5,32 @@
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000242"> <testcase classname="fastlane.lanes" name="0: default_platform" time="0.000491">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="1: increment_version_number" time="0.191393"> <testcase classname="fastlane.lanes" name="1: increment_version_number" time="39.414297">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="2: latest_testflight_build_number" time="4.210274"> <testcase classname="fastlane.lanes" name="2: latest_testflight_build_number" time="32.521647">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="3: increment_build_number" time="0.183895"> <testcase classname="fastlane.lanes" name="3: increment_build_number" time="0.511733">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="4: build_app" time="153.101993"> <testcase classname="fastlane.lanes" name="4: build_app" time="202.628277">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="5: upload_to_testflight" time="76.170022"> <testcase classname="fastlane.lanes" name="5: upload_to_testflight" time="73.861852">
</testcase> </testcase>

View File

@@ -50,8 +50,19 @@ class AssetNotifier extends StateNotifier<bool> {
await clearAssetsAndAlbums(_db); await clearAssetsAndAlbums(_db);
log.info("Manual refresh requested, cleared assets and albums from db"); log.info("Manual refresh requested, cleared assets and albums from db");
} }
final bool changedUsers = await _userService.refreshUsers(); final bool changedUsers = await _userService.refreshUsers();
final assetCount = await _db.assets.count();
if (assetCount == 0) {
debugPrint("First sync, refreshing all assets");
await _assetService.refreshRemoteAssets(firstSync: true);
debugPrint("First sync, DONE refreshing all assets");
}
debugPrint("First sync, CONTINUE refreshing all assets");
final bool newRemote = await _assetService.refreshRemoteAssets(); final bool newRemote = await _assetService.refreshRemoteAssets();
final bool newLocal = await _albumService.refreshDeviceAlbums(); final bool newLocal = await _albumService.refreshDeviceAlbums();
debugPrint( debugPrint(
"changedUsers: $changedUsers, newRemote: $newRemote, newLocal: $newLocal", "changedUsers: $changedUsers, newRemote: $newRemote, newLocal: $newLocal",

View File

@@ -43,7 +43,7 @@ class AssetService {
/// Checks the server for updated assets and updates the local database if /// Checks the server for updated assets and updates the local database if
/// required. Returns `true` if there were any changes. /// required. Returns `true` if there were any changes.
Future<bool> refreshRemoteAssets() async { Future<bool> refreshRemoteAssets({bool firstSync = false}) async {
final syncedUserIds = await _db.eTags.where().idProperty().findAll(); final syncedUserIds = await _db.eTags.where().idProperty().findAll();
final List<User> syncedUsers = syncedUserIds.isEmpty final List<User> syncedUsers = syncedUserIds.isEmpty
? [] ? []
@@ -57,6 +57,7 @@ class AssetService {
getChangedAssets: _getRemoteAssetChanges, getChangedAssets: _getRemoteAssetChanges,
loadAssets: _getRemoteAssets, loadAssets: _getRemoteAssets,
refreshUsers: _userService.getUsersFromServer, refreshUsers: _userService.getUsersFromServer,
firstSync: firstSync,
); );
debugPrint("refreshRemoteAssets full took ${sw.elapsedMilliseconds}ms"); debugPrint("refreshRemoteAssets full took ${sw.elapsedMilliseconds}ms");
return changes; return changes;
@@ -97,8 +98,12 @@ class AssetService {
} }
/// Returns `null` if the server state did not change, else list of assets /// Returns `null` if the server state did not change, else list of assets
Future<List<Asset>?> _getRemoteAssets(User user, DateTime until) async { Future<List<Asset>?> _getRemoteAssets(
const int chunkSize = 10000; User user,
DateTime until,
bool firstSync,
) async {
int chunkSize = firstSync ? 1000 : 10000;
try { try {
final List<Asset> allAssets = []; final List<Asset> allAssets = [];
String? lastId; String? lastId;
@@ -120,6 +125,11 @@ class AssetService {
allAssets.addAll(assets.map(Asset.remote)); allAssets.addAll(assets.map(Asset.remote));
if (assets.length != chunkSize) break; if (assets.length != chunkSize) break;
lastId = assets.last.id; lastId = assets.last.id;
if (firstSync) {
// first sync only loads the first chunk
break;
}
} }
return allAssets; return allAssets;
} catch (error, stack) { } catch (error, stack) {

View File

@@ -46,14 +46,18 @@ class SyncService {
List<User> users, List<User> users,
DateTime since, DateTime since,
) getChangedAssets, ) getChangedAssets,
required FutureOr<List<Asset>?> Function(User user, DateTime until) required FutureOr<List<Asset>?> Function(
loadAssets, User user,
DateTime until,
bool firstSync,
) loadAssets,
required FutureOr<List<User>?> Function() refreshUsers, required FutureOr<List<User>?> Function() refreshUsers,
required bool firstSync,
}) => }) =>
_lock.run( _lock.run(
() async => () async =>
await _syncRemoteAssetChanges(users, getChangedAssets) ?? await _syncRemoteAssetChanges(users, getChangedAssets) ??
await _syncRemoteAssetsFull(refreshUsers, loadAssets), await _syncRemoteAssetsFull(refreshUsers, loadAssets, firstSync),
); );
/// Syncs remote albums to the database /// Syncs remote albums to the database
@@ -212,7 +216,9 @@ class SyncService {
/// Syncs assets by loading and comparing all assets from the server. /// Syncs assets by loading and comparing all assets from the server.
Future<bool> _syncRemoteAssetsFull( Future<bool> _syncRemoteAssetsFull(
FutureOr<List<User>?> Function() refreshUsers, FutureOr<List<User>?> Function() refreshUsers,
FutureOr<List<Asset>?> Function(User user, DateTime until) loadAssets, FutureOr<List<Asset>?> Function(User user, DateTime until, bool firstSync)
loadAssets,
bool firstSync,
) async { ) async {
final serverUsers = await refreshUsers(); final serverUsers = await refreshUsers();
if (serverUsers == null) { if (serverUsers == null) {
@@ -228,17 +234,19 @@ class SyncService {
.findAll(); .findAll();
bool changes = false; bool changes = false;
for (User u in users) { for (User u in users) {
changes |= await _syncRemoteAssetsForUser(u, loadAssets); changes |= await _syncRemoteAssetsForUser(u, loadAssets, firstSync);
} }
return changes; return changes;
} }
Future<bool> _syncRemoteAssetsForUser( Future<bool> _syncRemoteAssetsForUser(
User user, User user,
FutureOr<List<Asset>?> Function(User user, DateTime until) loadAssets, FutureOr<List<Asset>?> Function(User user, DateTime until, bool firstSync)
loadAssets,
bool firstSync,
) async { ) async {
final DateTime now = DateTime.now().toUtc(); final DateTime now = DateTime.now().toUtc();
final List<Asset>? remote = await loadAssets(user, now); final List<Asset>? remote = await loadAssets(user, now, firstSync);
if (remote == null) { if (remote == null) {
return false; return false;
} }

View File

@@ -78,8 +78,9 @@ void main() {
final bool c1 = await s.syncRemoteAssetsToDb( final bool c1 = await s.syncRemoteAssetsToDb(
users: [owner], users: [owner],
getChangedAssets: _failDiff, getChangedAssets: _failDiff,
loadAssets: (u, d) => remoteAssets, loadAssets: (u, d, firstSync) => remoteAssets,
refreshUsers: () => [owner], refreshUsers: () => [owner],
firstSync: false,
); );
expect(c1, isFalse); expect(c1, isFalse);
expect(db.assets.countSync(), 5); expect(db.assets.countSync(), 5);
@@ -99,8 +100,9 @@ void main() {
final bool c1 = await s.syncRemoteAssetsToDb( final bool c1 = await s.syncRemoteAssetsToDb(
users: [owner], users: [owner],
getChangedAssets: _failDiff, getChangedAssets: _failDiff,
loadAssets: (u, d) => remoteAssets, loadAssets: (u, d, firstSync) => remoteAssets,
refreshUsers: () => [owner], refreshUsers: () => [owner],
firstSync: false,
); );
expect(c1, isTrue); expect(c1, isTrue);
expect(db.assets.countSync(), 7); expect(db.assets.countSync(), 7);
@@ -120,16 +122,18 @@ void main() {
final bool c1 = await s.syncRemoteAssetsToDb( final bool c1 = await s.syncRemoteAssetsToDb(
users: [owner], users: [owner],
getChangedAssets: _failDiff, getChangedAssets: _failDiff,
loadAssets: (u, d) => remoteAssets, loadAssets: (u, d, firstSync) => remoteAssets,
refreshUsers: () => [owner], refreshUsers: () => [owner],
firstSync: false,
); );
expect(c1, isTrue); expect(c1, isTrue);
expect(db.assets.countSync(), 8); expect(db.assets.countSync(), 8);
final bool c2 = await s.syncRemoteAssetsToDb( final bool c2 = await s.syncRemoteAssetsToDb(
users: [owner], users: [owner],
getChangedAssets: _failDiff, getChangedAssets: _failDiff,
loadAssets: (u, d) => remoteAssets, loadAssets: (u, d, firstSync) => remoteAssets,
refreshUsers: () => [owner], refreshUsers: () => [owner],
firstSync: false,
); );
expect(c2, isFalse); expect(c2, isFalse);
expect(db.assets.countSync(), 8); expect(db.assets.countSync(), 8);
@@ -137,8 +141,9 @@ void main() {
final bool c3 = await s.syncRemoteAssetsToDb( final bool c3 = await s.syncRemoteAssetsToDb(
users: [owner], users: [owner],
getChangedAssets: _failDiff, getChangedAssets: _failDiff,
loadAssets: (u, d) => remoteAssets, loadAssets: (u, d, firstSync) => remoteAssets,
refreshUsers: () => [owner], refreshUsers: () => [owner],
firstSync: false,
); );
expect(c3, isTrue); expect(c3, isTrue);
expect(db.assets.countSync(), 7); expect(db.assets.countSync(), 7);
@@ -147,8 +152,9 @@ void main() {
final bool c4 = await s.syncRemoteAssetsToDb( final bool c4 = await s.syncRemoteAssetsToDb(
users: [owner], users: [owner],
getChangedAssets: _failDiff, getChangedAssets: _failDiff,
loadAssets: (u, d) => remoteAssets, loadAssets: (u, d, firstSync) => remoteAssets,
refreshUsers: () => [owner], refreshUsers: () => [owner],
firstSync: false,
); );
expect(c4, isTrue); expect(c4, isTrue);
expect(db.assets.countSync(), 9); expect(db.assets.countSync(), 9);
@@ -166,8 +172,9 @@ void main() {
final bool c = await s.syncRemoteAssetsToDb( final bool c = await s.syncRemoteAssetsToDb(
users: [owner], users: [owner],
getChangedAssets: (user, since) async => (toUpsert, toDelete), getChangedAssets: (user, since) async => (toUpsert, toDelete),
loadAssets: (user, date) => throw Exception(), loadAssets: (user, date, firstSync) => throw Exception(),
refreshUsers: () => throw Exception(), refreshUsers: () => throw Exception(),
firstSync: false,
); );
expect(c, isTrue); expect(c, isTrue);
expect(db.assets.countSync(), 6); expect(db.assets.countSync(), 6);