Skip to content

Commit

Permalink
Merge branch 'dev' into sjmarf/matrix-id-cancel-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjmarf authored Jan 16, 2024
2 parents 459b11c + 308e5ab commit 9f00b52
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Mlem/Enums/Settings/PostSortType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions Mlem/Logic/URLHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions Mlem/Models/Content/Community/CommunityModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Mlem/Views/Shared/Comments/Comment Item Logic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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",
Expand Down

0 comments on commit 9f00b52

Please sign in to comment.