From cfb15ba2bf6e707474cb07055e05d80d92515c78 Mon Sep 17 00:00:00 2001 From: "Maxim V. Potapov" Date: Sat, 1 Jul 2023 10:12:10 +0200 Subject: [PATCH] migrate to Swift 5.9 --- .swift-version | 2 +- iLepra/Extras/View+HTML.swift | 3 +-- iLepra/LepraContentView.swift | 8 +++---- .../LepraVotesDetailsViewModel.swift | 7 +++--- iLepra/Views/LepraTabView.swift | 24 +++++++++---------- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.swift-version b/.swift-version index 3659ea2..95ee81a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -5.8 +5.9 diff --git a/iLepra/Extras/View+HTML.swift b/iLepra/Extras/View+HTML.swift index 11a8e4a..d3f6714 100644 --- a/iLepra/Extras/View+HTML.swift +++ b/iLepra/Extras/View+HTML.swift @@ -101,8 +101,7 @@ extension Element { .toView() .eraseToAny() case "span": - let color: Color - switch try className() { + let color = switch try className() { case "moderator": color = .blue case "irony": diff --git a/iLepra/LepraContentView.swift b/iLepra/LepraContentView.swift index ea93774..ad149ef 100644 --- a/iLepra/LepraContentView.swift +++ b/iLepra/LepraContentView.swift @@ -49,23 +49,23 @@ struct LepraContentView: View { private func view(for tab: LepraTab) -> some View { switch tab { case .feed: - return LepraFeedView(navigationPath: $navigationPathFeed, shouldReload: $shouldReloadFeed) + LepraFeedView(navigationPath: $navigationPathFeed, shouldReload: $shouldReloadFeed) .environmentObject(feedViewModel) .navigationTitle(tab.title) .eraseToAny() case .moar: - return LepraMoarView(navigationPath: $navigationPathMoar, shouldReload: $shouldReloadMoar) + LepraMoarView(navigationPath: $navigationPathMoar, shouldReload: $shouldReloadMoar) .environmentObject(moarViewModel) .navigationTitle(tab.title) .badge(moarViewModel.unreadCount) .eraseToAny() case .domains: - return LepraDomainsView(navigationPath: $navigationPathDomains, shouldReload: $shouldReloadDomains) + LepraDomainsView(navigationPath: $navigationPathDomains, shouldReload: $shouldReloadDomains) .environmentObject(domainsViewModel) .navigationTitle(tab.title) .eraseToAny() case .profile: - return LepraProfileView(shouldReload: $shouldReloadProfile) + LepraProfileView(shouldReload: $shouldReloadProfile) .environmentObject(profileViewModel) .navigationTitle(tab.title) .eraseToAny() diff --git a/iLepra/Screens/VotesDetails/LepraVotesDetailsViewModel.swift b/iLepra/Screens/VotesDetails/LepraVotesDetailsViewModel.swift index 83f103f..0b31c5b 100644 --- a/iLepra/Screens/VotesDetails/LepraVotesDetailsViewModel.swift +++ b/iLepra/Screens/VotesDetails/LepraVotesDetailsViewModel.swift @@ -69,9 +69,8 @@ final class LepraVotesDetailsViewModel: ObservableObject { ] ) - let result: AjaxVotes - if let votes { - result = .init( + let result: AjaxVotes = if let votes { + .init( cons: .init((votes.cons + response.cons).uniqued()), consCount: response.consCount, karma: response.karma, @@ -83,7 +82,7 @@ final class LepraVotesDetailsViewModel: ObservableObject { totalCount: response.totalCount ) } else { - result = response + response } await MainActor.run { votes = result diff --git a/iLepra/Views/LepraTabView.swift b/iLepra/Views/LepraTabView.swift index 79883c8..1c1e897 100644 --- a/iLepra/Views/LepraTabView.swift +++ b/iLepra/Views/LepraTabView.swift @@ -18,26 +18,26 @@ enum LepraTab: Hashable, CaseIterable { var title: String { switch self { case .feed: - return "Главная" + "Главная" case .moar: - return "Мои вещи" + "Мои вещи" case .domains: - return "Подлепры" + "Подлепры" case .profile: - return "Профиль" + "Профиль" } } var imageName: String { switch self { case .feed: - return "house" + "house" case .moar: - return "bookmark" + "bookmark" case .domains: - return "list.dash" + "list.dash" case .profile: - return "brain.head.profile" + "brain.head.profile" } } } @@ -107,13 +107,13 @@ struct LepraTabView: View { private func view(for tab: LepraTab) -> some View { switch tab { case .feed: - return feedView + feedView case .moar: - return moarView + moarView case .domains: - return domainsView + domainsView case .profile: - return profileView + profileView } } }