mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 17:51:01 +00:00
Make spelling of "favorite" consistent (#327)
"Favorite" was spelled using both UK English and US English variations: 113 favourite 64 favorite I made them consistent, using the US spelling.
This commit is contained in:
parent
baeba46dbc
commit
a7c7dfd24e
16 changed files with 99 additions and 99 deletions
|
@ -31,8 +31,8 @@ extension View {
|
||||||
AccountsListView(mode: .following(accountId: id))
|
AccountsListView(mode: .following(accountId: id))
|
||||||
case let .followers(id):
|
case let .followers(id):
|
||||||
AccountsListView(mode: .followers(accountId: id))
|
AccountsListView(mode: .followers(accountId: id))
|
||||||
case let .favouritedBy(id):
|
case let .favoritedBy(id):
|
||||||
AccountsListView(mode: .favouritedBy(statusId: id))
|
AccountsListView(mode: .favoritedBy(statusId: id))
|
||||||
case let .rebloggedBy(id):
|
case let .rebloggedBy(id):
|
||||||
AccountsListView(mode: .rebloggedBy(statusId: id))
|
AccountsListView(mode: .rebloggedBy(statusId: id))
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,10 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Tab: Int {
|
enum Tab: Int {
|
||||||
case statuses, favourites, bookmarks, followedTags, postsAndReplies, media, lists
|
case statuses, favorites, bookmarks, followedTags, postsAndReplies, media, lists
|
||||||
|
|
||||||
static var currentAccountTabs: [Tab] {
|
static var currentAccountTabs: [Tab] {
|
||||||
[.statuses, .favourites, .bookmarks, .followedTags, .lists]
|
[.statuses, .favorites, .bookmarks, .followedTags, .lists]
|
||||||
}
|
}
|
||||||
|
|
||||||
static var accountTabs: [Tab] {
|
static var accountTabs: [Tab] {
|
||||||
|
@ -28,7 +28,7 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
||||||
var iconName: String {
|
var iconName: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .statuses: return "bubble.right"
|
case .statuses: return "bubble.right"
|
||||||
case .favourites: return "star"
|
case .favorites: return "star"
|
||||||
case .bookmarks: return "bookmark"
|
case .bookmarks: return "bookmark"
|
||||||
case .followedTags: return "tag"
|
case .followedTags: return "tag"
|
||||||
case .postsAndReplies: return "bubble.left.and.bubble.right"
|
case .postsAndReplies: return "bubble.left.and.bubble.right"
|
||||||
|
@ -62,9 +62,9 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
||||||
|
|
||||||
@Published var relationship: Relationship?
|
@Published var relationship: Relationship?
|
||||||
@Published var pinned: [Status] = []
|
@Published var pinned: [Status] = []
|
||||||
@Published var favourites: [Status] = []
|
@Published var favorites: [Status] = []
|
||||||
@Published var bookmarks: [Status] = []
|
@Published var bookmarks: [Status] = []
|
||||||
private var favouritesNextPage: LinkHandler?
|
private var favoritesNextPage: LinkHandler?
|
||||||
private var bookmarksNextPage: LinkHandler?
|
private var bookmarksNextPage: LinkHandler?
|
||||||
@Published var featuredTags: [FeaturedTag] = []
|
@Published var featuredTags: [FeaturedTag] = []
|
||||||
@Published var fields: [Account.Field] = []
|
@Published var fields: [Account.Field] = []
|
||||||
|
@ -167,7 +167,7 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
||||||
pinned: true))
|
pinned: true))
|
||||||
}
|
}
|
||||||
if isCurrentUser {
|
if isCurrentUser {
|
||||||
(favourites, favouritesNextPage) = try await client.getWithLink(endpoint: Accounts.favourites(sinceId: nil))
|
(favorites, favoritesNextPage) = try await client.getWithLink(endpoint: Accounts.favorites(sinceId: nil))
|
||||||
(bookmarks, bookmarksNextPage) = try await client.getWithLink(endpoint: Accounts.bookmarks(sinceId: nil))
|
(bookmarks, bookmarksNextPage) = try await client.getWithLink(endpoint: Accounts.bookmarks(sinceId: nil))
|
||||||
}
|
}
|
||||||
reloadTabState()
|
reloadTabState()
|
||||||
|
@ -193,12 +193,12 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
||||||
statuses.append(contentsOf: newStatuses)
|
statuses.append(contentsOf: newStatuses)
|
||||||
tabState = .statuses(statusesState: .display(statuses: statuses,
|
tabState = .statuses(statusesState: .display(statuses: statuses,
|
||||||
nextPageState: newStatuses.count < 20 ? .none : .hasNextPage))
|
nextPageState: newStatuses.count < 20 ? .none : .hasNextPage))
|
||||||
case .favourites:
|
case .favorites:
|
||||||
guard let nextPageId = favouritesNextPage?.maxId else { return }
|
guard let nextPageId = favoritesNextPage?.maxId else { return }
|
||||||
let newFavourites: [Status]
|
let newFavorites: [Status]
|
||||||
(newFavourites, favouritesNextPage) = try await client.getWithLink(endpoint: Accounts.favourites(sinceId: nextPageId))
|
(newFavorites, favoritesNextPage) = try await client.getWithLink(endpoint: Accounts.favorites(sinceId: nextPageId))
|
||||||
favourites.append(contentsOf: newFavourites)
|
favorites.append(contentsOf: newFavorites)
|
||||||
tabState = .statuses(statusesState: .display(statuses: favourites, nextPageState: .hasNextPage))
|
tabState = .statuses(statusesState: .display(statuses: favorites, nextPageState: .hasNextPage))
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
guard let nextPageId = bookmarksNextPage?.maxId else { return }
|
guard let nextPageId = bookmarksNextPage?.maxId else { return }
|
||||||
let newBookmarks: [Status]
|
let newBookmarks: [Status]
|
||||||
|
@ -217,9 +217,9 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
||||||
switch selectedTab {
|
switch selectedTab {
|
||||||
case .statuses, .postsAndReplies, .media:
|
case .statuses, .postsAndReplies, .media:
|
||||||
tabState = .statuses(statusesState: .display(statuses: statuses, nextPageState: statuses.count < 20 ? .none : .hasNextPage))
|
tabState = .statuses(statusesState: .display(statuses: statuses, nextPageState: statuses.count < 20 ? .none : .hasNextPage))
|
||||||
case .favourites:
|
case .favorites:
|
||||||
tabState = .statuses(statusesState: .display(statuses: favourites,
|
tabState = .statuses(statusesState: .display(statuses: favorites,
|
||||||
nextPageState: favouritesNextPage != nil ? .hasNextPage : .none))
|
nextPageState: favoritesNextPage != nil ? .hasNextPage : .none))
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
tabState = .statuses(statusesState: .display(statuses: bookmarks,
|
tabState = .statuses(statusesState: .display(statuses: bookmarks,
|
||||||
nextPageState: bookmarksNextPage != nil ? .hasNextPage : .none))
|
nextPageState: bookmarksNextPage != nil ? .hasNextPage : .none))
|
||||||
|
|
|
@ -4,7 +4,7 @@ import SwiftUI
|
||||||
|
|
||||||
public enum AccountsListMode {
|
public enum AccountsListMode {
|
||||||
case following(accountId: String), followers(accountId: String)
|
case following(accountId: String), followers(accountId: String)
|
||||||
case favouritedBy(statusId: String), rebloggedBy(statusId: String)
|
case favoritedBy(statusId: String), rebloggedBy(statusId: String)
|
||||||
|
|
||||||
var title: LocalizedStringKey {
|
var title: LocalizedStringKey {
|
||||||
switch self {
|
switch self {
|
||||||
|
@ -12,7 +12,7 @@ public enum AccountsListMode {
|
||||||
return "account.following"
|
return "account.following"
|
||||||
case .followers:
|
case .followers:
|
||||||
return "account.followers"
|
return "account.followers"
|
||||||
case .favouritedBy:
|
case .favoritedBy:
|
||||||
return "account.favorited-by"
|
return "account.favorited-by"
|
||||||
case .rebloggedBy:
|
case .rebloggedBy:
|
||||||
return "account.boosted-by"
|
return "account.boosted-by"
|
||||||
|
@ -64,8 +64,8 @@ class AccountsListViewModel: ObservableObject {
|
||||||
case let .rebloggedBy(statusId):
|
case let .rebloggedBy(statusId):
|
||||||
(accounts, link) = try await client.getWithLink(endpoint: Statuses.rebloggedBy(id: statusId,
|
(accounts, link) = try await client.getWithLink(endpoint: Statuses.rebloggedBy(id: statusId,
|
||||||
maxId: nil))
|
maxId: nil))
|
||||||
case let .favouritedBy(statusId):
|
case let .favoritedBy(statusId):
|
||||||
(accounts, link) = try await client.getWithLink(endpoint: Statuses.favouritedBy(id: statusId,
|
(accounts, link) = try await client.getWithLink(endpoint: Statuses.favoritedBy(id: statusId,
|
||||||
maxId: nil))
|
maxId: nil))
|
||||||
}
|
}
|
||||||
nextPageId = link?.maxId
|
nextPageId = link?.maxId
|
||||||
|
@ -93,8 +93,8 @@ class AccountsListViewModel: ObservableObject {
|
||||||
case let .rebloggedBy(statusId):
|
case let .rebloggedBy(statusId):
|
||||||
(newAccounts, link) = try await client.getWithLink(endpoint: Statuses.rebloggedBy(id: statusId,
|
(newAccounts, link) = try await client.getWithLink(endpoint: Statuses.rebloggedBy(id: statusId,
|
||||||
maxId: nextPageId))
|
maxId: nextPageId))
|
||||||
case let .favouritedBy(statusId):
|
case let .favoritedBy(statusId):
|
||||||
(newAccounts, link) = try await client.getWithLink(endpoint: Statuses.favouritedBy(id: statusId,
|
(newAccounts, link) = try await client.getWithLink(endpoint: Statuses.favoritedBy(id: statusId,
|
||||||
maxId: nextPageId))
|
maxId: nextPageId))
|
||||||
}
|
}
|
||||||
accounts.append(contentsOf: newAccounts)
|
accounts.append(contentsOf: newAccounts)
|
||||||
|
|
|
@ -76,7 +76,7 @@ struct ConversationMessageView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
isLiked = message.favourited == true
|
isLiked = message.favorited == true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,12 +97,12 @@ struct ConversationMessageView: View {
|
||||||
do {
|
do {
|
||||||
let status: Status
|
let status: Status
|
||||||
if isLiked {
|
if isLiked {
|
||||||
status = try await client.post(endpoint: Statuses.unfavourite(id: message.id))
|
status = try await client.post(endpoint: Statuses.unfavorite(id: message.id))
|
||||||
} else {
|
} else {
|
||||||
status = try await client.post(endpoint: Statuses.favourite(id: message.id))
|
status = try await client.post(endpoint: Statuses.favorite(id: message.id))
|
||||||
}
|
}
|
||||||
withAnimation {
|
withAnimation {
|
||||||
isLiked = status.favourited == true
|
isLiked = status.favorited == true
|
||||||
}
|
}
|
||||||
} catch { }
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class PushNotificationsService: ObservableObject {
|
||||||
status: isNewPostsNotificationEnabled,
|
status: isNewPostsNotificationEnabled,
|
||||||
reblog: isReblogNotificationEnabled,
|
reblog: isReblogNotificationEnabled,
|
||||||
follow: isFollowNotificationEnabled,
|
follow: isFollowNotificationEnabled,
|
||||||
favourite: isFavoriteNotificationEnabled,
|
favorite: isFavoriteNotificationEnabled,
|
||||||
poll: isPollNotificationEnabled))
|
poll: isPollNotificationEnabled))
|
||||||
subscriptions.append(sub)
|
subscriptions.append(sub)
|
||||||
} catch {}
|
} catch {}
|
||||||
|
@ -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.favourite
|
isFavoriteNotificationEnabled = sub.alerts.favorite
|
||||||
isReblogNotificationEnabled = sub.alerts.reblog
|
isReblogNotificationEnabled = sub.alerts.reblog
|
||||||
isMentionNotificationEnabled = sub.alerts.mention
|
isMentionNotificationEnabled = sub.alerts.mention
|
||||||
isPollNotificationEnabled = sub.alerts.poll
|
isPollNotificationEnabled = sub.alerts.poll
|
||||||
|
|
|
@ -13,7 +13,7 @@ public enum RouterDestinations: Hashable {
|
||||||
case list(list: Models.List)
|
case list(list: Models.List)
|
||||||
case followers(id: String)
|
case followers(id: String)
|
||||||
case following(id: String)
|
case following(id: String)
|
||||||
case favouritedBy(id: String)
|
case favoritedBy(id: String)
|
||||||
case rebloggedBy(id: String)
|
case rebloggedBy(id: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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, favourite, poll, update
|
case follow, follow_request, mention, reblog, status, favorite, 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.favourite.rawValue,
|
type: NotificationType.favorite.rawValue,
|
||||||
createdAt: "2022-12-16T10:20:54.000Z",
|
createdAt: "2022-12-16T10:20:54.000Z",
|
||||||
account: .placeholder(),
|
account: .placeholder(),
|
||||||
status: .placeholder())
|
status: .placeholder())
|
||||||
|
|
|
@ -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 favourite: Bool
|
public let favorite: 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
|
||||||
|
|
|
@ -36,9 +36,9 @@ public protocol AnyStatus {
|
||||||
var mentions: [Mention] { get }
|
var mentions: [Mention] { get }
|
||||||
var repliesCount: Int { get }
|
var repliesCount: Int { get }
|
||||||
var reblogsCount: Int { get }
|
var reblogsCount: Int { get }
|
||||||
var favouritesCount: Int { get }
|
var favoritesCount: Int { get }
|
||||||
var card: Card? { get }
|
var card: Card? { get }
|
||||||
var favourited: Bool? { get }
|
var favorited: Bool? { get }
|
||||||
var reblogged: Bool? { get }
|
var reblogged: Bool? { get }
|
||||||
var pinned: Bool? { get }
|
var pinned: Bool? { get }
|
||||||
var bookmarked: Bool? { get }
|
var bookmarked: Bool? { get }
|
||||||
|
@ -77,9 +77,9 @@ public struct Status: AnyStatus, Decodable, Identifiable, Equatable, Hashable {
|
||||||
public let mentions: [Mention]
|
public let mentions: [Mention]
|
||||||
public let repliesCount: Int
|
public let repliesCount: Int
|
||||||
public let reblogsCount: Int
|
public let reblogsCount: Int
|
||||||
public let favouritesCount: Int
|
public let favoritesCount: Int
|
||||||
public let card: Card?
|
public let card: Card?
|
||||||
public let favourited: Bool?
|
public let favorited: Bool?
|
||||||
public let reblogged: Bool?
|
public let reblogged: Bool?
|
||||||
public let pinned: Bool?
|
public let pinned: Bool?
|
||||||
public let bookmarked: Bool?
|
public let bookmarked: Bool?
|
||||||
|
@ -105,9 +105,9 @@ public struct Status: AnyStatus, Decodable, Identifiable, Equatable, Hashable {
|
||||||
mentions: [],
|
mentions: [],
|
||||||
repliesCount: 0,
|
repliesCount: 0,
|
||||||
reblogsCount: 0,
|
reblogsCount: 0,
|
||||||
favouritesCount: 0,
|
favoritesCount: 0,
|
||||||
card: nil,
|
card: nil,
|
||||||
favourited: false,
|
favorited: false,
|
||||||
reblogged: false,
|
reblogged: false,
|
||||||
pinned: false,
|
pinned: false,
|
||||||
bookmarked: false,
|
bookmarked: false,
|
||||||
|
@ -150,9 +150,9 @@ public struct ReblogStatus: AnyStatus, Decodable, Identifiable, Equatable, Hasha
|
||||||
public let mentions: [Mention]
|
public let mentions: [Mention]
|
||||||
public let repliesCount: Int
|
public let repliesCount: Int
|
||||||
public let reblogsCount: Int
|
public let reblogsCount: Int
|
||||||
public let favouritesCount: Int
|
public let favoritesCount: Int
|
||||||
public let card: Card?
|
public let card: Card?
|
||||||
public let favourited: Bool?
|
public let favorited: Bool?
|
||||||
public let reblogged: Bool?
|
public let reblogged: Bool?
|
||||||
public let pinned: Bool?
|
public let pinned: Bool?
|
||||||
public let bookmarked: Bool?
|
public let bookmarked: Bool?
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Models
|
||||||
|
|
||||||
public enum Accounts: Endpoint {
|
public enum Accounts: Endpoint {
|
||||||
case accounts(id: String)
|
case accounts(id: String)
|
||||||
case favourites(sinceId: String?)
|
case favorites(sinceId: String?)
|
||||||
case bookmarks(sinceId: String?)
|
case bookmarks(sinceId: String?)
|
||||||
case followedTags
|
case followedTags
|
||||||
case featuredTags(id: String)
|
case featuredTags(id: String)
|
||||||
|
@ -39,8 +39,8 @@ public enum Accounts: Endpoint {
|
||||||
switch self {
|
switch self {
|
||||||
case let .accounts(id):
|
case let .accounts(id):
|
||||||
return "accounts/\(id)"
|
return "accounts/\(id)"
|
||||||
case .favourites:
|
case .favorites:
|
||||||
return "favourites"
|
return "favorites"
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
return "bookmarks"
|
return "bookmarks"
|
||||||
case .followedTags:
|
case .followedTags:
|
||||||
|
@ -117,7 +117,7 @@ public enum Accounts: Endpoint {
|
||||||
return makePaginationParam(sinceId: nil, maxId: maxId, mindId: nil)
|
return makePaginationParam(sinceId: nil, maxId: maxId, mindId: nil)
|
||||||
case let .following(_, maxId):
|
case let .following(_, maxId):
|
||||||
return makePaginationParam(sinceId: nil, maxId: maxId, mindId: nil)
|
return makePaginationParam(sinceId: nil, maxId: maxId, mindId: nil)
|
||||||
case let .favourites(sinceId):
|
case let .favorites(sinceId):
|
||||||
guard let sinceId else { return nil }
|
guard let sinceId else { return nil }
|
||||||
return [.init(name: "max_id", value: sinceId)]
|
return [.init(name: "max_id", value: sinceId)]
|
||||||
case let .bookmarks(sinceId):
|
case let .bookmarks(sinceId):
|
||||||
|
|
|
@ -9,7 +9,7 @@ public enum Push: Endpoint {
|
||||||
status: Bool,
|
status: Bool,
|
||||||
reblog: Bool,
|
reblog: Bool,
|
||||||
follow: Bool,
|
follow: Bool,
|
||||||
favourite: Bool,
|
favorite: Bool,
|
||||||
poll: Bool)
|
poll: Bool)
|
||||||
|
|
||||||
public func path() -> String {
|
public func path() -> String {
|
||||||
|
@ -21,7 +21,7 @@ public enum Push: Endpoint {
|
||||||
|
|
||||||
public func queryItems() -> [URLQueryItem]? {
|
public func queryItems() -> [URLQueryItem]? {
|
||||||
switch self {
|
switch self {
|
||||||
case let .createSub(endpoint, p256dh, auth, mentions, status, reblog, follow, favourite, poll):
|
case let .createSub(endpoint, p256dh, auth, mentions, status, reblog, follow, favorite, poll):
|
||||||
var params: [URLQueryItem] = []
|
var params: [URLQueryItem] = []
|
||||||
params.append(.init(name: "subscription[endpoint]", value: endpoint))
|
params.append(.init(name: "subscription[endpoint]", value: endpoint))
|
||||||
params.append(.init(name: "subscription[keys][p256dh]", value: p256dh.base64UrlEncodedString()))
|
params.append(.init(name: "subscription[keys][p256dh]", value: p256dh.base64UrlEncodedString()))
|
||||||
|
@ -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][favourite]", value: favourite ? "true" : "false"))
|
params.append(.init(name: "data[alerts][favorite]", 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
|
||||||
|
|
|
@ -6,12 +6,12 @@ public enum Statuses: Endpoint {
|
||||||
case editStatus(id: String, json: StatusData)
|
case editStatus(id: String, json: StatusData)
|
||||||
case status(id: String)
|
case status(id: String)
|
||||||
case context(id: String)
|
case context(id: String)
|
||||||
case favourite(id: String)
|
case favorite(id: String)
|
||||||
case unfavourite(id: String)
|
case unfavorite(id: String)
|
||||||
case reblog(id: String)
|
case reblog(id: String)
|
||||||
case unreblog(id: String)
|
case unreblog(id: String)
|
||||||
case rebloggedBy(id: String, maxId: String?)
|
case rebloggedBy(id: String, maxId: String?)
|
||||||
case favouritedBy(id: String, maxId: String?)
|
case favoritedBy(id: String, maxId: String?)
|
||||||
case pin(id: String)
|
case pin(id: String)
|
||||||
case unpin(id: String)
|
case unpin(id: String)
|
||||||
case bookmark(id: String)
|
case bookmark(id: String)
|
||||||
|
@ -28,18 +28,18 @@ public enum Statuses: Endpoint {
|
||||||
return "statuses/\(id)"
|
return "statuses/\(id)"
|
||||||
case let .context(id):
|
case let .context(id):
|
||||||
return "statuses/\(id)/context"
|
return "statuses/\(id)/context"
|
||||||
case let .favourite(id):
|
case let .favorite(id):
|
||||||
return "statuses/\(id)/favourite"
|
return "statuses/\(id)/favorite"
|
||||||
case let .unfavourite(id):
|
case let .unfavorite(id):
|
||||||
return "statuses/\(id)/unfavourite"
|
return "statuses/\(id)/unfavorite"
|
||||||
case let .reblog(id):
|
case let .reblog(id):
|
||||||
return "statuses/\(id)/reblog"
|
return "statuses/\(id)/reblog"
|
||||||
case let .unreblog(id):
|
case let .unreblog(id):
|
||||||
return "statuses/\(id)/unreblog"
|
return "statuses/\(id)/unreblog"
|
||||||
case let .rebloggedBy(id, _):
|
case let .rebloggedBy(id, _):
|
||||||
return "statuses/\(id)/reblogged_by"
|
return "statuses/\(id)/reblogged_by"
|
||||||
case let .favouritedBy(id, _):
|
case let .favoritedBy(id, _):
|
||||||
return "statuses/\(id)/favourited_by"
|
return "statuses/\(id)/favorited_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):
|
||||||
|
@ -57,7 +57,7 @@ public enum Statuses: Endpoint {
|
||||||
switch self {
|
switch self {
|
||||||
case let .rebloggedBy(_, maxId):
|
case let .rebloggedBy(_, maxId):
|
||||||
return makePaginationParam(sinceId: nil, maxId: maxId, mindId: nil)
|
return makePaginationParam(sinceId: nil, maxId: maxId, mindId: nil)
|
||||||
case let .favouritedBy(_, maxId):
|
case let .favoritedBy(_, maxId):
|
||||||
return makePaginationParam(sinceId: nil, maxId: maxId, mindId: nil)
|
return makePaginationParam(sinceId: nil, maxId: maxId, mindId: nil)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -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 .favourite:
|
case .favorite:
|
||||||
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 .favourite:
|
case .favorite:
|
||||||
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 .favourite:
|
case .favorite:
|
||||||
return "notifications.menu-title.favorite"
|
return "notifications.menu-title.favorite"
|
||||||
case .poll:
|
case .poll:
|
||||||
return "notifications.menu-title.poll"
|
return "notifications.menu-title.poll"
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct StatusActionsView: View {
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
enum Actions: CaseIterable {
|
enum Actions: CaseIterable {
|
||||||
case respond, boost, favourite, bookmark, share
|
case respond, boost, favorite, bookmark, share
|
||||||
|
|
||||||
func iconName(viewModel: StatusRowViewModel) -> String {
|
func iconName(viewModel: StatusRowViewModel) -> String {
|
||||||
switch self {
|
switch self {
|
||||||
|
@ -22,8 +22,8 @@ struct StatusActionsView: View {
|
||||||
return "arrowshape.turn.up.left"
|
return "arrowshape.turn.up.left"
|
||||||
case .boost:
|
case .boost:
|
||||||
return viewModel.isReblogged ? "arrow.left.arrow.right.circle.fill" : "arrow.left.arrow.right.circle"
|
return viewModel.isReblogged ? "arrow.left.arrow.right.circle.fill" : "arrow.left.arrow.right.circle"
|
||||||
case .favourite:
|
case .favorite:
|
||||||
return viewModel.isFavourited ? "star.fill" : "star"
|
return viewModel.isFavorited ? "star.fill" : "star"
|
||||||
case .bookmark:
|
case .bookmark:
|
||||||
return viewModel.isBookmarked ? "bookmark.fill" : "bookmark"
|
return viewModel.isBookmarked ? "bookmark.fill" : "bookmark"
|
||||||
case .share:
|
case .share:
|
||||||
|
@ -38,8 +38,8 @@ struct StatusActionsView: View {
|
||||||
switch self {
|
switch self {
|
||||||
case .respond:
|
case .respond:
|
||||||
return viewModel.repliesCount
|
return viewModel.repliesCount
|
||||||
case .favourite:
|
case .favorite:
|
||||||
return viewModel.favouritesCount
|
return viewModel.favoritesCount
|
||||||
case .boost:
|
case .boost:
|
||||||
return viewModel.reblogsCount
|
return viewModel.reblogsCount
|
||||||
case .share, .bookmark:
|
case .share, .bookmark:
|
||||||
|
@ -51,8 +51,8 @@ struct StatusActionsView: View {
|
||||||
switch self {
|
switch self {
|
||||||
case .respond, .share:
|
case .respond, .share:
|
||||||
return nil
|
return nil
|
||||||
case .favourite:
|
case .favorite:
|
||||||
return viewModel.isFavourited ? .yellow : nil
|
return viewModel.isFavorited ? .yellow : nil
|
||||||
case .bookmark:
|
case .bookmark:
|
||||||
return viewModel.isBookmarked ? .pink : nil
|
return viewModel.isBookmarked ? .pink : nil
|
||||||
case .boost:
|
case .boost:
|
||||||
|
@ -134,10 +134,10 @@ struct StatusActionsView: View {
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
}
|
}
|
||||||
|
|
||||||
if viewModel.favouritesCount > 0 {
|
if viewModel.favoritesCount > 0 {
|
||||||
Divider()
|
Divider()
|
||||||
NavigationLink(value: RouterDestinations.favouritedBy(id: viewModel.status.id)) {
|
NavigationLink(value: RouterDestinations.favoritedBy(id: viewModel.status.id)) {
|
||||||
Text("status.summary.n-favorites \(viewModel.favouritesCount)")
|
Text("status.summary.n-favorites \(viewModel.favoritesCount)")
|
||||||
.font(.scaledCallout)
|
.font(.scaledCallout)
|
||||||
Spacer()
|
Spacer()
|
||||||
Image(systemName: "chevron.right")
|
Image(systemName: "chevron.right")
|
||||||
|
@ -160,11 +160,11 @@ struct StatusActionsView: View {
|
||||||
switch action {
|
switch action {
|
||||||
case .respond:
|
case .respond:
|
||||||
routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
||||||
case .favourite:
|
case .favorite:
|
||||||
if viewModel.isFavourited {
|
if viewModel.isFavorited {
|
||||||
await viewModel.unFavourite()
|
await viewModel.unFavorite()
|
||||||
} else {
|
} else {
|
||||||
await viewModel.favourite()
|
await viewModel.favorite()
|
||||||
}
|
}
|
||||||
case .bookmark:
|
case .bookmark:
|
||||||
if viewModel.isBookmarked {
|
if viewModel.isBookmarked {
|
||||||
|
|
|
@ -14,13 +14,13 @@ struct StatusRowContextMenu: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if !viewModel.isRemote {
|
if !viewModel.isRemote {
|
||||||
Button { Task {
|
Button { Task {
|
||||||
if viewModel.isFavourited {
|
if viewModel.isFavorited {
|
||||||
await viewModel.unFavourite()
|
await viewModel.unFavorite()
|
||||||
} else {
|
} else {
|
||||||
await viewModel.favourite()
|
await viewModel.favorite()
|
||||||
}
|
}
|
||||||
} } label: {
|
} } label: {
|
||||||
Label(viewModel.isFavourited ? "status.action.unfavorite" : "status.action.favorite", systemImage: "star")
|
Label(viewModel.isFavorited ? "status.action.unfavorite" : "status.action.favorite", systemImage: "star")
|
||||||
}
|
}
|
||||||
Button { Task {
|
Button { Task {
|
||||||
if viewModel.isReblogged {
|
if viewModel.isReblogged {
|
||||||
|
|
|
@ -11,8 +11,8 @@ public class StatusRowViewModel: ObservableObject {
|
||||||
let isRemote: Bool
|
let isRemote: Bool
|
||||||
let showActions: Bool
|
let showActions: Bool
|
||||||
|
|
||||||
@Published var favouritesCount: Int
|
@Published var favoritesCount: Int
|
||||||
@Published var isFavourited: Bool
|
@Published var isFavorited: Bool
|
||||||
@Published var isReblogged: Bool
|
@Published var isReblogged: Bool
|
||||||
@Published var isPinned: Bool
|
@Published var isPinned: Bool
|
||||||
@Published var isBookmarked: Bool
|
@Published var isBookmarked: Bool
|
||||||
|
@ -44,17 +44,17 @@ public class StatusRowViewModel: ObservableObject {
|
||||||
self.isRemote = isRemote
|
self.isRemote = isRemote
|
||||||
self.showActions = showActions
|
self.showActions = showActions
|
||||||
if let reblog = status.reblog {
|
if let reblog = status.reblog {
|
||||||
isFavourited = reblog.favourited == true
|
isFavorited = reblog.favorited == true
|
||||||
isReblogged = reblog.reblogged == true
|
isReblogged = reblog.reblogged == true
|
||||||
isPinned = reblog.pinned == true
|
isPinned = reblog.pinned == true
|
||||||
isBookmarked = reblog.bookmarked == true
|
isBookmarked = reblog.bookmarked == true
|
||||||
} else {
|
} else {
|
||||||
isFavourited = status.favourited == true
|
isFavorited = status.favorited == true
|
||||||
isReblogged = status.reblogged == true
|
isReblogged = status.reblogged == true
|
||||||
isPinned = status.pinned == true
|
isPinned = status.pinned == true
|
||||||
isBookmarked = status.bookmarked == true
|
isBookmarked = status.bookmarked == true
|
||||||
}
|
}
|
||||||
favouritesCount = status.reblog?.favouritesCount ?? status.favouritesCount
|
favoritesCount = status.reblog?.favoritesCount ?? status.favoritesCount
|
||||||
reblogsCount = status.reblog?.reblogsCount ?? status.reblogsCount
|
reblogsCount = status.reblog?.reblogsCount ?? status.reblogsCount
|
||||||
repliesCount = status.reblog?.repliesCount ?? status.repliesCount
|
repliesCount = status.reblog?.repliesCount ?? status.repliesCount
|
||||||
displaySpoiler = !(status.reblog?.spoilerText.asRawText ?? status.spoilerText.asRawText).isEmpty
|
displaySpoiler = !(status.reblog?.spoilerText.asRawText ?? status.spoilerText.asRawText).isEmpty
|
||||||
|
@ -104,29 +104,29 @@ public class StatusRowViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func favourite() async {
|
func favorite() async {
|
||||||
guard let client, client.isAuth else { return }
|
guard let client, client.isAuth else { return }
|
||||||
isFavourited = true
|
isFavorited = true
|
||||||
favouritesCount += 1
|
favoritesCount += 1
|
||||||
do {
|
do {
|
||||||
let status: Status = try await client.post(endpoint: Statuses.favourite(id: status.reblog?.id ?? status.id))
|
let status: Status = try await client.post(endpoint: Statuses.favorite(id: status.reblog?.id ?? status.id))
|
||||||
updateFromStatus(status: status)
|
updateFromStatus(status: status)
|
||||||
} catch {
|
} catch {
|
||||||
isFavourited = false
|
isFavorited = false
|
||||||
favouritesCount -= 1
|
favoritesCount -= 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func unFavourite() async {
|
func unFavorite() async {
|
||||||
guard let client, client.isAuth else { return }
|
guard let client, client.isAuth else { return }
|
||||||
isFavourited = false
|
isFavorited = false
|
||||||
favouritesCount -= 1
|
favoritesCount -= 1
|
||||||
do {
|
do {
|
||||||
let status: Status = try await client.post(endpoint: Statuses.unfavourite(id: status.reblog?.id ?? status.id))
|
let status: Status = try await client.post(endpoint: Statuses.unfavorite(id: status.reblog?.id ?? status.id))
|
||||||
updateFromStatus(status: status)
|
updateFromStatus(status: status)
|
||||||
} catch {
|
} catch {
|
||||||
isFavourited = true
|
isFavorited = true
|
||||||
favouritesCount += 1
|
favoritesCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,17 +209,17 @@ public class StatusRowViewModel: ObservableObject {
|
||||||
|
|
||||||
private func updateFromStatus(status: Status) {
|
private func updateFromStatus(status: Status) {
|
||||||
if let reblog = status.reblog {
|
if let reblog = status.reblog {
|
||||||
isFavourited = reblog.favourited == true
|
isFavorited = reblog.favorited == true
|
||||||
isReblogged = reblog.reblogged == true
|
isReblogged = reblog.reblogged == true
|
||||||
isPinned = reblog.pinned == true
|
isPinned = reblog.pinned == true
|
||||||
isBookmarked = reblog.bookmarked == true
|
isBookmarked = reblog.bookmarked == true
|
||||||
} else {
|
} else {
|
||||||
isFavourited = status.favourited == true
|
isFavorited = status.favorited == true
|
||||||
isReblogged = status.reblogged == true
|
isReblogged = status.reblogged == true
|
||||||
isPinned = status.pinned == true
|
isPinned = status.pinned == true
|
||||||
isBookmarked = status.bookmarked == true
|
isBookmarked = status.bookmarked == true
|
||||||
}
|
}
|
||||||
favouritesCount = status.reblog?.favouritesCount ?? status.favouritesCount
|
favoritesCount = status.reblog?.favoritesCount ?? status.favoritesCount
|
||||||
reblogsCount = status.reblog?.reblogsCount ?? status.reblogsCount
|
reblogsCount = status.reblog?.reblogsCount ?? status.reblogsCount
|
||||||
repliesCount = status.reblog?.repliesCount ?? status.repliesCount
|
repliesCount = status.reblog?.repliesCount ?? status.repliesCount
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue