fix file transfer load/save config, opt breadCrumbScroll

This commit is contained in:
csf 2022-12-04 22:41:44 +09:00
parent efc9f312e9
commit 5b9a76f8a5
3 changed files with 28 additions and 22 deletions

View File

@ -93,6 +93,7 @@ class _FileManagerPageState extends State<FileManagerPage>
Wakelock.enable(); Wakelock.enable();
} }
debugPrint("File manager page init success with id ${widget.id}"); debugPrint("File manager page init success with id ${widget.id}");
model.onDirChanged = breadCrumbScrollToEnd;
// register location listener // register location listener
_locationNodeLocal.addListener(onLocalLocationFocusChanged); _locationNodeLocal.addListener(onLocalLocationFocusChanged);
_locationNodeRemote.addListener(onRemoteLocationFocusChanged); _locationNodeRemote.addListener(onRemoteLocationFocusChanged);
@ -100,17 +101,18 @@ class _FileManagerPageState extends State<FileManagerPage>
@override @override
void dispose() { void dispose() {
model.onClose(); model.onClose().whenComplete(() {
_ffi.close(); _ffi.close();
_ffi.dialogManager.dismissAll(); _ffi.dialogManager.dismissAll();
if (!Platform.isLinux) { if (!Platform.isLinux) {
Wakelock.disable(); Wakelock.disable();
} }
Get.delete<FFI>(tag: 'ft_${widget.id}'); Get.delete<FFI>(tag: 'ft_${widget.id}');
_locationNodeLocal.removeListener(onLocalLocationFocusChanged); _locationNodeLocal.removeListener(onLocalLocationFocusChanged);
_locationNodeRemote.removeListener(onRemoteLocationFocusChanged); _locationNodeRemote.removeListener(onRemoteLocationFocusChanged);
_locationNodeLocal.dispose(); _locationNodeLocal.dispose();
_locationNodeRemote.dispose(); _locationNodeRemote.dispose();
});
super.dispose(); super.dispose();
} }
@ -636,7 +638,6 @@ class _FileManagerPageState extends State<FileManagerPage>
}), }),
IconButton( IconButton(
onPressed: () { onPressed: () {
breadCrumbScrollToEnd(isLocal);
model.refresh(isLocal: isLocal); model.refresh(isLocal: isLocal);
}, },
splashRadius: kDesktopIconButtonSplashRadius, splashRadius: kDesktopIconButtonSplashRadius,
@ -999,9 +1000,7 @@ class _FileManagerPageState extends State<FileManagerPage>
} }
openDirectory(String path, {bool isLocal = false}) { openDirectory(String path, {bool isLocal = false}) {
model.openDirectory(path, isLocal: isLocal).then((_) { model.openDirectory(path, isLocal: isLocal);
breadCrumbScrollToEnd(isLocal);
});
} }
void handleDragDone(DropDoneDetails details, bool isLocal) { void handleDragDone(DropDoneDetails details, bool isLocal) {

View File

@ -32,15 +32,17 @@ class _FileManagerPageState extends State<FileManagerPage> {
.showLoading(translate('Connecting...'), onCancel: closeConnection); .showLoading(translate('Connecting...'), onCancel: closeConnection);
}); });
gFFI.ffiModel.updateEventListener(widget.id); gFFI.ffiModel.updateEventListener(widget.id);
model.onDirChanged = (_) => breadCrumbScrollToEnd();
Wakelock.enable(); Wakelock.enable();
} }
@override @override
void dispose() { void dispose() {
model.onClose(); model.onClose().whenComplete(() {
gFFI.close(); gFFI.close();
gFFI.dialogManager.dismissAll(); gFFI.dialogManager.dismissAll();
Wakelock.disable(); Wakelock.disable();
});
super.dispose(); super.dispose();
} }
@ -309,7 +311,6 @@ class _FileManagerPageState extends State<FileManagerPage> {
} }
if (entries[index].isDirectory || entries[index].isDrive) { if (entries[index].isDirectory || entries[index].isDrive) {
model.openDirectory(entries[index].path); model.openDirectory(entries[index].path);
breadCrumbScrollToEnd();
} else { } else {
// Perform file-related tasks. // Perform file-related tasks.
} }

View File

@ -42,6 +42,9 @@ class FileModel extends ChangeNotifier {
/// JobTable <jobId, JobProgress> /// JobTable <jobId, JobProgress>
final _jobTable = List<JobProgress>.empty(growable: true).obs; final _jobTable = List<JobProgress>.empty(growable: true).obs;
/// `isLocal` bool
Function(bool)? onDirChanged;
RxList<JobProgress> get jobTable => _jobTable; RxList<JobProgress> get jobTable => _jobTable;
bool get isLocal => _isSelectedLocal; bool get isLocal => _isSelectedLocal;
@ -354,10 +357,12 @@ class FileModel extends ChangeNotifier {
await bind.sessionLoadLastTransferJobs(id: '${parent.target?.id}'); await bind.sessionLoadLastTransferJobs(id: '${parent.target?.id}');
} }
onClose() { Future<void> onClose() async {
parent.target?.dialogManager.dismissAll(); parent.target?.dialogManager.dismissAll();
jobReset(); jobReset();
onDirChanged = null;
// save config // save config
Map<String, String> msgMap = {}; Map<String, String> msgMap = {};
@ -367,7 +372,7 @@ class FileModel extends ChangeNotifier {
msgMap["remote_show_hidden"] = _remoteOption.showHidden ? "Y" : ""; msgMap["remote_show_hidden"] = _remoteOption.showHidden ? "Y" : "";
final id = parent.target?.id ?? ""; final id = parent.target?.id ?? "";
for (final msg in msgMap.entries) { for (final msg in msgMap.entries) {
bind.sessionPeerOption(id: id, name: msg.key, value: msg.value); await bind.sessionPeerOption(id: id, name: msg.key, value: msg.value);
} }
_currentLocalDir.clear(); _currentLocalDir.clear();
_currentRemoteDir.clear(); _currentRemoteDir.clear();
@ -421,6 +426,7 @@ class FileModel extends ChangeNotifier {
_currentRemoteDir = fd; _currentRemoteDir = fd;
} }
notifyListeners(); notifyListeners();
onDirChanged?.call(isLocal);
} catch (e) { } catch (e) {
debugPrint("Failed to openDirectory $path: $e"); debugPrint("Failed to openDirectory $path: $e");
} }