Skip to content

Commit 62723fc

Browse files
committed
ui: hide conflicted files from extra files list by default
Signed-off-by: Tommy van der Vorst <tommy@pixelspark.nl>
1 parent 1bad2a0 commit 62723fc

File tree

3 files changed

+92
-30
lines changed

3 files changed

+92
-30
lines changed

Localizable.xcstrings

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28094,6 +28094,52 @@
2809428094
}
2809528095
}
2809628096
},
28097+
"Show conflicted files" : {
28098+
"localizations" : {
28099+
"de" : {
28100+
"stringUnit" : {
28101+
"state" : "translated",
28102+
"value" : "Konfliktdateien anzeigen"
28103+
}
28104+
},
28105+
"es" : {
28106+
"stringUnit" : {
28107+
"state" : "translated",
28108+
"value" : "Mostrar archivos en conflicto"
28109+
}
28110+
},
28111+
"it" : {
28112+
"stringUnit" : {
28113+
"state" : "translated",
28114+
"value" : "Mostra file in conflitto"
28115+
}
28116+
},
28117+
"ja" : {
28118+
"stringUnit" : {
28119+
"state" : "translated",
28120+
"value" : "競合ファイルを表示"
28121+
}
28122+
},
28123+
"nl" : {
28124+
"stringUnit" : {
28125+
"state" : "translated",
28126+
"value" : "Toon conflicterende bestanden"
28127+
}
28128+
},
28129+
"uk" : {
28130+
"stringUnit" : {
28131+
"state" : "translated",
28132+
"value" : "Показати файли з конфліктами"
28133+
}
28134+
},
28135+
"zh-Hans" : {
28136+
"stringUnit" : {
28137+
"state" : "translated",
28138+
"value" : "显示冲突的文件"
28139+
}
28140+
}
28141+
}
28142+
},
2809728143
"Show details" : {
2809828144
"localizations" : {
2809928145
"de" : {

Sushitrain/AppState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ struct SyncState {
382382
}
383383
}
384384
}
385-
385+
386386
pm.start(queue: .main)
387387
self.currentNetworkPath = pm.currentPath
388388
Task {

Sushitrain/ExtraFilesView.swift

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import SushitrainCore
99
import QuickLook
1010

1111
struct ExtraFilesView: View {
12+
private static let conflictFileMarker = ".sync-conflict"
13+
1214
var folder: SushitrainFolder
1315
@Environment(AppState.self) private var appState
1416
@State private var extraFiles: [String] = []
@@ -18,6 +20,8 @@ struct ExtraFilesView: View {
1820
@State private var allVerdict: Bool? = nil
1921
@State private var errorMessage: String? = nil
2022
@State private var showApplyConfirmation = false
23+
@State private var showConflictFiles = false
24+
@State private var hasConflictFiles = false
2125

2226
var body: some View {
2327
Group {
@@ -64,43 +68,53 @@ struct ExtraFilesView: View {
6468

6569
Section {
6670
ForEach(extraFiles, id: \.self) { path in
67-
let verdict = verdicts[path]
68-
let globalEntry = try? folder.getFileInformation(path)
71+
if showConflictFiles || !path.contains(Self.conflictFileMarker) {
72+
let verdict = verdicts[path]
73+
let globalEntry = try? folder.getFileInformation(path)
6974

70-
HStack {
71-
VStack(alignment: .leading) {
72-
Text(path).multilineTextAlignment(.leading).dynamicTypeSize(.small).foregroundStyle(
73-
verdict == false ? .red : verdict == true ? .green : .primary
74-
).onTapGesture {
75-
if let folderNativePath = folder.localNativeURL { self.localItemURL = folderNativePath.appending(path: path) }
76-
}.disabled(folder.localNativeURL == nil)
77-
}.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
75+
HStack {
76+
VStack(alignment: .leading) {
77+
Text(path).multilineTextAlignment(.leading).dynamicTypeSize(.small).foregroundStyle(
78+
verdict == false ? .red : verdict == true ? .green : .primary
79+
).onTapGesture {
80+
if let folderNativePath = folder.localNativeURL {
81+
self.localItemURL = folderNativePath.appending(path: path)
82+
}
83+
}.disabled(folder.localNativeURL == nil)
84+
}.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
7885

79-
Picker(
80-
"Action",
81-
selection: Binding(
82-
get: { return verdicts[path] },
83-
set: { s in
84-
verdicts[path] = s
85-
allVerdict = nil
86-
})
87-
) {
88-
Image(systemName: "trash").tint(.red).tag(false).accessibilityLabel("Delete file")
89-
if folder.folderType() == SushitrainFolderTypeReceiveOnly {
90-
Image(systemName: "trash.slash").tag(true).accessibilityLabel("Keep file")
91-
}
92-
else {
93-
if let ge = globalEntry, !ge.isDeleted() {
94-
Image(systemName: "rectangle.2.swap").tag(true).accessibilityLabel("Replace existing file")
86+
Picker(
87+
"Action",
88+
selection: Binding(
89+
get: { return verdicts[path] },
90+
set: { s in
91+
verdicts[path] = s
92+
allVerdict = nil
93+
})
94+
) {
95+
Image(systemName: "trash").tint(.red).tag(false).accessibilityLabel("Delete file")
96+
if folder.folderType() == SushitrainFolderTypeReceiveOnly {
97+
Image(systemName: "trash.slash").tag(true).accessibilityLabel("Keep file")
9598
}
9699
else {
97-
Image(systemName: "plus.square.fill").tag(true).accessibilityLabel("Keep file")
100+
if let ge = globalEntry, !ge.isDeleted() {
101+
Image(systemName: "rectangle.2.swap").tag(true).accessibilityLabel("Replace existing file")
102+
}
103+
else {
104+
Image(systemName: "plus.square.fill").tag(true).accessibilityLabel("Keep file")
105+
}
98106
}
99-
}
100-
}.pickerStyle(.segmented).frame(width: 100)
107+
}.pickerStyle(.segmented).frame(width: 100)
108+
}
101109
}
102110
}
103111
}
112+
113+
if hasConflictFiles && !showConflictFiles {
114+
Button("Show conflicted files") {
115+
self.showConflictFiles = true
116+
}
117+
}
104118
}
105119
}
106120
}
@@ -180,9 +194,11 @@ struct ExtraFilesView: View {
180194
private func reload() async {
181195
if folder.isIdleOrSyncing {
182196
extraFiles = await Task.detached { return (try? folder.extraneousFiles().asArray().sorted()) ?? [] }.value
197+
hasConflictFiles = extraFiles.contains(where: { $0.contains(Self.conflictFileMarker) })
183198
}
184199
else {
185200
extraFiles = []
201+
hasConflictFiles = false
186202
}
187203
}
188204
}

0 commit comments

Comments
 (0)