mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 02:01:02 +00:00
Added a "Moved To" Button to accounts that moved to other instances (#2001)
* added moved information to Account model * Added "Moved To" button to account details for accounts that have moved
This commit is contained in:
parent
7c343eb4e9
commit
bc2a09891a
3 changed files with 36 additions and 2 deletions
|
@ -17067,6 +17067,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"account.movedto.redirect-%@" : {
|
||||||
|
"extractionState" : "manual",
|
||||||
|
"localizations" : {
|
||||||
|
"de" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Umgezogen nach %@"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Moved To %@"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"account.post.pinned" : {
|
"account.post.pinned" : {
|
||||||
"extractionState" : "manual",
|
"extractionState" : "manual",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
|
|
|
@ -207,6 +207,7 @@ struct AccountDetailHeaderView: View {
|
||||||
.foregroundStyle(.secondary)
|
.foregroundStyle(.secondary)
|
||||||
.textSelection(.enabled)
|
.textSelection(.enabled)
|
||||||
.accessibilityRespondsToUserInteraction(false)
|
.accessibilityRespondsToUserInteraction(false)
|
||||||
|
movedToView
|
||||||
joinedAtView
|
joinedAtView
|
||||||
}
|
}
|
||||||
.accessibilityElement(children: .contain)
|
.accessibilityElement(children: .contain)
|
||||||
|
@ -311,6 +312,17 @@ struct AccountDetailHeaderView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private var movedToView: some View {
|
||||||
|
if let movedTo = viewModel.account?.moved {
|
||||||
|
Button("account.movedto.redirect-\("@\(movedTo.acct)")") {
|
||||||
|
routerPath.navigate(to: .accountDetailWithAccount(account: movedTo))
|
||||||
|
}
|
||||||
|
.font(.scaledCallout)
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func makeNoteView(_ note: String) -> some View {
|
private func makeNoteView(_ note: String) -> some View {
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
|
|
|
@ -61,6 +61,7 @@ public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable
|
||||||
public let source: Source?
|
public let source: Source?
|
||||||
public let bot: Bool
|
public let bot: Bool
|
||||||
public let discoverable: Bool?
|
public let discoverable: Bool?
|
||||||
|
public let moved: Account?
|
||||||
|
|
||||||
public var haveAvatar: Bool {
|
public var haveAvatar: Bool {
|
||||||
avatar.lastPathComponent != "missing.png"
|
avatar.lastPathComponent != "missing.png"
|
||||||
|
@ -70,7 +71,7 @@ public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable
|
||||||
header.lastPathComponent != "missing.png"
|
header.lastPathComponent != "missing.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(id: String, username: String, displayName: String?, avatar: URL, header: URL, acct: String, note: HTMLString, createdAt: ServerDate, followersCount: Int, followingCount: Int, statusesCount: Int, lastStatusAt: String? = nil, fields: [Account.Field], locked: Bool, emojis: [Emoji], url: URL? = nil, source: Account.Source? = nil, bot: Bool, discoverable: Bool? = nil) {
|
public init(id: String, username: String, displayName: String?, avatar: URL, header: URL, acct: String, note: HTMLString, createdAt: ServerDate, followersCount: Int, followingCount: Int, statusesCount: Int, lastStatusAt: String? = nil, fields: [Account.Field], locked: Bool, emojis: [Emoji], url: URL? = nil, source: Account.Source? = nil, bot: Bool, discoverable: Bool? = nil, moved: Account? = nil) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.username = username
|
self.username = username
|
||||||
self.displayName = displayName
|
self.displayName = displayName
|
||||||
|
@ -90,6 +91,7 @@ public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable
|
||||||
self.source = source
|
self.source = source
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.discoverable = discoverable
|
self.discoverable = discoverable
|
||||||
|
self.moved = moved
|
||||||
|
|
||||||
if let displayName, !displayName.isEmpty {
|
if let displayName, !displayName.isEmpty {
|
||||||
cachedDisplayName = .init(stringValue: displayName)
|
cachedDisplayName = .init(stringValue: displayName)
|
||||||
|
@ -118,6 +120,7 @@ public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable
|
||||||
case source
|
case source
|
||||||
case bot
|
case bot
|
||||||
case discoverable
|
case discoverable
|
||||||
|
case moved
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(from decoder: Decoder) throws {
|
public init(from decoder: Decoder) throws {
|
||||||
|
@ -141,6 +144,8 @@ public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable
|
||||||
source = try container.decodeIfPresent(Account.Source.self, forKey: .source)
|
source = try container.decodeIfPresent(Account.Source.self, forKey: .source)
|
||||||
bot = try container.decode(Bool.self, forKey: .bot)
|
bot = try container.decode(Bool.self, forKey: .bot)
|
||||||
discoverable = try container.decodeIfPresent(Bool.self, forKey: .discoverable)
|
discoverable = try container.decodeIfPresent(Bool.self, forKey: .discoverable)
|
||||||
|
moved = try container.decodeIfPresent(Account.self, forKey: .moved)
|
||||||
|
|
||||||
if let displayName, !displayName.isEmpty {
|
if let displayName, !displayName.isEmpty {
|
||||||
cachedDisplayName = .init(stringValue: displayName)
|
cachedDisplayName = .init(stringValue: displayName)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue