Skip to content

Commit d8e2c1b

Browse files
authored
Merge pull request #28 from engingulek/develop
Develop
2 parents 7d0dd4c + 9d1153d commit d8e2c1b

2 files changed

Lines changed: 25 additions & 21 deletions

File tree

ICTMDBHomeModule/HomeInteractor.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ final class HomeInteractor: PresenterToInteractorHomeProtocol,@unchecked Sendabl
3636
do {
3737
let (popularResult, airingResult) = try await (popularMovies, airingMovies)
3838

39-
await presenter?.sendPopularTvShows(popularResult.results)
40-
await presenter?.sendAiringTvShows(airingResult.results)
39+
await MainActor.run {
40+
presenter?.sendPopularTvShows(popularResult.results)
41+
presenter?.sendAiringTvShows(airingResult.results)
42+
}
4143
} catch {
42-
await presenter?.sendError()
44+
await MainActor.run {
45+
presenter?.sendError()
46+
}
4347
}
4448
}
4549
}

ICTMDBHomeModule/HomePresenter.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,28 @@ final class HomePresenter {
5151

5252
// MARK: - ViewToPresenterHomeProtocol
5353
/// Handles actions triggered by the View layer.
54-
54+
@MainActor
5555
extension HomePresenter: ViewToPresenterHomeProtocol {
56-
5756

58-
57+
58+
5959
func viewDidLoad() {
6060
view?.setBackColorAble(color: "backColor")
6161
view?.setNavigationTitle(title: LocalizableUI.homePageNavTitle.localized)
6262

63-
Task {@MainActor in
64-
await loadData()
63+
Task {
64+
await loadData()
6565
}
6666
}
6767

68-
69-
@MainActor
68+
69+
7070
func loadData() async {
7171
view?.startLoading()
7272
await interactor.loadData()
7373
view?.finishLoading()
7474
}
75-
75+
7676
}
7777

7878

@@ -100,11 +100,11 @@ extension HomePresenter {
100100
}
101101
}
102102

103-
103+
104104
func numberOfSections() -> Int {
105105
SectionType.allCases.count
106106
}
107-
107+
108108
func cellForItem(section: Int, item: Int) -> CellItemType {
109109
guard let sectionType = SectionType(rawValue: section) else { return .none }
110110
switch sectionType {
@@ -117,7 +117,7 @@ extension HomePresenter {
117117
}
118118
}
119119

120-
120+
121121
func didSelectItem(section: Int, item: Int) {
122122
guard let sectionType = SectionType(rawValue: section) else { return }
123123
switch sectionType {
@@ -154,7 +154,7 @@ extension HomePresenter {
154154
return headerViewItem
155155
}
156156

157-
157+
158158
func onTappedTitleButton(buttonType: TitleForSectionButtonType, section: Int) {
159159
guard let sectionType = SectionType(rawValue: section) else { return }
160160

@@ -195,30 +195,30 @@ extension HomePresenter {
195195
/// Receives data from the Interactor and updates the view.
196196
extension HomePresenter: InteractorToPresenterHomeProtocol {
197197
func sendError() {
198-
198+
199199
view?.sendError(errorState: (isHidden: true,
200200
message: LocalizableUI.somethingWentWrong.localized))
201201
view?.relaodCollectionView()
202-
202+
203203
}
204204

205205

206206
func sendAiringTvShows(_ data: [AiringToday]) {
207-
207+
208208
airingTodayShows = data.map { AiringTodayPresentation(tvShow: $0) }
209209
view?.sendError(errorState: (isHidden: false, message: ""))
210210
view?.relaodCollectionView()
211-
211+
212212
}
213213

214214
func sendPopularTvShows(_ data: [PopularTvShows]) {
215-
215+
216216
popularTvShows = data
217217
.map { PopularTVShowPresentation(tvShow: $0) }
218218
.sorted { $0.rating > $1.rating }
219219
view?.sendError(errorState: (isHidden: false, message: ""))
220220
view?.relaodCollectionView()
221-
221+
222222
}
223223
}
224224

0 commit comments

Comments
 (0)