chore: show sync error in footer corner instead of toast notification [skip e2e]
This commit is contained in:
@@ -1,13 +1,6 @@
|
|||||||
import { WebApplicationGroup } from '@/Application/WebApplicationGroup'
|
import { WebApplicationGroup } from '@/Application/WebApplicationGroup'
|
||||||
import { getPlatformString } from '@/Utils'
|
import { getPlatformString } from '@/Utils'
|
||||||
import {
|
import { ApplicationEvent, Challenge, removeFromArray, WebAppEvent } from '@standardnotes/snjs'
|
||||||
ApplicationEvent,
|
|
||||||
Challenge,
|
|
||||||
getErrorMessageFromErrorResponseBody,
|
|
||||||
HttpErrorResponseBody,
|
|
||||||
removeFromArray,
|
|
||||||
WebAppEvent,
|
|
||||||
} from '@standardnotes/snjs'
|
|
||||||
import { alertDialog, isIOS, RouteType } from '@standardnotes/ui-services'
|
import { alertDialog, isIOS, RouteType } from '@standardnotes/ui-services'
|
||||||
import { WebApplication } from '@/Application/WebApplication'
|
import { WebApplication } from '@/Application/WebApplication'
|
||||||
import Footer from '@/Components/Footer/Footer'
|
import Footer from '@/Components/Footer/Footer'
|
||||||
@@ -124,7 +117,7 @@ const ApplicationView: FunctionComponent<Props> = ({ application, mainApplicatio
|
|||||||
onAppLaunch()
|
onAppLaunch()
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeAppObserver = application.addEventObserver(async (eventName, data?: unknown) => {
|
const removeAppObserver = application.addEventObserver(async (eventName) => {
|
||||||
if (eventName === ApplicationEvent.Started) {
|
if (eventName === ApplicationEvent.Started) {
|
||||||
onAppStart()
|
onAppStart()
|
||||||
} else if (eventName === ApplicationEvent.Launched) {
|
} else if (eventName === ApplicationEvent.Launched) {
|
||||||
@@ -154,14 +147,6 @@ const ApplicationView: FunctionComponent<Props> = ({ application, mainApplicatio
|
|||||||
type: ToastType.Error,
|
type: ToastType.Error,
|
||||||
message: 'Too many requests. Please try again later.',
|
message: 'Too many requests. Please try again later.',
|
||||||
})
|
})
|
||||||
} else if (eventName === ApplicationEvent.FailedSync) {
|
|
||||||
addToast({
|
|
||||||
type: ToastType.Error,
|
|
||||||
message: getErrorMessageFromErrorResponseBody(
|
|
||||||
data as HttpErrorResponseBody,
|
|
||||||
'Sync error. Please try again later.',
|
|
||||||
),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,14 @@ import { WebApplication } from '@/Application/WebApplication'
|
|||||||
import { WebApplicationGroup } from '@/Application/WebApplicationGroup'
|
import { WebApplicationGroup } from '@/Application/WebApplicationGroup'
|
||||||
import { AbstractComponent } from '@/Components/Abstract/PureComponent'
|
import { AbstractComponent } from '@/Components/Abstract/PureComponent'
|
||||||
import { destroyAllObjectProperties, preventRefreshing } from '@/Utils'
|
import { destroyAllObjectProperties, preventRefreshing } from '@/Utils'
|
||||||
import { ApplicationEvent, ApplicationDescriptor, WebAppEvent, StatusServiceEvent } from '@standardnotes/snjs'
|
import {
|
||||||
|
ApplicationEvent,
|
||||||
|
ApplicationDescriptor,
|
||||||
|
WebAppEvent,
|
||||||
|
StatusServiceEvent,
|
||||||
|
HttpErrorResponseBody,
|
||||||
|
getErrorMessageFromErrorResponseBody,
|
||||||
|
} from '@standardnotes/snjs'
|
||||||
import {
|
import {
|
||||||
STRING_NEW_UPDATE_READY,
|
STRING_NEW_UPDATE_READY,
|
||||||
STRING_CONFIRM_APP_QUIT_DURING_UPGRADE,
|
STRING_CONFIRM_APP_QUIT_DURING_UPGRADE,
|
||||||
@@ -39,6 +46,7 @@ type State = {
|
|||||||
offline: boolean
|
offline: boolean
|
||||||
hasError: boolean
|
hasError: boolean
|
||||||
arbitraryStatusMessage?: string
|
arbitraryStatusMessage?: string
|
||||||
|
failedSyncError?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
class Footer extends AbstractComponent<Props, State> {
|
class Footer extends AbstractComponent<Props, State> {
|
||||||
@@ -158,7 +166,7 @@ class Footer extends AbstractComponent<Props, State> {
|
|||||||
this.reloadPasscodeStatus().catch(console.error)
|
this.reloadPasscodeStatus().catch(console.error)
|
||||||
}
|
}
|
||||||
|
|
||||||
override onAppEvent(eventName: ApplicationEvent) {
|
override onAppEvent(eventName: ApplicationEvent, data?: unknown) {
|
||||||
switch (eventName) {
|
switch (eventName) {
|
||||||
case ApplicationEvent.KeyStatusChanged:
|
case ApplicationEvent.KeyStatusChanged:
|
||||||
this.reloadUpgradeStatus()
|
this.reloadUpgradeStatus()
|
||||||
@@ -186,6 +194,9 @@ class Footer extends AbstractComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
this.findErrors()
|
this.findErrors()
|
||||||
this.updateOfflineStatus()
|
this.updateOfflineStatus()
|
||||||
|
this.setState({
|
||||||
|
failedSyncError: undefined,
|
||||||
|
})
|
||||||
break
|
break
|
||||||
case ApplicationEvent.SyncStatusChanged:
|
case ApplicationEvent.SyncStatusChanged:
|
||||||
this.updateSyncStatus()
|
this.updateSyncStatus()
|
||||||
@@ -194,6 +205,12 @@ class Footer extends AbstractComponent<Props, State> {
|
|||||||
this.updateSyncStatus()
|
this.updateSyncStatus()
|
||||||
this.findErrors()
|
this.findErrors()
|
||||||
this.updateOfflineStatus()
|
this.updateOfflineStatus()
|
||||||
|
this.setState({
|
||||||
|
failedSyncError: getErrorMessageFromErrorResponseBody(
|
||||||
|
data as HttpErrorResponseBody,
|
||||||
|
'Sync error. Please try again later.',
|
||||||
|
),
|
||||||
|
})
|
||||||
break
|
break
|
||||||
case ApplicationEvent.LocalDataIncrementalLoad:
|
case ApplicationEvent.LocalDataIncrementalLoad:
|
||||||
case ApplicationEvent.LocalDataLoaded:
|
case ApplicationEvent.LocalDataLoaded:
|
||||||
@@ -384,6 +401,11 @@ class Footer extends AbstractComponent<Props, State> {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="right flex h-full flex-shrink-0">
|
<div className="right flex h-full flex-shrink-0">
|
||||||
|
{this.state.failedSyncError && (
|
||||||
|
<div className="relative z-footer-bar-item flex select-none items-center text-xs font-bold text-neutral">
|
||||||
|
Sync error: {this.state.failedSyncError}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{this.state.dataUpgradeAvailable && (
|
{this.state.dataUpgradeAvailable && (
|
||||||
<div
|
<div
|
||||||
onClick={this.securityUpdateClickHandler}
|
onClick={this.securityUpdateClickHandler}
|
||||||
|
|||||||
Reference in New Issue
Block a user