@@ -21,7 +21,8 @@ public struct RemindFeature {
2121 private var remindClient
2222 @Dependency ( ContentClient . self)
2323 private var contentClient
24-
24+ @Dependency ( SwiftSoupClient . self)
25+ private var swiftSoupClient
2526 /// - State
2627 @ObservableState
2728 public struct State : Equatable {
@@ -84,19 +85,29 @@ public struct RemindFeature {
8485 case 링크_공유_완료
8586
8687 case 뷰가_나타났을때
88+ case 즐겨찾기_항목_이미지_조회( contentId: Int )
89+ case 읽지않음_항목_이미지_조회( contentId: Int )
90+ case 리마인드_항목_이미지오류_나타났을때( contentId: Int )
8791 }
8892 public enum InnerAction : Equatable {
8993 case 바텀시트_해제
9094 case 오늘의_리마인드_조회_API_반영( contents: [ BaseContentItem ] )
9195 case 읽지않음_컨텐츠_조회_API_반영( contentList: BaseContentListInquiry )
9296 case 즐겨찾기_링크모음_조회_API_반영( contentList: BaseContentListInquiry )
97+ case 즐겨찾기_이미지_조회_수행_반영( imageURL: String , index: Int )
98+ case 읽지않음_이미지_조회_수행_반영( imageURL: String , index: Int )
99+ case 리마인드_이미지_조회_수행_반영( imageURL: String , index: Int )
93100 case 컨텐츠_삭제_API_반영( id: Int )
101+
94102 }
95103 public enum AsyncAction : Equatable {
96104 case 오늘의_리마인드_조회_API
97105 case 읽지않음_컨텐츠_조회_API
98106 case 즐겨찾기_링크모음_조회_API
99107 case 컨텐츠_삭제_API( id: Int )
108+ case 즐겨찾기_이미지_조회_수행( contentId: Int )
109+ case 읽지않음_이미지_조회_수행( contentId: Int )
110+ case 리마인드_이미지_조회_수행( contentId: Int )
100111 }
101112 public enum ScopeAction : Equatable {
102113 case bottomSheet(
@@ -175,6 +186,12 @@ private extension RemindFeature {
175186 case . 링크_공유_완료:
176187 state. shareSheetItem = nil
177188 return . none
189+ case let . 즐겨찾기_항목_이미지_조회( contentId) :
190+ return . send( . async( . 즐겨찾기_이미지_조회_수행( contentId: contentId) ) )
191+ case let . 읽지않음_항목_이미지_조회( contentId) :
192+ return . send( . async( . 읽지않음_이미지_조회_수행( contentId: contentId) ) )
193+ case let . 리마인드_항목_이미지오류_나타났을때( contentId) :
194+ return . send( . async( . 리마인드_이미지_조회_수행( contentId: contentId) ) )
178195 }
179196 }
180197 /// - Inner Effect
@@ -198,6 +215,24 @@ private extension RemindFeature {
198215 state. domain. unreadList. data? . removeAll { $0. id == contentId }
199216 state. domain. favoriteList. data? . removeAll { $0. id == contentId }
200217 return . none
218+ case let . 즐겨찾기_이미지_조회_수행_반영( imageURL, index) :
219+ var content = state. domain. favoriteList. data? . remove ( at: index)
220+ content? . thumbNail = imageURL
221+ guard let content else { return . none }
222+ state. domain. favoriteList. data? . insert ( content, at: index)
223+ return . none
224+ case let . 읽지않음_이미지_조회_수행_반영( imageURL, index) :
225+ var content = state. domain. unreadList. data? . remove ( at: index)
226+ content? . thumbNail = imageURL
227+ guard let content else { return . none }
228+ state. domain. unreadList. data? . insert ( content, at: index)
229+ return . none
230+ case let . 리마인드_이미지_조회_수행_반영( imageURL, index) :
231+ var content = state. domain. recommendedList? . remove ( at: index)
232+ content? . thumbNail = imageURL
233+ guard let content else { return . none }
234+ state. domain. recommendedList? . insert ( content, at: index)
235+ return . none
201236 }
202237 }
203238 /// - Async Effect
@@ -235,6 +270,52 @@ private extension RemindFeature {
235270 let _ = try await contentClient. 컨텐츠_삭제 ( " \( id) " )
236271 await send ( . inner( . 컨텐츠_삭제_API_반영( id: id) ) , animation: . pokitSpring)
237272 }
273+ case let . 즐겨찾기_이미지_조회_수행( contentId) :
274+ return . run { [ favoriteContents = state. favoriteContents] send in
275+ guard let index = favoriteContents? . index ( id: contentId) ,
276+ let content = favoriteContents ? [ index] ,
277+ let url = URL ( string: content. data) else {
278+ return
279+ }
280+
281+ let imageURL = try await swiftSoupClient. parseOGImageURL ( url)
282+ guard let imageURL else { return }
283+
284+ await send ( . inner( . 즐겨찾기_이미지_조회_수행_반영(
285+ imageURL: imageURL,
286+ index: index
287+ ) ) )
288+ }
289+ case let . 읽지않음_이미지_조회_수행( contentId) :
290+ return . run { [ unreadContents = state. unreadContents] send in
291+ guard let index = unreadContents? . index ( id: contentId) ,
292+ let content = unreadContents ? [ index] ,
293+ let url = URL ( string: content. data) else {
294+ return
295+ }
296+ let imageURL = try await swiftSoupClient. parseOGImageURL ( url)
297+ guard let imageURL else { return }
298+
299+ await send ( . inner( . 읽지않음_이미지_조회_수행_반영(
300+ imageURL: imageURL,
301+ index: index
302+ ) ) )
303+ }
304+ case let . 리마인드_이미지_조회_수행( contentId) :
305+ return . run { [ recommendedContents = state. recommendedContents] send in
306+ guard let index = recommendedContents? . index ( id: contentId) ,
307+ let content = recommendedContents ? [ index] ,
308+ let url = URL ( string: content. data) else {
309+ return
310+ }
311+ let imageURL = try await swiftSoupClient. parseOGImageURL ( url)
312+ guard let imageURL else { return }
313+
314+ await send ( . inner( . 리마인드_이미지_조회_수행_반영(
315+ imageURL: imageURL,
316+ index: index
317+ ) ) )
318+ }
238319 }
239320 }
240321 /// - Scope Effect
0 commit comments