mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 00:11:00 +00:00
Add timer for sub.club account
This commit is contained in:
parent
8c6d2bee7f
commit
83bf872cca
1 changed files with 14 additions and 0 deletions
|
@ -24,6 +24,8 @@ struct AccountDetailHeaderView: View {
|
|||
let account: Account
|
||||
let scrollViewProxy: ScrollViewProxy?
|
||||
|
||||
private let premiumTimer = Timer.publish(every: 5, on: .main, in: .common).autoconnect()
|
||||
@State private var shouldListenToPremiumTimer: Bool = false
|
||||
@State private var isTipSheetPresented: Bool = false
|
||||
|
||||
var body: some View {
|
||||
|
@ -61,6 +63,17 @@ struct AccountDetailHeaderView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onReceive(premiumTimer) { _ in
|
||||
if shouldListenToPremiumTimer {
|
||||
Task {
|
||||
if viewModel.account?.isLinkedToPremiumAccount == true {
|
||||
await viewModel.fetchAccount()
|
||||
} else{
|
||||
try? await viewModel.followButtonViewModel?.refreshRelationship()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var headerImageView: some View {
|
||||
|
@ -332,6 +345,7 @@ struct AccountDetailHeaderView: View {
|
|||
private var tipView: some View {
|
||||
Button {
|
||||
isTipSheetPresented = true
|
||||
shouldListenToPremiumTimer = true
|
||||
Task {
|
||||
if viewModel.account?.isLinkedToPremiumAccount == true {
|
||||
try? await viewModel.followPremiumAccount()
|
||||
|
|
Loading…
Reference in a new issue