Skip to content

Commit 522f7c4

Browse files
committed
fix(ssh): Fixed an issue with message display during SSH configuration import
- Modified the format of the import success message to display the number of servers successfully imported - Added a prompt for manual selection when permissions are denied - Optimized the server deduplication logic to display an “already exists” message based on the original count
1 parent 0608d6a commit 522f7c4

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/core/utils/server_dedup.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class ServerDeduplication {
7474
/// Import servers with deduplication and show appropriate notifications
7575
/// Returns the number of servers actually imported
7676
/// Note: Caller must check mounted before calling this method
77+
/// If resolvedServers is provided, it should be pre-filtered (non-empty)
7778
static Future<int> importServersWithNotification({
7879
List<Spi>? servers,
7980
required WidgetRef ref,
@@ -85,11 +86,11 @@ class ServerDeduplication {
8586
assert(servers != null || resolvedServers != null,
8687
'Either servers or resolvedServers must be provided');
8788

88-
final source = servers ?? resolvedServers!;
89-
final resolved = resolvedServers ?? _resolveServers(source);
89+
final originalCount = servers?.length ?? resolvedServers!.length;
90+
final resolved = resolvedServers ?? _resolveServers(servers!);
9091

9192
if (resolved.isEmpty) {
92-
context.showSnackBar(allExistMessage('${source.length}'));
93+
context.showSnackBar(allExistMessage('$originalCount'));
9394
return 0;
9495
}
9596

lib/view/page/server/edit/actions.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ extension _Utils on _ServerEditPageState {
185185
Stores.setting.firstTimeReadSSHCfg.put(false);
186186
if (e is PathAccessException ||
187187
e.toString().contains('Operation not permitted')) {
188-
context.showSnackBar(l10n.sshConfigPermissionDenied);
188+
context.showSnackBar(
189+
'${l10n.sshConfigPermissionDenied} ${l10n.sshConfigManualSelect}',
190+
);
189191
} else {
190192
dprint('Error checking SSH config: $e');
191193
}

lib/view/page/setting/entries/ssh.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ extension _SSH on _AppSettingsPageState {
132132
ref: ref,
133133
context: context,
134134
allExistMessage: l10n.sshConfigAllExist,
135-
importedMessage: l10n.sshConfigImported,
135+
importedMessage: (count) => '${libL10n.success}: $count ${libL10n.servers}',
136136
);
137137
}
138138
} finally {

0 commit comments

Comments
 (0)