diff --git a/IceCubesApp/App/AppRouter.swift b/IceCubesApp/App/AppRouter.swift index 960e9c15..b96506c0 100644 --- a/IceCubesApp/App/AppRouter.swift +++ b/IceCubesApp/App/AppRouter.swift @@ -155,8 +155,8 @@ struct ActivityView: UIViewControllerRepresentable { } func makeUIViewController(context _: UIViewControllerRepresentableContext) -> UIActivityViewController { - return UIActivityViewController(activityItems: [image, LinkDelegate(image: image, status: status)], - applicationActivities: nil) + UIActivityViewController(activityItems: [image, LinkDelegate(image: image, status: status)], + applicationActivities: nil) } func updateUIViewController(_: UIActivityViewController, context _: UIViewControllerRepresentableContext) {} diff --git a/IceCubesApp/App/IceCubesApp.swift b/IceCubesApp/App/IceCubesApp.swift index 56a54d61..d18a7e4d 100644 --- a/IceCubesApp/App/IceCubesApp.swift +++ b/IceCubesApp/App/IceCubesApp.swift @@ -100,7 +100,7 @@ struct IceCubesApp: App { } private func badgeFor(tab: Tab) -> Int { - if tab == .notifications && selectedTab != tab, + if tab == .notifications, selectedTab != tab, let token = appAccountsManager.currentAccount.oauthToken { return watcher.unreadNotificationsCount + userPreferences.getNotificationsCount(for: token) diff --git a/IceCubesApp/App/QuickLookRepresentable.swift b/IceCubesApp/App/QuickLookRepresentable.swift index ee568cfc..c647c00b 100644 --- a/IceCubesApp/App/QuickLookRepresentable.swift +++ b/IceCubesApp/App/QuickLookRepresentable.swift @@ -13,7 +13,7 @@ struct QuickLookPreview: UIViewControllerRepresentable { let urls: [URL] func makeUIViewController(context _: Context) -> UIViewController { - return AppQLPreviewController(selectedURL: selectedURL, urls: urls) + AppQLPreviewController(selectedURL: selectedURL, urls: urls) } func updateUIViewController( @@ -53,11 +53,11 @@ class AppQLPreviewController: UIViewController { extension AppQLPreviewController: QLPreviewControllerDataSource { nonisolated func numberOfPreviewItems(in _: QLPreviewController) -> Int { - return urls.count + urls.count } nonisolated func previewController(_: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem { - return urls[index] as QLPreviewItem + urls[index] as QLPreviewItem } } @@ -81,7 +81,7 @@ extension AppQLPreviewController: QLPreviewControllerDelegate { struct TransparentBackground: UIViewControllerRepresentable { public func makeUIViewController(context _: Context) -> UIViewController { - return TransparentController() + TransparentController() } public func updateUIViewController(_: UIViewController, context _: Context) {} diff --git a/IceCubesApp/App/SafariRouter.swift b/IceCubesApp/App/SafariRouter.swift index bd5088a0..c3d40784 100644 --- a/IceCubesApp/App/SafariRouter.swift +++ b/IceCubesApp/App/SafariRouter.swift @@ -51,7 +51,7 @@ private struct SafariRouter: ViewModifier { } .background { WindowReader { window in - self.safariManager.windowScene = window.windowScene + safariManager.windowScene = window.windowScene } } } @@ -65,7 +65,7 @@ private class InAppSafariManager: NSObject, ObservableObject, SFSafariViewContro @MainActor func open(_ url: URL) -> OpenURLAction.Result { - guard let windowScene = windowScene else { return .systemAction } + guard let windowScene else { return .systemAction } window = setupWindow(windowScene: windowScene) @@ -85,7 +85,7 @@ private class InAppSafariManager: NSObject, ObservableObject, SFSafariViewContro } func setupWindow(windowScene: UIWindowScene) -> UIWindow { - let window = self.window ?? UIWindow(windowScene: windowScene) + let window = window ?? UIWindow(windowScene: windowScene) window.rootViewController = viewController window.makeKeyAndVisible() diff --git a/IceCubesApp/App/SideBarView.swift b/IceCubesApp/App/SideBarView.swift index 1e6ee060..6bbf7e71 100644 --- a/IceCubesApp/App/SideBarView.swift +++ b/IceCubesApp/App/SideBarView.swift @@ -19,7 +19,7 @@ struct SideBarView: View { @ViewBuilder var content: () -> Content private func badgeFor(tab: Tab) -> Int { - if tab == .notifications && selectedTab != tab, + if tab == .notifications, selectedTab != tab, let token = appAccounts.currentAccount.oauthToken { return watcher.unreadNotificationsCount + userPreferences.getNotificationsCount(for: token) diff --git a/IceCubesApp/App/Tabs/ExploreTab.swift b/IceCubesApp/App/Tabs/ExploreTab.swift index ea0efa45..4459c35c 100644 --- a/IceCubesApp/App/Tabs/ExploreTab.swift +++ b/IceCubesApp/App/Tabs/ExploreTab.swift @@ -29,7 +29,7 @@ struct ExploreTab: View { AppAccountsSelectorView(routerPath: routerPath) } } - if UIDevice.current.userInterfaceIdiom == .pad && !preferences.showiPadSecondaryColumn { + if UIDevice.current.userInterfaceIdiom == .pad, !preferences.showiPadSecondaryColumn { SecondaryColumnToolbarItem() } } diff --git a/IceCubesApp/App/Tabs/Settings/AboutView.swift b/IceCubesApp/App/Tabs/Settings/AboutView.swift index 40203c72..2daa1da5 100644 --- a/IceCubesApp/App/Tabs/Settings/AboutView.swift +++ b/IceCubesApp/App/Tabs/Settings/AboutView.swift @@ -75,7 +75,7 @@ struct AboutView: View { • [SwiftUI-Introspect](https://github.com/siteline/SwiftUI-Introspect) • [RevenueCat](https://github.com/RevenueCat/purchases-ios) - + • [SFSafeSymbols](https://github.com/SFSafeSymbols/SFSafeSymbols) """) .multilineTextAlignment(.leading) diff --git a/IceCubesApp/App/Tabs/Settings/AddAccountsView.swift b/IceCubesApp/App/Tabs/Settings/AddAccountsView.swift index dace26a1..722a752d 100644 --- a/IceCubesApp/App/Tabs/Settings/AddAccountsView.swift +++ b/IceCubesApp/App/Tabs/Settings/AddAccountsView.swift @@ -100,11 +100,11 @@ struct AddAccountView: View { Task { do { // bare bones preflight for domain validity - if client.server.contains(".") && client.server.last != "." { + if client.server.contains("."), client.server.last != "." { let instance: Instance = try await client.get(endpoint: Instances.instance) withAnimation { self.instance = instance - self.instanceName = sanitizedName // clean up the text box, principally to chop off the username if present so it's clear that you might not wind up siging in as the thing in the box + instanceName = sanitizedName // clean up the text box, principally to chop off the username if present so it's clear that you might not wind up siging in as the thing in the box } instanceFetchError = nil } else { @@ -178,7 +178,7 @@ struct AddAccountView: View { } else { ForEach(sanitizedName.isEmpty ? instances : instances.filter { $0.name.contains(sanitizedName.lowercased()) }) { instance in Button { - self.instanceName = instance.name + instanceName = instance.name } label: { VStack(alignment: .leading, spacing: 4) { Text(instance.name) diff --git a/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift b/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift index c99e0e1f..32d1620b 100644 --- a/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift @@ -83,19 +83,20 @@ struct ContentSettingsView: View { } } .disabled(userPreferences.useInstanceContentSettings) - + Picker("settings.content.default-reply-visibility", selection: $userPreferences.appDefaultReplyVisibility) { ForEach(Visibility.allCases, id: \.rawValue) { vis in if UserPreferences.getIntOfVisibility(vis) <= - UserPreferences.getIntOfVisibility(userPreferences.postVisibility) { + UserPreferences.getIntOfVisibility(userPreferences.postVisibility) + { Text(vis.title).tag(vis) } } } - .onChange(of: userPreferences.postVisibility) { newValue in + .onChange(of: userPreferences.postVisibility) { _ in userPreferences.conformReplyVisibilityConstraints() } - + Toggle(isOn: $userPreferences.appDefaultPostsSensitive) { Text("settings.content.default-sensitive") } diff --git a/IceCubesApp/App/Tabs/Settings/IconSelectorView.swift b/IceCubesApp/App/Tabs/Settings/IconSelectorView.swift index dbb65c41..76e0d01b 100644 --- a/IceCubesApp/App/Tabs/Settings/IconSelectorView.swift +++ b/IceCubesApp/App/Tabs/Settings/IconSelectorView.swift @@ -32,9 +32,9 @@ struct IconSelectorView: View { var appIconName: String { switch self { case .primary: - return "AppIcon" + "AppIcon" default: - return "AppIconAlternate\(rawValue)" + "AppIconAlternate\(rawValue)" } } @@ -120,6 +120,6 @@ struct IconSelectorView: View { extension String { var localized: String { - return NSLocalizedString(self, comment: "") + NSLocalizedString(self, comment: "") } } diff --git a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift index ebb3dedf..9be59060 100644 --- a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift +++ b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift @@ -51,7 +51,7 @@ struct SettingsTabs: View { } } } - if UIDevice.current.userInterfaceIdiom == .pad && !preferences.showiPadSecondaryColumn { + if UIDevice.current.userInterfaceIdiom == .pad, !preferences.showiPadSecondaryColumn { SecondaryColumnToolbarItem() } } @@ -326,7 +326,6 @@ struct SettingsTabs: View { } } - private func moveTimelineItems(from source: IndexSet, to destination: Int) { preferences.remoteLocalTimelines.move(fromOffsets: source, toOffset: destination) } diff --git a/IceCubesApp/App/Tabs/Settings/SupportAppView.swift b/IceCubesApp/App/Tabs/Settings/SupportAppView.swift index c5b133b3..5410a851 100644 --- a/IceCubesApp/App/Tabs/Settings/SupportAppView.swift +++ b/IceCubesApp/App/Tabs/Settings/SupportAppView.swift @@ -19,30 +19,30 @@ struct SupportAppView: View { var title: LocalizedStringKey { switch self { case .one: - return "settings.support.one.title" + "settings.support.one.title" case .two: - return "settings.support.two.title" + "settings.support.two.title" case .three: - return "settings.support.three.title" + "settings.support.three.title" case .four: - return "settings.support.four.title" + "settings.support.four.title" case .supporter: - return "settings.support.supporter.title" + "settings.support.supporter.title" } } var subtitle: LocalizedStringKey { switch self { case .one: - return "settings.support.one.subtitle" + "settings.support.one.subtitle" case .two: - return "settings.support.two.subtitle" + "settings.support.two.subtitle" case .three: - return "settings.support.three.subtitle" + "settings.support.three.subtitle" case .four: - return "settings.support.four.subtitle" + "settings.support.four.subtitle" case .supporter: - return "settings.support.supporter.subtitle" + "settings.support.supporter.subtitle" } } } @@ -103,8 +103,8 @@ struct SupportAppView: View { } private func fetchStoreProducts() { - Purchases.shared.getProducts(Tip.allCases.map { $0.productId }) { products in - self.subscription = products.first(where: { $0.productIdentifier == Tip.supporter.productId }) + Purchases.shared.getProducts(Tip.allCases.map(\.productId)) { products in + subscription = products.first(where: { $0.productIdentifier == Tip.supporter.productId }) self.products = products.filter { $0.productIdentifier != Tip.supporter.productId }.sorted(by: { $0.price < $1.price }) withAnimation { loadingProducts = false @@ -114,7 +114,7 @@ struct SupportAppView: View { private func refreshUserInfo() { Purchases.shared.getCustomerInfo { info, _ in - self.customerInfo = info + customerInfo = info } } @@ -221,7 +221,7 @@ struct SupportAppView: View { Spacer() Button { Purchases.shared.restorePurchases { info, _ in - self.customerInfo = info + customerInfo = info } } label: { Text("settings.support.restore-purchase.button") diff --git a/IceCubesApp/App/Tabs/Settings/SwipeActionsSettingsView.swift b/IceCubesApp/App/Tabs/Settings/SwipeActionsSettingsView.swift index 88bbd14c..9e23eeb9 100644 --- a/IceCubesApp/App/Tabs/Settings/SwipeActionsSettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/SwipeActionsSettingsView.swift @@ -68,7 +68,7 @@ struct SwipeActionsSettingsView: View { } private func createStatusActionPicker(selection: Binding, label: LocalizedStringKey) -> some View { - return Picker(selection: selection, label: Text(label)) { + Picker(selection: selection, label: Text(label)) { Section { Text(StatusAction.none.displayName()).tag(StatusAction.none) } diff --git a/IceCubesApp/App/Tabs/Tabs.swift b/IceCubesApp/App/Tabs/Tabs.swift index 289600bf..38c265bc 100644 --- a/IceCubesApp/App/Tabs/Tabs.swift +++ b/IceCubesApp/App/Tabs/Tabs.swift @@ -86,27 +86,27 @@ enum Tab: Int, Identifiable, Hashable { var iconName: String { switch self { case .timeline: - return "rectangle.stack" + "rectangle.stack" case .trending: - return "chart.line.uptrend.xyaxis" + "chart.line.uptrend.xyaxis" case .local: - return "person.2" + "person.2" case .federated: - return "globe.americas" + "globe.americas" case .notifications: - return "bell" + "bell" case .mentions: - return "at" + "at" case .explore: - return "magnifyingglass" + "magnifyingglass" case .messages: - return "tray" + "tray" case .settings: - return "gear" + "gear" case .profile: - return "person.crop.circle" + "person.crop.circle" case .other: - return "" + "" } } } diff --git a/IceCubesApp/App/Tabs/Timeline/AddRemoteTimelineView.swift b/IceCubesApp/App/Tabs/Timeline/AddRemoteTimelineView.swift index 54014dfb..bba68ad4 100644 --- a/IceCubesApp/App/Tabs/Timeline/AddRemoteTimelineView.swift +++ b/IceCubesApp/App/Tabs/Timeline/AddRemoteTimelineView.swift @@ -71,7 +71,7 @@ struct AddRemoteTimelineView: View { isInstanceURLFieldFocused = true let client = InstanceSocialClient() Task { - self.instances = await client.fetchInstances() + instances = await client.fetchInstances() } } } @@ -85,7 +85,7 @@ struct AddRemoteTimelineView: View { } else { ForEach(instanceName.isEmpty ? instances : instances.filter { $0.name.contains(instanceName.lowercased()) }) { instance in Button { - self.instanceName = instance.name + instanceName = instance.name } label: { VStack(alignment: .leading, spacing: 4) { Text(instance.name) diff --git a/IceCubesApp/App/Tabs/Timeline/EditTagGroupView.swift b/IceCubesApp/App/Tabs/Timeline/EditTagGroupView.swift index 4fb6e217..91626021 100644 --- a/IceCubesApp/App/Tabs/Timeline/EditTagGroupView.swift +++ b/IceCubesApp/App/Tabs/Timeline/EditTagGroupView.swift @@ -35,7 +35,7 @@ struct EditTagGroupView: View { case symbol case new } - + init(editingTagGroup: TagGroup? = nil, onSaved: ((TagGroup) -> Void)? = nil) { self.editingTagGroup = editingTagGroup self.onSaved = onSaved @@ -163,7 +163,7 @@ struct EditTagGroupView: View { private func save() { var toSave = tags let main = toSave.removeFirst() - + let tagGroup: TagGroup = .init( title: title.trimmingCharacters(in: .whitespaces), sfSymbolName: sfSymbolName, @@ -171,7 +171,8 @@ struct EditTagGroupView: View { additional: toSave ) if let editingTagGroup, - let index = preferences.tagGroups.firstIndex(of: editingTagGroup) { + let index = preferences.tagGroups.firstIndex(of: editingTagGroup) + { preferences.tagGroups[index] = tagGroup } else { preferences.tagGroups.append(tagGroup) @@ -183,7 +184,7 @@ struct EditTagGroupView: View { @ViewBuilder private var symbolsSuggestionView: some View { - if focusedField == .symbol && !sfSymbolName.isEmpty { + if focusedField == .symbol, !sfSymbolName.isEmpty { let filteredMatches = allSymbols .filter { $0.contains(sfSymbolName) } if !filteredMatches.isEmpty { diff --git a/IceCubesApp/App/Tabs/Timeline/Symbols.swift b/IceCubesApp/App/Tabs/Timeline/Symbols.swift index 07ad59ff..08b7469e 100644 --- a/IceCubesApp/App/Tabs/Timeline/Symbols.swift +++ b/IceCubesApp/App/Tabs/Timeline/Symbols.swift @@ -9,5 +9,5 @@ import Foundation import SFSafeSymbols let allSymbols: [String] = SFSymbol.allSymbols.map { symbol in - symbol.rawValue + symbol.rawValue } diff --git a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift index 43733899..7e44753c 100644 --- a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift +++ b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift @@ -43,7 +43,7 @@ struct TimelineTab: View { } .onAppear { routerPath.client = client - if !didAppear && canFilterTimeline { + if !didAppear, canFilterTimeline { didAppear = true if client.isAuth { timeline = lastTimelineFilter @@ -97,7 +97,7 @@ struct TimelineTab: View { private var timelineFilterButton: some View { if timeline.supportNewestPagination { Button { - self.timeline = .latest + timeline = .latest } label: { Label(TimelineFilter.latest.localizedTitle(), systemImage: TimelineFilter.latest.iconName() ?? "") } @@ -197,7 +197,7 @@ struct TimelineTab: View { } statusEditorToolbarItem(routerPath: routerPath, visibility: preferences.postVisibility) - if UIDevice.current.userInterfaceIdiom == .pad && !preferences.showiPadSecondaryColumn { + if UIDevice.current.userInterfaceIdiom == .pad, !preferences.showiPadSecondaryColumn { SecondaryColumnToolbarItem() } } else { diff --git a/IceCubesNotifications/NotificationService.swift b/IceCubesNotifications/NotificationService.swift index f26d9a0d..bd2c149a 100644 --- a/IceCubesNotifications/NotificationService.swift +++ b/IceCubesNotifications/NotificationService.swift @@ -70,7 +70,7 @@ class NotificationService: UNNotificationServiceExtension { preferences.setNotification(count: currentCount, token: token) } - let tokens = AppAccountsManager.shared.pushAccounts.map { $0.token } + let tokens = AppAccountsManager.shared.pushAccounts.map(\.token) bestAttemptContent.badge = .init(integerLiteral: preferences.getNotificationsTotalCount(for: tokens)) if let urlString = notification.icon, diff --git a/Packages/Account/Package.swift b/Packages/Account/Package.swift index 96828ae2..64e50a98 100644 --- a/Packages/Account/Package.swift +++ b/Packages/Account/Package.swift @@ -29,7 +29,7 @@ let package = Package( .product(name: "Status", package: "Status"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), .testTarget( diff --git a/Packages/Account/Sources/Account/AccountDetailView.swift b/Packages/Account/Sources/Account/AccountDetailView.swift index 5827a8e3..0e094e68 100644 --- a/Packages/Account/Sources/Account/AccountDetailView.swift +++ b/Packages/Account/Sources/Account/AccountDetailView.swift @@ -89,7 +89,7 @@ public struct AccountDetailView: View { viewModel.client = client // Avoid capturing non-Sendable `self` just to access the view model. - let viewModel = self.viewModel + let viewModel = viewModel Task { await withTaskGroup(of: Void.self) { group in group.addTask { await viewModel.fetchAccount() } @@ -334,7 +334,7 @@ public struct AccountDetailView: View { } label: { Label("account.action.edit-info", systemImage: "pencil") } - + Button { if let url = URL(string: "https://\(client.server)/settings/privacy") { openURL(url) diff --git a/Packages/Account/Sources/Account/AccountDetailViewModel.swift b/Packages/Account/Sources/Account/AccountDetailViewModel.swift index 8832cceb..23ba94ab 100644 --- a/Packages/Account/Sources/Account/AccountDetailViewModel.swift +++ b/Packages/Account/Sources/Account/AccountDetailViewModel.swift @@ -27,25 +27,25 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher { var iconName: String { switch self { - case .statuses: return "bubble.right" - case .favorites: return "star" - case .bookmarks: return "bookmark" - case .followedTags: return "tag" - case .postsAndReplies: return "bubble.left.and.bubble.right" - case .media: return "photo.on.rectangle.angled" - case .lists: return "list.bullet" + case .statuses: "bubble.right" + case .favorites: "star" + case .bookmarks: "bookmark" + case .followedTags: "tag" + case .postsAndReplies: "bubble.left.and.bubble.right" + case .media: "photo.on.rectangle.angled" + case .lists: "list.bullet" } } var accessibilityLabel: LocalizedStringKey { switch self { - case .statuses: return "accessibility.tabs.profile.picker.statuses" - case .favorites: return "accessibility.tabs.profile.picker.favorites" - case .bookmarks: return "accessibility.tabs.profile.picker.bookmarks" - case .followedTags: return "accessibility.tabs.profile.picker.followed-tags" - case .postsAndReplies: return "accessibility.tabs.profile.picker.posts-and-replies" - case .media: return "accessibility.tabs.profile.picker.media" - case .lists: return "accessibility.tabs.profile.picker.lists" + case .statuses: "accessibility.tabs.profile.picker.statuses" + case .favorites: "accessibility.tabs.profile.picker.favorites" + case .bookmarks: "accessibility.tabs.profile.picker.bookmarks" + case .followedTags: "accessibility.tabs.profile.picker.followed-tags" + case .postsAndReplies: "accessibility.tabs.profile.picker.posts-and-replies" + case .media: "accessibility.tabs.profile.picker.media" + case .lists: "accessibility.tabs.profile.picker.lists" } } } @@ -145,7 +145,7 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher { private func fetchAccountData(accountId: String, client: Client) async throws -> AccountData { async let account: Account = client.get(endpoint: Accounts.accounts(id: accountId)) async let featuredTags: [FeaturedTag] = client.get(endpoint: Accounts.featuredTags(id: accountId)) - if client.isAuth && !isCurrentUser { + if client.isAuth, !isCurrentUser { async let relationships: [Relationship] = client.get(endpoint: Accounts.relationships(ids: [accountId])) do { return try await .init(account: account, diff --git a/Packages/Account/Sources/Account/AccountsList/AccountsListViewModel.swift b/Packages/Account/Sources/Account/AccountsList/AccountsListViewModel.swift index ce38ef59..31a163f2 100644 --- a/Packages/Account/Sources/Account/AccountsList/AccountsListViewModel.swift +++ b/Packages/Account/Sources/Account/AccountsList/AccountsListViewModel.swift @@ -10,15 +10,15 @@ public enum AccountsListMode { var title: LocalizedStringKey { switch self { case .following: - return "account.following" + "account.following" case .followers: - return "account.followers" + "account.followers" case .favoritedBy: - return "account.favorited-by" + "account.favorited-by" case .rebloggedBy: - return "account.boosted-by" + "account.boosted-by" case .accountsList: - return "" + "" } } } @@ -76,7 +76,7 @@ class AccountsListViewModel: ObservableObject { } nextPageId = link?.maxId relationships = try await client.get(endpoint: - Accounts.relationships(ids: accounts.map { $0.id })) + Accounts.relationships(ids: accounts.map(\.id))) state = .display(accounts: accounts, relationships: relationships, nextPageState: link?.maxId != nil ? .hasNextPage : .none) @@ -108,7 +108,7 @@ class AccountsListViewModel: ObservableObject { } accounts.append(contentsOf: newAccounts) let newRelationships: [Relationship] = - try await client.get(endpoint: Accounts.relationships(ids: newAccounts.map { $0.id })) + try await client.get(endpoint: Accounts.relationships(ids: newAccounts.map(\.id))) relationships.append(contentsOf: newRelationships) self.nextPageId = link?.maxId diff --git a/Packages/Account/Sources/Account/Filters/EditFilterView.swift b/Packages/Account/Sources/Account/Filters/EditFilterView.swift index 70f9601c..d93454d9 100644 --- a/Packages/Account/Sources/Account/Filters/EditFilterView.swift +++ b/Packages/Account/Sources/Account/Filters/EditFilterView.swift @@ -20,23 +20,21 @@ struct EditFilterView: View { @State private var filterAction: ServerFilter.Action @State private var expiresAt: Date? @State private var expirySelection: Duration - + enum Fields { case title, newKeyword } - + @FocusState private var focusedField: Fields? private var data: ServerFilterData { - var expiresIn: String? - // we add 50 seconds, otherwise we immediately show 6d for a 7d filter (6d, 23h, 59s) - switch expirySelection { + let expiresIn: String? = switch expirySelection { case .infinite: - expiresIn = "" // need to send an empty value in order for the server to clear this field in the filter + "" // need to send an empty value in order for the server to clear this field in the filter case .custom: - expiresIn = String(Int(expiresAt?.timeIntervalSince(Date()) ?? 0) + 50) + String(Int(expiresAt?.timeIntervalSince(Date()) ?? 0) + 50) default: - expiresIn = String(expirySelection.rawValue + 50) + String(expirySelection.rawValue + 50) } return ServerFilterData(title: title, @@ -100,7 +98,7 @@ struct EditFilterView: View { } if expirySelection != .infinite { DatePicker("filter.edit.expiry.date-time", - selection: Binding(get: { self.expiresAt ?? Date() }, set: { self.expiresAt = $0 }), + selection: Binding(get: { expiresAt ?? Date() }, set: { expiresAt = $0 }), displayedComponents: [.date, .hourAndMinute]) .disabled(expirySelection != .custom) } diff --git a/Packages/Account/Sources/Account/Filters/FiltersListView.swift b/Packages/Account/Sources/Account/Filters/FiltersListView.swift index 09001a1e..ca56f2a8 100644 --- a/Packages/Account/Sources/Account/Filters/FiltersListView.swift +++ b/Packages/Account/Sources/Account/Filters/FiltersListView.swift @@ -19,11 +19,11 @@ public struct FiltersListView: View { public var body: some View { NavigationStack { Form { - if !isLoading && filters.isEmpty { + if !isLoading, filters.isEmpty { EmptyView() } else { Section { - if isLoading && filters.isEmpty { + if isLoading, filters.isEmpty { ProgressView() } else { ForEach(filters) { filter in @@ -31,7 +31,7 @@ public struct FiltersListView: View { VStack(alignment: .leading) { Text(filter.title) .font(.scaledSubheadline) - Text("\(filter.context.map { $0.name }.joined(separator: ", "))") + Text("\(filter.context.map(\.name).joined(separator: ", "))") .font(.scaledBody) .foregroundColor(.gray) if filter.hasExpiry() { diff --git a/Packages/AppAccount/Package.swift b/Packages/AppAccount/Package.swift index 081ca04d..d2a0cb0d 100644 --- a/Packages/AppAccount/Package.swift +++ b/Packages/AppAccount/Package.swift @@ -31,7 +31,7 @@ let package = Package( .product(name: "DesignSystem", package: "DesignSystem"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), ] diff --git a/Packages/AppAccount/Sources/AppAccount/AppAccountViewModel.swift b/Packages/AppAccount/Sources/AppAccount/AppAccountViewModel.swift index 464b1f2c..0f53294e 100644 --- a/Packages/AppAccount/Sources/AppAccount/AppAccountViewModel.swift +++ b/Packages/AppAccount/Sources/AppAccount/AppAccountViewModel.swift @@ -25,9 +25,9 @@ public class AppAccountViewModel: ObservableObject { var acct: String { if let acct = appAccount.accountName { - return acct + acct } else { - return "@\(account?.acct ?? "...")@\(appAccount.server)" + "@\(account?.acct ?? "...")@\(appAccount.server)" } } diff --git a/Packages/AppAccount/Sources/AppAccount/AppAccountsManager.swift b/Packages/AppAccount/Sources/AppAccount/AppAccountsManager.swift index 2eaa3103..e1f90a0c 100644 --- a/Packages/AppAccount/Sources/AppAccount/AppAccountsManager.swift +++ b/Packages/AppAccount/Sources/AppAccount/AppAccountsManager.swift @@ -27,7 +27,7 @@ public class AppAccountsManager: ObservableObject { public static var shared = AppAccountsManager() - internal init() { + init() { var defaultAccount = AppAccount(server: AppInfo.defaultServer, accountName: nil, oauthToken: nil) let keychainAccounts = AppAccount.retrieveAll() availableAccounts = keychainAccounts diff --git a/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift b/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift index f9e4e440..355a19dd 100644 --- a/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift +++ b/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift @@ -19,7 +19,7 @@ public struct AppAccountsSelectorView: View { private var showNotificationBadge: Bool { accountsViewModel .filter { $0.account?.id != currentAccount.account?.id } - .compactMap { $0.appAccount.oauthToken } + .compactMap(\.appAccount.oauthToken) .map { preferences.getNotificationsCount(for: $0) } .reduce(0, +) > 0 } @@ -84,7 +84,7 @@ public struct AppAccountsSelectorView: View { .redacted(reason: .placeholder) } }.overlay(alignment: .topTrailing) { - if (!currentAccount.followRequests.isEmpty || showNotificationBadge) && accountCreationEnabled { + if !currentAccount.followRequests.isEmpty || showNotificationBadge, accountCreationEnabled { Circle() .fill(Color.red) .frame(width: 9, height: 9) diff --git a/Packages/Conversations/Package.swift b/Packages/Conversations/Package.swift index 8505f8e4..cd769c5f 100644 --- a/Packages/Conversations/Package.swift +++ b/Packages/Conversations/Package.swift @@ -31,7 +31,7 @@ let package = Package( .product(name: "DesignSystem", package: "DesignSystem"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), ] diff --git a/Packages/Conversations/Sources/Conversations/List/ConversationsListRow.swift b/Packages/Conversations/Sources/Conversations/List/ConversationsListRow.swift index 1712db8e..d2fae12e 100644 --- a/Packages/Conversations/Sources/Conversations/List/ConversationsListRow.swift +++ b/Packages/Conversations/Sources/Conversations/List/ConversationsListRow.swift @@ -27,8 +27,8 @@ struct ConversationsListRow: View { .accessibilityHidden(true) VStack(alignment: .leading, spacing: 4) { HStack { - EmojiTextApp(.init(stringValue: conversation.accounts.map { $0.safeDisplayName }.joined(separator: ", ")), - emojis: conversation.accounts.flatMap { $0.emojis }) + EmojiTextApp(.init(stringValue: conversation.accounts.map(\.safeDisplayName).joined(separator: ", ")), + emojis: conversation.accounts.flatMap(\.emojis)) .font(.scaledSubheadline) .foregroundColor(theme.labelColor) .emojiSize(Font.scaledSubheadlineFont.emojiSize) diff --git a/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift b/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift index b47c2285..da34ae03 100644 --- a/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift +++ b/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift @@ -18,9 +18,9 @@ public struct ConversationsListView: View { private var conversations: Binding<[Conversation]> { if viewModel.isLoadingFirstPage { - return Binding.constant(Conversation.placeholders()) + Binding.constant(Conversation.placeholders()) } else { - return $viewModel.conversations + $viewModel.conversations } } @@ -40,7 +40,7 @@ public struct ConversationsListView: View { } Divider() } - } else if conversations.isEmpty && !viewModel.isLoadingFirstPage && !viewModel.isError { + } else if conversations.isEmpty, !viewModel.isLoadingFirstPage, !viewModel.isError { EmptyView(iconName: "tray", title: "conversations.empty.title", message: "conversations.empty.message") @@ -79,7 +79,7 @@ public struct ConversationsListView: View { .navigationBarTitleDisplayMode(.inline) .toolbar { StatusEditorToolbarItem(visibility: .direct) - if UIDevice.current.userInterfaceIdiom == .pad && !preferences.showiPadSecondaryColumn { + if UIDevice.current.userInterfaceIdiom == .pad, !preferences.showiPadSecondaryColumn { SecondaryColumnToolbarItem() } } diff --git a/Packages/Conversations/Sources/Conversations/List/ConversationsListViewModel.swift b/Packages/Conversations/Sources/Conversations/List/ConversationsListViewModel.swift index 96062dfd..805655d3 100644 --- a/Packages/Conversations/Sources/Conversations/List/ConversationsListViewModel.swift +++ b/Packages/Conversations/Sources/Conversations/List/ConversationsListViewModel.swift @@ -60,11 +60,10 @@ class ConversationsListViewModel: ObservableObject { func favorite(conversation: Conversation) async { guard let client, let message = conversation.lastStatus else { return } - let endpoint: Endpoint - if message.favourited ?? false { - endpoint = Statuses.unfavorite(id: message.id) + let endpoint: Endpoint = if message.favourited ?? false { + Statuses.unfavorite(id: message.id) } else { - endpoint = Statuses.favorite(id: message.id) + Statuses.favorite(id: message.id) } do { let status: Status = try await client.post(endpoint: endpoint) @@ -74,11 +73,10 @@ class ConversationsListViewModel: ObservableObject { func bookmark(conversation: Conversation) async { guard let client, let message = conversation.lastStatus else { return } - let endpoint: Endpoint - if message.bookmarked ?? false { - endpoint = Statuses.unbookmark(id: message.id) + let endpoint: Endpoint = if message.bookmarked ?? false { + Statuses.unbookmark(id: message.id) } else { - endpoint = Statuses.bookmark(id: message.id) + Statuses.bookmark(id: message.id) } do { let status: Status = try await client.post(endpoint: endpoint) diff --git a/Packages/DesignSystem/Package.swift b/Packages/DesignSystem/Package.swift index 6929c382..2747103f 100644 --- a/Packages/DesignSystem/Package.swift +++ b/Packages/DesignSystem/Package.swift @@ -34,7 +34,7 @@ let package = Package( .product(name: "EmojiText", package: "EmojiText"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), ] diff --git a/Packages/DesignSystem/Sources/DesignSystem/ColorSet.swift b/Packages/DesignSystem/Sources/DesignSystem/ColorSet.swift index d240a099..f1613d2c 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/ColorSet.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/ColorSet.swift @@ -160,19 +160,18 @@ public struct ConstellationDark: ColorSet { public var scheme: ColorScheme = .dark public var tintColor: Color = .init(hex: 0xFFD966) public var primaryBackgroundColor: Color = .init(hex: 0x09192C) - public var secondaryBackgroundColor: Color = .init(hex: 0x304c7a) + public var secondaryBackgroundColor: Color = .init(hex: 0x304C7A) public var labelColor: Color = .init(hex: 0xE2E4E2) public init() {} } - public struct ConstellationLight: ColorSet { public var name: ColorSetName = .constellationLight public var scheme: ColorScheme = .light - public var tintColor: Color = .init(hex: 0xc82238) - public var primaryBackgroundColor: Color = .init(hex: 0xf4f5f7) - public var secondaryBackgroundColor: Color = .init(hex: 0xacc7e5) + public var tintColor: Color = .init(hex: 0xC82238) + public var primaryBackgroundColor: Color = .init(hex: 0xF4F5F7) + public var secondaryBackgroundColor: Color = .init(hex: 0xACC7E5) public var labelColor: Color = .black public init() {} diff --git a/Packages/DesignSystem/Sources/DesignSystem/Resources/Colors.swift b/Packages/DesignSystem/Sources/DesignSystem/Resources/Colors.swift index 85866722..84028a8c 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Resources/Colors.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Resources/Colors.swift @@ -27,7 +27,7 @@ extension Color: RawRepresentable { } public var rawValue: Int { - guard let coreImageColor = coreImageColor else { + guard let coreImageColor else { return 0 } let red = Int(coreImageColor.red * 255 + 0.5) @@ -37,7 +37,7 @@ extension Color: RawRepresentable { } private var coreImageColor: CIColor? { - return CIColor(color: .init(self)) + CIColor(color: .init(self)) } } diff --git a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift index cb7458cf..6ff63d71 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift @@ -22,15 +22,15 @@ public class Theme: ObservableObject { public var title: LocalizedStringKey { switch self { case .system: - return "settings.display.font.system" + "settings.display.font.system" case .openDyslexic: - return "Open Dyslexic" + "Open Dyslexic" case .hyperLegible: - return "Hyper Legible" + "Hyper Legible" case .SFRounded: - return "SF Rounded" + "SF Rounded" case .custom: - return "settings.display.font.custom" + "settings.display.font.custom" } } } @@ -41,9 +41,9 @@ public class Theme: ObservableObject { public var description: LocalizedStringKey { switch self { case .leading: - return "enum.avatar-position.leading" + "enum.avatar-position.leading" case .top: - return "enum.avatar-position.top" + "enum.avatar-position.top" } } } @@ -54,9 +54,9 @@ public class Theme: ObservableObject { public var description: LocalizedStringKey { switch self { case .circle: - return "enum.avatar-shape.circle" + "enum.avatar-shape.circle" case .rounded: - return "enum.avatar-shape.rounded" + "enum.avatar-shape.rounded" } } } @@ -67,11 +67,11 @@ public class Theme: ObservableObject { public var description: LocalizedStringKey { switch self { case .full: - return "enum.status-actions-display.all" + "enum.status-actions-display.all" case .discret: - return "enum.status-actions-display.only-buttons" + "enum.status-actions-display.only-buttons" case .none: - return "enum.status-actions-display.no-buttons" + "enum.status-actions-display.no-buttons" } } } @@ -82,11 +82,11 @@ public class Theme: ObservableObject { public var description: LocalizedStringKey { switch self { case .large: - return "enum.status-display-style.large" + "enum.status-display-style.large" case .medium: - return "enum.status-display-style.medium" + "enum.status-display-style.medium" case .compact: - return "enum.status-display-style.compact" + "enum.status-display-style.compact" } } } diff --git a/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift b/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift index ea87b3aa..bc953e98 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift @@ -97,7 +97,7 @@ struct ThemeApplier: ViewModifier { private func allWindows() -> [UIWindow] { UIApplication.shared.connectedScenes .compactMap { $0 as? UIWindowScene } - .flatMap { $0.windows } + .flatMap(\.windows) } #endif } diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift index 2515b941..b487ac43 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift @@ -33,9 +33,9 @@ public struct AvatarView: View { var cornerRadius: CGFloat { switch self { case .badge, .boost, .list: - return size.width / 2 + size.width / 2 default: - return 4 + 4 } } } @@ -55,7 +55,7 @@ public struct AvatarView: View { .fill(.gray) .frame(width: size.size.width, height: size.size.height) } else { - LazyImage(request: url.map{ makeImageRequest(for: $0) }) { state in + LazyImage(request: url.map { makeImageRequest(for: $0) }) { state in if let image = state.image { image .resizable() @@ -80,9 +80,9 @@ public struct AvatarView: View { private var clipShape: some Shape { switch theme.avatarShape { case .circle: - return AnyShape(Circle()) + AnyShape(Circle()) case .rounded: - return AnyShape(RoundedRectangle(cornerRadius: size.cornerRadius)) + AnyShape(RoundedRectangle(cornerRadius: size.cornerRadius)) } } } diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/EmojiText.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/EmojiText.swift index 975b8fdf..15895d86 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/EmojiText.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/EmojiText.swift @@ -38,6 +38,6 @@ public struct EmojiTextApp: View { private func isRTL() -> Bool { // Arabic, Hebrew, Persian, Urdu, Kurdish, Azeri, Dhivehi - return ["ar", "he", "fa", "ur", "ku", "az", "dv"].contains(language) + ["ar", "he", "fa", "ur", "ku", "az", "dv"].contains(language) } } diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/StatusEditorToolbarItem.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/StatusEditorToolbarItem.swift index 535b95f6..d9fe8586 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/StatusEditorToolbarItem.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/StatusEditorToolbarItem.swift @@ -59,7 +59,7 @@ public struct SecondaryColumnToolbarItem: ToolbarContent { public init() {} - public var body: some ToolbarContent { + public var body: some ToolbarContent { ToolbarItem(placement: isSecondaryColumn ? .navigationBarLeading : .navigationBarTrailing) { Button { withAnimation { diff --git a/Packages/Env/Package.swift b/Packages/Env/Package.swift index 315160f2..390c934d 100644 --- a/Packages/Env/Package.swift +++ b/Packages/Env/Package.swift @@ -29,7 +29,7 @@ let package = Package( .product(name: "KeychainSwift", package: "keychain-swift"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), ] diff --git a/Packages/Env/Sources/Env/CurrentAccount.swift b/Packages/Env/Sources/Env/CurrentAccount.swift index 7ab1abc9..b3db9321 100644 --- a/Packages/Env/Sources/Env/CurrentAccount.swift +++ b/Packages/Env/Sources/Env/CurrentAccount.swift @@ -48,7 +48,7 @@ public class CurrentAccount: ObservableObject { } public func fetchConnections() async { - guard let client = client else { return } + guard let client else { return } do { let connections: [String] = try await client.get(endpoint: Instances.peers) client.addConnections(connections) @@ -56,7 +56,7 @@ public class CurrentAccount: ObservableObject { } public func fetchCurrentAccount() async { - guard let client = client, client.isAuth else { + guard let client, client.isAuth else { account = nil return } diff --git a/Packages/Env/Sources/Env/CurrentInstance.swift b/Packages/Env/Sources/Env/CurrentInstance.swift index beec3dfb..8535eb7e 100644 --- a/Packages/Env/Sources/Env/CurrentInstance.swift +++ b/Packages/Env/Sources/Env/CurrentInstance.swift @@ -41,7 +41,7 @@ public class CurrentInstance: ObservableObject { } public func fetchCurrentInstance() async { - guard let client = client else { return } + guard let client else { return } instance = try? await client.get(endpoint: Instances.instance) } } diff --git a/Packages/Env/Sources/Env/Duration.swift b/Packages/Env/Sources/Env/Duration.swift index 29340b51..eb3547f6 100644 --- a/Packages/Env/Sources/Env/Duration.swift +++ b/Packages/Env/Sources/Env/Duration.swift @@ -15,37 +15,37 @@ public enum Duration: Int, CaseIterable { public var description: LocalizedStringKey { switch self { case .infinite: - return "enum.durations.infinite" + "enum.durations.infinite" case .fiveMinutes: - return "enum.durations.fiveMinutes" + "enum.durations.fiveMinutes" case .thirtyMinutes: - return "enum.durations.thirtyMinutes" + "enum.durations.thirtyMinutes" case .oneHour: - return "enum.durations.oneHour" + "enum.durations.oneHour" case .sixHours: - return "enum.durations.sixHours" + "enum.durations.sixHours" case .twelveHours: - return "enum.durations.twelveHours" + "enum.durations.twelveHours" case .oneDay: - return "enum.durations.oneDay" + "enum.durations.oneDay" case .threeDays: - return "enum.durations.threeDays" + "enum.durations.threeDays" case .sevenDays: - return "enum.durations.sevenDays" + "enum.durations.sevenDays" case .custom: - return "enum.durations.custom" + "enum.durations.custom" } } public static func mutingDurations() -> [Duration] { - return Self.allCases.filter { $0 != .custom } + allCases.filter { $0 != .custom } } public static func filterDurations() -> [Duration] { - return [.infinite, .thirtyMinutes, .oneHour, .sixHours, .twelveHours, .oneDay, .sevenDays, .custom] + [.infinite, .thirtyMinutes, .oneHour, .sixHours, .twelveHours, .oneDay, .sevenDays, .custom] } public static func pollDurations() -> [Duration] { - return [.fiveMinutes, .thirtyMinutes, .oneHour, .sixHours, .twelveHours, .oneDay, .threeDays, .sevenDays] + [.fiveMinutes, .thirtyMinutes, .oneHour, .sixHours, .twelveHours, .oneDay, .threeDays, .sevenDays] } } diff --git a/Packages/Env/Sources/Env/PollPreferences.swift b/Packages/Env/Sources/Env/PollPreferences.swift index d06592cf..5ccb87a0 100644 --- a/Packages/Env/Sources/Env/PollPreferences.swift +++ b/Packages/Env/Sources/Env/PollPreferences.swift @@ -7,15 +7,15 @@ public enum PollVotingFrequency: String, CaseIterable { public var canVoteMultipleTimes: Bool { switch self { - case .multipleVotes: return true - case .oneVote: return false + case .multipleVotes: true + case .oneVote: false } } public var displayString: LocalizedStringKey { switch self { - case .oneVote: return "env.poll-vote-frequency.one" - case .multipleVotes: return "env.poll-vote-frequency.multiple" + case .oneVote: "env.poll-vote-frequency.one" + case .multipleVotes: "env.poll-vote-frequency.multiple" } } } diff --git a/Packages/Env/Sources/Env/PreferredShareButtonBehavior.swift b/Packages/Env/Sources/Env/PreferredShareButtonBehavior.swift index 244c29ea..5faa3498 100644 --- a/Packages/Env/Sources/Env/PreferredShareButtonBehavior.swift +++ b/Packages/Env/Sources/Env/PreferredShareButtonBehavior.swift @@ -7,8 +7,8 @@ public enum PreferredShareButtonBehavior: Int, CaseIterable, Codable { public var title: LocalizedStringKey { switch self { - case .linkOnly: return "settings.content.sharing.share-behavior.link-only" - case .linkAndText: return "settings.content.sharing.share-behavior.link-and-text" + case .linkOnly: "settings.content.sharing.share-behavior.link-only" + case .linkAndText: "settings.content.sharing.share-behavior.link-and-text" } } } diff --git a/Packages/Env/Sources/Env/PushNotificationsService.swift b/Packages/Env/Sources/Env/PushNotificationsService.swift index c867fd59..636d01ca 100644 --- a/Packages/Env/Sources/Env/PushNotificationsService.swift +++ b/Packages/Env/Sources/Env/PushNotificationsService.swift @@ -7,8 +7,8 @@ import Network import SwiftUI import UserNotifications -extension UNNotificationResponse: @unchecked Sendable { } -extension UNUserNotificationCenter: @unchecked Sendable { } +extension UNNotificationResponse: @unchecked Sendable {} +extension UNUserNotificationCenter: @unchecked Sendable {} public struct PushAccount: Equatable { public let server: String @@ -157,7 +157,7 @@ extension PushNotificationsService: UNUserNotificationCenterDelegate { extension Data { var hexString: String { - return map { String(format: "%02.2hhx", arguments: [$0]) }.joined() + map { String(format: "%02.2hhx", arguments: [$0]) }.joined() } } @@ -199,7 +199,7 @@ public class PushNotificationSubscriptionSettings: ObservableObject { } public func updateSubscription() async { - guard let pushToken = pushToken else { return } + guard let pushToken else { return } let client = Client(server: account.server, oauthToken: account.token) do { var listenerURL = PushNotificationsService.Constants.endpoint diff --git a/Packages/Env/Sources/Env/Router.swift b/Packages/Env/Sources/Env/Router.swift index d43935da..57507d24 100644 --- a/Packages/Env/Sources/Env/Router.swift +++ b/Packages/Env/Sources/Env/Router.swift @@ -45,25 +45,25 @@ public enum SheetDestination: Identifiable { switch self { case .editStatusEditor, .newStatusEditor, .replyToStatusEditor, .quoteStatusEditor, .mentionStatusEditor, .settings, .accountPushNotficationsSettings: - return "statusEditor" + "statusEditor" case .listEdit: - return "listEdit" + "listEdit" case .listAddAccount: - return "listAddAccount" + "listAddAccount" case .addAccount: - return "addAccount" + "addAccount" case .addTagGroup: - return "addTagGroup" + "addTagGroup" case .addRemoteLocalTimeline: - return "addRemoteLocalTimeline" + "addRemoteLocalTimeline" case .statusEditHistory: - return "statusEditHistory" + "statusEditHistory" case .report: - return "report" + "report" case .shareImage: - return "shareImage" + "shareImage" case .editTagGroup: - return "editTagGroup" + "editTagGroup" } } } @@ -83,9 +83,9 @@ public class RouterPath: ObservableObject { } public func handleStatus(status: AnyStatus, url: URL) -> OpenURLAction.Result { - if url.pathComponents.count == 3 && url.pathComponents[1] == "tags" && - url.host() == status.account.url?.host(), - let tag = url.pathComponents.last + if url.pathComponents.count == 3, url.pathComponents[1] == "tags", + url.host() == status.account.url?.host(), + let tag = url.pathComponents.last { // OK this test looks weird but it's // A 3 component path i.e. ["/", "tags", "tagname"] @@ -97,7 +97,7 @@ public class RouterPath: ObservableObject { } else if let mention = status.mentions.first(where: { $0.url == url }) { navigate(to: .accountDetail(id: mention.id)) return .handled - } else if let client = client, + } else if let client, client.isAuth, client.hasConnection(with: url), let id = Int(url.lastPathComponent) @@ -126,7 +126,7 @@ public class RouterPath: ObservableObject { await navigateToAccountFrom(acct: acct, url: url) } return .handled - } else if let client = client, + } else if let client, client.isAuth, client.hasConnection(with: url), let id = Int(url.lastPathComponent) diff --git a/Packages/Env/Sources/Env/SoundEffectManager.swift b/Packages/Env/Sources/Env/SoundEffectManager.swift index fb626e0f..d8cd863f 100644 --- a/Packages/Env/Sources/Env/SoundEffectManager.swift +++ b/Packages/Env/Sources/Env/SoundEffectManager.swift @@ -1,16 +1,16 @@ +import AudioToolbox import AVKit import CoreHaptics import UIKit -import AudioToolbox @MainActor public class SoundEffectManager { public static let shared: SoundEffectManager = .init() - + public enum SoundEffect: String, CaseIterable { case pull, refresh, tootSent, tabSelection, bookmark, boost, favorite, share } - + var pullId: SystemSoundID = 0 var refreshId: SystemSoundID = 1 var tootSentId: SystemSoundID = 2 @@ -19,9 +19,9 @@ public class SoundEffectManager { var boostId: SystemSoundID = 5 var favoriteId: SystemSoundID = 6 var shareId: SystemSoundID = 7 - + private let userPreferences = UserPreferences.shared - + private init() { registerSounds() } @@ -50,7 +50,7 @@ public class SoundEffectManager { } } } - + public func playSound(of type: SoundEffect) { guard userPreferences.soundEffectEnabled else { return } switch type { diff --git a/Packages/Env/Sources/Env/StreamWatcher.swift b/Packages/Env/Sources/Env/StreamWatcher.swift index 77247e27..cf3dc1b4 100644 --- a/Packages/Env/Sources/Env/StreamWatcher.swift +++ b/Packages/Env/Sources/Env/StreamWatcher.swift @@ -73,7 +73,7 @@ public class StreamWatcher: ObservableObject { private func receiveMessage() { task?.receive(completionHandler: { [weak self] result in - guard let self = self else { return } + guard let self else { return } switch result { case let .success(message): switch message { @@ -83,8 +83,8 @@ public class StreamWatcher: ObservableObject { print("Error decoding streaming event string") return } - let rawEvent = try self.decoder.decode(RawStreamEvent.self, from: data) - if let event = self.rawEventToEvent(rawEvent: rawEvent) { + let rawEvent = try decoder.decode(RawStreamEvent.self, from: data) + if let event = rawEventToEvent(rawEvent: rawEvent) { Task { @MainActor in self.events.append(event) self.latestEvent = event @@ -101,10 +101,10 @@ public class StreamWatcher: ObservableObject { break } - self.receiveMessage() + receiveMessage() case .failure: - DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(self.retryDelay)) { + DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(retryDelay)) { self.retryDelay += 30 self.stopWatching() self.connect() diff --git a/Packages/Env/Sources/Env/UserPreferences.swift b/Packages/Env/Sources/Env/UserPreferences.swift index 44ef7db7..19e5776e 100644 --- a/Packages/Env/Sources/Env/UserPreferences.swift +++ b/Packages/Env/Sources/Env/UserPreferences.swift @@ -65,9 +65,9 @@ public class UserPreferences: ObservableObject { public var description: LocalizedStringKey { switch self { case .iconWithText: - return "enum.swipeactions.icon-with-text" + "enum.swipeactions.icon-with-text" case .iconOnly: - return "enum.swipeactions.icon-only" + "enum.swipeactions.icon-only" } } @@ -84,52 +84,52 @@ public class UserPreferences: ObservableObject { public var postVisibility: Models.Visibility { if useInstanceContentSettings { - return serverPreferences?.postVisibility ?? .pub + serverPreferences?.postVisibility ?? .pub } else { - return appDefaultPostVisibility + appDefaultPostVisibility } } - + public func conformReplyVisibilityConstraints() { appDefaultReplyVisibility = getReplyVisibility() } - + private func getReplyVisibility() -> Models.Visibility { getMinVisibility(postVisibility, appDefaultReplyVisibility) } - + public func getReplyVisibility(of status: Status) -> Models.Visibility { getMinVisibility(getReplyVisibility(), status.visibility) } - + private func getMinVisibility(_ vis1: Models.Visibility, _ vis2: Models.Visibility) -> Models.Visibility { let no1 = Self.getIntOfVisibility(vis1) let no2 = Self.getIntOfVisibility(vis2) - + return no1 < no2 ? vis1 : vis2 } - + public var postIsSensitive: Bool { if useInstanceContentSettings { - return serverPreferences?.postIsSensitive ?? false + serverPreferences?.postIsSensitive ?? false } else { - return appDefaultPostsSensitive + appDefaultPostsSensitive } } public var autoExpandSpoilers: Bool { if useInstanceContentSettings { - return serverPreferences?.autoExpandSpoilers ?? true + serverPreferences?.autoExpandSpoilers ?? true } else { - return appAutoExpandSpoilers + appAutoExpandSpoilers } } public var autoExpandMedia: ServerPreferences.AutoExpandMedia { if useInstanceContentSettings { - return serverPreferences?.autoExpandMedia ?? .hideSensitive + serverPreferences?.autoExpandMedia ?? .hideSensitive } else { - return appAutoExpandMedia + appAutoExpandMedia } } @@ -174,17 +174,17 @@ public class UserPreferences: ObservableObject { copy.insert(isoCode, at: 0) recentlyUsedLanguages = Array(copy.prefix(3)) } - + public static func getIntOfVisibility(_ vis: Models.Visibility) -> Int { switch vis { - case .direct: - return 0 - case .priv: - return 1 - case .unlisted: - return 2 - case .pub: - return 3 + case .direct: + 0 + case .priv: + 1 + case .unlisted: + 2 + case .pub: + 3 } } } diff --git a/Packages/Explore/Package.swift b/Packages/Explore/Package.swift index dca758f4..08dd9b92 100644 --- a/Packages/Explore/Package.swift +++ b/Packages/Explore/Package.swift @@ -35,7 +35,7 @@ let package = Package( .product(name: "DesignSystem", package: "DesignSystem"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), ] diff --git a/Packages/Explore/Sources/Explore/ExploreView.swift b/Packages/Explore/Sources/Explore/ExploreView.swift index f6a9154a..f8f84adc 100644 --- a/Packages/Explore/Sources/Explore/ExploreView.swift +++ b/Packages/Explore/Sources/Explore/ExploreView.swift @@ -126,7 +126,7 @@ public struct ExploreView: View { @ViewBuilder private func makeSearchResultsView(results: SearchResults) -> some View { - if !results.accounts.isEmpty && (viewModel.searchScope == .all || viewModel.searchScope == .people) { + if !results.accounts.isEmpty, viewModel.searchScope == .all || viewModel.searchScope == .people { Section("explore.section.users") { ForEach(results.accounts) { account in if let relationship = results.relationships.first(where: { $0.id == account.id }) { @@ -136,7 +136,7 @@ public struct ExploreView: View { } } } - if !results.hashtags.isEmpty && (viewModel.searchScope == .all || viewModel.searchScope == .hashtags) { + if !results.hashtags.isEmpty, viewModel.searchScope == .all || viewModel.searchScope == .hashtags { Section("explore.section.tags") { ForEach(results.hashtags) { tag in TagRowView(tag: tag) @@ -145,7 +145,7 @@ public struct ExploreView: View { } } } - if !results.statuses.isEmpty && (viewModel.searchScope == .all || viewModel.searchScope == .posts) { + if !results.statuses.isEmpty, viewModel.searchScope == .all || viewModel.searchScope == .posts { Section("explore.section.posts") { ForEach(results.statuses) { status in StatusRowView(viewModel: { .init(status: status, client: client, routerPath: routerPath) }) diff --git a/Packages/Explore/Sources/Explore/ExploreViewModel.swift b/Packages/Explore/Sources/Explore/ExploreViewModel.swift index 4df4a9b9..af19b021 100644 --- a/Packages/Explore/Sources/Explore/ExploreViewModel.swift +++ b/Packages/Explore/Sources/Explore/ExploreViewModel.swift @@ -11,13 +11,13 @@ class ExploreViewModel: ObservableObject { var localizedString: LocalizedStringKey { switch self { case .all: - return .init("explore.scope.all") + .init("explore.scope.all") case .people: - return .init("explore.scope.people") + .init("explore.scope.people") case .hashtags: - return .init("explore.scope.hashtags") + .init("explore.scope.hashtags") case .posts: - return .init("explore.scope.posts") + .init("explore.scope.posts") } } } @@ -77,7 +77,7 @@ class ExploreViewModel: ObservableObject { trendingStatuses = data.trendingStatuses trendingLinks = data.trendingLinks - suggestedAccountsRelationShips = try await client.get(endpoint: Accounts.relationships(ids: suggestedAccounts.map { $0.id })) + suggestedAccountsRelationShips = try await client.get(endpoint: Accounts.relationships(ids: suggestedAccounts.map(\.id))) withAnimation { isLoaded = true } @@ -118,7 +118,7 @@ class ExploreViewModel: ObservableObject { following: nil), forceVersion: .v2) let relationships: [Relationship] = - try await client.get(endpoint: Accounts.relationships(ids: results.accounts.map { $0.id })) + try await client.get(endpoint: Accounts.relationships(ids: results.accounts.map(\.id))) results.relationships = relationships withAnimation { self.results[searchQuery] = results diff --git a/Packages/Lists/Package.swift b/Packages/Lists/Package.swift index 8daf9815..50c43eae 100644 --- a/Packages/Lists/Package.swift +++ b/Packages/Lists/Package.swift @@ -31,7 +31,7 @@ let package = Package( .product(name: "DesignSystem", package: "DesignSystem"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), ] diff --git a/Packages/Models/Package.swift b/Packages/Models/Package.swift index f7e645b8..dd90f005 100644 --- a/Packages/Models/Package.swift +++ b/Packages/Models/Package.swift @@ -25,7 +25,7 @@ let package = Package( "SwiftSoup", ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), .testTarget( diff --git a/Packages/Models/Sources/Models/Account.swift b/Packages/Models/Sources/Models/Account.swift index 984cb9b1..8bfe66a2 100644 --- a/Packages/Models/Sources/Models/Account.swift +++ b/Packages/Models/Sources/Models/Account.swift @@ -60,11 +60,11 @@ public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable public let discoverable: Bool? public var haveAvatar: Bool { - return avatar.lastPathComponent != "missing.png" + avatar.lastPathComponent != "missing.png" } public var haveHeader: Bool { - return header.lastPathComponent != "missing.png" + header.lastPathComponent != "missing.png" } public init(id: String, username: String, displayName: String?, avatar: URL, header: URL, acct: String, note: HTMLString, createdAt: ServerDate, followersCount: Int, followingCount: Int, statusesCount: Int, lastStatusAt: String? = nil, fields: [Account.Field], locked: Bool, emojis: [Emoji], url: URL? = nil, source: Account.Source? = nil, bot: Bool, discoverable: Bool? = nil) { diff --git a/Packages/Models/Sources/Models/Alias/DateFormatterCache.swift b/Packages/Models/Sources/Models/Alias/DateFormatterCache.swift index 905e641f..bbc617b9 100644 --- a/Packages/Models/Sources/Models/Alias/DateFormatterCache.swift +++ b/Packages/Models/Sources/Models/Alias/DateFormatterCache.swift @@ -6,17 +6,17 @@ class DateFormatterCache: @unchecked Sendable { let createdAtRelativeFormatter: RelativeDateTimeFormatter let createdAtShortDateFormatted: DateFormatter let createdAtDateFormatter: DateFormatter - + init() { let createdAtRelativeFormatter = RelativeDateTimeFormatter() createdAtRelativeFormatter.unitsStyle = .short self.createdAtRelativeFormatter = createdAtRelativeFormatter - + let createdAtShortDateFormatted = DateFormatter() createdAtShortDateFormatted.dateStyle = .short createdAtShortDateFormatted.timeStyle = .none self.createdAtShortDateFormatted = createdAtShortDateFormatted - + let createdAtDateFormatter = DateFormatter() createdAtDateFormatter.calendar = .init(identifier: .iso8601) createdAtDateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX" diff --git a/Packages/Models/Sources/Models/Alias/HTMLString.swift b/Packages/Models/Sources/Models/Alias/HTMLString.swift index 0f3f1e5b..ea19a449 100644 --- a/Packages/Models/Sources/Models/Alias/HTMLString.swift +++ b/Packages/Models/Sources/Models/Alias/HTMLString.swift @@ -11,7 +11,7 @@ public struct HTMLString: Codable, Equatable, Hashable, @unchecked Sendable { public var asMarkdown: String = "" public var asRawText: String = "" public var statusesURLs = [URL]() - private(set) public var links = [Link]() + public private(set) var links = [Link]() public var asSafeMarkdownAttributedString: AttributedString = .init() private var main_regex: NSRegularExpression? @@ -155,16 +155,16 @@ public struct HTMLString: Codable, Equatable, Hashable, @unchecked Sendable { let finish = asMarkdown.endIndex var linkRef = href - + // Try creating a URL from the string. If it fails, try URL encoding // the string first. var url = URL(string: href) if url == nil { url = URL(string: href, encodePath: true) } - if let linkUrl = url { + if let linkUrl = url { linkRef = linkUrl.absoluteString - let displayString = asMarkdown[start.. Bool { - return expiresAt != nil + expiresAt != nil } public func isExpired() -> Bool { if let expiresAtDate = expiresAt?.asDate { - return expiresAtDate < Date() + expiresAtDate < Date() } else { - return false + false } } } @@ -40,30 +40,30 @@ public extension ServerFilter.Context { var iconName: String { switch self { case .home: - return "rectangle.stack" + "rectangle.stack" case .notifications: - return "bell" + "bell" case .public: - return "globe.americas" + "globe.americas" case .thread: - return "bubble.left.and.bubble.right" + "bubble.left.and.bubble.right" case .account: - return "person.crop.circle" + "person.crop.circle" } } var name: String { switch self { case .home: - return NSLocalizedString("filter.contexts.home", comment: "") + NSLocalizedString("filter.contexts.home", comment: "") case .notifications: - return NSLocalizedString("filter.contexts.notifications", comment: "") + NSLocalizedString("filter.contexts.notifications", comment: "") case .public: - return NSLocalizedString("filter.contexts.public", comment: "") + NSLocalizedString("filter.contexts.public", comment: "") case .thread: - return NSLocalizedString("filter.contexts.conversations", comment: "") + NSLocalizedString("filter.contexts.conversations", comment: "") case .account: - return NSLocalizedString("filter.contexts.profiles", comment: "") + NSLocalizedString("filter.contexts.profiles", comment: "") } } } @@ -72,9 +72,9 @@ public extension ServerFilter.Action { var label: String { switch self { case .warn: - return NSLocalizedString("filter.action.warning", comment: "") + NSLocalizedString("filter.action.warning", comment: "") case .hide: - return NSLocalizedString("filter.action.hide", comment: "") + NSLocalizedString("filter.action.hide", comment: "") } } } diff --git a/Packages/Models/Sources/Models/ServerPreferences.swift b/Packages/Models/Sources/Models/ServerPreferences.swift index c74b603d..9b4f8cea 100644 --- a/Packages/Models/Sources/Models/ServerPreferences.swift +++ b/Packages/Models/Sources/Models/ServerPreferences.swift @@ -16,11 +16,11 @@ public struct ServerPreferences: Decodable { public var description: LocalizedStringKey { switch self { case .showAll: - return "enum.expand-media.show" + "enum.expand-media.show" case .hideAll: - return "enum.expand-media.hide" + "enum.expand-media.hide" case .hideSensitive: - return "enum.expand-media.hide-sensitive" + "enum.expand-media.hide-sensitive" } } } diff --git a/Packages/Models/Tests/ModelsTests/HTMLStringTests.swift b/Packages/Models/Tests/ModelsTests/HTMLStringTests.swift index e1cff3f8..9b47238e 100644 --- a/Packages/Models/Tests/ModelsTests/HTMLStringTests.swift +++ b/Packages/Models/Tests/ModelsTests/HTMLStringTests.swift @@ -6,28 +6,28 @@ final class HTMLStringTests: XCTestCase { XCTAssertNil(URL(string: "go to www.google.com", encodePath: true)) XCTAssertNil(URL(string: "go to www.google.com", encodePath: false)) XCTAssertNil(URL(string: "", encodePath: true)) - + let simpleUrl = URL(string: "https://www.google.com", encodePath: true) XCTAssertEqual("https://www.google.com", simpleUrl?.absoluteString) - + let urlWithTrailingSlash = URL(string: "https://www.google.com/", encodePath: true) XCTAssertEqual("https://www.google.com/", urlWithTrailingSlash?.absoluteString) - + let extendedCharPath = URL(string: "https://en.wikipedia.org/wiki/Elbbrücken_station", encodePath: true) XCTAssertEqual("https://en.wikipedia.org/wiki/Elbbr%C3%BCcken_station", extendedCharPath?.absoluteString) XCTAssertNil(URL(string: "https://en.wikipedia.org/wiki/Elbbrücken_station", encodePath: false)) - + let extendedCharQuery = URL(string: "http://test.com/blah/city?name=京都市", encodePath: true) XCTAssertEqual("http://test.com/blah/city?name=%E4%BA%AC%E9%83%BD%E5%B8%82", extendedCharQuery?.absoluteString) - + // Double encoding will happen if you ask to encodePath on an already encoded string let alreadyEncodedPath = URL(string: "https://en.wikipedia.org/wiki/Elbbr%C3%BCcken_station", encodePath: true) XCTAssertEqual("https://en.wikipedia.org/wiki/Elbbr%25C3%25BCcken_station", alreadyEncodedPath?.absoluteString) } - + func testHTMLStringInit() throws { let decoder = JSONDecoder() - + let basicContent = "\"

This is a test

\"" var htmlString = try decoder.decode(HTMLString.self, from: Data(basicContent.utf8)) XCTAssertEqual("This is a test", htmlString.asRawText) @@ -35,7 +35,7 @@ final class HTMLStringTests: XCTestCase { XCTAssertEqual("This is a test", htmlString.asMarkdown) XCTAssertEqual(0, htmlString.statusesURLs.count) XCTAssertEqual(0, htmlString.links.count) - + let basicLink = "\"

This is a test

\"" htmlString = try decoder.decode(HTMLString.self, from: Data(basicLink.utf8)) XCTAssertEqual("This is a test", htmlString.asRawText) @@ -45,7 +45,7 @@ final class HTMLStringTests: XCTestCase { XCTAssertEqual(1, htmlString.links.count) XCTAssertEqual("https://test.com", htmlString.links[0].url.absoluteString) XCTAssertEqual("test", htmlString.links[0].displayString) - + let extendedCharLink = "\"

This is a test

\"" htmlString = try decoder.decode(HTMLString.self, from: Data(extendedCharLink.utf8)) XCTAssertEqual("This is a test", htmlString.asRawText) @@ -55,7 +55,7 @@ final class HTMLStringTests: XCTestCase { XCTAssertEqual(1, htmlString.links.count) XCTAssertEqual("https://test.com/go%C3%9F%C3%AB%C3%B1a", htmlString.links[0].url.absoluteString) XCTAssertEqual("test", htmlString.links[0].displayString) - + let alreadyEncodedLink = "\"

This is a test

\"" htmlString = try decoder.decode(HTMLString.self, from: Data(alreadyEncodedLink.utf8)) XCTAssertEqual("This is a test", htmlString.asRawText) @@ -66,16 +66,16 @@ final class HTMLStringTests: XCTestCase { XCTAssertEqual("https://test.com/go%C3%9F%C3%AB%C3%B1a", htmlString.links[0].url.absoluteString) XCTAssertEqual("test", htmlString.links[0].displayString) } - + func testHTMLStringInit_markdownEscaping() throws { let decoder = JSONDecoder() - + let stdMarkdownContent = "\"

This [*is*] `a`\\n**test**

\"" var htmlString = try decoder.decode(HTMLString.self, from: Data(stdMarkdownContent.utf8)) XCTAssertEqual("This [*is*] `a`\n**test**", htmlString.asRawText) XCTAssertEqual("

This [*is*] `a`\n**test**

", htmlString.htmlValue) XCTAssertEqual("This \\[\\*is\\*] \\`a\\` \\*\\*test\\*\\*", htmlString.asMarkdown) - + let underscoreContent = "\"

This _is_ an :emoji_maybe:

\"" htmlString = try decoder.decode(HTMLString.self, from: Data(underscoreContent.utf8)) XCTAssertEqual("This _is_ an :emoji_maybe:", htmlString.asRawText) diff --git a/Packages/Network/Package.swift b/Packages/Network/Package.swift index 3dd8a78d..abf2405f 100644 --- a/Packages/Network/Package.swift +++ b/Packages/Network/Package.swift @@ -25,7 +25,7 @@ let package = Package( .product(name: "Models", package: "Models"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), .testTarget( diff --git a/Packages/Network/Sources/Network/Endpoint/Accounts.swift b/Packages/Network/Sources/Network/Endpoint/Accounts.swift index 5830db32..62b206c1 100644 --- a/Packages/Network/Sources/Network/Endpoint/Accounts.swift +++ b/Packages/Network/Sources/Network/Endpoint/Accounts.swift @@ -33,49 +33,49 @@ public enum Accounts: Endpoint { public func path() -> String { switch self { case let .accounts(id): - return "accounts/\(id)" + "accounts/\(id)" case .favorites: - return "favourites" + "favourites" case .bookmarks: - return "bookmarks" + "bookmarks" case .followedTags: - return "followed_tags" + "followed_tags" case let .featuredTags(id): - return "accounts/\(id)/featured_tags" + "accounts/\(id)/featured_tags" case .verifyCredentials: - return "accounts/verify_credentials" + "accounts/verify_credentials" case .updateCredentials: - return "accounts/update_credentials" + "accounts/update_credentials" case let .statuses(id, _, _, _, _, _): - return "accounts/\(id)/statuses" + "accounts/\(id)/statuses" case .relationships: - return "accounts/relationships" + "accounts/relationships" case let .follow(id, _, _): - return "accounts/\(id)/follow" + "accounts/\(id)/follow" case let .unfollow(id): - return "accounts/\(id)/unfollow" + "accounts/\(id)/unfollow" case .familiarFollowers: - return "accounts/familiar_followers" + "accounts/familiar_followers" case .suggestions: - return "suggestions" + "suggestions" case let .following(id, _): - return "accounts/\(id)/following" + "accounts/\(id)/following" case let .followers(id, _): - return "accounts/\(id)/followers" + "accounts/\(id)/followers" case let .lists(id): - return "accounts/\(id)/lists" + "accounts/\(id)/lists" case .preferences: - return "preferences" + "preferences" case let .block(id): - return "accounts/\(id)/block" + "accounts/\(id)/block" case let .unblock(id): - return "accounts/\(id)/unblock" + "accounts/\(id)/unblock" case let .mute(id, _): - return "accounts/\(id)/mute" + "accounts/\(id)/mute" case let .unmute(id): - return "accounts/\(id)/unmute" + "accounts/\(id)/unmute" case let .relationshipNote(id, _): - return "accounts/\(id)/note" + "accounts/\(id)/note" } } @@ -128,13 +128,13 @@ public enum Accounts: Endpoint { public var jsonValue: Encodable? { switch self { case let .mute(_, json): - return json + json case let .relationshipNote(_, json): - return json + json case let .updateCredentials(json): - return json + json default: - return nil + nil } } } diff --git a/Packages/Network/Sources/Network/Endpoint/Apps.swift b/Packages/Network/Sources/Network/Endpoint/Apps.swift index ca2174ec..cd4e61f2 100644 --- a/Packages/Network/Sources/Network/Endpoint/Apps.swift +++ b/Packages/Network/Sources/Network/Endpoint/Apps.swift @@ -7,7 +7,7 @@ public enum Apps: Endpoint { public func path() -> String { switch self { case .registerApp: - return "apps" + "apps" } } diff --git a/Packages/Network/Sources/Network/Endpoint/Conversations.swift b/Packages/Network/Sources/Network/Endpoint/Conversations.swift index 36820cdd..517090b0 100644 --- a/Packages/Network/Sources/Network/Endpoint/Conversations.swift +++ b/Packages/Network/Sources/Network/Endpoint/Conversations.swift @@ -8,20 +8,20 @@ public enum Conversations: Endpoint { public func path() -> String { switch self { case .conversations: - return "conversations" + "conversations" case let .delete(id): - return "conversations/\(id)" + "conversations/\(id)" case let .read(id): - return "conversations/\(id)/read" + "conversations/\(id)/read" } } public func queryItems() -> [URLQueryItem]? { switch self { case let .conversations(maxId): - return makePaginationParam(sinceId: nil, maxId: maxId, mindId: nil) + makePaginationParam(sinceId: nil, maxId: maxId, mindId: nil) default: - return nil + nil } } } diff --git a/Packages/Network/Sources/Network/Endpoint/CustomEmojis.swift b/Packages/Network/Sources/Network/Endpoint/CustomEmojis.swift index 1889340a..affb75af 100644 --- a/Packages/Network/Sources/Network/Endpoint/CustomEmojis.swift +++ b/Packages/Network/Sources/Network/Endpoint/CustomEmojis.swift @@ -6,7 +6,7 @@ public enum CustomEmojis: Endpoint { public func path() -> String { switch self { case .customEmojis: - return "custom_emojis" + "custom_emojis" } } diff --git a/Packages/Network/Sources/Network/Endpoint/FollowRequests.swift b/Packages/Network/Sources/Network/Endpoint/FollowRequests.swift index a86d174b..f291513e 100644 --- a/Packages/Network/Sources/Network/Endpoint/FollowRequests.swift +++ b/Packages/Network/Sources/Network/Endpoint/FollowRequests.swift @@ -8,11 +8,11 @@ public enum FollowRequests: Endpoint { public func path() -> String { switch self { case .list: - return "follow_requests" + "follow_requests" case let .accept(id): - return "follow_requests/\(id)/authorize" + "follow_requests/\(id)/authorize" case let .reject(id): - return "follow_requests/\(id)/reject" + "follow_requests/\(id)/reject" } } diff --git a/Packages/Network/Sources/Network/Endpoint/Instances.swift b/Packages/Network/Sources/Network/Endpoint/Instances.swift index 879b6147..89d3dba4 100644 --- a/Packages/Network/Sources/Network/Endpoint/Instances.swift +++ b/Packages/Network/Sources/Network/Endpoint/Instances.swift @@ -7,9 +7,9 @@ public enum Instances: Endpoint { public func path() -> String { switch self { case .instance: - return "instance" + "instance" case .peers: - return "instance/peers" + "instance/peers" } } diff --git a/Packages/Network/Sources/Network/Endpoint/Lists.swift b/Packages/Network/Sources/Network/Endpoint/Lists.swift index 477d231e..24bb2f47 100644 --- a/Packages/Network/Sources/Network/Endpoint/Lists.swift +++ b/Packages/Network/Sources/Network/Endpoint/Lists.swift @@ -10,13 +10,13 @@ public enum Lists: Endpoint { public func path() -> String { switch self { case .lists, .createList: - return "lists" + "lists" case let .list(id): - return "lists/\(id)" + "lists/\(id)" case let .accounts(listId): - return "lists/\(listId)/accounts" + "lists/\(listId)/accounts" case let .updateAccounts(listId, _): - return "lists/\(listId)/accounts" + "lists/\(listId)/accounts" } } diff --git a/Packages/Network/Sources/Network/Endpoint/Media.swift b/Packages/Network/Sources/Network/Endpoint/Media.swift index f7ddc32d..b3cb3147 100644 --- a/Packages/Network/Sources/Network/Endpoint/Media.swift +++ b/Packages/Network/Sources/Network/Endpoint/Media.swift @@ -7,22 +7,22 @@ public enum Media: Endpoint { public func path() -> String { switch self { case .medias: - return "media" + "media" case let .media(id, _): - return "media/\(id)" + "media/\(id)" } } public func queryItems() -> [URLQueryItem]? { - return nil + nil } public var jsonValue: Encodable? { switch self { case let .media(_, json): - return json + json default: - return nil + nil } } } diff --git a/Packages/Network/Sources/Network/Endpoint/Notifications.swift b/Packages/Network/Sources/Network/Endpoint/Notifications.swift index 58d8233a..701061d7 100644 --- a/Packages/Network/Sources/Network/Endpoint/Notifications.swift +++ b/Packages/Network/Sources/Network/Endpoint/Notifications.swift @@ -11,11 +11,11 @@ public enum Notifications: Endpoint { public func path() -> String { switch self { case .notifications: - return "notifications" + "notifications" case let .notification(id): - return "notifications/\(id)" + "notifications/\(id)" case .clear: - return "notifications/clear" + "notifications/clear" } } diff --git a/Packages/Network/Sources/Network/Endpoint/Oauth.swift b/Packages/Network/Sources/Network/Endpoint/Oauth.swift index edcc6808..187ff7e2 100644 --- a/Packages/Network/Sources/Network/Endpoint/Oauth.swift +++ b/Packages/Network/Sources/Network/Endpoint/Oauth.swift @@ -8,18 +8,18 @@ public enum Oauth: Endpoint { public func path() -> String { switch self { case .authorize: - return "oauth/authorize" + "oauth/authorize" case .token: - return "oauth/token" + "oauth/token" } } public var jsonValue: Encodable? { switch self { case let .token(code, clientId, clientSecret): - return TokenData(clientId: clientId, clientSecret: clientSecret, code: code) + TokenData(clientId: clientId, clientSecret: clientSecret, code: code) default: - return nil + nil } } diff --git a/Packages/Network/Sources/Network/Endpoint/Polls.swift b/Packages/Network/Sources/Network/Endpoint/Polls.swift index 4925335e..aa1e2c3e 100644 --- a/Packages/Network/Sources/Network/Endpoint/Polls.swift +++ b/Packages/Network/Sources/Network/Endpoint/Polls.swift @@ -7,9 +7,9 @@ public enum Polls: Endpoint { public func path() -> String { switch self { case let .poll(id): - return "polls/\(id)" + "polls/\(id)" case let .vote(id, _): - return "polls/\(id)/votes" + "polls/\(id)/votes" } } diff --git a/Packages/Network/Sources/Network/Endpoint/Push.swift b/Packages/Network/Sources/Network/Endpoint/Push.swift index 23fcf5de..65692a24 100644 --- a/Packages/Network/Sources/Network/Endpoint/Push.swift +++ b/Packages/Network/Sources/Network/Endpoint/Push.swift @@ -15,7 +15,7 @@ public enum Push: Endpoint { public func path() -> String { switch self { case .subscription, .createSub: - return "push/subscription" + "push/subscription" } } diff --git a/Packages/Network/Sources/Network/Endpoint/Search.swift b/Packages/Network/Sources/Network/Endpoint/Search.swift index da70a9ff..c111a3fb 100644 --- a/Packages/Network/Sources/Network/Endpoint/Search.swift +++ b/Packages/Network/Sources/Network/Endpoint/Search.swift @@ -6,7 +6,7 @@ public enum Search: Endpoint { public func path() -> String { switch self { case .search: - return "search" + "search" } } diff --git a/Packages/Network/Sources/Network/Endpoint/ServerFilters.swift b/Packages/Network/Sources/Network/Endpoint/ServerFilters.swift index a18258c7..ec8ca91e 100644 --- a/Packages/Network/Sources/Network/Endpoint/ServerFilters.swift +++ b/Packages/Network/Sources/Network/Endpoint/ServerFilters.swift @@ -12,17 +12,17 @@ public enum ServerFilters: Endpoint { public func path() -> String { switch self { case .filters: - return "filters" + "filters" case .createFilter: - return "filters" + "filters" case let .filter(id): - return "filters/\(id)" + "filters/\(id)" case let .editFilter(id, _): - return "filters/\(id)" + "filters/\(id)" case let .addKeyword(id, _, _): - return "filters/\(id)/keywords" + "filters/\(id)/keywords" case let .removeKeyword(id): - return "filters/keywords/\(id)" + "filters/keywords/\(id)" } } @@ -39,11 +39,11 @@ public enum ServerFilters: Endpoint { public var jsonValue: Encodable? { switch self { case let .createFilter(json): - return json + json case let .editFilter(_, json): - return json + json default: - return nil + nil } } } diff --git a/Packages/Network/Sources/Network/Endpoint/Statuses.swift b/Packages/Network/Sources/Network/Endpoint/Statuses.swift index ce705db6..f651e5c1 100644 --- a/Packages/Network/Sources/Network/Endpoint/Statuses.swift +++ b/Packages/Network/Sources/Network/Endpoint/Statuses.swift @@ -23,39 +23,39 @@ public enum Statuses: Endpoint { public func path() -> String { switch self { case .postStatus: - return "statuses" + "statuses" case let .status(id): - return "statuses/\(id)" + "statuses/\(id)" case let .editStatus(id, _): - return "statuses/\(id)" + "statuses/\(id)" case let .context(id): - return "statuses/\(id)/context" + "statuses/\(id)/context" case let .favorite(id): - return "statuses/\(id)/favourite" + "statuses/\(id)/favourite" case let .unfavorite(id): - return "statuses/\(id)/unfavourite" + "statuses/\(id)/unfavourite" case let .reblog(id): - return "statuses/\(id)/reblog" + "statuses/\(id)/reblog" case let .unreblog(id): - return "statuses/\(id)/unreblog" + "statuses/\(id)/unreblog" case let .rebloggedBy(id, _): - return "statuses/\(id)/reblogged_by" + "statuses/\(id)/reblogged_by" case let .favoritedBy(id, _): - return "statuses/\(id)/favourited_by" + "statuses/\(id)/favourited_by" case let .pin(id): - return "statuses/\(id)/pin" + "statuses/\(id)/pin" case let .unpin(id): - return "statuses/\(id)/unpin" + "statuses/\(id)/unpin" case let .bookmark(id): - return "statuses/\(id)/bookmark" + "statuses/\(id)/bookmark" case let .unbookmark(id): - return "statuses/\(id)/unbookmark" + "statuses/\(id)/unbookmark" case let .history(id): - return "statuses/\(id)/history" + "statuses/\(id)/history" case let .translate(id, _): - return "statuses/\(id)/translate" + "statuses/\(id)/translate" case .report: - return "reports" + "reports" } } @@ -82,11 +82,11 @@ public enum Statuses: Endpoint { public var jsonValue: Encodable? { switch self { case let .postStatus(json): - return json + json case let .editStatus(_, json): - return json + json default: - return nil + nil } } } diff --git a/Packages/Network/Sources/Network/Endpoint/Streaming.swift b/Packages/Network/Sources/Network/Endpoint/Streaming.swift index 791d3407..81e79ff2 100644 --- a/Packages/Network/Sources/Network/Endpoint/Streaming.swift +++ b/Packages/Network/Sources/Network/Endpoint/Streaming.swift @@ -6,14 +6,14 @@ public enum Streaming: Endpoint { public func path() -> String { switch self { case .streaming: - return "streaming" + "streaming" } } public func queryItems() -> [URLQueryItem]? { switch self { default: - return nil + nil } } } diff --git a/Packages/Network/Sources/Network/Endpoint/Tags.swift b/Packages/Network/Sources/Network/Endpoint/Tags.swift index 4e9d2816..b00416d8 100644 --- a/Packages/Network/Sources/Network/Endpoint/Tags.swift +++ b/Packages/Network/Sources/Network/Endpoint/Tags.swift @@ -8,18 +8,18 @@ public enum Tags: Endpoint { public func path() -> String { switch self { case let .tag(id): - return "tags/\(id)/" + "tags/\(id)/" case let .follow(id): - return "tags/\(id)/follow" + "tags/\(id)/follow" case let .unfollow(id): - return "tags/\(id)/unfollow" + "tags/\(id)/unfollow" } } public func queryItems() -> [URLQueryItem]? { switch self { default: - return nil + nil } } } diff --git a/Packages/Network/Sources/Network/Endpoint/Timelines.swift b/Packages/Network/Sources/Network/Endpoint/Timelines.swift index 1e2b8388..c4526b33 100644 --- a/Packages/Network/Sources/Network/Endpoint/Timelines.swift +++ b/Packages/Network/Sources/Network/Endpoint/Timelines.swift @@ -9,13 +9,13 @@ public enum Timelines: Endpoint { public func path() -> String { switch self { case .pub: - return "timelines/public" + "timelines/public" case .home: - return "timelines/home" + "timelines/home" case let .list(listId, _, _, _): - return "timelines/list/\(listId)" + "timelines/list/\(listId)" case let .hashtag(tag, _, _): - return "timelines/tag/\(tag)" + "timelines/tag/\(tag)" } } diff --git a/Packages/Network/Sources/Network/Endpoint/Trends.swift b/Packages/Network/Sources/Network/Endpoint/Trends.swift index 43e3e6bb..3c700442 100644 --- a/Packages/Network/Sources/Network/Endpoint/Trends.swift +++ b/Packages/Network/Sources/Network/Endpoint/Trends.swift @@ -8,11 +8,11 @@ public enum Trends: Endpoint { public func path() -> String { switch self { case .tags: - return "trends/tags" + "trends/tags" case .statuses: - return "trends/statuses" + "trends/statuses" case .links: - return "trends/links" + "trends/links" } } diff --git a/Packages/Network/Sources/Network/OpenAIClient.swift b/Packages/Network/Sources/Network/OpenAIClient.swift index d1074713..00accee3 100644 --- a/Packages/Network/Sources/Network/OpenAIClient.swift +++ b/Packages/Network/Sources/Network/OpenAIClient.swift @@ -62,15 +62,15 @@ public struct OpenAIClient { var request: OpenAIRequest { switch self { case let .correct(input): - return ChatRequest(content: "Fix the spelling and grammar mistakes in the following text: \(input)", temperature: 0.2) + ChatRequest(content: "Fix the spelling and grammar mistakes in the following text: \(input)", temperature: 0.2) case let .addTags(input): - return ChatRequest(content: "Replace relevant words with camel-cased hashtags in the following text. Don't try to search for context or add hashtags if there is not enough context: \(input)", temperature: 0.1) + ChatRequest(content: "Replace relevant words with camel-cased hashtags in the following text. Don't try to search for context or add hashtags if there is not enough context: \(input)", temperature: 0.1) case let .insertTags(input): - return ChatRequest(content: "Return the input with added camel-cased hashtags at the end of the input. Don't try to search for context or add hashtags if there is not enough context: \(input)", temperature: 0.2) + ChatRequest(content: "Return the input with added camel-cased hashtags at the end of the input. Don't try to search for context or add hashtags if there is not enough context: \(input)", temperature: 0.2) case let .shorten(input): - return ChatRequest(content: "Make a shorter version of this text: \(input)", temperature: 0.5) + ChatRequest(content: "Make a shorter version of this text: \(input)", temperature: 0.5) case let .emphasize(input): - return ChatRequest(content: "Make this text catchy, more fun: \(input)", temperature: 1) + ChatRequest(content: "Make this text catchy, more fun: \(input)", temperature: 1) } } } diff --git a/Packages/Network/Sources/Network/String.swift b/Packages/Network/Sources/Network/String.swift index 4c72e2e0..78508528 100644 --- a/Packages/Network/Sources/Network/String.swift +++ b/Packages/Network/Sources/Network/String.swift @@ -2,7 +2,7 @@ import Foundation public extension String { func escape() -> String { - return replacingOccurrences(of: "&", with: "&") + replacingOccurrences(of: "&", with: "&") .replacingOccurrences(of: "<", with: "<") .replacingOccurrences(of: ">", with: ">") .replacingOccurrences(of: """, with: "\"") diff --git a/Packages/Network/Sources/Network/URLData.swift b/Packages/Network/Sources/Network/URLData.swift index 1ff0204b..61783a7e 100644 --- a/Packages/Network/Sources/Network/URLData.swift +++ b/Packages/Network/Sources/Network/URLData.swift @@ -2,7 +2,7 @@ import Foundation extension Data { func base64UrlEncodedString() -> String { - return base64EncodedString() + base64EncodedString() .replacingOccurrences(of: "+", with: "-") .replacingOccurrences(of: "/", with: "_") .replacingOccurrences(of: "=", with: "") diff --git a/Packages/Notifications/Package.swift b/Packages/Notifications/Package.swift index 412e4751..28f95a38 100644 --- a/Packages/Notifications/Package.swift +++ b/Packages/Notifications/Package.swift @@ -33,7 +33,7 @@ let package = Package( .product(name: "DesignSystem", package: "DesignSystem"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), ] diff --git a/Packages/Notifications/Sources/Notifications/ConsolidatedNotificationExt.swift b/Packages/Notifications/Sources/Notifications/ConsolidatedNotificationExt.swift index fa91668c..57604436 100644 --- a/Packages/Notifications/Sources/Notifications/ConsolidatedNotificationExt.swift +++ b/Packages/Notifications/Sources/Notifications/ConsolidatedNotificationExt.swift @@ -11,7 +11,7 @@ extension ConsolidatedNotification { var notificationIds: [String] { notifications.map(\.id) } } -extension Array where Element == ConsolidatedNotification { +extension [ConsolidatedNotification] { var notificationCount: Int { reduce(0) { $0 + ($1.accounts.isEmpty ? 1 : $1.accounts.count) } } diff --git a/Packages/Notifications/Sources/Notifications/Notification+Consolidated.swift b/Packages/Notifications/Sources/Notifications/Notification+Consolidated.swift index c8f60477..8b1b6320 100644 --- a/Packages/Notifications/Sources/Notifications/Notification+Consolidated.swift +++ b/Packages/Notifications/Sources/Notifications/Notification+Consolidated.swift @@ -8,7 +8,7 @@ import Foundation import Models -extension Array where Element == Models.Notification { +extension [Models.Notification] { func consolidated(selectedType: Models.Notification.NotificationType?) async -> [ConsolidatedNotification] { await withCheckedContinuation { result in DispatchQueue.global().async { diff --git a/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift b/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift index 9aded4aa..ea8ea745 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift @@ -6,42 +6,42 @@ extension Models.Notification.NotificationType { public func label(count: Int) -> LocalizedStringKey { switch self { case .status: - return "notifications.label.status" + "notifications.label.status" case .mention: - return "" + "" case .reblog: - return "notifications.label.reblog \(count)" + "notifications.label.reblog \(count)" case .follow: - return "notifications.label.follow \(count)" + "notifications.label.follow \(count)" case .follow_request: - return "notifications.label.follow-request" + "notifications.label.follow-request" case .favourite: - return "notifications.label.favorite \(count)" + "notifications.label.favorite \(count)" case .poll: - return "notifications.label.poll" + "notifications.label.poll" case .update: - return "notifications.label.update" + "notifications.label.update" } } public func notificationKey() -> String { switch self { case .status: - return "notifications.label.status.push" + "notifications.label.status.push" case .mention: - return "" + "" case .reblog: - return "notifications.label.reblog.push" + "notifications.label.reblog.push" case .follow: - return "notifications.label.follow.push" + "notifications.label.follow.push" case .follow_request: - return "notifications.label.follow-request.push" + "notifications.label.follow-request.push" case .favourite: - return "notifications.label.favorite.push" + "notifications.label.favorite.push" case .poll: - return "notifications.label.poll.push" + "notifications.label.poll.push" case .update: - return "notifications.label.update.push" + "notifications.label.update.push" } } @@ -86,21 +86,21 @@ extension Models.Notification.NotificationType { func menuTitle() -> LocalizedStringKey { switch self { case .status: - return "notifications.menu-title.status" + "notifications.menu-title.status" case .mention: - return "notifications.menu-title.mention" + "notifications.menu-title.mention" case .reblog: - return "notifications.menu-title.reblog" + "notifications.menu-title.reblog" case .follow: - return "notifications.menu-title.follow" + "notifications.menu-title.follow" case .follow_request: - return "notifications.menu-title.follow-request" + "notifications.menu-title.follow-request" case .favourite: - return "notifications.menu-title.favorite" + "notifications.menu-title.favorite" case .poll: - return "notifications.menu-title.poll" + "notifications.menu-title.poll" case .update: - return "notifications.menu-title.update" + "notifications.menu-title.update" } } } diff --git a/Packages/Notifications/Sources/Notifications/NotificationsViewModel.swift b/Packages/Notifications/Sources/Notifications/NotificationsViewModel.swift index aea80cd0..f6fcca88 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationsViewModel.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationsViewModel.swift @@ -51,7 +51,7 @@ class NotificationsViewModel: ObservableObject { if let selectedType { var excludedTypes = Models.Notification.NotificationType.allCases excludedTypes.removeAll(where: { $0 == selectedType }) - return excludedTypes.map { $0.rawValue } + return excludedTypes.map(\.rawValue) } return nil } diff --git a/Packages/Status/Package.swift b/Packages/Status/Package.swift index 6db87408..0673ce45 100644 --- a/Packages/Status/Package.swift +++ b/Packages/Status/Package.swift @@ -33,7 +33,7 @@ let package = Package( .product(name: "DesignSystem", package: "DesignSystem"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), ] diff --git a/Packages/Status/Sources/Status/Detail/StatusDetailView.swift b/Packages/Status/Sources/Status/Detail/StatusDetailView.swift index e566cb66..5baf2b0b 100644 --- a/Packages/Status/Sources/Status/Detail/StatusDetailView.swift +++ b/Packages/Status/Sources/Status/Detail/StatusDetailView.swift @@ -161,7 +161,7 @@ public struct StatusDetailView: View { .id(status.id) // VoiceOver / Switch Control focus workaround .onAppear { - self.initialFocusBugWorkaround = true + initialFocusBugWorkaround = true } } diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAIPrompt.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAIPrompt.swift index 37783272..7a8d4800 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAIPrompt.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAIPrompt.swift @@ -24,15 +24,15 @@ enum StatusEditorAIPrompt: CaseIterable { func toRequestPrompt(text: String) -> OpenAIClient.Prompt { switch self { case .correct: - return .correct(input: text) + .correct(input: text) case .addTags: - return .addTags(input: text) + .addTags(input: text) case .insertTags: - return .insertTags(input: text) + .insertTags(input: text) case .fit: - return .shorten(input: text) + .shorten(input: text) case .emphasize: - return .emphasize(input: text) + .emphasize(input: text) } } } diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift index c99ecf88..b7e97738 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift @@ -162,7 +162,7 @@ struct StatusEditorAccessoryView: View { @ViewBuilder private func languageTextView(isoCode: String, nativeName: String?, name: String?) -> some View { - if let nativeName = nativeName, let name = name { + if let nativeName, let name { Text("\(nativeName) (\(name))") } else { Text(isoCode.uppercased()) diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorCompressor.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorCompressor.swift index e0a30457..d8f1e79b 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorCompressor.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorCompressor.swift @@ -8,7 +8,7 @@ actor StatusEditorCompressor { } func compressImageFrom(url: URL) async -> Data? { - return await withCheckedContinuation { continuation in + await withCheckedContinuation { continuation in let sourceOptions = [kCGImageSourceShouldCache: false] as CFDictionary guard let source = CGImageSourceCreateWithURL(url as CFURL, sourceOptions) else { continuation.resume(returning: nil) diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaEditView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaEditView.swift index 363b8c2d..5e626f13 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaEditView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaEditView.swift @@ -66,7 +66,7 @@ struct StatusEditorMediaEditView: View { Button { if !imageDescription.isEmpty { isUpdating = true - if currentInstance.isEditAltTextSupported && viewModel.mode.isEditing { + if currentInstance.isEditAltTextSupported, viewModel.mode.isEditing { Task { await viewModel.editDescription(container: container, description: imageDescription) dismiss() diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorUTTypeSupported.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorUTTypeSupported.swift index f10b3574..15b4953c 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorUTTypeSupported.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorUTTypeSupported.swift @@ -43,18 +43,18 @@ enum StatusEditorUTTypeSupported: String, CaseIterable { var isVideo: Bool { switch self { case .video, .movie, .mp4, .quickTimeMovie: - return true + true default: - return false + false } } var isGif: Bool { switch self { case .gif, .gif2: - return true + true default: - return false + false } } @@ -100,7 +100,7 @@ enum StatusEditorUTTypeSupported: String, CaseIterable { } private func getVideoTransferable(item: NSItemProvider) async -> MovieFileTranseferable? { - return await withCheckedContinuation { continuation in + await withCheckedContinuation { continuation in _ = item.loadTransferable(type: MovieFileTranseferable.self) { result in switch result { case let .success(success): @@ -113,7 +113,7 @@ enum StatusEditorUTTypeSupported: String, CaseIterable { } private func getGifTransferable(item: NSItemProvider) async -> GifFileTranseferable? { - return await withCheckedContinuation { continuation in + await withCheckedContinuation { continuation in _ = item.loadTransferable(type: GifFileTranseferable.self) { result in switch result { case let .success(success): @@ -126,7 +126,7 @@ enum StatusEditorUTTypeSupported: String, CaseIterable { } private func getImageTansferable(item: NSItemProvider) async -> ImageFileTranseferable? { - return await withCheckedContinuation { continuation in + await withCheckedContinuation { continuation in _ = item.loadTransferable(type: ImageFileTranseferable.self) { result in switch result { case let .success(success): diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift index b2c0c5ac..de87f289 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift @@ -157,7 +157,7 @@ public class StatusEditorViewModel: NSObject, ObservableObject { func evaluateLanguages() { if let detectedLang = detectLanguage(text: statusText.string), - let selectedLanguage = selectedLanguage, + let selectedLanguage, selectedLanguage != "", selectedLanguage != detectedLang { @@ -311,14 +311,14 @@ public class StatusEditorViewModel: NSObject, ObservableObject { let range = NSMakeRange(0, statusText.string.utf16.count) var ranges = hashtagRegex.matches(in: statusText.string, options: [], - range: range).map { $0.range } + range: range).map(\.range) ranges.append(contentsOf: mentionRegex.matches(in: statusText.string, options: [], - range: range).map { $0.range }) + range: range).map(\.range)) let urlRanges = urlRegex.matches(in: statusText.string, options: [], - range: range).map { $0.range } + range: range).map(\.range) var foundSuggestionRange = false for nsRange in ranges { diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorViewModelMode.swift b/Packages/Status/Sources/Status/Editor/StatusEditorViewModelMode.swift index 5d5ed687..e14e0955 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorViewModelMode.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorViewModelMode.swift @@ -14,40 +14,40 @@ public extension StatusEditorViewModel { var isInShareExtension: Bool { switch self { case .shareExtension: - return true + true default: - return false + false } } var isEditing: Bool { switch self { case .edit: - return true + true default: - return false + false } } var replyToStatus: Status? { switch self { case let .replyTo(status): - return status + status default: - return nil + nil } } var title: LocalizedStringKey { switch self { case .new, .mention, .shareExtension: - return "status.editor.mode.new" + "status.editor.mode.new" case .edit: - return "status.editor.mode.edit" + "status.editor.mode.edit" case let .replyTo(status): - return "status.editor.mode.reply-\(status.reblog?.account.displayNameWithoutEmojis ?? status.account.displayNameWithoutEmojis)" + "status.editor.mode.reply-\(status.reblog?.account.displayNameWithoutEmojis ?? status.account.displayNameWithoutEmojis)" case let .quote(status): - return "status.editor.mode.quote-\(status.reblog?.account.displayNameWithoutEmojis ?? status.account.displayNameWithoutEmojis)" + "status.editor.mode.quote-\(status.reblog?.account.displayNameWithoutEmojis ?? status.account.displayNameWithoutEmojis)" } } } diff --git a/Packages/Status/Sources/Status/Editor/UITextView/Coordinator.swift b/Packages/Status/Sources/Status/Editor/UITextView/Coordinator.swift index 75beaecb..a625b78e 100644 --- a/Packages/Status/Sources/Status/Editor/UITextView/Coordinator.swift +++ b/Packages/Status/Sources/Status/Editor/UITextView/Coordinator.swift @@ -3,7 +3,7 @@ import SwiftUI extension TextView.Representable { final class Coordinator: NSObject, UITextViewDelegate { - internal let textView: UIKitTextView + let textView: UIKitTextView private var originalText: NSMutableAttributedString = .init() private var text: Binding @@ -64,7 +64,7 @@ extension TextView.Representable { } func textView(_: UITextView, shouldChangeTextIn _: NSRange, replacementText _: String) -> Bool { - return true + true } } } diff --git a/Packages/Status/Sources/Status/Editor/UITextView/Modifiers.swift b/Packages/Status/Sources/Status/Editor/UITextView/Modifiers.swift index 270f9cce..65ac313e 100644 --- a/Packages/Status/Sources/Status/Editor/UITextView/Modifiers.swift +++ b/Packages/Status/Sources/Status/Editor/UITextView/Modifiers.swift @@ -15,7 +15,7 @@ public extension TextView { /// .placeholder("placeholder") { view in /// view.foregroundColor(.red) /// } - func placeholder(_ placeholder: String, _ configure: (Text) -> V) -> TextView { + func placeholder(_ placeholder: String, _ configure: (Text) -> some View) -> TextView { var view = self let text = Text(placeholder) view.placeholderView = AnyView(configure(text)) @@ -24,7 +24,7 @@ public extension TextView { } /// Specify a custom placeholder view - func placeholder(_ placeholder: V) -> TextView { + func placeholder(_ placeholder: some View) -> TextView { var view = self view.placeholderView = AnyView(placeholder) return view diff --git a/Packages/Status/Sources/Status/Editor/UITextView/TextView.swift b/Packages/Status/Sources/Status/Editor/UITextView/TextView.swift index 3f3154eb..ef76e7f1 100644 --- a/Packages/Status/Sources/Status/Editor/UITextView/TextView.swift +++ b/Packages/Status/Sources/Status/Editor/UITextView/TextView.swift @@ -59,7 +59,7 @@ public struct TextView: View { final class UIKitTextView: UITextView { override var keyCommands: [UIKeyCommand]? { - return (super.keyCommands ?? []) + [ + (super.keyCommands ?? []) + [ UIKeyCommand(input: UIKeyCommand.inputEscape, modifierFlags: [], action: #selector(escape(_:))), ] } diff --git a/Packages/Status/Sources/Status/Ext/Visibility.swift b/Packages/Status/Sources/Status/Ext/Visibility.swift index b9111535..e6abcd3b 100644 --- a/Packages/Status/Sources/Status/Ext/Visibility.swift +++ b/Packages/Status/Sources/Status/Ext/Visibility.swift @@ -9,26 +9,26 @@ public extension Models.Visibility { var iconName: String { switch self { case .pub: - return "globe.americas" + "globe.americas" case .unlisted: - return "lock.open" + "lock.open" case .priv: - return "lock" + "lock" case .direct: - return "tray.full" + "tray.full" } } var title: LocalizedStringKey { switch self { case .pub: - return "status.visibility.public" + "status.visibility.public" case .unlisted: - return "status.visibility.unlisted" + "status.visibility.unlisted" case .priv: - return "status.visibility.follower" + "status.visibility.follower" case .direct: - return "status.visibility.direct" + "status.visibility.direct" } } } diff --git a/Packages/Status/Sources/Status/Media/VideoPlayerView.swift b/Packages/Status/Sources/Status/Media/VideoPlayerView.swift index 8eb250ea..e8943440 100644 --- a/Packages/Status/Sources/Status/Media/VideoPlayerView.swift +++ b/Packages/Status/Sources/Status/Media/VideoPlayerView.swift @@ -32,7 +32,6 @@ class VideoPlayerViewModel: ObservableObject { } } } - func pause() { player?.pause() diff --git a/Packages/Status/Sources/Status/Poll/StatusPollView.swift b/Packages/Status/Sources/Status/Poll/StatusPollView.swift index afe7d8aa..3c85f492 100644 --- a/Packages/Status/Sources/Status/Poll/StatusPollView.swift +++ b/Packages/Status/Sources/Status/Poll/StatusPollView.swift @@ -34,9 +34,9 @@ public struct StatusPollView: View { private func ratioForOption(option: Poll.Option) -> CGFloat { if let votesCount = option.votesCount, viewModel.poll.safeVotersCount != 0 { - return CGFloat(votesCount) / CGFloat(viewModel.poll.safeVotersCount) + CGFloat(votesCount) / CGFloat(viewModel.poll.safeVotersCount) } else { - return 0.0 + 0.0 } } diff --git a/Packages/Status/Sources/Status/Row/StatusActionButtonStyle.swift b/Packages/Status/Sources/Status/Row/StatusActionButtonStyle.swift index 4725e730..003c0b18 100644 --- a/Packages/Status/Sources/Status/Row/StatusActionButtonStyle.swift +++ b/Packages/Status/Sources/Status/Row/StatusActionButtonStyle.swift @@ -29,7 +29,7 @@ struct StatusActionButtonStyle: ButtonStyle { } } .onChange(of: configuration.isPressed) { isPressed in - guard tintColor != nil && !isPressed && !isOn else { return } + guard tintColor != nil, !isPressed, !isOn else { return } withAnimation(.spring(response: 1, dampingFraction: 1)) { sparklesCounter += 1 @@ -39,9 +39,9 @@ struct StatusActionButtonStyle: ButtonStyle { func brightness(configuration: Configuration) -> Double { switch (configuration.isPressed, isOn) { - case (true, true): return 0.6 - case (true, false): return 0.2 - default: return 0 + case (true, true): 0.6 + case (true, false): 0.2 + default: 0 } } @@ -120,7 +120,7 @@ struct StatusActionButtonStyle: ButtonStyle { } static func deg2rad(_ number: Double) -> Double { - return number * .pi / 180 + number * .pi / 180 } } } diff --git a/Packages/Status/Sources/Status/Row/StatusRowView.swift b/Packages/Status/Sources/Status/Row/StatusRowView.swift index c6ed8f3e..9ebcdad4 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowView.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowView.swift @@ -188,7 +188,7 @@ public struct StatusRowView: View { HapticManager.shared.fireHaptic(of: .notification(.success)) Task { let attachments = viewModel.finalStatus.mediaAttachments - await quickLook.prepareFor(urls: attachments.compactMap { $0.url }, selectedURL: attachments[0].url!) + await quickLook.prepareFor(urls: attachments.compactMap(\.url), selectedURL: attachments[0].url!) } } } @@ -300,12 +300,12 @@ private struct CombinedAccessibilityLabel { if let filter { switch filter.filterAction { case .warn: - return Text("status.filter.filtered-by-\(filter.title)") + Text("status.filter.filtered-by-\(filter.title)") case .hide: - return Text("") + Text("") } } else { - return userNamePreamble() + + userNamePreamble() + Text(hasSpoiler ? viewModel.finalStatus.spoilerText.asRawText : viewModel.finalStatus.content.asRawText @@ -326,11 +326,11 @@ private struct CombinedAccessibilityLabel { func userNamePreamble() -> Text { switch (isReply, isBoost) { case (true, false): - return Text("accessibility.status.a-replied-to-\(finalUserDisplayName())") + Text(" ") + Text("accessibility.status.a-replied-to-\(finalUserDisplayName())") + Text(" ") case (_, true): - return Text("accessibility.status.a-boosted-b-\(userDisplayName())-\(finalUserDisplayName())") + Text(", ") + Text("accessibility.status.a-boosted-b-\(userDisplayName())-\(finalUserDisplayName())") + Text(", ") default: - return Text(userDisplayName()) + Text(", ") + Text(userDisplayName()) + Text(", ") } } diff --git a/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift b/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift index fc1f52da..f8420e63 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift @@ -88,11 +88,11 @@ public class StatusRowViewModel: ObservableObject { var highlightRowColor: Color { if status.visibility == .direct { - return theme.tintColor.opacity(0.15) + theme.tintColor.opacity(0.15) } else if userMentionned { - return theme.secondaryBackgroundColor + theme.secondaryBackgroundColor } else { - return theme.primaryBackgroundColor + theme.primaryBackgroundColor } } @@ -147,10 +147,10 @@ public class StatusRowViewModel: ObservableObject { func markSeen() { // called in on appear so we can cache that the status has been seen. - if UserPreferences.shared.suppressDupeReblogs && !seen { + if UserPreferences.shared.suppressDupeReblogs, !seen { DispatchQueue.global().async { [weak self] in guard let self else { return } - ReblogCache.shared.cache(self.status, seen: true) + ReblogCache.shared.cache(status, seen: true) Task { @MainActor in self.seen = true } diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowActionsView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowActionsView.swift index 1c64962a..a904ebee 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowActionsView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowActionsView.swift @@ -12,7 +12,7 @@ struct StatusRowActionsView: View { @ObservedObject var viewModel: StatusRowViewModel func privateBoost() -> Bool { - return viewModel.status.visibility == .priv && viewModel.status.account.id == currentAccount.account?.id + viewModel.status.visibility == .priv && viewModel.status.account.id == currentAccount.account?.id } @MainActor @@ -76,7 +76,7 @@ struct StatusRowActionsView: View { } func count(dataController: StatusDataController, viewModel: StatusRowViewModel, theme: Theme) -> Int? { - if theme.statusActionsDisplay == .discret && !viewModel.isFocused { + if theme.statusActionsDisplay == .discret, !viewModel.isFocused { return nil } switch self { @@ -94,22 +94,22 @@ struct StatusRowActionsView: View { func tintColor(theme: Theme) -> Color? { switch self { case .respond, .share: - return nil + nil case .favorite: - return .yellow + .yellow case .bookmark: - return .pink + .pink case .boost: - return theme.tintColor + theme.tintColor } } func isOn(dataController: StatusDataController) -> Bool { switch self { - case .respond, .share: return false - case .favorite: return dataController.isFavorited - case .bookmark: return dataController.isBookmarked - case .boost: return dataController.isReblogged + case .respond, .share: false + case .favorite: dataController.isFavorited + case .bookmark: dataController.isBookmarked + case .boost: dataController.isReblogged } } } diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift index f929ec4d..c877fdd8 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift @@ -17,14 +17,14 @@ struct StatusRowContextMenu: View { @ObservedObject var viewModel: StatusRowViewModel var boostLabel: some View { - if self.viewModel.status.visibility == .priv && self.viewModel.status.account.id == self.account.account?.id { - if self.statusDataController.isReblogged { + if viewModel.status.visibility == .priv, viewModel.status.account.id == account.account?.id { + if statusDataController.isReblogged { return Label("status.action.unboost", systemImage: "lock.rotation") } return Label("status.action.boost-to-followers", systemImage: "lock.rotation") } - if self.statusDataController.isReblogged { + if statusDataController.isReblogged { return Label("status.action.unboost", image: "Rocket") } return Label("status.action.boost", image: "Rocket") @@ -262,7 +262,7 @@ struct ActivityView: UIViewControllerRepresentable { let image: Image func makeUIViewController(context _: UIViewControllerRepresentableContext) -> UIActivityViewController { - return UIActivityViewController(activityItems: [image], applicationActivities: nil) + UIActivityViewController(activityItems: [image], applicationActivities: nil) } func updateUIViewController(_: UIActivityViewController, context _: UIViewControllerRepresentableContext) {} diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift index d04e3ee3..7b0dacc0 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift @@ -87,7 +87,7 @@ public struct StatusRowMediaPreviewView: View { makeFeaturedImagePreview(attachment: attachment) .onTapGesture { Task { - await quickLook.prepareFor(urls: attachments.compactMap { $0.url }, selectedURL: attachment.url!) + await quickLook.prepareFor(urls: attachments.compactMap(\.url), selectedURL: attachment.url!) } } .accessibilityElement(children: .ignore) @@ -134,7 +134,7 @@ public struct StatusRowMediaPreviewView: View { Text(altTextDisplayed ?? "") } .onAppear { - if sensitive && preferences.autoExpandMedia == .hideSensitive { + if sensitive, preferences.autoExpandMedia == .hideSensitive { isHidingMedia = true } else if preferences.autoExpandMedia == .hideAll { isHidingMedia = true @@ -278,7 +278,7 @@ public struct StatusRowMediaPreviewView: View { .contentShape(Rectangle()) .onTapGesture { Task { - await quickLook.prepareFor(urls: attachments.compactMap { $0.url }, selectedURL: attachment.url!) + await quickLook.prepareFor(urls: attachments.compactMap(\.url), selectedURL: attachment.url!) } } .accessibilityElement(children: .ignore) @@ -345,11 +345,11 @@ public struct StatusRowMediaPreviewView: View { private static func accessibilityLabel(for attachment: MediaAttachment) -> Text { if let altText = attachment.description { - return Text("accessibility.image.alt-text-\(altText)") + Text("accessibility.image.alt-text-\(altText)") } else if let typeDescription = attachment.localizedTypeDescription { - return Text(typeDescription) + Text(typeDescription) } else { - return Text("accessibility.tabs.profile.picker.media") + Text("accessibility.tabs.profile.picker.media") } } } diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowSwipeView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowSwipeView.swift index 0590c98d..b2185529 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowSwipeView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowSwipeView.swift @@ -14,7 +14,7 @@ struct StatusRowSwipeView: View { } func privateBoost() -> Bool { - return viewModel.status.visibility == .priv && viewModel.status.account.id == currentAccount.account?.id + viewModel.status.visibility == .priv && viewModel.status.account.id == currentAccount.account?.id } @ObservedObject var viewModel: StatusRowViewModel @@ -60,7 +60,7 @@ struct StatusRowSwipeView: View { makeSwipeButtonForRouterPath(action: action, destination: .replyToStatusEditor(status: viewModel.status)) case .quote: makeSwipeButtonForRouterPath(action: action, destination: .quoteStatusEditor(status: viewModel.status)) - .disabled(viewModel.status.visibility == .direct || viewModel.status.visibility == .priv) + .disabled(viewModel.status.visibility == .direct || viewModel.status.visibility == .priv) case .favorite: makeSwipeButtonForTask(action: action) { await statusDataController.toggleFavorite(remoteStatus: nil) diff --git a/Packages/Timeline/Package.swift b/Packages/Timeline/Package.swift index c621f4da..fe24615e 100644 --- a/Packages/Timeline/Package.swift +++ b/Packages/Timeline/Package.swift @@ -37,7 +37,7 @@ let package = Package( .product(name: "Bodega", package: "Bodega"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") + .enableExperimentalFeature("StrictConcurrency"), ] ), .testTarget( diff --git a/Packages/Timeline/Sources/Timeline/TimelineFilter.swift b/Packages/Timeline/Sources/Timeline/TimelineFilter.swift index 06fe5a47..a2763722 100644 --- a/Packages/Timeline/Sources/Timeline/TimelineFilter.swift +++ b/Packages/Timeline/Sources/Timeline/TimelineFilter.swift @@ -9,22 +9,22 @@ public enum RemoteTimelineFilter: String, CaseIterable, Hashable, Equatable { public func localizedTitle() -> LocalizedStringKey { switch self { case .federated: - return "timeline.federated" + "timeline.federated" case .local: - return "timeline.local" + "timeline.local" case .trending: - return "timeline.trending" + "timeline.trending" } } public func iconName() -> String { switch self { case .federated: - return "globe.americas" + "globe.americas" case .local: - return "person.2" + "person.2" case .trending: - return "chart.line.uptrend.xyaxis" + "chart.line.uptrend.xyaxis" } } } @@ -51,106 +51,106 @@ public enum TimelineFilter: Hashable, Equatable { public var supportNewestPagination: Bool { switch self { case .trending: - return false + false case let .remoteLocal(_, filter): - return filter != .trending + filter != .trending default: - return true + true } } public var title: String { switch self { case .latest: - return "Latest" + "Latest" case .federated: - return "Federated" + "Federated" case .local: - return "Local" + "Local" case .trending: - return "Trending" + "Trending" case .home: - return "Home" + "Home" case let .hashtag(tag, _): - return "#\(tag)" + "#\(tag)" case let .tagGroup(group): - return group.title + group.title case let .list(list): - return list.title + list.title case let .remoteLocal(server, _): - return server + server } } public func localizedTitle() -> LocalizedStringKey { switch self { case .latest: - return "timeline.latest" + "timeline.latest" case .federated: - return "timeline.federated" + "timeline.federated" case .local: - return "timeline.local" + "timeline.local" case .trending: - return "timeline.trending" + "timeline.trending" case .home: - return "timeline.home" + "timeline.home" case let .hashtag(tag, _): - return "#\(tag)" + "#\(tag)" case let .tagGroup(group): - return LocalizedStringKey(group.title) // ?? not sure since this can't be localized. + LocalizedStringKey(group.title) // ?? not sure since this can't be localized. case let .list(list): - return LocalizedStringKey(list.title) + LocalizedStringKey(list.title) case let .remoteLocal(server, _): - return LocalizedStringKey(server) + LocalizedStringKey(server) } } public func iconName() -> String? { switch self { case .latest: - return "arrow.counterclockwise" + "arrow.counterclockwise" case .federated: - return "globe.americas" + "globe.americas" case .local: - return "person.2" + "person.2" case .trending: - return "chart.line.uptrend.xyaxis" + "chart.line.uptrend.xyaxis" case .home: - return "house" + "house" case .list: - return "list.bullet" + "list.bullet" case .remoteLocal: - return "dot.radiowaves.right" + "dot.radiowaves.right" default: - return nil + nil } } public func endpoint(sinceId: String?, maxId: String?, minId: String?, offset: Int?) -> Endpoint { switch self { - case .federated: return Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: false) - case .local: return Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: true) + case .federated: Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: false) + case .local: Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: true) case let .remoteLocal(_, filter): switch filter { case .local: - return Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: true) + Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: true) case .federated: - return Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: false) + Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: false) case .trending: - return Trends.statuses(offset: offset) + Trends.statuses(offset: offset) } - case .latest: return Timelines.home(sinceId: nil, maxId: nil, minId: nil) - case .home: return Timelines.home(sinceId: sinceId, maxId: maxId, minId: minId) - case .trending: return Trends.statuses(offset: offset) - case let .list(list): return Timelines.list(listId: list.id, sinceId: sinceId, maxId: maxId, minId: minId) + case .latest: Timelines.home(sinceId: nil, maxId: nil, minId: nil) + case .home: Timelines.home(sinceId: sinceId, maxId: maxId, minId: minId) + case .trending: Trends.statuses(offset: offset) + case let .list(list): Timelines.list(listId: list.id, sinceId: sinceId, maxId: maxId, minId: minId) case let .hashtag(tag, accountId): if let accountId { - return Accounts.statuses(id: accountId, sinceId: nil, tag: tag, onlyMedia: nil, excludeReplies: nil, pinned: nil) + Accounts.statuses(id: accountId, sinceId: nil, tag: tag, onlyMedia: nil, excludeReplies: nil, pinned: nil) } else { - return Timelines.hashtag(tag: tag, additional: nil, maxId: maxId) + Timelines.hashtag(tag: tag, additional: nil, maxId: maxId) } case let .tagGroup(group): - return Timelines.hashtag(tag: group.main, additional: group.additional, maxId: maxId) + Timelines.hashtag(tag: group.main, additional: group.additional, maxId: maxId) } } } diff --git a/Packages/Timeline/Sources/Timeline/TimelineView.swift b/Packages/Timeline/Sources/Timeline/TimelineView.swift index 9f1023f8..36bfed27 100644 --- a/Packages/Timeline/Sources/Timeline/TimelineView.swift +++ b/Packages/Timeline/Sources/Timeline/TimelineView.swift @@ -62,9 +62,9 @@ public struct TimelineView: View { DispatchQueue.main.async { self.collectionView = collectionView } - self.prefetcher.viewModel = viewModel + prefetcher.viewModel = viewModel collectionView.isPrefetchingEnabled = true - collectionView.prefetchDataSource = self.prefetcher + collectionView.prefetchDataSource = prefetcher } if viewModel.timeline.supportNewestPagination { PendingStatusesObserverView(observer: viewModel.pendingStatusesObserver) diff --git a/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift b/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift index da35bfd6..9092fda9 100644 --- a/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift +++ b/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift @@ -250,7 +250,7 @@ extension TimelineViewModel: StatusesFetcher { var newStatuses: [Status] = await fetchNewPages(minId: latestStatus.id, maxPages: 10) // Dedup statuses, a status with the same id could have been streamed in. - let ids = await datasource.get().map { $0.id } + let ids = await datasource.get().map(\.id) newStatuses = newStatuses.filter { status in !ids.contains(where: { $0 == status.id }) } @@ -292,7 +292,7 @@ extension TimelineViewModel: StatusesFetcher { await cacheHome() // Append new statuses in the timeline indicator. - pendingStatusesObserver.pendingStatuses.insert(contentsOf: newStatuses.map { $0.id }, at: 0) + pendingStatusesObserver.pendingStatuses.insert(contentsOf: newStatuses.map(\.id), at: 0) // High chance the user is scrolled to the top. // We need to update the statuses state, and then scroll to the previous top most status.