mirror of
https://github.com/immich-app/immich.git
synced 2025-11-14 10:52:39 +09:00
Refactor mobile to use OpenApi generated SDK (#336)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/modules/home/models/home_page_state.model.dart';
|
||||
import 'package:immich_mobile/shared/models/immich_asset.model.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class HomePageStateNotifier extends StateNotifier<HomePageState> {
|
||||
HomePageStateNotifier()
|
||||
@@ -14,7 +14,8 @@ class HomePageStateNotifier extends StateNotifier<HomePageState> {
|
||||
|
||||
void addSelectedDateGroup(String dateGroupTitle) {
|
||||
state = state.copyWith(
|
||||
selectedDateGroup: {...state.selectedDateGroup, dateGroupTitle});
|
||||
selectedDateGroup: {...state.selectedDateGroup, dateGroupTitle},
|
||||
);
|
||||
}
|
||||
|
||||
void removeSelectedDateGroup(String dateGroupTitle) {
|
||||
@@ -25,36 +26,39 @@ class HomePageStateNotifier extends StateNotifier<HomePageState> {
|
||||
state = state.copyWith(selectedDateGroup: currentDateGroup);
|
||||
}
|
||||
|
||||
void enableMultiSelect(Set<ImmichAsset> selectedItems) {
|
||||
void enableMultiSelect(Set<AssetResponseDto> selectedItems) {
|
||||
state =
|
||||
state.copyWith(isMultiSelectEnable: true, selectedItems: selectedItems);
|
||||
}
|
||||
|
||||
void disableMultiSelect() {
|
||||
state = state.copyWith(
|
||||
isMultiSelectEnable: false, selectedItems: {}, selectedDateGroup: {});
|
||||
isMultiSelectEnable: false,
|
||||
selectedItems: {},
|
||||
selectedDateGroup: {},
|
||||
);
|
||||
}
|
||||
|
||||
void addSingleSelectedItem(ImmichAsset asset) {
|
||||
void addSingleSelectedItem(AssetResponseDto asset) {
|
||||
state = state.copyWith(selectedItems: {...state.selectedItems, asset});
|
||||
}
|
||||
|
||||
void addMultipleSelectedItems(List<ImmichAsset> assets) {
|
||||
void addMultipleSelectedItems(List<AssetResponseDto> assets) {
|
||||
state = state.copyWith(selectedItems: {...state.selectedItems, ...assets});
|
||||
}
|
||||
|
||||
void removeSingleSelectedItem(ImmichAsset asset) {
|
||||
Set<ImmichAsset> currentList = state.selectedItems;
|
||||
void removeSingleSelectedItem(AssetResponseDto asset) {
|
||||
Set<AssetResponseDto> currentList = state.selectedItems;
|
||||
|
||||
currentList.removeWhere((e) => e.id == asset.id);
|
||||
|
||||
state = state.copyWith(selectedItems: currentList);
|
||||
}
|
||||
|
||||
void removeMultipleSelectedItem(List<ImmichAsset> assets) {
|
||||
Set<ImmichAsset> currentList = state.selectedItems;
|
||||
void removeMultipleSelectedItem(List<AssetResponseDto> assets) {
|
||||
Set<AssetResponseDto> currentList = state.selectedItems;
|
||||
|
||||
for (ImmichAsset asset in assets) {
|
||||
for (AssetResponseDto asset in assets) {
|
||||
currentList.removeWhere((e) => e.id == asset.id);
|
||||
}
|
||||
|
||||
@@ -64,4 +68,5 @@ class HomePageStateNotifier extends StateNotifier<HomePageState> {
|
||||
|
||||
final homePageStateProvider =
|
||||
StateNotifierProvider<HomePageStateNotifier, HomePageState>(
|
||||
((ref) => HomePageStateNotifier()));
|
||||
((ref) => HomePageStateNotifier()),
|
||||
);
|
||||
|
||||
@@ -73,10 +73,12 @@ class UploadProfileImageState {
|
||||
class UploadProfileImageNotifier
|
||||
extends StateNotifier<UploadProfileImageState> {
|
||||
UploadProfileImageNotifier(this._userSErvice)
|
||||
: super(UploadProfileImageState(
|
||||
profileImagePath: '',
|
||||
status: UploadProfileStatus.idle,
|
||||
));
|
||||
: super(
|
||||
UploadProfileImageState(
|
||||
profileImagePath: '',
|
||||
status: UploadProfileStatus.idle,
|
||||
),
|
||||
);
|
||||
|
||||
final UserService _userSErvice;
|
||||
|
||||
@@ -88,8 +90,9 @@ class UploadProfileImageNotifier
|
||||
if (res != null) {
|
||||
debugPrint("Succesfully upload profile image");
|
||||
state = state.copyWith(
|
||||
status: UploadProfileStatus.success,
|
||||
profileImagePath: res.profileImagePath);
|
||||
status: UploadProfileStatus.success,
|
||||
profileImagePath: res.profileImagePath,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -100,4 +103,5 @@ class UploadProfileImageNotifier
|
||||
|
||||
final uploadProfileImageProvider =
|
||||
StateNotifierProvider<UploadProfileImageNotifier, UploadProfileImageState>(
|
||||
((ref) => UploadProfileImageNotifier(ref.watch(userServiceProvider))));
|
||||
((ref) => UploadProfileImageNotifier(ref.watch(userServiceProvider))),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user