mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-03-14 22:22:41 +00:00
Fix flow
This commit is contained in:
parent
0efdf565d0
commit
f8b606cb48
2 changed files with 34 additions and 14 deletions
|
@ -122,7 +122,8 @@ struct PremiumAcccountSubsciptionSheetView: View {
|
|||
.onAppear {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
if let accountName = appAccount.currentAccount.accountName,
|
||||
let url = URL(string: "https://\(AppInfo.premiumInstance)/subscribe/to/\(account.username)?callback=icecubesapp://socialproxy&id=@\(accountName)&amount=\(500)¤cy=USD") {
|
||||
let premiumUsername = account.premiumUsername,
|
||||
let url = URL(string: "https://\(AppInfo.premiumInstance)/subscribe/to/\(premiumUsername)?callback=icecubesapp://socialproxy&id=@\(accountName)&amount=\(500)¤cy=USD") {
|
||||
openURL(url)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,19 +70,7 @@ public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable
|
|||
public var haveHeader: Bool {
|
||||
header.lastPathComponent != "missing.png"
|
||||
}
|
||||
|
||||
public var isLinkedToPremiumAccount: Bool {
|
||||
fields.first(where: { $0.value.asRawText.hasSuffix(AppInfo.premiumInstance) }) != nil
|
||||
}
|
||||
|
||||
public var premiumAcct: String? {
|
||||
fields.first(where: { $0.value.asRawText.hasSuffix(AppInfo.premiumInstance) })?.value.asRawText
|
||||
}
|
||||
|
||||
public var isPremiumAccount: Bool {
|
||||
url?.host() == AppInfo.premiumInstance
|
||||
}
|
||||
|
||||
|
||||
public var fullAccountName: String {
|
||||
"\(acct)@\(url?.host() ?? "")"
|
||||
}
|
||||
|
@ -203,3 +191,34 @@ public struct FamiliarAccounts: Decodable {
|
|||
}
|
||||
|
||||
extension FamiliarAccounts: Sendable {}
|
||||
|
||||
// Premium Stuff
|
||||
extension Account {
|
||||
public var isLinkedToPremiumAccount: Bool {
|
||||
guard url?.host() != AppInfo.premiumInstance else {
|
||||
return false
|
||||
}
|
||||
return fields.first(where: { $0.value.asRawText.contains(AppInfo.premiumInstance) }) != nil
|
||||
}
|
||||
|
||||
public var premiumAcct: String? {
|
||||
if let field = fields.first(where: { $0.value.asRawText.hasSuffix(AppInfo.premiumInstance) }) {
|
||||
return field.value.asRawText
|
||||
} else if let field = fields.first(where: { $0.value.asRawText.hasPrefix("https://\(AppInfo.premiumInstance)") }),
|
||||
let url = URL(string: field.value.asRawText) {
|
||||
return "\(url.lastPathComponent)@\(url.host() ?? "\(AppInfo.premiumInstance)")"
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
public var premiumUsername: String? {
|
||||
var username = premiumAcct?.replacingOccurrences(of: "@\(AppInfo.premiumInstance)", with: "")
|
||||
username?.removeFirst()
|
||||
return username
|
||||
}
|
||||
|
||||
public var isPremiumAccount: Bool {
|
||||
url?.host() == AppInfo.premiumInstance
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue