Skip to content

Commit c75540f

Browse files
committed
[Feat] #192 - 로그아웃, 탈퇴 시 인메모리 캐싱된 데이터 상태 초기화
1 parent 21b5422 commit c75540f

4 files changed

Lines changed: 29 additions & 1 deletion

File tree

Neki-iOS/Features/Archive/Sources/Data/Sources/DefaultArchiveRepository.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff 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

Neki-iOS/Features/Archive/Sources/Domain/Sources/Client/ArchiveClient.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

2829
extension 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
}

Neki-iOS/Features/Archive/Sources/Domain/Sources/Interfaces/Repositories/ArchiveRepository.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

3233
public enum PhotoUploadMethod: String, Sendable {

Neki-iOS/Features/Archive/Sources/Presentation/Sources/Feature/ArchiveFeature.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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))

0 commit comments

Comments
 (0)