mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-17 02:05:13 +00:00
Fixed on post detail
This commit is contained in:
parent
a32014991c
commit
4e2d15eff6
1 changed files with 13 additions and 7 deletions
|
@ -39,7 +39,7 @@ class StatusDetailViewModel: ObservableObject {
|
||||||
|
|
||||||
func fetch() async -> Bool {
|
func fetch() async -> Bool {
|
||||||
if statusId != nil {
|
if statusId != nil {
|
||||||
await fetchStatusDetail()
|
await fetchStatusDetail(animate: false)
|
||||||
return true
|
return true
|
||||||
} else if remoteStatusURL != nil {
|
} else if remoteStatusURL != nil {
|
||||||
return await fetchRemoteStatus()
|
return await fetchRemoteStatus()
|
||||||
|
@ -56,7 +56,7 @@ class StatusDetailViewModel: ObservableObject {
|
||||||
forceVersion: .v2)
|
forceVersion: .v2)
|
||||||
if let statusId = results?.statuses.first?.id {
|
if let statusId = results?.statuses.first?.id {
|
||||||
self.statusId = statusId
|
self.statusId = statusId
|
||||||
await fetchStatusDetail()
|
await fetchStatusDetail(animate: false)
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
@ -68,13 +68,19 @@ class StatusDetailViewModel: ObservableObject {
|
||||||
let context: StatusContext
|
let context: StatusContext
|
||||||
}
|
}
|
||||||
|
|
||||||
private func fetchStatusDetail() async {
|
private func fetchStatusDetail(animate: Bool) async {
|
||||||
guard let client, let statusId else { return }
|
guard let client, let statusId else { return }
|
||||||
do {
|
do {
|
||||||
let data = try await fetchContextData(client: client, statusId: statusId)
|
let data = try await fetchContextData(client: client, statusId: statusId)
|
||||||
title = "status.post-from-\(data.status.account.displayNameWithoutEmojis)"
|
title = "status.post-from-\(data.status.account.displayNameWithoutEmojis)"
|
||||||
|
if animate {
|
||||||
|
withAnimation {
|
||||||
|
state = .display(status: data.status, context: data.context)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
state = .display(status: data.status, context: data.context)
|
state = .display(status: data.status, context: data.context)
|
||||||
scrollToId = statusId
|
scrollToId = statusId
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
state = .error(error: error)
|
state = .error(error: error)
|
||||||
}
|
}
|
||||||
|
@ -91,11 +97,11 @@ class StatusDetailViewModel: ObservableObject {
|
||||||
event.status.account.id == currentAccount?.id
|
event.status.account.id == currentAccount?.id
|
||||||
{
|
{
|
||||||
Task {
|
Task {
|
||||||
await fetchStatusDetail()
|
await fetchStatusDetail(animate: true)
|
||||||
}
|
}
|
||||||
} else if event is StreamEventDelete {
|
} else if event is StreamEventDelete {
|
||||||
Task {
|
Task {
|
||||||
await fetchStatusDetail()
|
await fetchStatusDetail(animate: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue