Skip to content

Commit 4c56097

Browse files
committed
refactor: Move loading thumbnail actions on appear/modifier to a function
1 parent 959c5bd commit 4c56097

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

FileBrowserClient/FileBrowserClient/DataManagers/RemoteThumbnail.swift

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,12 @@ struct RemoteThumbnail: View {
129129
.modifier(ViewVisibilityModifier(onVisible: {
130130
// MARK: Only attempt load once per view lifecycle
131131
// Keep threshold [0] as tight as possible to avoid loading anything outside current view
132-
if !loadAttempted {
133-
loadAttempted = true
134-
// Show spinner immediately for first-frame visibility
135-
isLoading = true
136-
loadingFiles[file.path] = true
137-
loadThumbnail()
138-
}
132+
loadThumbnailsOnAppear()
139133
}, threshold: 0))
140134
.onAppear {
141-
// Also check on appear to handle navigation back from detail view
135+
// Check onAppear to handle navigation back from detail view
142136
// When navigated back, views are already "visible" so ViewVisibilityModifier won't fire
143-
if !loadAttempted {
144-
loadAttempted = true
145-
isLoading = true
146-
loadingFiles[file.path] = true
147-
loadThumbnail()
148-
}
137+
loadThumbnailsOnAppear()
149138
}
150139
.onDisappear {
151140
image = nil
@@ -155,6 +144,16 @@ struct RemoteThumbnail: View {
155144
}
156145
}
157146

147+
private func loadThumbnailsOnAppear() {
148+
if !loadAttempted {
149+
loadAttempted = true
150+
// Show spinner immediately for first-frame visibility
151+
isLoading = true
152+
loadingFiles[file.path] = true
153+
loadThumbnail()
154+
}
155+
}
156+
158157
func overlayPlayIcon(on image: UIImage) -> UIImage {
159158
let size = image.size
160159
let renderer = UIGraphicsImageRenderer(size: size)

0 commit comments

Comments
 (0)