new: open sftp with last viewed path

This commit is contained in:
lollipopkit
2023-10-14 23:03:12 +08:00
parent c9d54f4fea
commit a397f81988
14 changed files with 123 additions and 12 deletions

View File

@@ -647,6 +647,12 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
_status.files = fs;
});
context.pop();
// Only update history when success
if (Stores.setting.sftpOpenLastPath.fetch()) {
Stores.history.sftpLastPath.put(widget.spi.id, listPath);
}
return true;
}
return false;
@@ -679,7 +685,14 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
@override
FutureOr<void> afterFirstLayout(BuildContext context) {
_status.path = AbsolutePath(widget.initPath ?? '/');
var initPath = '/';
if (Stores.setting.sftpOpenLastPath.fetch()) {
final history = Stores.history.sftpLastPath.fetch(widget.spi.id);
if (history != null) {
initPath = history;
}
}
_status.path = AbsolutePath(widget.initPath ?? initPath);
_listDir();
}
}