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

feat!: Implemented simple offline check #782

Draft
wants to merge 1 commit into
base: staging
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions src/wrappers/AnnotateWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const AnnotateWrapper = ({
[username: string]: Annotations;
}>({}); // object mapping usernames to annotations for the current image

const [offline, setOffline] = useState<boolean>(false);
const plugins = usePlugins(collectionUid, auth, Product.ANNOTATE);

const isMounted = useRef(false);
Expand Down Expand Up @@ -265,6 +266,10 @@ export const AnnotateWrapper = ({
(newAnnotationsObject: Annotations): void => {
if (!auth?.user?.username) return;

const isOffline = !navigator.onLine;
setOffline(isOffline);
if (isOffline) return;

// Save annotations data
setTask({
isLoading: true,
Expand Down Expand Up @@ -526,6 +531,7 @@ export const AnnotateWrapper = ({
annotationsObject2={annotationsObject2}
saveAnnotationsCallback={saveAnnotation}
setIsLoading={setIsLoading}
offline={offline}
userAccess={auth.userAccess}
plugins={plugins}
launchPluginSettingsCallback={
Expand Down