Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clear error in store fetchers and timers #43

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Sources/Screens/Account/AccountOverview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ struct AccountOverview: View, ViewDataProvider, LoadStateProvider, TimerLifecycl
if isLoading {
ProgressView()
} else if let error {
VOErrorMessage(error)
VStack {
VOErrorMessage(error)
Button {
performSignOut()
} label: {
VOButtonLabel("Sign Out")
}
.voButton(color: .red500)
.fixedSize()
.padding(.horizontal)
}
} else {
if let identityUser = accountStore.identityUser {
VOAvatar(
Expand Down
4 changes: 4 additions & 0 deletions Sources/Screens/Account/AccountStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class AccountStore: ObservableObject {
self.identityUserIsLoading = true
} success: {
self.identityUser = identityUser
self.identityUserError = nil
} failure: { message in
self.identityUserError = message
} invalidCredentials: {
Expand All @@ -90,6 +91,7 @@ class AccountStore: ObservableObject {
self.storageUsageIsLoading = true
} success: {
self.storageUsage = storageUsage
self.storageUsageError = nil
} failure: { message in
self.storageUsageError = message
} anyways: {
Expand Down Expand Up @@ -126,6 +128,7 @@ class AccountStore: ObservableObject {
if let user {
DispatchQueue.main.async {
self.identityUser = user
self.identityUserError = nil
}
}
}
Expand All @@ -136,6 +139,7 @@ class AccountStore: ObservableObject {
if let storageUsage {
DispatchQueue.main.async {
self.storageUsage = storageUsage
self.storageUsageError = nil
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/Screens/Browser/BrowserStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class BrowserStore: ObservableObject {
self.folderIsLoading = true
} success: {
self.folder = folder
self.folderError = nil
} failure: { message in
self.folderError = message
} anyways: {
Expand Down Expand Up @@ -108,6 +109,7 @@ class BrowserStore: ObservableObject {
if !self.hasNextPage() { return false }
nextPage = self.nextPage()
list = try await self.fetchList(folderID, page: nextPage)
self.entitiesError = nil
return true
} before: {
self.entitiesIsLoading = true
Expand Down Expand Up @@ -190,6 +192,7 @@ class BrowserStore: ObservableObject {
if let list {
DispatchQueue.main.async {
self.entities = list.data
self.entitiesError = nil
}
}
}
Expand All @@ -200,6 +203,7 @@ class BrowserStore: ObservableObject {
if let folder {
DispatchQueue.main.async {
self.folder = folder
self.folderError = nil
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions Sources/Screens/File/FileStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class FileStore: ObservableObject {
self.fileIsLoading = true
} success: {
self.file = folder
self.fileError = nil
} failure: { message in
self.fileError = message
} anyways: {
Expand Down Expand Up @@ -163,6 +164,7 @@ class FileStore: ObservableObject {
if !self.hasNextPage() { return false }
nextPage = self.nextPage()
list = try await self.fetchList(file.id, page: nextPage)
self.entitiesError = nil
return true
} before: {
self.entitiesIsLoading = true
Expand Down Expand Up @@ -190,6 +192,7 @@ class FileStore: ObservableObject {
var taskCount: Int?
withErrorHandling {
taskCount = try await self.fetchTaskCount()
self.taskCountError = nil
return true
} before: {
self.taskCountIsLoading = true
Expand All @@ -211,6 +214,7 @@ class FileStore: ObservableObject {
var storageUsage: VOStorage.Usage?
withErrorHandling {
storageUsage = try await self.fetchStorageUsage()
self.storageUsageError = nil
return true
} before: {
self.storageUsageIsLoading = true
Expand All @@ -232,6 +236,7 @@ class FileStore: ObservableObject {
var itemCount: Int?
withErrorHandling {
itemCount = try await self.fetchItemCount()
self.itemCountError = nil
return true
} before: {
self.itemCountIsLoading = true
Expand Down Expand Up @@ -364,6 +369,7 @@ class FileStore: ObservableObject {
if let list {
DispatchQueue.main.async {
self.entities = list.data
self.entitiesError = nil
}
}
}
Expand All @@ -374,6 +380,7 @@ class FileStore: ObservableObject {
if let file {
DispatchQueue.main.async {
self.file = file
self.fileError = nil
}
}
}
Expand All @@ -383,6 +390,7 @@ class FileStore: ObservableObject {
let taskCount = try await self.fetchTaskCount()
DispatchQueue.main.async {
self.taskCount = taskCount
self.taskCountError = nil
}
}
}
Expand Down
12 changes: 2 additions & 10 deletions Sources/Screens/Group/GroupStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class GroupStore: ObservableObject {
self.append(list.data)
}
}
self.entitiesError = nil
} failure: { message in
self.entitiesError = message
} anyways: {
Expand Down Expand Up @@ -210,16 +211,7 @@ class GroupStore: ObservableObject {
if let list {
DispatchQueue.main.async {
self.entities = list.data
}
}
}
}
if let current = self.current {
Task {
let group = try await self.groupClient?.fetch(current.id)
if let group {
DispatchQueue.main.async {
self.current = group
self.entitiesError = nil
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/Screens/Insights/InsightsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class InsightsStore: ObservableObject {
self.languagesIsLoading = true
} success: {
self.languages = languages
self.languagesError = nil
} failure: { message in
self.languagesError = message
} anyways: {
Expand All @@ -87,6 +88,7 @@ class InsightsStore: ObservableObject {
var info: VOInsights.Info?
withErrorHandling {
info = try await self.fetchInfo()
self.infoError = nil
return true
} before: {
self.infoIsLoading = true
Expand Down Expand Up @@ -148,6 +150,7 @@ class InsightsStore: ObservableObject {
if !self.hasNextPage() { return false }
nextPage = self.nextPage()
list = try await self.fetchEntityList(page: nextPage)
self.entitiesError = nil
return true
} before: {
self.entitiesIsLoading = true
Expand Down Expand Up @@ -247,6 +250,7 @@ class InsightsStore: ObservableObject {
if let list {
DispatchQueue.main.async {
self.entities = list.data
self.entitiesError = nil
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/Screens/Invitation/InvitationStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class InvitationStore: ObservableObject {
self.append(list.data)
}
}
self.entitiesError = nil
} failure: { message in
self.entitiesError = message
} anyways: {
Expand All @@ -110,6 +111,7 @@ class InvitationStore: ObservableObject {
self.incomingCountIsLoading = true
} success: {
self.incomingCount = incomingCount
self.incomingCountError = nil
} failure: { message in
self.incomingCountError = message
} anyways: {
Expand Down Expand Up @@ -199,6 +201,7 @@ class InvitationStore: ObservableObject {
if let list {
DispatchQueue.main.async {
self.entities = list.data
self.entitiesError = nil
}
}
}
Expand All @@ -209,6 +212,7 @@ class InvitationStore: ObservableObject {
if let incomingCount {
DispatchQueue.main.async {
self.incomingCount = incomingCount
self.incomingCountError = nil
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Screens/Mosaic/MosaicStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class MosaicStore: ObservableObject {
self.infoIsLoading = true
} success: {
self.info = info
self.infoError = nil
} failure: { message in
self.infoError = message
} anyways: {
Expand All @@ -71,6 +72,7 @@ class MosaicStore: ObservableObject {
if let info {
DispatchQueue.main.async {
self.info = info
self.infoError = nil
}
}
}
Expand Down
12 changes: 2 additions & 10 deletions Sources/Screens/Organization/OrganizationStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class OrganizationStore: ObservableObject {
self.append(list.data)
}
}
self.entitiesError = nil
} failure: { message in
self.entitiesError = message
} anyways: {
Expand Down Expand Up @@ -184,16 +185,7 @@ class OrganizationStore: ObservableObject {
if let list {
DispatchQueue.main.async {
self.entities = list.data
}
}
}
}
if let current = self.current {
Task {
let organization = try await self.fetch(current.id)
if let organization {
DispatchQueue.main.async {
self.current = organization
self.entitiesError = nil
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/Screens/Sharing/SharingStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class SharingStore: ObservableObject {
self.userPermissionsIsLoading = true
} success: {
self.userPermissions = userPermissions
self.userPermissionsError = nil
} failure: { message in
self.userPermissionsError = message
} anyways: {
Expand All @@ -75,6 +76,7 @@ class SharingStore: ObservableObject {

withErrorHandling {
groupPermissions = try await self.fetchGroupPermissions(fileID)
self.groupPermissionsError = nil
return true
} before: {
self.groupPermissionsIsLoading = true
Expand Down Expand Up @@ -117,6 +119,7 @@ class SharingStore: ObservableObject {
if let values {
DispatchQueue.main.async {
self.userPermissions = values
self.userPermissionsError = nil
}
}
}
Expand All @@ -127,6 +130,7 @@ class SharingStore: ObservableObject {
if let values {
DispatchQueue.main.async {
self.groupPermissions = values
self.groupPermissionsError = nil
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Screens/SignUp/SignUpStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SignUpStore: ObservableObject {
self.passwordRequirementsIsLoading = true
} success: {
self.passwordRequirements = passwordRequirements
self.passwordRequirementsError = nil
} failure: { message in
self.passwordRequirementsError = message
} anyways: {
Expand All @@ -58,6 +59,7 @@ class SignUpStore: ObservableObject {
if let passwordRequirements {
DispatchQueue.main.async {
self.passwordRequirements = passwordRequirements
self.passwordRequirementsError = nil
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Screens/Snapshot/SnapshotStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class SnapshotStore: ObservableObject {
self.append(list.data)
}
}
self.entitiesError = nil
} failure: { message in
self.entitiesError = message
} anyways: {
Expand Down Expand Up @@ -166,6 +167,7 @@ class SnapshotStore: ObservableObject {
if let list {
DispatchQueue.main.async {
self.entities = list.data
self.entitiesError = nil
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Screens/Task/TaskStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class TaskStore: ObservableObject {
self.append(list.data)
}
}
self.entitiesError = nil
} failure: { message in
self.entitiesError = message
} anyways: {
Expand Down Expand Up @@ -156,6 +157,7 @@ class TaskStore: ObservableObject {
if let list {
DispatchQueue.main.async {
self.entities = list.data
self.entitiesError = nil
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Screens/User/UserStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class UserStore: ObservableObject {
self.append(list.data)
}
}
self.entitiesError = nil
} failure: { message in
self.entitiesError = message
} anyways: {
Expand Down Expand Up @@ -209,6 +210,7 @@ class UserStore: ObservableObject {
if let list {
DispatchQueue.main.async {
self.entities = list.data
self.entitiesError = nil
}
}
}
Expand Down
Loading