migrate: riverpod 3

This commit is contained in:
lollipopkit🏳️‍⚧️
2025-10-08 17:03:13 +08:00
parent f68c4a851b
commit da8517bcf7
51 changed files with 840 additions and 884 deletions

View File

@@ -359,7 +359,7 @@ extension _OnTapFile on _LocalFilePageState {
final spi = await context.showPickSingleDialog<Spi>(
title: libL10n.select,
items: ref.read(serversNotifierProvider).servers.values.toList(),
items: ref.read(serversProvider).servers.values.toList(),
display: (e) => e.name,
);
if (spi == null) return;
@@ -370,7 +370,7 @@ extension _OnTapFile on _LocalFilePageState {
return;
}
ref.read(sftpNotifierProvider.notifier).add(SftpReq(spi, '$remotePath/$fileName', file.absolute.path, SftpReqType.upload));
ref.read(sftpProvider.notifier).add(SftpReq(spi, '$remotePath/$fileName', file.absolute.path, SftpReqType.upload));
context.showSnackBar(l10n.added2List);
}
}

View File

@@ -50,7 +50,7 @@ class _SftpPageState extends ConsumerState<SftpPage> with AfterLayoutMixin {
@override
void initState() {
super.initState();
final serverState = ref.read(serverNotifierProvider(widget.args.spi.id));
final serverState = ref.read(serverProvider(widget.args.spi.id));
_client = serverState.client!;
_status = SftpBrowserStatus(_client);
}
@@ -290,7 +290,7 @@ extension _Actions on _SftpPageState {
final localPath = _getLocalPath(remotePath);
final completer = Completer();
final req = SftpReq(widget.args.spi, remotePath, localPath, SftpReqType.download);
ref.read(sftpNotifierProvider.notifier).add(req, completer: completer);
ref.read(sftpProvider.notifier).add(req, completer: completer);
final (suc, err) = await context.showLoadingDialog(fn: () => completer.future);
if (suc == null || err != null) return;
@@ -300,7 +300,7 @@ extension _Actions on _SftpPageState {
path: localPath,
onSave: (_) {
ref
.read(sftpNotifierProvider.notifier)
.read(sftpProvider.notifier)
.add(SftpReq(req.spi, remotePath, localPath, SftpReqType.upload));
context.showSnackBar(l10n.added2List);
},
@@ -323,7 +323,7 @@ extension _Actions on _SftpPageState {
final remotePath = _getRemotePath(name);
ref
.read(sftpNotifierProvider.notifier)
.read(sftpProvider.notifier)
.add(SftpReq(widget.args.spi, remotePath, _getLocalPath(remotePath), SftpReqType.download));
context.pop();
@@ -653,7 +653,7 @@ extension _Actions on _SftpPageState {
final remotePath = '$remoteDir/$fileName';
Loggers.app.info('SFTP upload local: $path, remote: $remotePath');
ref
.read(sftpNotifierProvider.notifier)
.read(sftpProvider.notifier)
.add(SftpReq(widget.args.spi, remotePath, path, SftpReqType.upload));
},
icon: const Icon(Icons.upload_file),

View File

@@ -25,7 +25,7 @@ class _SftpMissionPageState extends ConsumerState<SftpMissionPage> {
}
Widget _buildBody() {
final status = ref.watch(sftpNotifierProvider.select((pro) => pro.requests));
final status = ref.watch(sftpProvider.select((pro) => pro.requests));
if (status.isEmpty) {
return Center(child: Text(libL10n.empty));
}
@@ -143,7 +143,7 @@ class _SftpMissionPageState extends ConsumerState<SftpMissionPage> {
child: Text(libL10n.askContinue('${libL10n.delete} ${l10n.mission}($name)')),
actions: Btn.ok(
onTap: () {
ref.read(sftpNotifierProvider.notifier).cancel(id);
ref.read(sftpProvider.notifier).cancel(id);
context.pop();
},
).toList,