mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Display loading when fetching remote user on status row
This commit is contained in:
parent
62c3f6e04a
commit
e84a57ed7f
4 changed files with 72 additions and 43 deletions
|
@ -124,7 +124,6 @@ public class RouterPath: ObservableObject {
|
||||||
|
|
||||||
public func navigateToAccountFrom(acct: String, url: URL) async {
|
public func navigateToAccountFrom(acct: String, url: URL) async {
|
||||||
guard let client else { return }
|
guard let client else { return }
|
||||||
Task {
|
|
||||||
let results: SearchResults? = try? await client.get(endpoint: Search.search(query: acct,
|
let results: SearchResults? = try? await client.get(endpoint: Search.search(query: acct,
|
||||||
type: "accounts",
|
type: "accounts",
|
||||||
offset: nil,
|
offset: nil,
|
||||||
|
@ -136,11 +135,9 @@ public class RouterPath: ObservableObject {
|
||||||
await UIApplication.shared.open(url)
|
await UIApplication.shared.open(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public func navigateToAccountFrom(url: URL) async {
|
public func navigateToAccountFrom(url: URL) async {
|
||||||
guard let client else { return }
|
guard let client else { return }
|
||||||
Task {
|
|
||||||
let results: SearchResults? = try? await client.get(endpoint: Search.search(query: url.absoluteString,
|
let results: SearchResults? = try? await client.get(endpoint: Search.search(query: url.absoluteString,
|
||||||
type: "accounts",
|
type: "accounts",
|
||||||
offset: nil,
|
offset: nil,
|
||||||
|
@ -153,4 +150,3 @@ public class RouterPath: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ class VideoPlayerViewModel: ObservableObject {
|
||||||
func preparePlayer(autoPlay: Bool) {
|
func preparePlayer(autoPlay: Bool) {
|
||||||
player = .init(url: url)
|
player = .init(url: url)
|
||||||
player?.isMuted = true
|
player?.isMuted = true
|
||||||
|
player?.audiovisualBackgroundPlaybackPolicy = .pauses
|
||||||
if autoPlay {
|
if autoPlay {
|
||||||
player?.play()
|
player?.play()
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,11 @@ public struct StatusRowView: View {
|
||||||
viewModel.navigateToDetail(routerPath: routerPath)
|
viewModel.navigateToDetail(routerPath: routerPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.overlay {
|
||||||
|
if viewModel.isLoadingRemoteContent {
|
||||||
|
remoteContentLoadingView
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,13 +154,7 @@ public struct StatusRowView: View {
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
.fontWeight(.semibold)
|
.fontWeight(.semibold)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
if viewModel.isRemote, let url = viewModel.status.account.url {
|
viewModel.navigateToAccountDetail(account: viewModel.status.account, routerPath: routerPath)
|
||||||
Task {
|
|
||||||
await routerPath.navigateToAccountFrom(url: url)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
routerPath.navigate(to: .accountDetailWithAccount(account: viewModel.status.account))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,13 +173,7 @@ public struct StatusRowView: View {
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
.fontWeight(.semibold)
|
.fontWeight(.semibold)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
if viewModel.isRemote {
|
viewModel.navigateToMention(mention: mention, routerPath: routerPath)
|
||||||
Task {
|
|
||||||
await routerPath.navigateToAccountFrom(url: mention.url)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
routerPath.navigate(to: .accountDetail(id: mention.id))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,13 +184,7 @@ public struct StatusRowView: View {
|
||||||
if !viewModel.isCompact {
|
if !viewModel.isCompact {
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .top) {
|
||||||
Button {
|
Button {
|
||||||
if viewModel.isRemote, let url = status.account.url {
|
viewModel.navigateToAccountDetail(account: status.account, routerPath: routerPath)
|
||||||
Task {
|
|
||||||
await routerPath.navigateToAccountFrom(url: url)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
routerPath.navigate(to: .accountDetailWithAccount(account: status.account))
|
|
||||||
}
|
|
||||||
} label: {
|
} label: {
|
||||||
accountView(status: status)
|
accountView(status: status)
|
||||||
}
|
}
|
||||||
|
@ -396,4 +383,20 @@ public struct StatusRowView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var remoteContentLoadingView: some View {
|
||||||
|
ZStack(alignment: .center) {
|
||||||
|
VStack {
|
||||||
|
Spacer()
|
||||||
|
HStack {
|
||||||
|
Spacer()
|
||||||
|
ProgressView()
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.background(Color.black.opacity(0.40))
|
||||||
|
.transition(.opacity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class StatusRowViewModel: ObservableObject {
|
||||||
@Published var displaySpoiler: Bool = false
|
@Published var displaySpoiler: Bool = false
|
||||||
@Published var isEmbedLoading: Bool = false
|
@Published var isEmbedLoading: Bool = false
|
||||||
@Published var isFiltered: Bool = false
|
@Published var isFiltered: Bool = false
|
||||||
|
@Published var isLoadingRemoteContent: Bool = false
|
||||||
|
|
||||||
@Published var translation: String?
|
@Published var translation: String?
|
||||||
@Published var isLoadingTranslation: Bool = false
|
@Published var isLoadingTranslation: Bool = false
|
||||||
|
@ -71,6 +72,34 @@ public class StatusRowViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func navigateToAccountDetail(account: Account, routerPath: RouterPath) {
|
||||||
|
if isRemote, let url = account.url {
|
||||||
|
withAnimation {
|
||||||
|
isLoadingRemoteContent = true
|
||||||
|
}
|
||||||
|
Task {
|
||||||
|
await routerPath.navigateToAccountFrom(url: url)
|
||||||
|
isLoadingRemoteContent = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
routerPath.navigate(to: .accountDetailWithAccount(account: account))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func navigateToMention(mention: Mention, routerPath: RouterPath) {
|
||||||
|
if isRemote {
|
||||||
|
withAnimation {
|
||||||
|
isLoadingRemoteContent = true
|
||||||
|
}
|
||||||
|
Task {
|
||||||
|
await routerPath.navigateToAccountFrom(url: mention.url)
|
||||||
|
isLoadingRemoteContent = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
routerPath.navigate(to: .accountDetail(id: mention.id))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func loadEmbeddedStatus() async {
|
func loadEmbeddedStatus() async {
|
||||||
guard let client,
|
guard let client,
|
||||||
embeddedStatus == nil,
|
embeddedStatus == nil,
|
||||||
|
|
Loading…
Reference in a new issue