@@ -9,6 +9,8 @@ import SushitrainCore
99import QuickLook
1010
1111struct 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