Skip to content

Commit

Permalink
Merge branch 'main' into mobile/native-video-player
Browse files Browse the repository at this point in the history
  • Loading branch information
alextran1502 authored Aug 29, 2024
2 parents ddfbb0f + ebecb60 commit 744bf50
Show file tree
Hide file tree
Showing 37 changed files with 1,450 additions and 300 deletions.
6 changes: 4 additions & 2 deletions mobile/lib/providers/authentication.provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
UserPreferencesResponseDto? userPreferences;
try {
final responses = await Future.wait([
_apiService.usersApi.getMyUser(),
_apiService.usersApi.getMyPreferences(),
_apiService.usersApi.getMyUser().timeout(const Duration(seconds: 7)),
_apiService.usersApi
.getMyPreferences()
.timeout(const Duration(seconds: 7)),
]);
userResponse = responses[0] as UserAdminResponseDto;
userPreferences = responses[1] as UserPreferencesResponseDto;
Expand Down
30 changes: 23 additions & 7 deletions mobile/lib/utils/openapi_patching.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,30 @@ dynamic upgradeDto(dynamic value, String targetType) {
switch (targetType) {
case 'UserPreferencesResponseDto':
if (value is Map) {
if (value['rating'] == null) {
value['rating'] = RatingResponse().toJson();
}

if (value['download']['includeEmbeddedVideos'] == null) {
value['download']['includeEmbeddedVideos'] = false;
}
addDefault(value, 'download.includeEmbeddedVideos', false);
addDefault(value, 'folders', FoldersResponse().toJson());
addDefault(value, 'memories', MemoriesResponse().toJson());
addDefault(value, 'ratings', RatingsResponse().toJson());
addDefault(value, 'people', PeopleResponse().toJson());
addDefault(value, 'tags', TagsResponse().toJson());
}
break;
}
}

addDefault(dynamic value, String keys, dynamic defaultValue) {
// Loop through the keys and assign the default value if the key is not present
List<String> keyList = keys.split('.');
dynamic current = value;

for (int i = 0; i < keyList.length - 1; i++) {
if (current[keyList[i]] == null) {
current[keyList[i]] = {};
}
current = current[keyList[i]];
}

if (current[keyList.last] == null) {
current[keyList.last] = defaultValue;
}
}
14 changes: 10 additions & 4 deletions mobile/openapi/README.md

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

14 changes: 10 additions & 4 deletions mobile/openapi/lib/api.dart

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

28 changes: 20 additions & 8 deletions mobile/openapi/lib/api_client.dart

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

106 changes: 106 additions & 0 deletions mobile/openapi/lib/model/folders_response.dart

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

Loading

0 comments on commit 744bf50

Please sign in to comment.