diff --git a/PLAT/PLAT/Domain/UseCase/TrackUseCase.swift b/PLAT/PLAT/Domain/UseCase/TrackUseCase.swift index 396734e2..884be2d0 100644 --- a/PLAT/PLAT/Domain/UseCase/TrackUseCase.swift +++ b/PLAT/PLAT/Domain/UseCase/TrackUseCase.swift @@ -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: 에러 처리 } } diff --git a/PLAT/PLAT/Presentaion/TrackFeed/TrackFeedView.swift b/PLAT/PLAT/Presentaion/TrackFeed/TrackFeedView.swift index 08f94426..33acdd87 100644 --- a/PLAT/PLAT/Presentaion/TrackFeed/TrackFeedView.swift +++ b/PLAT/PLAT/Presentaion/TrackFeed/TrackFeedView.swift @@ -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 { @@ -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() } } } @@ -165,7 +168,6 @@ private struct FeedRowView: View { @Environment(PathModel.self) private var pathModel @State private var isPaused = true - @State private var fetchMusicTask: Task? @Binding private(set) var currentTrack: Track? @Binding private(set) var isLoading: Bool @@ -247,10 +249,6 @@ private struct FeedRowView: View { .onAppear { authUseCase.effect(.fetchProfile) } - .onDisappear { - fetchMusicTask?.cancel() - fetchMusicTask = nil - } } }