2026-03-05 12:04:45 -05:00
|
|
|
import 'dart:async';
|
2023-12-10 15:56:39 +00:00
|
|
|
|
2022-05-06 07:22:23 -05:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2025-02-20 00:57:32 +05:30
|
|
|
import 'package:immich_mobile/models/server_info/server_disk_info.model.dart';
|
2024-05-02 15:59:14 -05:00
|
|
|
import 'package:immich_mobile/services/server_info.service.dart';
|
2022-05-06 07:22:23 -05:00
|
|
|
|
2026-04-15 23:00:27 +05:30
|
|
|
final backupProvider = StateNotifierProvider<BackupNotifier, ServerDiskInfo>((ref) {
|
|
|
|
|
return BackupNotifier(ref.watch(serverInfoServiceProvider));
|
2025-02-27 09:56:23 -06:00
|
|
|
});
|
|
|
|
|
|
2026-04-15 23:00:27 +05:30
|
|
|
class BackupNotifier extends StateNotifier<ServerDiskInfo> {
|
|
|
|
|
BackupNotifier(this._serverInfoService)
|
|
|
|
|
: super(const ServerDiskInfo(diskAvailable: "0", diskSize: "0", diskUse: "0", diskUsagePercentage: 0));
|
2022-05-06 07:22:23 -05:00
|
|
|
|
2022-06-26 03:46:51 +09:00
|
|
|
final ServerInfoService _serverInfoService;
|
2022-05-06 07:22:23 -05:00
|
|
|
|
2024-05-22 10:25:55 +01:00
|
|
|
Future<void> updateDiskInfo() async {
|
|
|
|
|
final diskInfo = await _serverInfoService.getDiskInfo();
|
|
|
|
|
if (diskInfo != null) {
|
2026-04-15 23:00:27 +05:30
|
|
|
state = diskInfo;
|
2023-03-18 15:55:11 +01:00
|
|
|
}
|
2023-08-06 02:40:50 +00:00
|
|
|
}
|
2022-05-06 07:22:23 -05:00
|
|
|
}
|