Skip to content

Commit

Permalink
feat(web): show partners assets on the main timeline (immich-app#4933)
Browse files Browse the repository at this point in the history
  • Loading branch information
alextran1502 authored Nov 11, 2023
1 parent 3b11854 commit 3576759
Show file tree
Hide file tree
Showing 59 changed files with 1,929 additions and 172 deletions.
264 changes: 250 additions & 14 deletions cli/src/api/open-api/api.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,15 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
if (userResponseDto != null) {
Store.put(StoreKey.deviceId, deviceId);
Store.put(StoreKey.deviceIdHash, fastHash(deviceId));
Store.put(StoreKey.currentUser, User.fromDto(userResponseDto));
Store.put(
StoreKey.currentUser,
User.fromUserDto(userResponseDto),
);
Store.put(StoreKey.serverUrl, serverUrl);
Store.put(StoreKey.accessToken, accessToken);

shouldChangePassword = userResponseDto.shouldChangePassword;
user = User.fromDto(userResponseDto);
user = User.fromUserDto(userResponseDto);

retResult = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/modules/partner/services/partner.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PartnerService {
final userDtos =
await _apiService.partnerApi.getPartners(direction._value);
if (userDtos != null) {
return userDtos.map((u) => User.fromDto(u)).toList();
return userDtos.map((u) => User.fromPartnerDto(u)).toList();
}
} catch (e) {
_log.warning("failed to get partners for direction $direction:\n$e");
Expand Down
5 changes: 4 additions & 1 deletion mobile/lib/routing/tab_navigation_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ class TabNavigationObserver extends AutoRouterObserver {
return;
}

Store.put(StoreKey.currentUser, User.fromDto(userResponseDto));
Store.put(
StoreKey.currentUser,
User.fromUserDto(userResponseDto),
);
ref.read(serverInfoProvider.notifier).getServerVersion();
} catch (e) {
debugPrint("Error refreshing user info $e");
Expand Down
24 changes: 21 additions & 3 deletions mobile/lib/shared/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ class User {
this.isPartnerSharedWith = false,
this.profileImagePath = '',
this.memoryEnabled = true,
this.inTimeline = false,
});

Id get isarId => fastHash(id);

User.fromDto(UserResponseDto dto)
User.fromUserDto(UserResponseDto dto)
: id = dto.id,
updatedAt = dto.updatedAt,
email = dto.email,
Expand All @@ -34,6 +35,19 @@ class User {
isAdmin = dto.isAdmin,
memoryEnabled = dto.memoriesEnabled;

User.fromPartnerDto(PartnerResponseDto dto)
: id = dto.id,
updatedAt = dto.updatedAt,
email = dto.email,
firstName = dto.firstName,
lastName = dto.lastName,
isPartnerSharedBy = false,
isPartnerSharedWith = false,
profileImagePath = dto.profileImagePath,
isAdmin = dto.isAdmin,
memoryEnabled = dto.memoriesEnabled,
inTimeline = dto.inTimeline;

@Index(unique: true, replace: false, type: IndexType.hash)
String id;
DateTime updatedAt;
Expand All @@ -45,6 +59,8 @@ class User {
bool isAdmin;
String profileImagePath;
bool? memoryEnabled;
bool? inTimeline;

@Backlink(to: 'owner')
final IsarLinks<Album> albums = IsarLinks<Album>();
@Backlink(to: 'sharedUsers')
Expand All @@ -62,7 +78,8 @@ class User {
isPartnerSharedWith == other.isPartnerSharedWith &&
profileImagePath == other.profileImagePath &&
isAdmin == other.isAdmin &&
memoryEnabled == other.memoryEnabled;
memoryEnabled == other.memoryEnabled &&
inTimeline == other.inTimeline;
}

@override
Expand All @@ -77,5 +94,6 @@ class User {
isPartnerSharedWith.hashCode ^
profileImagePath.hashCode ^
isAdmin.hashCode ^
memoryEnabled.hashCode;
memoryEnabled.hashCode ^
inTimeline.hashCode;
}
123 changes: 97 additions & 26 deletions mobile/lib/shared/models/user.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mobile/lib/shared/services/user.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class UserService {
Future<List<User>?> _getAllUsers({required bool isAll}) async {
try {
final dto = await _apiService.userApi.getAllUsers(isAll);
return dto?.map(User.fromDto).toList();
return dto?.map(User.fromUserDto).toList();
} catch (e) {
_log.warning("Failed get all users:\n$e");
return null;
Expand Down
6 changes: 6 additions & 0 deletions mobile/openapi/.openapi-generator/FILES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions mobile/openapi/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3576759

Please sign in to comment.