From 0d80ae3a91b09d66a837ed58b160e2193baeaa98 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 14 Aug 2023 12:52:06 -0500 Subject: [PATCH] fix(mobile): make user.memoryEnable optional (#3680) * chore(server): avoid breaking changes * generate api * mobile app --- cli/src/api/open-api/api.ts | 2 +- mobile/lib/modules/home/views/home_page.dart | 9 +++++---- mobile/lib/shared/models/user.dart | 2 +- mobile/openapi/doc/UserResponseDto.md | 2 +- .../openapi/lib/model/user_response_dto.dart | 19 ++++++++++++++----- server/immich-openapi-specs.json | 3 +-- .../user/response-dto/user-response.dto.ts | 2 +- web/src/api/open-api/api.ts | 2 +- 8 files changed, 25 insertions(+), 16 deletions(-) diff --git a/cli/src/api/open-api/api.ts b/cli/src/api/open-api/api.ts index 9cedbdf2c4..e8662175a4 100644 --- a/cli/src/api/open-api/api.ts +++ b/cli/src/api/open-api/api.ts @@ -3159,7 +3159,7 @@ export interface UserResponseDto { * @type {boolean} * @memberof UserResponseDto */ - 'memoriesEnabled': boolean; + 'memoriesEnabled'?: boolean; /** * * @type {string} diff --git a/mobile/lib/modules/home/views/home_page.dart b/mobile/lib/modules/home/views/home_page.dart index a628df9bd0..c3226f228e 100644 --- a/mobile/lib/modules/home/views/home_page.dart +++ b/mobile/lib/modules/home/views/home_page.dart @@ -342,10 +342,11 @@ class HomePage extends HookConsumerWidget { listener: selectionListener, selectionActive: selectionEnabledHook.value, onRefresh: refreshAssets, - topWidget: - (currentUser != null && currentUser.memoryEnabled) - ? const MemoryLane() - : const SizedBox(), + topWidget: (currentUser != null && + currentUser.memoryEnabled != null && + currentUser.memoryEnabled!) + ? const MemoryLane() + : const SizedBox(), ), error: (error, _) => Center(child: Text(error.toString())), loading: buildLoadingIndicator, diff --git a/mobile/lib/shared/models/user.dart b/mobile/lib/shared/models/user.dart index 3041500641..df742a1541 100644 --- a/mobile/lib/shared/models/user.dart +++ b/mobile/lib/shared/models/user.dart @@ -44,7 +44,7 @@ class User { bool isPartnerSharedWith; bool isAdmin; String profileImagePath; - bool memoryEnabled; + bool? memoryEnabled; @Backlink(to: 'owner') final IsarLinks albums = IsarLinks(); @Backlink(to: 'sharedUsers') diff --git a/mobile/openapi/doc/UserResponseDto.md b/mobile/openapi/doc/UserResponseDto.md index 6455c12d03..b6e42b33e1 100644 --- a/mobile/openapi/doc/UserResponseDto.md +++ b/mobile/openapi/doc/UserResponseDto.md @@ -16,7 +16,7 @@ Name | Type | Description | Notes **id** | **String** | | **isAdmin** | **bool** | | **lastName** | **String** | | -**memoriesEnabled** | **bool** | | +**memoriesEnabled** | **bool** | | [optional] **oauthId** | **String** | | **profileImagePath** | **String** | | **shouldChangePassword** | **bool** | | diff --git a/mobile/openapi/lib/model/user_response_dto.dart b/mobile/openapi/lib/model/user_response_dto.dart index 5ecc26b492..488c9aafd2 100644 --- a/mobile/openapi/lib/model/user_response_dto.dart +++ b/mobile/openapi/lib/model/user_response_dto.dart @@ -21,7 +21,7 @@ class UserResponseDto { required this.id, required this.isAdmin, required this.lastName, - required this.memoriesEnabled, + this.memoriesEnabled, required this.oauthId, required this.profileImagePath, required this.shouldChangePassword, @@ -45,7 +45,13 @@ class UserResponseDto { String lastName; - bool memoriesEnabled; + /// + /// Please note: This property should have been non-nullable! Since the specification file + /// does not include a default value (using the "default:" property), however, the generated + /// source code must fall back to having a nullable type. + /// Consider adding a "default:" property in the specification file to hide this note. + /// + bool? memoriesEnabled; String oauthId; @@ -85,7 +91,7 @@ class UserResponseDto { (id.hashCode) + (isAdmin.hashCode) + (lastName.hashCode) + - (memoriesEnabled.hashCode) + + (memoriesEnabled == null ? 0 : memoriesEnabled!.hashCode) + (oauthId.hashCode) + (profileImagePath.hashCode) + (shouldChangePassword.hashCode) + @@ -113,7 +119,11 @@ class UserResponseDto { json[r'id'] = this.id; json[r'isAdmin'] = this.isAdmin; json[r'lastName'] = this.lastName; + if (this.memoriesEnabled != null) { json[r'memoriesEnabled'] = this.memoriesEnabled; + } else { + // json[r'memoriesEnabled'] = null; + } json[r'oauthId'] = this.oauthId; json[r'profileImagePath'] = this.profileImagePath; json[r'shouldChangePassword'] = this.shouldChangePassword; @@ -142,7 +152,7 @@ class UserResponseDto { id: mapValueOfType(json, r'id')!, isAdmin: mapValueOfType(json, r'isAdmin')!, lastName: mapValueOfType(json, r'lastName')!, - memoriesEnabled: mapValueOfType(json, r'memoriesEnabled')!, + memoriesEnabled: mapValueOfType(json, r'memoriesEnabled'), oauthId: mapValueOfType(json, r'oauthId')!, profileImagePath: mapValueOfType(json, r'profileImagePath')!, shouldChangePassword: mapValueOfType(json, r'shouldChangePassword')!, @@ -203,7 +213,6 @@ class UserResponseDto { 'id', 'isAdmin', 'lastName', - 'memoriesEnabled', 'oauthId', 'profileImagePath', 'shouldChangePassword', diff --git a/server/immich-openapi-specs.json b/server/immich-openapi-specs.json index d5504ba324..a60fcbd544 100644 --- a/server/immich-openapi-specs.json +++ b/server/immich-openapi-specs.json @@ -7152,8 +7152,7 @@ "createdAt", "deletedAt", "updatedAt", - "oauthId", - "memoriesEnabled" + "oauthId" ], "type": "object" }, diff --git a/server/src/domain/user/response-dto/user-response.dto.ts b/server/src/domain/user/response-dto/user-response.dto.ts index 9a3372ad55..59a387de1b 100644 --- a/server/src/domain/user/response-dto/user-response.dto.ts +++ b/server/src/domain/user/response-dto/user-response.dto.ts @@ -14,7 +14,7 @@ export class UserResponseDto { deletedAt!: Date | null; updatedAt!: Date; oauthId!: string; - memoriesEnabled!: boolean; + memoriesEnabled?: boolean; } export function mapUser(entity: UserEntity): UserResponseDto { diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts index 9cedbdf2c4..e8662175a4 100644 --- a/web/src/api/open-api/api.ts +++ b/web/src/api/open-api/api.ts @@ -3159,7 +3159,7 @@ export interface UserResponseDto { * @type {boolean} * @memberof UserResponseDto */ - 'memoriesEnabled': boolean; + 'memoriesEnabled'?: boolean; /** * * @type {string}