Skip to content

Commit

Permalink
[FIX/#177] FeedView 삭제 후 View 리프레쉬 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkySide committed Nov 3, 2024
1 parent 3b90a7d commit 23010fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion PLAT/PLAT/Domain/UseCase/TrackUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ extension TrackUseCase {
Task {
let result = await trackService.delete(trackId: trackId)
switch result {
case .success: break
case .success: feedTrackList.removeAll { $0.id == trackId }
case .failure(let error): print(error) // TODO: 에러 처리
}
}
Expand Down
20 changes: 9 additions & 11 deletions PLAT/PLAT/Presentaion/TrackFeed/TrackFeedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ struct TrackFeedView: View {
}
}

/// 다음 페이지를 Fetch합니다.
private func fetchNextPage() {
Task {
let trackList = await trackUseCase.paginationFeedTrackList()
try await updateFeed(from: trackList)
}
}

var body: some View {
@Bindable var musicControlUseCase = musicControlUseCase
ZStack {
Expand All @@ -91,14 +99,9 @@ struct TrackFeedView: View {
address: track.location.place?.address ?? ""
)
.onAppear {
print("현재 피드 ID: \(track.id)")
if index == trackList.count - 1
&& trackUseCase.feedListHasNext {
print("답변 페이지네이션!")
Task {
let trackList = await trackUseCase.paginationFeedTrackList()
try await updateFeed(from: trackList)
}
fetchNextPage()
}
}
}
Expand Down Expand Up @@ -165,7 +168,6 @@ private struct FeedRowView: View {
@Environment(PathModel.self) private var pathModel

@State private var isPaused = true
@State private var fetchMusicTask: Task<Void, Never>?

@Binding private(set) var currentTrack: Track?
@Binding private(set) var isLoading: Bool
Expand Down Expand Up @@ -247,10 +249,6 @@ private struct FeedRowView: View {
.onAppear {
authUseCase.effect(.fetchProfile)
}
.onDisappear {
fetchMusicTask?.cancel()
fetchMusicTask = nil
}
}
}

Expand Down

0 comments on commit 23010fe

Please sign in to comment.