diff --git a/Mlem/Enums/Settings/PostSortType.swift b/Mlem/Enums/Settings/PostSortType.swift index a8aa7fae1..480961317 100644 --- a/Mlem/Enums/Settings/PostSortType.swift +++ b/Mlem/Enums/Settings/PostSortType.swift @@ -85,9 +85,9 @@ enum PostSortType: String, Codable, CaseIterable, Identifiable { case .topHour: return "Top of the last hour" case .topSixHour: - return "Top of the last six hours" + return "Top of the last 6 hours" case .topTwelveHour: - return "Top of the last twelve hours" + return "Top of the last 12 hours" case .topDay: return "Top of today" case .topWeek: @@ -164,9 +164,9 @@ extension PostSortType: SettingsOptions { case .topHour: return "Hour" case .topSixHour: - return "Six Hours" + return "6 Hours" case .topTwelveHour: - return "Twelve Hours" + return "12 Hours" case .topDay: return "Day" case .topWeek: diff --git a/Mlem/Logic/URLHandler.swift b/Mlem/Logic/URLHandler.swift index 30f8b0107..7b7f9a037 100644 --- a/Mlem/Logic/URLHandler.swift +++ b/Mlem/Logic/URLHandler.swift @@ -30,10 +30,14 @@ class URLHandler { guard let scheme = url.scheme, scheme.hasPrefix("http") else { return .init(result: .systemAction, action: .error("This type of link is not currently supported 😞")) } - - Task { @MainActor in - let viewController = SFSafariViewController(url: url, configuration: .default) - UIApplication.shared.firstKeyWindow?.rootViewController?.topMostViewController().present(viewController, animated: true) + let openLinksInBrowser = UserDefaults.standard.bool(forKey: "openLinksInBrowser") + if openLinksInBrowser { + UIApplication.shared.open(url) + } else { + Task { @MainActor in + let viewController = SFSafariViewController(url: url, configuration: .default) + UIApplication.shared.firstKeyWindow?.rootViewController?.topMostViewController().present(viewController, animated: true) + } } return .init(result: .handled, action: nil) diff --git a/Mlem/Models/Content/Community/CommunityModel.swift b/Mlem/Models/Content/Community/CommunityModel.swift index 256e2fd73..8066a62d9 100644 --- a/Mlem/Models/Content/Community/CommunityModel.swift +++ b/Mlem/Models/Content/Community/CommunityModel.swift @@ -185,24 +185,24 @@ struct CommunityModel { func toggleFavorite(_ callback: @escaping (_ item: Self) -> Void = { _ in }) async throws { var new = self new.favorited.toggle() - if favorited { - favoriteCommunitiesTracker.unfavorite(community) - } else { - favoriteCommunitiesTracker.favorite(community) + if new.favorited { + favoriteCommunitiesTracker.favorite(self.community) if let subscribed, !subscribed { - try await self.toggleSubscribe { [self] community in + try await new.toggleSubscribe { community in var community = community if !(community.subscribed ?? true) { print("Subscribe failed, unfavoriting...") community.favorited = false - favoriteCommunitiesTracker.unfavorite(self.community) + favoriteCommunitiesTracker.unfavorite(community.community) } - callback(new) + callback(community) } } - } - RunLoop.main.perform { [new] in - callback(new) + } else { + favoriteCommunitiesTracker.unfavorite(community) + RunLoop.main.perform { [new] in + callback(new) + } } } diff --git a/Mlem/Views/Shared/Comments/Comment Item Logic.swift b/Mlem/Views/Shared/Comments/Comment Item Logic.swift index 16957ebdd..a99be893f 100644 --- a/Mlem/Views/Shared/Comments/Comment Item Logic.swift +++ b/Mlem/Views/Shared/Comments/Comment Item Logic.swift @@ -151,7 +151,7 @@ extension CommentItem { // upvote let (upvoteText, upvoteImg) = hierarchicalComment.commentView.myVote == .upvote ? - ("Undo upvote", Icons.upvoteSquareFill) : + ("Undo Upvote", Icons.upvoteSquareFill) : ("Upvote", Icons.upvoteSquare) ret.append(MenuFunction.standardMenuFunction( text: upvoteText, @@ -166,7 +166,7 @@ extension CommentItem { // downvote let (downvoteText, downvoteImg) = hierarchicalComment.commentView.myVote == .downvote ? - ("Undo downvote", Icons.downvoteSquareFill) : + ("Undo Downvote", Icons.downvoteSquareFill) : ("Downvote", Icons.downvoteSquare) ret.append(MenuFunction.standardMenuFunction( text: downvoteText, diff --git a/Mlem/Views/Tabs/Settings/Components/Views/General/GeneralSettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/General/GeneralSettingsView.swift index 9e59dbba3..5326ec24b 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/General/GeneralSettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/General/GeneralSettingsView.swift @@ -22,6 +22,7 @@ struct GeneralSettingsView: View { @AppStorage("upvoteOnSave") var upvoteOnSave: Bool = false @AppStorage("showSettingsIcons") var showSettingsIcons: Bool = false + @AppStorage("openLinksInBrowser") var openLinksInBrowser: Bool = false @EnvironmentObject var appState: AppState @@ -30,6 +31,11 @@ struct GeneralSettingsView: View { var body: some View { List { Section { + SwitchableSettingsItem( + settingPictureSystemName: Icons.browser, + settingName: "Open Links in Browser", + isTicked: $openLinksInBrowser + ) SelectableSettingsItem( settingIconSystemName: Icons.haptics, settingName: "Haptic Level",