Compare commits
14 Commits
v1.32.0_50
...
v1.32.1_51
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ec7122381 | ||
|
|
061b229e12 | ||
|
|
3617433858 | ||
|
|
d6d525cc1b | ||
|
|
e752290458 | ||
|
|
d77e25425e | ||
|
|
028c0249a3 | ||
|
|
a3ca5307a5 | ||
|
|
6796462b13 | ||
|
|
d08475d5af | ||
|
|
d310c77fc8 | ||
|
|
75d8ca1306 | ||
|
|
894eea739e | ||
|
|
1156290377 |
@@ -20,7 +20,7 @@ jobs:
|
|||||||
uses: docker/setup-qemu-action@v2.1.0
|
uses: docker/setup-qemu-action@v2.1.0
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
@@ -48,7 +48,7 @@ jobs:
|
|||||||
uses: docker/setup-qemu-action@v2.1.0
|
uses: docker/setup-qemu-action@v2.1.0
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
@@ -75,7 +75,7 @@ jobs:
|
|||||||
uses: docker/setup-qemu-action@v2.1.0
|
uses: docker/setup-qemu-action@v2.1.0
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
@@ -103,7 +103,7 @@ jobs:
|
|||||||
uses: docker/setup-qemu-action@v2.1.0
|
uses: docker/setup-qemu-action@v2.1.0
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
uses: docker/setup-qemu-action@v2.1.0
|
uses: docker/setup-qemu-action@v2.1.0
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: ${{ github.repository == 'immich-app/immich' }}
|
if: ${{ github.repository == 'immich-app/immich' }}
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
@@ -50,7 +50,7 @@ jobs:
|
|||||||
uses: docker/setup-qemu-action@v2.1.0
|
uses: docker/setup-qemu-action@v2.1.0
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: ${{ github.repository == 'immich-app/immich' }}
|
if: ${{ github.repository == 'immich-app/immich' }}
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
@@ -79,7 +79,7 @@ jobs:
|
|||||||
uses: docker/setup-qemu-action@v2.1.0
|
uses: docker/setup-qemu-action@v2.1.0
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: ${{ github.repository == 'immich-app/immich' }}
|
if: ${{ github.repository == 'immich-app/immich' }}
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
@@ -109,7 +109,7 @@ jobs:
|
|||||||
uses: docker/setup-qemu-action@v2.1.0
|
uses: docker/setup-qemu-action@v2.1.0
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: ${{ github.repository == 'immich-app/immich' }}
|
if: ${{ github.repository == 'immich-app/immich' }}
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
@@ -61,7 +61,7 @@ jobs:
|
|||||||
uses: docker/setup-qemu-action@v2.1.0
|
uses: docker/setup-qemu-action@v2.1.0
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
@@ -98,7 +98,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
@@ -138,7 +138,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.1.0
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ platform :android do
|
|||||||
task: 'bundle',
|
task: 'bundle',
|
||||||
build_type: 'Release',
|
build_type: 'Release',
|
||||||
properties: {
|
properties: {
|
||||||
"android.injected.version.code" => 50,
|
"android.injected.version.code" => 51,
|
||||||
"android.injected.version.name" => "1.32.0",
|
"android.injected.version.name" => "1.32.1",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
upload_to_play_store(skip_upload_apk: true, skip_upload_images: true, skip_upload_screenshots: true, aab: '../build/app/outputs/bundle/release/app-release.aab')
|
upload_to_play_store(skip_upload_apk: true, skip_upload_images: true, skip_upload_screenshots: true, aab: '../build/app/outputs/bundle/release/app-release.aab')
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ platform :ios do
|
|||||||
desc "iOS Beta"
|
desc "iOS Beta"
|
||||||
lane :beta do
|
lane :beta do
|
||||||
increment_version_number(
|
increment_version_number(
|
||||||
version_number: "1.32.0"
|
version_number: "1.32.1"
|
||||||
)
|
)
|
||||||
increment_build_number(
|
increment_build_number(
|
||||||
build_number: latest_testflight_build_number + 1,
|
build_number: latest_testflight_build_number + 1,
|
||||||
|
|||||||
@@ -1,22 +1,35 @@
|
|||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/modules/album/services/album.service.dart';
|
import 'package:immich_mobile/modules/album/services/album.service.dart';
|
||||||
|
import 'package:immich_mobile/modules/album/services/album_cache.service.dart';
|
||||||
import 'package:openapi/api.dart';
|
import 'package:openapi/api.dart';
|
||||||
|
|
||||||
class AlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
class AlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
||||||
AlbumNotifier(this._albumService) : super([]);
|
AlbumNotifier(this._albumService, this._albumCacheService) : super([]);
|
||||||
final AlbumService _albumService;
|
final AlbumService _albumService;
|
||||||
|
final AlbumCacheService _albumCacheService;
|
||||||
|
|
||||||
|
_cacheState() {
|
||||||
|
_albumCacheService.put(state);
|
||||||
|
}
|
||||||
|
|
||||||
getAllAlbums() async {
|
getAllAlbums() async {
|
||||||
|
|
||||||
|
if (await _albumCacheService.isValid() && state.isEmpty) {
|
||||||
|
state = await _albumCacheService.get();
|
||||||
|
}
|
||||||
|
|
||||||
List<AlbumResponseDto>? albums =
|
List<AlbumResponseDto>? albums =
|
||||||
await _albumService.getAlbums(isShared: false);
|
await _albumService.getAlbums(isShared: false);
|
||||||
|
|
||||||
if (albums != null) {
|
if (albums != null) {
|
||||||
state = albums;
|
state = albums;
|
||||||
|
_cacheState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAlbum(String albumId) {
|
deleteAlbum(String albumId) {
|
||||||
state = state.where((album) => album.id != albumId).toList();
|
state = state.where((album) => album.id != albumId).toList();
|
||||||
|
_cacheState();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<AlbumResponseDto?> createAlbum(
|
Future<AlbumResponseDto?> createAlbum(
|
||||||
@@ -28,6 +41,8 @@ class AlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
|||||||
|
|
||||||
if (album != null) {
|
if (album != null) {
|
||||||
state = [...state, album];
|
state = [...state, album];
|
||||||
|
_cacheState();
|
||||||
|
|
||||||
return album;
|
return album;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -36,5 +51,8 @@ class AlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
|||||||
|
|
||||||
final albumProvider =
|
final albumProvider =
|
||||||
StateNotifierProvider<AlbumNotifier, List<AlbumResponseDto>>((ref) {
|
StateNotifierProvider<AlbumNotifier, List<AlbumResponseDto>>((ref) {
|
||||||
return AlbumNotifier(ref.watch(albumServiceProvider));
|
return AlbumNotifier(
|
||||||
|
ref.watch(albumServiceProvider),
|
||||||
|
ref.watch(albumCacheServiceProvider),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/modules/album/services/album.service.dart';
|
import 'package:immich_mobile/modules/album/services/album.service.dart';
|
||||||
|
import 'package:immich_mobile/modules/album/services/album_cache.service.dart';
|
||||||
import 'package:openapi/api.dart';
|
import 'package:openapi/api.dart';
|
||||||
|
|
||||||
class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
||||||
SharedAlbumNotifier(this._sharedAlbumService) : super([]);
|
SharedAlbumNotifier(this._sharedAlbumService, this._sharedAlbumCacheService) : super([]);
|
||||||
|
|
||||||
final AlbumService _sharedAlbumService;
|
final AlbumService _sharedAlbumService;
|
||||||
|
final SharedAlbumCacheService _sharedAlbumCacheService;
|
||||||
|
|
||||||
|
_cacheState() {
|
||||||
|
_sharedAlbumCacheService.put(state);
|
||||||
|
}
|
||||||
|
|
||||||
Future<AlbumResponseDto?> createSharedAlbum(
|
Future<AlbumResponseDto?> createSharedAlbum(
|
||||||
String albumName,
|
String albumName,
|
||||||
@@ -22,6 +28,7 @@ class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
|||||||
|
|
||||||
if (newAlbum != null) {
|
if (newAlbum != null) {
|
||||||
state = [...state, newAlbum];
|
state = [...state, newAlbum];
|
||||||
|
_cacheState();
|
||||||
}
|
}
|
||||||
|
|
||||||
return newAlbum;
|
return newAlbum;
|
||||||
@@ -33,16 +40,22 @@ class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAllSharedAlbums() async {
|
getAllSharedAlbums() async {
|
||||||
|
if (await _sharedAlbumCacheService.isValid() && state.isEmpty) {
|
||||||
|
state = await _sharedAlbumCacheService.get();
|
||||||
|
}
|
||||||
|
|
||||||
List<AlbumResponseDto>? sharedAlbums =
|
List<AlbumResponseDto>? sharedAlbums =
|
||||||
await _sharedAlbumService.getAlbums(isShared: true);
|
await _sharedAlbumService.getAlbums(isShared: true);
|
||||||
|
|
||||||
if (sharedAlbums != null) {
|
if (sharedAlbums != null) {
|
||||||
state = sharedAlbums;
|
state = sharedAlbums;
|
||||||
|
_cacheState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAlbum(String albumId) async {
|
deleteAlbum(String albumId) async {
|
||||||
state = state.where((album) => album.id != albumId).toList();
|
state = state.where((album) => album.id != albumId).toList();
|
||||||
|
_cacheState();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> leaveAlbum(String albumId) async {
|
Future<bool> leaveAlbum(String albumId) async {
|
||||||
@@ -50,6 +63,7 @@ class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
|||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
state = state.where((album) => album.id != albumId).toList();
|
state = state.where((album) => album.id != albumId).toList();
|
||||||
|
_cacheState();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -72,7 +86,10 @@ class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
|||||||
|
|
||||||
final sharedAlbumProvider =
|
final sharedAlbumProvider =
|
||||||
StateNotifierProvider<SharedAlbumNotifier, List<AlbumResponseDto>>((ref) {
|
StateNotifierProvider<SharedAlbumNotifier, List<AlbumResponseDto>>((ref) {
|
||||||
return SharedAlbumNotifier(ref.watch(albumServiceProvider));
|
return SharedAlbumNotifier(
|
||||||
|
ref.watch(albumServiceProvider),
|
||||||
|
ref.watch(sharedAlbumCacheServiceProvider),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
final sharedAlbumDetailProvider = FutureProvider.autoDispose
|
final sharedAlbumDetailProvider = FutureProvider.autoDispose
|
||||||
|
|||||||
49
mobile/lib/modules/album/services/album_cache.service.dart
Normal file
49
mobile/lib/modules/album/services/album_cache.service.dart
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/shared/services/json_cache.dart';
|
||||||
|
import 'package:openapi/api.dart';
|
||||||
|
|
||||||
|
class BaseAlbumCacheService extends JsonCache<List<AlbumResponseDto>> {
|
||||||
|
BaseAlbumCacheService(super.cacheFileName);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void put(List<AlbumResponseDto> data) {
|
||||||
|
putRawData(data.map((e) => e.toJson()).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<AlbumResponseDto>> get() async {
|
||||||
|
try {
|
||||||
|
final mapList = await readRawData() as List<dynamic>;
|
||||||
|
|
||||||
|
final responseData = mapList
|
||||||
|
.map((e) => AlbumResponseDto.fromJson(e))
|
||||||
|
.whereNotNull()
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return responseData;
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint(e.toString());
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AlbumCacheService extends BaseAlbumCacheService {
|
||||||
|
AlbumCacheService() : super("album_cache");
|
||||||
|
}
|
||||||
|
|
||||||
|
class SharedAlbumCacheService extends BaseAlbumCacheService {
|
||||||
|
SharedAlbumCacheService() : super("shared_album_cache");
|
||||||
|
}
|
||||||
|
|
||||||
|
final albumCacheServiceProvider = Provider(
|
||||||
|
(ref) => AlbumCacheService(),
|
||||||
|
);
|
||||||
|
|
||||||
|
final sharedAlbumCacheServiceProvider = Provider(
|
||||||
|
(ref) => SharedAlbumCacheService(),
|
||||||
|
);
|
||||||
|
|
||||||
37
mobile/lib/modules/home/services/asset_cache.service.dart
Normal file
37
mobile/lib/modules/home/services/asset_cache.service.dart
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/shared/services/json_cache.dart';
|
||||||
|
import 'package:openapi/api.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class AssetCacheService extends JsonCache<List<AssetResponseDto>> {
|
||||||
|
AssetCacheService() : super("asset_cache");
|
||||||
|
|
||||||
|
@override
|
||||||
|
void put(List<AssetResponseDto> data) {
|
||||||
|
putRawData(data.map((e) => e.toJson()).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<AssetResponseDto>> get() async {
|
||||||
|
try {
|
||||||
|
final mapList = await readRawData() as List<dynamic>;
|
||||||
|
|
||||||
|
final responseData = mapList
|
||||||
|
.map((e) => AssetResponseDto.fromJson(e))
|
||||||
|
.whereNotNull()
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return responseData;
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint(e.toString());
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final assetCacheServiceProvider = Provider(
|
||||||
|
(ref) => AssetCacheService(),
|
||||||
|
);
|
||||||
@@ -3,6 +3,8 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/constants/hive_box.dart';
|
import 'package:immich_mobile/constants/hive_box.dart';
|
||||||
|
import 'package:immich_mobile/modules/album/services/album_cache.service.dart';
|
||||||
|
import 'package:immich_mobile/modules/home/services/asset_cache.service.dart';
|
||||||
import 'package:immich_mobile/modules/login/models/authentication_state.model.dart';
|
import 'package:immich_mobile/modules/login/models/authentication_state.model.dart';
|
||||||
import 'package:immich_mobile/modules/login/models/hive_saved_login_info.model.dart';
|
import 'package:immich_mobile/modules/login/models/hive_saved_login_info.model.dart';
|
||||||
import 'package:immich_mobile/modules/backup/services/backup.service.dart';
|
import 'package:immich_mobile/modules/backup/services/backup.service.dart';
|
||||||
@@ -16,6 +18,9 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
|||||||
this._deviceInfoService,
|
this._deviceInfoService,
|
||||||
this._backupService,
|
this._backupService,
|
||||||
this._apiService,
|
this._apiService,
|
||||||
|
this._assetCacheService,
|
||||||
|
this._albumCacheService,
|
||||||
|
this._sharedAlbumCacheService,
|
||||||
) : super(
|
) : super(
|
||||||
AuthenticationState(
|
AuthenticationState(
|
||||||
deviceId: "",
|
deviceId: "",
|
||||||
@@ -42,6 +47,9 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
|||||||
final DeviceInfoService _deviceInfoService;
|
final DeviceInfoService _deviceInfoService;
|
||||||
final BackupService _backupService;
|
final BackupService _backupService;
|
||||||
final ApiService _apiService;
|
final ApiService _apiService;
|
||||||
|
final AssetCacheService _assetCacheService;
|
||||||
|
final AlbumCacheService _albumCacheService;
|
||||||
|
final SharedAlbumCacheService _sharedAlbumCacheService;
|
||||||
|
|
||||||
Future<bool> login(
|
Future<bool> login(
|
||||||
String email,
|
String email,
|
||||||
@@ -153,7 +161,9 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
|||||||
Future<bool> logout() async {
|
Future<bool> logout() async {
|
||||||
Hive.box(userInfoBox).delete(accessTokenKey);
|
Hive.box(userInfoBox).delete(accessTokenKey);
|
||||||
state = state.copyWith(isAuthenticated: false);
|
state = state.copyWith(isAuthenticated: false);
|
||||||
|
_assetCacheService.invalidate();
|
||||||
|
_albumCacheService.invalidate();
|
||||||
|
_sharedAlbumCacheService.invalidate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,5 +209,8 @@ final authenticationProvider =
|
|||||||
ref.watch(deviceInfoServiceProvider),
|
ref.watch(deviceInfoServiceProvider),
|
||||||
ref.watch(backupServiceProvider),
|
ref.watch(backupServiceProvider),
|
||||||
ref.watch(apiServiceProvider),
|
ref.watch(apiServiceProvider),
|
||||||
|
ref.watch(assetCacheServiceProvider),
|
||||||
|
ref.watch(albumCacheServiceProvider),
|
||||||
|
ref.watch(sharedAlbumCacheServiceProvider),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ class LoginButton extends ConsumerWidget {
|
|||||||
AutoRouter.of(context).push(const ChangePasswordRoute());
|
AutoRouter.of(context).push(const ChangePasswordRoute());
|
||||||
} else {
|
} else {
|
||||||
ref.watch(backupProvider.notifier).resumeBackup();
|
ref.watch(backupProvider.notifier).resumeBackup();
|
||||||
AutoRouter.of(context).pushNamed("/tab-controller-page");
|
AutoRouter.of(context).replace(const TabControllerRoute());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ImmichToast.show(
|
ImmichToast.show(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/modules/home/services/asset.service.dart';
|
import 'package:immich_mobile/modules/home/services/asset.service.dart';
|
||||||
|
import 'package:immich_mobile/modules/home/services/asset_cache.service.dart';
|
||||||
import 'package:immich_mobile/shared/services/device_info.service.dart';
|
import 'package:immich_mobile/shared/services/device_info.service.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
@@ -9,24 +10,50 @@ import 'package:photo_manager/photo_manager.dart';
|
|||||||
|
|
||||||
class AssetNotifier extends StateNotifier<List<AssetResponseDto>> {
|
class AssetNotifier extends StateNotifier<List<AssetResponseDto>> {
|
||||||
final AssetService _assetService;
|
final AssetService _assetService;
|
||||||
|
final AssetCacheService _assetCacheService;
|
||||||
|
|
||||||
final DeviceInfoService _deviceInfoService = DeviceInfoService();
|
final DeviceInfoService _deviceInfoService = DeviceInfoService();
|
||||||
|
|
||||||
AssetNotifier(this._assetService) : super([]);
|
AssetNotifier(this._assetService, this._assetCacheService) : super([]);
|
||||||
|
|
||||||
|
_cacheState() {
|
||||||
|
_assetCacheService.put(state);
|
||||||
|
}
|
||||||
|
|
||||||
getAllAsset() async {
|
getAllAsset() async {
|
||||||
|
final stopwatch = Stopwatch();
|
||||||
|
|
||||||
|
|
||||||
|
if (await _assetCacheService.isValid() && state.isEmpty) {
|
||||||
|
stopwatch.start();
|
||||||
|
state = await _assetCacheService.get();
|
||||||
|
debugPrint("Reading assets from cache: ${stopwatch.elapsedMilliseconds}ms");
|
||||||
|
stopwatch.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
stopwatch.start();
|
||||||
var allAssets = await _assetService.getAllAsset();
|
var allAssets = await _assetService.getAllAsset();
|
||||||
|
debugPrint("Query assets from API: ${stopwatch.elapsedMilliseconds}ms");
|
||||||
|
stopwatch.reset();
|
||||||
|
|
||||||
if (allAssets != null) {
|
if (allAssets != null) {
|
||||||
state = allAssets;
|
state = allAssets;
|
||||||
|
|
||||||
|
stopwatch.start();
|
||||||
|
_cacheState();
|
||||||
|
debugPrint("Store assets in cache: ${stopwatch.elapsedMilliseconds}ms");
|
||||||
|
stopwatch.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAllAsset() {
|
clearAllAsset() {
|
||||||
state = [];
|
state = [];
|
||||||
|
_cacheState();
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewAssetUploaded(AssetResponseDto newAsset) {
|
onNewAssetUploaded(AssetResponseDto newAsset) {
|
||||||
state = [...state, newAsset];
|
state = [...state, newAsset];
|
||||||
|
_cacheState();
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAssets(Set<AssetResponseDto> deleteAssets) async {
|
deleteAssets(Set<AssetResponseDto> deleteAssets) async {
|
||||||
@@ -65,12 +92,15 @@ class AssetNotifier extends StateNotifier<List<AssetResponseDto>> {
|
|||||||
state.where((immichAsset) => immichAsset.id != asset.id).toList();
|
state.where((immichAsset) => immichAsset.id != asset.id).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cacheState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final assetProvider =
|
final assetProvider =
|
||||||
StateNotifierProvider<AssetNotifier, List<AssetResponseDto>>((ref) {
|
StateNotifierProvider<AssetNotifier, List<AssetResponseDto>>((ref) {
|
||||||
return AssetNotifier(ref.watch(assetServiceProvider));
|
return AssetNotifier(
|
||||||
|
ref.watch(assetServiceProvider), ref.watch(assetCacheServiceProvider));
|
||||||
});
|
});
|
||||||
|
|
||||||
final assetGroupByDateTimeProvider = StateProvider((ref) {
|
final assetGroupByDateTimeProvider = StateProvider((ref) {
|
||||||
|
|||||||
49
mobile/lib/shared/services/json_cache.dart
Normal file
49
mobile/lib/shared/services/json_cache.dart
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
|
abstract class JsonCache<T> {
|
||||||
|
final String cacheFileName;
|
||||||
|
|
||||||
|
JsonCache(this.cacheFileName);
|
||||||
|
|
||||||
|
Future<File> _getCacheFile() async {
|
||||||
|
final basePath = await getTemporaryDirectory();
|
||||||
|
final basePathName = basePath.path;
|
||||||
|
|
||||||
|
final file = File("$basePathName/$cacheFileName.bin");
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> isValid() async {
|
||||||
|
final file = await _getCacheFile();
|
||||||
|
return await file.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> invalidate() async {
|
||||||
|
final file = await _getCacheFile();
|
||||||
|
await file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> putRawData(dynamic data) async {
|
||||||
|
final jsonString = json.encode(data);
|
||||||
|
final file = await _getCacheFile();
|
||||||
|
|
||||||
|
if (!await file.exists()) {
|
||||||
|
await file.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
await file.writeAsString(jsonString);
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamic readRawData() async {
|
||||||
|
final file = await _getCacheFile();
|
||||||
|
final data = await file.readAsString();
|
||||||
|
return json.decode(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void put(T data);
|
||||||
|
Future<T> get();
|
||||||
|
}
|
||||||
@@ -29,9 +29,9 @@ class SplashScreenPage extends HookConsumerWidget {
|
|||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
// Resume backup (if enable) then navigate
|
// Resume backup (if enable) then navigate
|
||||||
ref.watch(backupProvider.notifier).resumeBackup();
|
ref.watch(backupProvider.notifier).resumeBackup();
|
||||||
AutoRouter.of(context).pushNamed("/tab-controller-page");
|
AutoRouter.of(context).replace(const TabControllerRoute());
|
||||||
} else {
|
} else {
|
||||||
AutoRouter.of(context).push(const LoginRoute());
|
AutoRouter.of(context).replace(const LoginRoute());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ class SplashScreenPage extends HookConsumerWidget {
|
|||||||
if (loginInfo?.isSaveLogin == true) {
|
if (loginInfo?.isSaveLogin == true) {
|
||||||
performLoggingIn();
|
performLoggingIn();
|
||||||
} else {
|
} else {
|
||||||
AutoRouter.of(context).push(const LoginRoute());
|
AutoRouter.of(context).replace(const LoginRoute());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class TabControllerPage extends ConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final multiselectEnabled = ref.watch(multiselectProvider);
|
final multiselectEnabled = ref.watch(multiselectProvider);
|
||||||
|
|
||||||
return AutoTabsRouter(
|
return AutoTabsRouter(
|
||||||
routes: [
|
routes: [
|
||||||
const HomeRoute(),
|
const HomeRoute(),
|
||||||
@@ -22,9 +21,17 @@ class TabControllerPage extends ConsumerWidget {
|
|||||||
],
|
],
|
||||||
builder: (context, child, animation) {
|
builder: (context, child, animation) {
|
||||||
final tabsRouter = AutoTabsRouter.of(context);
|
final tabsRouter = AutoTabsRouter.of(context);
|
||||||
|
final appRouter = AutoRouter.of(context);
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
tabsRouter.setActiveIndex(0);
|
if (tabsRouter.activeIndex == 0) {
|
||||||
|
if (!appRouter.canNavigateBack) {
|
||||||
|
appRouter.navigateBack();
|
||||||
|
}
|
||||||
|
return appRouter.canNavigateBack;
|
||||||
|
} else {
|
||||||
|
tabsRouter.setActiveIndex(0);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: immich_mobile
|
|||||||
description: Immich - selfhosted backup media file on mobile phone
|
description: Immich - selfhosted backup media file on mobile phone
|
||||||
|
|
||||||
publish_to: "none"
|
publish_to: "none"
|
||||||
version: 1.32.0+50
|
version: 1.32.1+51
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.17.0 <3.0.0"
|
sdk: ">=2.17.0 <3.0.0"
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ export interface IServerVersion {
|
|||||||
export const serverVersion: IServerVersion = {
|
export const serverVersion: IServerVersion = {
|
||||||
major: 1,
|
major: 1,
|
||||||
minor: 32,
|
minor: 32,
|
||||||
patch: 0,
|
patch: 1,
|
||||||
build: 50,
|
build: 51,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user