From b1520c549e60f6f81d208c6bfd151a1f21da5fa6 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Tue, 24 Jan 2023 07:19:09 +0100 Subject: [PATCH] Various fixes due to recent merges --- .../Env/Sources/Env/PushNotificationsService.swift | 2 +- Packages/Models/Sources/Models/Alias/HTMLString.swift | 11 +---------- Packages/Models/Sources/Models/Notification.swift | 4 ++-- Packages/Models/Sources/Models/PushSubscription.swift | 2 +- .../Network/Sources/Network/Endpoint/Accounts.swift | 2 +- Packages/Network/Sources/Network/Endpoint/Push.swift | 2 +- .../Network/Sources/Network/Endpoint/Statuses.swift | 6 +++--- .../Sources/Notifications/NotificationTypeExt.swift | 6 +++--- 8 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Packages/Env/Sources/Env/PushNotificationsService.swift b/Packages/Env/Sources/Env/PushNotificationsService.swift index 663d48bd..3b23d3f2 100644 --- a/Packages/Env/Sources/Env/PushNotificationsService.swift +++ b/Packages/Env/Sources/Env/PushNotificationsService.swift @@ -120,7 +120,7 @@ public class PushNotificationsService: ObservableObject { if let sub = subscriptions.first { isPushEnabled = true isFollowNotificationEnabled = sub.alerts.follow - isFavoriteNotificationEnabled = sub.alerts.favorite + isFavoriteNotificationEnabled = sub.alerts.favourite isReblogNotificationEnabled = sub.alerts.reblog isMentionNotificationEnabled = sub.alerts.mention isPollNotificationEnabled = sub.alerts.poll diff --git a/Packages/Models/Sources/Models/Alias/HTMLString.swift b/Packages/Models/Sources/Models/Alias/HTMLString.swift index 7534130e..54dc33ba 100644 --- a/Packages/Models/Sources/Models/Alias/HTMLString.swift +++ b/Packages/Models/Sources/Models/Alias/HTMLString.swift @@ -4,7 +4,7 @@ import SwiftSoup import SwiftUI public struct HTMLString: Decodable, Equatable, Hashable { - public var htmlValue: String + public let htmlValue: String public let asMarkdown: String public let asRawText: String public let statusesURLs: [URL] @@ -17,15 +17,6 @@ public struct HTMLString: Decodable, Equatable, Hashable { } catch { htmlValue = "" } - - // https://daringfireball.net/projects/markdown/syntax - // HTML2Markdown only auto escapes * on the way out - // so we pre-escape all other escapable sequences on - // the way in here. - - if let regex = try? NSRegularExpression(pattern: "([\\\\_(){}\\[\\]\\.\\+\\-#!])", options: .caseInsensitive) { - htmlValue = regex.stringByReplacingMatches(in: htmlValue, options: [], range: NSRange(location: 0, length: htmlValue.count), withTemplate: "\\\\$1") - } do { asMarkdown = try HTMLParser().parse(html: htmlValue) diff --git a/Packages/Models/Sources/Models/Notification.swift b/Packages/Models/Sources/Models/Notification.swift index 9d9c1d51..2f581cc3 100644 --- a/Packages/Models/Sources/Models/Notification.swift +++ b/Packages/Models/Sources/Models/Notification.swift @@ -2,7 +2,7 @@ import Foundation public struct Notification: Decodable, Identifiable { public enum NotificationType: String, CaseIterable { - case follow, follow_request, mention, reblog, status, favorite, poll, update + case follow, follow_request, mention, reblog, status, favourite, poll, update } public let id: String @@ -17,7 +17,7 @@ public struct Notification: Decodable, Identifiable { public static func placeholder() -> Notification { .init(id: UUID().uuidString, - type: NotificationType.favorite.rawValue, + type: NotificationType.favourite.rawValue, createdAt: "2022-12-16T10:20:54.000Z", account: .placeholder(), status: .placeholder()) diff --git a/Packages/Models/Sources/Models/PushSubscription.swift b/Packages/Models/Sources/Models/PushSubscription.swift index 6f971c8f..ecd3999c 100644 --- a/Packages/Models/Sources/Models/PushSubscription.swift +++ b/Packages/Models/Sources/Models/PushSubscription.swift @@ -3,7 +3,7 @@ import Foundation public struct PushSubscription: Identifiable, Decodable { public struct Alerts: Decodable { public let follow: Bool - public let favorite: Bool + public let favourite: Bool public let reblog: Bool public let mention: Bool public let poll: Bool diff --git a/Packages/Network/Sources/Network/Endpoint/Accounts.swift b/Packages/Network/Sources/Network/Endpoint/Accounts.swift index eb5f10df..c59e639b 100644 --- a/Packages/Network/Sources/Network/Endpoint/Accounts.swift +++ b/Packages/Network/Sources/Network/Endpoint/Accounts.swift @@ -40,7 +40,7 @@ public enum Accounts: Endpoint { case let .accounts(id): return "accounts/\(id)" case .favorites: - return "favorites" + return "favourites" case .bookmarks: return "bookmarks" case .followedTags: diff --git a/Packages/Network/Sources/Network/Endpoint/Push.swift b/Packages/Network/Sources/Network/Endpoint/Push.swift index 5aeec4c9..23fcf5de 100644 --- a/Packages/Network/Sources/Network/Endpoint/Push.swift +++ b/Packages/Network/Sources/Network/Endpoint/Push.swift @@ -30,7 +30,7 @@ public enum Push: Endpoint { params.append(.init(name: "data[alerts][status]", value: status ? "true" : "false")) params.append(.init(name: "data[alerts][follow]", value: follow ? "true" : "false")) params.append(.init(name: "data[alerts][reblog]", value: reblog ? "true" : "false")) - params.append(.init(name: "data[alerts][favorite]", value: favorite ? "true" : "false")) + params.append(.init(name: "data[alerts][favourite]", value: favorite ? "true" : "false")) params.append(.init(name: "data[alerts][poll]", value: poll ? "true" : "false")) params.append(.init(name: "policy", value: "all")) return params diff --git a/Packages/Network/Sources/Network/Endpoint/Statuses.swift b/Packages/Network/Sources/Network/Endpoint/Statuses.swift index 55e8a958..9ea6c331 100644 --- a/Packages/Network/Sources/Network/Endpoint/Statuses.swift +++ b/Packages/Network/Sources/Network/Endpoint/Statuses.swift @@ -29,9 +29,9 @@ public enum Statuses: Endpoint { case let .context(id): return "statuses/\(id)/context" case let .favorite(id): - return "statuses/\(id)/favorite" + return "statuses/\(id)/favourite" case let .unfavorite(id): - return "statuses/\(id)/unfavorite" + return "statuses/\(id)/unfavourite" case let .reblog(id): return "statuses/\(id)/reblog" case let .unreblog(id): @@ -39,7 +39,7 @@ public enum Statuses: Endpoint { case let .rebloggedBy(id, _): return "statuses/\(id)/reblogged_by" case let .favoritedBy(id, _): - return "statuses/\(id)/favorited_by" + return "statuses/\(id)/favourited_by" case let .pin(id): return "statuses/\(id)/pin" case let .unpin(id): diff --git a/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift b/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift index ea97ee27..f84d7cea 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift @@ -14,7 +14,7 @@ extension Models.Notification.NotificationType { return "notifications.label.follow" case .follow_request: return "notifications.label.follow-request" - case .favorite: + case .favourite: return "notifications.label.favorite" case .poll: return "notifications.label.poll" @@ -33,7 +33,7 @@ extension Models.Notification.NotificationType { return "arrow.left.arrow.right.circle.fill" case .follow, .follow_request: return "person.fill.badge.plus" - case .favorite: + case .favourite: return "star.fill" case .poll: return "chart.bar.fill" @@ -54,7 +54,7 @@ extension Models.Notification.NotificationType { return "notifications.menu-title.follow" case .follow_request: return "notifications.menu-title.follow-request" - case .favorite: + case .favourite: return "notifications.menu-title.favorite" case .poll: return "notifications.menu-title.poll"