feat(local file page): Display server names for server folders (#996)

* feat(local file page): Display server names for server folders

In the local file list, server folders will display their corresponding server names, enhancing the user experience.

* fix(storage page): Use ref.read instead of ref.watch to fetch the server list

Avoid unnecessary watch operations during construction, reducing potential performance overhead
This commit is contained in:
GT610
2026-01-08 18:57:02 +08:00
committed by GitHub
parent 29a57ad742
commit 9ceeaf7cc4

View File

@@ -140,11 +140,23 @@ class _LocalFilePageState extends ConsumerState<LocalFilePage> with AutomaticKee
required FileStat stat,
required bool isDir,
}) {
final isServerFolder = isDir && file.parent.path == Paths.file;
String? serverName;
if (isServerFolder) {
final servers = ref.read(serversProvider).servers;
final server = servers[fileName];
if (server != null) {
serverName = server.name;
}
}
return CardX(
child: ListTile(
leading: isDir ? const Icon(Icons.folder_open) : const Icon(Icons.insert_drive_file),
title: Text(fileName),
subtitle: isDir ? null : Text(stat.size.bytes2Str, style: UIs.textGrey),
title: Text(serverName ?? fileName),
subtitle: isDir
? (serverName != null ? Text(fileName, style: UIs.textGrey) : null)
: Text(stat.size.bytes2Str, style: UIs.textGrey),
trailing: Text(stat.modified.ymdhms(), style: UIs.textGrey),
onLongPress: () {
if (isDir) {