Various small UI fixes

This commit is contained in:
Thomas Ricouard 2023-01-12 19:12:23 +01:00
parent 5deb928dee
commit e69fcee9fb
4 changed files with 30 additions and 27 deletions

View File

@ -72,8 +72,9 @@ class ExploreViewModel: ObservableObject {
self.trendingLinks = data.trendingLinks
self.suggestedAccountsRelationShips = try await client.get(endpoint: Accounts.relationships(ids: self.suggestedAccounts.map{ $0.id }))
isLoaded = true
withAnimation {
isLoaded = true
}
} catch {
isLoaded = true
}

View File

@ -52,15 +52,20 @@ class NotificationsViewModel: ObservableObject {
types: queryTypes))
nextPageState = notifications.count < 15 ? .none : .hasNextPage
} else if let first = notifications.first {
let newNotifications: [Models.Notification] =
var newNotifications: [Models.Notification] =
try await client.get(endpoint: Notifications.notifications(sinceId: first.id,
maxId: nil,
types: queryTypes))
nextPageState = notifications.count < 15 ? .none : .hasNextPage
newNotifications = newNotifications.filter({ notification in
!notifications.contains(where: { $0.id == notification.id })
})
notifications.insert(contentsOf: newNotifications, at: 0)
}
state = .display(notifications: notifications,
nextPageState: notifications.isEmpty ? .none : nextPageState)
withAnimation {
state = .display(notifications: notifications,
nextPageState: notifications.isEmpty ? .none : nextPageState)
}
} catch {
state = .error(error: error)
}

View File

@ -98,10 +98,12 @@ struct StatusActionsView: View {
@ViewBuilder
private var summaryView: some View {
Divider()
HStack {
Text(viewModel.status.createdAt.asDate, style: .date)
Text(viewModel.status.createdAt.asDate, style: .time)
Text("·")
Text(viewModel.status.createdAt.asDate, style: .date) +
Text(" at ") +
Text(viewModel.status.createdAt.asDate, style: .time) +
Text(" ·")
Image(systemName: viewModel.status.visibility.iconName)
Spacer()
Text(viewModel.status.application?.name ?? "")
@ -114,30 +116,23 @@ struct StatusActionsView: View {
}
.font(.caption)
.foregroundColor(.gray)
if viewModel.favouritesCount > 0 {
Divider()
Button {
routeurPath.navigate(to: .favouritedBy(id: viewModel.status.id))
} label: {
HStack {
Text("\(viewModel.favouritesCount) favorites")
Spacer()
Image(systemName: "chevron.right")
}
.font(.callout)
NavigationLink(value: RouteurDestinations.favouritedBy(id: viewModel.status.id)) {
Text("\(viewModel.favouritesCount) favorites")
.font(.callout)
Spacer()
Image(systemName: "chevron.right")
}
}
if viewModel.reblogsCount > 0 {
Divider()
Button {
routeurPath.navigate(to: .rebloggedBy(id: viewModel.status.id))
} label: {
HStack {
Text("\(viewModel.reblogsCount) boosts")
Spacer()
Image(systemName: "chevron.right")
}
.font(.callout)
NavigationLink(value: RouteurDestinations.rebloggedBy(id: viewModel.status.id)) {
Text("\(viewModel.reblogsCount) boosts")
.font(.callout)
Spacer()
Image(systemName: "chevron.right")
}
}
}

View File

@ -74,7 +74,9 @@ class TimelineViewModel: ObservableObject, StatusesFetcher {
maxId: nil,
minId: nil,
offset: statuses.count))
statusesState = .display(statuses: statuses, nextPageState: statuses.count < 20 ? .none : .hasNextPage)
withAnimation {
statusesState = .display(statuses: statuses, nextPageState: statuses.count < 20 ? .none : .hasNextPage)
}
} else if let first = pendingStatuses.first ?? statuses.first {
var newStatuses: [Status] = await fetchNewPages(minId: first.id, maxPages: 20)
if userIntent || !pendingStatusesEnabled {