refactor: rename uid to id

This commit is contained in:
shenlong-tanwen 2025-03-12 12:22:00 +05:30
parent c96406737a
commit 734566db50
13 changed files with 31 additions and 33 deletions

View File

@ -105,8 +105,7 @@ class AlbumAdditionalSharedUserSelectionPage extends HookConsumerWidget {
if (sharedUsersList.value.contains(users[index])) { if (sharedUsersList.value.contains(users[index])) {
sharedUsersList.value = sharedUsersList.value sharedUsersList.value = sharedUsersList.value
.where( .where(
(selectedUser) => (selectedUser) => selectedUser.id != users[index].id,
selectedUser.uid != users[index].uid,
) )
.toSet(); .toSet();
} else { } else {

View File

@ -118,8 +118,7 @@ class AlbumSharedUserSelectionPage extends HookConsumerWidget {
if (sharedUsersList.value.contains(users[index])) { if (sharedUsersList.value.contains(users[index])) {
sharedUsersList.value = sharedUsersList.value sharedUsersList.value = sharedUsersList.value
.where( .where(
(selectedUser) => (selectedUser) => selectedUser.id != users[index].id,
selectedUser.uid != users[index].uid,
) )
.toSet(); .toSet();
} else { } else {

View File

@ -51,7 +51,7 @@ class ActivitiesPage extends HookConsumerWidget {
final liked = data.firstWhereOrNull( final liked = data.firstWhereOrNull(
(a) => (a) =>
a.type == ActivityType.like && a.type == ActivityType.like &&
a.user.uid == user?.uid && a.user.id == user?.id &&
a.assetId == asset?.remoteId, a.assetId == asset?.remoteId,
); );

View File

@ -111,7 +111,7 @@ class PartnerDetailPage extends HookConsumerWidget {
), ),
), ),
), ),
renderListProvider: singleUserTimelineProvider(partner.uid), renderListProvider: singleUserTimelineProvider(partner.id),
onRefresh: () => ref.read(assetProvider.notifier).getAllAsset(), onRefresh: () => ref.read(assetProvider.notifier).getAllAsset(),
deleteEnabled: false, deleteEnabled: false,
favoriteEnabled: false, favoriteEnabled: false,

View File

@ -110,7 +110,7 @@ class PhotosPage extends HookConsumerWidget {
: const SizedBox(), : const SizedBox(),
renderListProvider: timelineUsers.length > 1 renderListProvider: timelineUsers.length > 1
? multiUsersTimelineProvider(timelineUsers) ? multiUsersTimelineProvider(timelineUsers)
: singleUserTimelineProvider(currentUser?.uid), : singleUserTimelineProvider(currentUser?.id),
buildLoadingIndicator: buildLoadingIndicator, buildLoadingIndicator: buildLoadingIndicator,
onRefresh: refreshAssets, onRefresh: refreshAssets,
stackEnabled: true, stackEnabled: true,

View File

@ -10,6 +10,6 @@ final otherUsersProvider =
final currentUser = ref.watch(currentUserProvider); final currentUser = ref.watch(currentUserProvider);
final allUsers = await userService.getAll(); final allUsers = await userService.getAll();
allUsers.removeWhere((u) => currentUser?.uid == u.uid); allUsers.removeWhere((u) => currentUser?.id == u.id);
return allUsers; return allUsers;
}); });

View File

@ -314,7 +314,7 @@ class AssetService {
await refreshRemoteAssets(); await refreshRemoteAssets();
final owner = _userService.getMyUser(); final owner = _userService.getMyUser();
final remoteAssets = await _assetRepository.getAll( final remoteAssets = await _assetRepository.getAll(
ownerId: owner.uid, ownerId: owner.id,
state: AssetState.merged, state: AssetState.merged,
); );
@ -516,11 +516,11 @@ class AssetService {
Future<List<Asset>> getRecentlyAddedAssets() { Future<List<Asset>> getRecentlyAddedAssets() {
final me = _userService.getMyUser(); final me = _userService.getMyUser();
return _assetRepository.getRecentlyAddedAssets(me.uid); return _assetRepository.getRecentlyAddedAssets(me.id);
} }
Future<List<Asset>> getMotionAssets() { Future<List<Asset>> getMotionAssets() {
final me = _userService.getMyUser(); final me = _userService.getMyUser();
return _assetRepository.getMotionAssets(me.uid); return _assetRepository.getMotionAssets(me.id);
} }
} }

View File

@ -38,7 +38,7 @@ class BackupVerificationService {
/// Returns at most [limit] assets that were backed up without exif /// Returns at most [limit] assets that were backed up without exif
Future<List<Asset>> findWronglyBackedUpAssets({int limit = 100}) async { Future<List<Asset>> findWronglyBackedUpAssets({int limit = 100}) async {
final owner = _userService.getMyUser().uid; final owner = _userService.getMyUser().id;
final List<Asset> onlyLocal = await _assetRepository.getAll( final List<Asset> onlyLocal = await _assetRepository.getAll(
ownerId: owner, ownerId: owner,
state: AssetState.local, state: AssetState.local,

View File

@ -183,7 +183,7 @@ class SyncService {
return false; return false;
}, },
onlyFirst: (UserDto a) => toUpsert.add(a), onlyFirst: (UserDto a) => toUpsert.add(a),
onlySecond: (UserDto b) => toDelete.add(b.uid), onlySecond: (UserDto b) => toDelete.add(b.id),
); );
if (changes) { if (changes) {
await _userRepository.transaction(() async { await _userRepository.transaction(() async {
@ -222,7 +222,7 @@ class SyncService {
) async { ) async {
final currentUser = _userService.getMyUser(); final currentUser = _userService.getMyUser();
final DateTime? since = final DateTime? since =
(await _eTagRepository.get(currentUser.uid))?.time?.toUtc(); (await _eTagRepository.get(currentUser.id))?.time?.toUtc();
if (since == null) return null; if (since == null) return null;
final DateTime now = DateTime.now(); final DateTime now = DateTime.now();
final (toUpsert, toDelete) = await getChangedAssets(users, since); final (toUpsert, toDelete) = await getChangedAssets(users, since);
@ -321,7 +321,7 @@ class SyncService {
return false; return false;
} }
final List<Asset> inDb = await _assetRepository.getAll( final List<Asset> inDb = await _assetRepository.getAll(
ownerId: user.uid, ownerId: user.id,
sortBy: AssetSort.checksum, sortBy: AssetSort.checksum,
); );
assert(inDb.isSorted(Asset.compareByChecksum), "inDb not sorted!"); assert(inDb.isSorted(Asset.compareByChecksum), "inDb not sorted!");
@ -427,15 +427,15 @@ class SyncService {
// update shared users // update shared users
final List<UserDto> sharedUsers = final List<UserDto> sharedUsers =
album.sharedUsers.map((u) => u.toDto()).toList(growable: false); album.sharedUsers.map((u) => u.toDto()).toList(growable: false);
sharedUsers.sort((a, b) => a.uid.compareTo(b.uid)); sharedUsers.sort((a, b) => a.id.compareTo(b.id));
final List<UserDto> users = dto.remoteUsers.map((u) => u.toDto()).toList() final List<UserDto> users = dto.remoteUsers.map((u) => u.toDto()).toList()
..sort((a, b) => a.uid.compareTo(b.uid)); ..sort((a, b) => a.id.compareTo(b.id));
final List<String> userIdsToAdd = []; final List<String> userIdsToAdd = [];
final List<UserDto> usersToUnlink = []; final List<UserDto> usersToUnlink = [];
diffSortedListsSync( diffSortedListsSync(
users, users,
sharedUsers, sharedUsers,
compare: (UserDto a, UserDto b) => a.uid.compareTo(b.uid), compare: (UserDto a, UserDto b) => a.id.compareTo(b.id),
both: (a, b) => false, both: (a, b) => false,
onlyFirst: (UserDto a) => userIdsToAdd.add(a.id), onlyFirst: (UserDto a) => userIdsToAdd.add(a.id),
onlySecond: (UserDto a) => usersToUnlink.add(a), onlySecond: (UserDto a) => usersToUnlink.add(a),
@ -482,7 +482,7 @@ class SyncService {
} }
if (album.shared || dto.shared) { if (album.shared || dto.shared) {
final userId = (_userService.getMyUser()).uid; final userId = (_userService.getMyUser()).id;
final foreign = final foreign =
await _assetRepository.getByAlbum(album, notOwnedBy: [userId]); await _assetRepository.getByAlbum(album, notOwnedBy: [userId]);
existing.addAll(foreign); existing.addAll(foreign);
@ -536,7 +536,7 @@ class SyncService {
); );
} else if (album.shared) { } else if (album.shared) {
// delete assets in DB unless they belong to this user or are part of some other shared album or belong to a partner // delete assets in DB unless they belong to this user or are part of some other shared album or belong to a partner
final userIds = (await _getAllAccessibleUsers()).map((user) => user.uid); final userIds = (await _getAllAccessibleUsers()).map((user) => user.id);
final orphanedAssets = final orphanedAssets =
await _assetRepository.getByAlbum(album, notOwnedBy: userIds); await _assetRepository.getByAlbum(album, notOwnedBy: userIds);
deleteCandidates.addAll(orphanedAssets); deleteCandidates.addAll(orphanedAssets);
@ -622,7 +622,7 @@ class SyncService {
// general case, e.g. some assets have been deleted or there are excluded albums on iOS // general case, e.g. some assets have been deleted or there are excluded albums on iOS
final inDb = await _assetRepository.getByAlbum( final inDb = await _assetRepository.getByAlbum(
dbAlbum, dbAlbum,
ownerId: (_userService.getMyUser()).uid, ownerId: (_userService.getMyUser()).id,
sortBy: AssetSort.checksum, sortBy: AssetSort.checksum,
); );

View File

@ -30,12 +30,12 @@ class TimelineService {
Future<List<String>> getTimelineUserIds() async { Future<List<String>> getTimelineUserIds() async {
final me = _userService.getMyUser(); final me = _userService.getMyUser();
return _timelineRepository.getTimelineUserIds(me.uid); return _timelineRepository.getTimelineUserIds(me.id);
} }
Stream<List<String>> watchTimelineUserIds() async* { Stream<List<String>> watchTimelineUserIds() async* {
final me = _userService.getMyUser(); final me = _userService.getMyUser();
yield* _timelineRepository.watchTimelineUsers(me.uid); yield* _timelineRepository.watchTimelineUsers(me.id);
} }
Stream<RenderList> watchHomeTimeline(String userId) { Stream<RenderList> watchHomeTimeline(String userId) {
@ -52,13 +52,13 @@ class TimelineService {
Stream<RenderList> watchArchiveTimeline() async* { Stream<RenderList> watchArchiveTimeline() async* {
final user = _userService.getMyUser(); final user = _userService.getMyUser();
yield* _timelineRepository.watchArchiveTimeline(user.uid); yield* _timelineRepository.watchArchiveTimeline(user.id);
} }
Stream<RenderList> watchFavoriteTimeline() async* { Stream<RenderList> watchFavoriteTimeline() async* {
final user = _userService.getMyUser(); final user = _userService.getMyUser();
yield* _timelineRepository.watchFavoriteTimeline(user.uid); yield* _timelineRepository.watchFavoriteTimeline(user.id);
} }
Stream<RenderList> watchAlbumTimeline(Album album) async* { Stream<RenderList> watchAlbumTimeline(Album album) async* {
@ -71,7 +71,7 @@ class TimelineService {
Stream<RenderList> watchTrashTimeline() async* { Stream<RenderList> watchTrashTimeline() async* {
final user = _userService.getMyUser(); final user = _userService.getMyUser();
yield* _timelineRepository.watchTrashTimeline(user.uid); yield* _timelineRepository.watchTrashTimeline(user.id);
} }
Stream<RenderList> watchAllVideosTimeline() { Stream<RenderList> watchAllVideosTimeline() {
@ -98,7 +98,7 @@ class TimelineService {
Stream<RenderList> watchAssetSelectionTimeline() async* { Stream<RenderList> watchAssetSelectionTimeline() async* {
final user = _userService.getMyUser(); final user = _userService.getMyUser();
yield* _timelineRepository.watchAssetSelectionTimeline(user.uid); yield* _timelineRepository.watchAssetSelectionTimeline(user.id);
} }
GroupAssetsBy _getGroupByOption() { GroupAssetsBy _getGroupByOption() {

View File

@ -46,7 +46,7 @@ class TrashService {
await _apiService.trashApi.emptyTrash(); await _apiService.trashApi.emptyTrash();
final trashedAssets = await _assetRepository.getTrashAssets(user.uid); final trashedAssets = await _assetRepository.getTrashAssets(user.id);
final ids = trashedAssets.map((e) => e.remoteId!).toList(); final ids = trashedAssets.map((e) => e.remoteId!).toList();
await _assetRepository.transaction(() async { await _assetRepository.transaction(() async {
@ -77,7 +77,7 @@ class TrashService {
await _apiService.trashApi.restoreTrash(); await _apiService.trashApi.restoreTrash();
final trashedAssets = await _assetRepository.getTrashAssets(user.uid); final trashedAssets = await _assetRepository.getTrashAssets(user.id);
final updatedAssets = trashedAssets.map((asset) { final updatedAssets = trashedAssets.map((asset) {
asset.isTrashed = false; asset.isTrashed = false;
return asset; return asset;

View File

@ -16,7 +16,7 @@ Widget userAvatar(BuildContext context, UserDto u, {double? radius}) {
foregroundImage: CachedNetworkImageProvider( foregroundImage: CachedNetworkImageProvider(
url, url,
headers: ApiService.getRequestHeaders(), headers: ApiService.getRequestHeaders(),
cacheKey: "user-${u.uid}-profile", cacheKey: "user-${u.id}-profile",
), ),
// silence errors if user has no profile image, use initials as fallback // silence errors if user has no profile image, use initials as fallback
onForegroundImageError: (exception, stackTrace) {}, onForegroundImageError: (exception, stackTrace) {},

View File

@ -125,7 +125,7 @@ void main() {
when(() => userRepository.getAll()).thenAnswer((_) async => [owner]); when(() => userRepository.getAll()).thenAnswer((_) async => [owner]);
when( when(
() => assetRepository.getAll( () => assetRepository.getAll(
ownerId: owner.uid, ownerId: owner.id,
sortBy: AssetSort.checksum, sortBy: AssetSort.checksum,
), ),
).thenAnswer((_) async => initialAssets); ).thenAnswer((_) async => initialAssets);
@ -200,7 +200,7 @@ void main() {
expect(c1, isTrue); expect(c1, isTrue);
when( when(
() => assetRepository.getAll( () => assetRepository.getAll(
ownerId: owner.uid, ownerId: owner.id,
sortBy: AssetSort.checksum, sortBy: AssetSort.checksum,
), ),
).thenAnswer((_) async => remoteAssets); ).thenAnswer((_) async => remoteAssets);
@ -213,7 +213,7 @@ void main() {
final currentState = [...remoteAssets]; final currentState = [...remoteAssets];
when( when(
() => assetRepository.getAll( () => assetRepository.getAll(
ownerId: owner.uid, ownerId: owner.id,
sortBy: AssetSort.checksum, sortBy: AssetSort.checksum,
), ),
).thenAnswer((_) async => currentState); ).thenAnswer((_) async => currentState);