Various fixes due to recent merges

This commit is contained in:
Thomas Ricouard 2023-01-24 07:19:09 +01:00
parent c6e815855e
commit b1520c549e
8 changed files with 13 additions and 22 deletions

View File

@ -120,7 +120,7 @@ public class PushNotificationsService: ObservableObject {
if let sub = subscriptions.first { if let sub = subscriptions.first {
isPushEnabled = true isPushEnabled = true
isFollowNotificationEnabled = sub.alerts.follow isFollowNotificationEnabled = sub.alerts.follow
isFavoriteNotificationEnabled = sub.alerts.favorite isFavoriteNotificationEnabled = sub.alerts.favourite
isReblogNotificationEnabled = sub.alerts.reblog isReblogNotificationEnabled = sub.alerts.reblog
isMentionNotificationEnabled = sub.alerts.mention isMentionNotificationEnabled = sub.alerts.mention
isPollNotificationEnabled = sub.alerts.poll isPollNotificationEnabled = sub.alerts.poll

View File

@ -4,7 +4,7 @@ import SwiftSoup
import SwiftUI import SwiftUI
public struct HTMLString: Decodable, Equatable, Hashable { public struct HTMLString: Decodable, Equatable, Hashable {
public var htmlValue: String public let htmlValue: String
public let asMarkdown: String public let asMarkdown: String
public let asRawText: String public let asRawText: String
public let statusesURLs: [URL] public let statusesURLs: [URL]
@ -17,15 +17,6 @@ public struct HTMLString: Decodable, Equatable, Hashable {
} catch { } catch {
htmlValue = "" 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 { do {
asMarkdown = try HTMLParser().parse(html: htmlValue) asMarkdown = try HTMLParser().parse(html: htmlValue)

View File

@ -2,7 +2,7 @@ import Foundation
public struct Notification: Decodable, Identifiable { public struct Notification: Decodable, Identifiable {
public enum NotificationType: String, CaseIterable { 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 public let id: String
@ -17,7 +17,7 @@ public struct Notification: Decodable, Identifiable {
public static func placeholder() -> Notification { public static func placeholder() -> Notification {
.init(id: UUID().uuidString, .init(id: UUID().uuidString,
type: NotificationType.favorite.rawValue, type: NotificationType.favourite.rawValue,
createdAt: "2022-12-16T10:20:54.000Z", createdAt: "2022-12-16T10:20:54.000Z",
account: .placeholder(), account: .placeholder(),
status: .placeholder()) status: .placeholder())

View File

@ -3,7 +3,7 @@ import Foundation
public struct PushSubscription: Identifiable, Decodable { public struct PushSubscription: Identifiable, Decodable {
public struct Alerts: Decodable { public struct Alerts: Decodable {
public let follow: Bool public let follow: Bool
public let favorite: Bool public let favourite: Bool
public let reblog: Bool public let reblog: Bool
public let mention: Bool public let mention: Bool
public let poll: Bool public let poll: Bool

View File

@ -40,7 +40,7 @@ public enum Accounts: Endpoint {
case let .accounts(id): case let .accounts(id):
return "accounts/\(id)" return "accounts/\(id)"
case .favorites: case .favorites:
return "favorites" return "favourites"
case .bookmarks: case .bookmarks:
return "bookmarks" return "bookmarks"
case .followedTags: case .followedTags:

View File

@ -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][status]", value: status ? "true" : "false"))
params.append(.init(name: "data[alerts][follow]", value: follow ? "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][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: "data[alerts][poll]", value: poll ? "true" : "false"))
params.append(.init(name: "policy", value: "all")) params.append(.init(name: "policy", value: "all"))
return params return params

View File

@ -29,9 +29,9 @@ public enum Statuses: Endpoint {
case let .context(id): case let .context(id):
return "statuses/\(id)/context" return "statuses/\(id)/context"
case let .favorite(id): case let .favorite(id):
return "statuses/\(id)/favorite" return "statuses/\(id)/favourite"
case let .unfavorite(id): case let .unfavorite(id):
return "statuses/\(id)/unfavorite" return "statuses/\(id)/unfavourite"
case let .reblog(id): case let .reblog(id):
return "statuses/\(id)/reblog" return "statuses/\(id)/reblog"
case let .unreblog(id): case let .unreblog(id):
@ -39,7 +39,7 @@ public enum Statuses: Endpoint {
case let .rebloggedBy(id, _): case let .rebloggedBy(id, _):
return "statuses/\(id)/reblogged_by" return "statuses/\(id)/reblogged_by"
case let .favoritedBy(id, _): case let .favoritedBy(id, _):
return "statuses/\(id)/favorited_by" return "statuses/\(id)/favourited_by"
case let .pin(id): case let .pin(id):
return "statuses/\(id)/pin" return "statuses/\(id)/pin"
case let .unpin(id): case let .unpin(id):

View File

@ -14,7 +14,7 @@ extension Models.Notification.NotificationType {
return "notifications.label.follow" return "notifications.label.follow"
case .follow_request: case .follow_request:
return "notifications.label.follow-request" return "notifications.label.follow-request"
case .favorite: case .favourite:
return "notifications.label.favorite" return "notifications.label.favorite"
case .poll: case .poll:
return "notifications.label.poll" return "notifications.label.poll"
@ -33,7 +33,7 @@ extension Models.Notification.NotificationType {
return "arrow.left.arrow.right.circle.fill" return "arrow.left.arrow.right.circle.fill"
case .follow, .follow_request: case .follow, .follow_request:
return "person.fill.badge.plus" return "person.fill.badge.plus"
case .favorite: case .favourite:
return "star.fill" return "star.fill"
case .poll: case .poll:
return "chart.bar.fill" return "chart.bar.fill"
@ -54,7 +54,7 @@ extension Models.Notification.NotificationType {
return "notifications.menu-title.follow" return "notifications.menu-title.follow"
case .follow_request: case .follow_request:
return "notifications.menu-title.follow-request" return "notifications.menu-title.follow-request"
case .favorite: case .favourite:
return "notifications.menu-title.favorite" return "notifications.menu-title.favorite"
case .poll: case .poll:
return "notifications.menu-title.poll" return "notifications.menu-title.poll"