File tree Expand file tree Collapse file tree
Neki-iOS/Features/Archive/Sources
Presentation/Sources/Feature Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -347,6 +347,27 @@ extension DefaultArchiveRepository {
347347 self . isFavoriteAlbumInfoDirty = true
348348 }
349349 }
350+
351+ func clearCache( ) async {
352+ // 캐시 데이터 초기화
353+ self . photoCache. removeAll ( )
354+ self . currentSortOrder. removeAll ( )
355+ self . albumCache. removeAll ( )
356+ self . favoritePhotoCache. removeAll ( )
357+ self . favoriteAlbumInfoCache = nil
358+
359+ // Dirty Flag 초기화
360+ self . isPhotoCacheDirty. removeAll ( )
361+ self . isAlbumCacheDirty = true
362+ self . isFavoriteCacheDirty = true
363+ self . isFavoriteAlbumInfoDirty = true
364+
365+ // 페이징 상태 초기화
366+ self . currentPhotoPage. removeAll ( )
367+ self . hasNextPhoto. removeAll ( )
368+ self . currentFavoritePage = 0
369+ self . hasNextFavorite = true
370+ }
350371}
351372
352373
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ struct ArchiveClient {
2323 public var excludePhotosInAlbum : ( _ albumID: Int , _ photoIDs: [ Int ] ) async throws -> Void
2424 public var editAlbumName : ( _ albumID: Int , _ name: String ) async throws -> Void
2525 public var updatePhotoMemo : ( _ photoID: Int , _ memo: String ) async throws -> Void
26+ public var clearCache : ( ) async -> Void
2627}
2728
2829extension ArchiveClient : DependencyKey {
@@ -65,6 +66,9 @@ extension ArchiveClient: DependencyKey {
6566 } ,
6667 updatePhotoMemo: { photoID, memo in
6768 try await archiveRepository. updatePhotoMemo ( photoID: photoID, memo: memo)
69+ } ,
70+ clearCache: {
71+ await archiveRepository. clearCache ( )
6872 }
6973 )
7074 }
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ protocol ArchiveRepository: Sendable {
2727 // Delete
2828 func deletePhotoList( photoIDs: [ Int ] ) async throws
2929 func deleteFolders( folderIDs: [ Int ] , deletePhotos: Bool ) async throws
30+ func clearCache( ) async
3031}
3132
3233public enum PhotoUploadMethod : String , Sendable {
Original file line number Diff line number Diff line change @@ -93,7 +93,9 @@ struct ArchiveFeature {
9393 case . clearData:
9494 state. photos. removeAll ( )
9595 state. albums. removeAll ( )
96- return . none
96+ return . run { _ in
97+ await archiveClient. clearCache ( )
98+ }
9799
98100 case . onAppear:
99101 return . merge( . send( . fetchAlbums) , . send( . fetchPhotos) )
You can’t perform that action at this time.
0 commit comments