Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: sync progress

ammarahm-ed74f70949ba11
diff --git a/apps/mobile/src/components/dialogprovider/index.js b/apps/mobile/src/components/dialogprovider/index.js
index 62dd9c70c..d8c2a5887 100644
--- a/apps/mobile/src/components/dialogprovider/index.js
+++ b/apps/mobile/src/components/dialogprovider/index.js
@@ -38,6 +38,7 @@ const DialogProvider = React.memo(
<ExportNotesSheet />
<RecoveryKeySheet colors={colors} />
<SheetProvider />
+ <SheetProvider context="sync_progress" />
<RestoreDataSheet />
<ResultDialog />
<VaultDialog colors={colors} />
diff --git a/apps/mobile/src/components/sheets/progress/index.tsx b/apps/mobile/src/components/sheets/progress/index.tsx
new file mode 100644
index 000000000..655e571fe
--- /dev/null
+++ b/apps/mobile/src/components/sheets/progress/index.tsx
@@ -0,0 +1,72 @@
+import React, { useEffect, useState } from 'react';
+import { View } from 'react-native';
+import * as ProgressBar from 'react-native-progress';
+import { presentSheet } from '../../../services/event-manager';
+import { useThemeStore } from '../../../stores/theme';
+import useSyncProgress from '../../../utils/hooks/use-sync-progress';
+import { SIZE } from '../../../utils/size';
+import Seperator from '../../ui/seperator';
+import Heading from '../../ui/typography/heading';
+import Paragraph from '../../ui/typography/paragraph';
+
+export const Progress = () => {
+ const colors = useThemeStore(state => state.colors);
+ const { progress } = useSyncProgress();
+ const [currentProgress, setCurrentProgress] = useState(0.1);
+
+ useEffect(() => {
+ let nextProgress = progress ? progress?.current / progress?.total : 0.1;
+
+ setCurrentProgress(currentProgress => {
+ if (currentProgress > nextProgress) return currentProgress;
+ return progress ? progress?.current / progress?.total : 0.1;
+ });
+ }, [progress]);
+
+ return (
+ <View
+ style={{
+ width: '100%',
+ justifyContent: 'center',
+ alignItems: 'center',
+ paddingTop: 25,
+ paddingBottom: 15
+ }}
+ >
+ <Heading size={SIZE.lg}>Syncing your data</Heading>
+ <Paragraph>Please wait while we sync all your data.</Paragraph>
+ <Seperator />
+ <View
+ style={{
+ width: 200
+ }}
+ >
+ <ProgressBar.Bar
+ height={5}
+ width={null}
+ animated={true}
+ useNativeDriver
+ progress={currentProgress || 0.1}
+ unfilledColor={colors.nav}
+ color={colors.accent}
+ borderWidth={0}
+ />
+ </View>
+
+ {progress ? (
+ <Paragraph color={colors.icon}>
+ {progress.type?.slice(0, 1).toUpperCase() + progress.type?.slice(1)}ing{' '}
+ {progress?.current}/{progress?.total}
+ </Paragraph>
+ ) : null}
+ </View>
+ );
+};
+
+Progress.present = () => {
+ presentSheet({
+ component: <Progress />,
+ disableClosing: true,
+ context: 'sync_progress'
+ });
+};
diff --git a/apps/mobile/src/components/sidemenu/userstatus.js b/apps/mobile/src/components/sidemenu/userstatus.js
index 22846c817..4bcb91c2d 100644
--- a/apps/mobile/src/components/sidemenu/userstatus.js
+++ b/apps/mobile/src/components/sidemenu/userstatus.js
@@ -12,6 +12,8 @@ import { PressableButton } from '../ui/pressable';
import Heading from '../ui/typography/heading';
import Paragraph from '../ui/typography/paragraph';
import { TimeSince } from '../ui/time-since';
+import useSyncProgress from '../../utils/hooks/use-sync-progress';
+import * as Progress from 'react-native-progress';
export const UserStatus = () => {
const colors = useThemeStore(state => state.colors);
@@ -19,6 +21,7 @@ export const UserStatus = () => {
const syncing = useUserStore(state => state.syncing);
const lastSynced = useUserStore(state => state.lastSynced);
const insets = useSafeAreaInsets();
+ const { progress } = useSyncProgress();
return (
<View
@@ -82,7 +85,7 @@ export const UserStatus = () => {
'never'
)
) : (
- 'Syncing your notes'
+ `Syncing your notes${progress ? ` (${progress.current}/${progress.total})` : ''}`
)}{' '}
<Icon
name="checkbox-blank-circle"
@@ -103,7 +106,20 @@ export const UserStatus = () => {
{user ? (
syncing ? (
- <ActivityIndicator size={SIZE.lg} color={colors.accent} />
+ <>
+ <Progress.Circle
+ size={SIZE.xl}
+ progress={progress ? progress.current / progress.total : 0.1}
+ textStyle={{
+ fontSize: 8
+ }}
+ animated={true}
+ color={colors.accent}
+ unfilledColor={colors.nav}
+ borderWidth={0}
+ thickness={2}
+ />
+ </>
) : (
<Icon color={colors.accent} name="sync" size={SIZE.lg} />
)
diff --git a/apps/mobile/src/screens/settings/usersection.js b/apps/mobile/src/screens/settings/usersection.js
index fd01765c5..3b6f9bd37 100644
--- a/apps/mobile/src/screens/settings/usersection.js
+++ b/apps/mobile/src/screens/settings/usersection.js
@@ -4,6 +4,7 @@ import { Linking, Platform, View } from 'react-native';
import * as RNIap from 'react-native-iap';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { ChangePassword } from '../../components/auth/change-password';
+import { Progress } from '../../components/sheets/progress';
import { Button } from '../../components/ui/button';
import Seperator from '../../components/ui/seperator';
import Heading from '../../components/ui/typography/heading';
@@ -284,11 +285,7 @@ const SettingsUserSection = () => {
{
name: 'Having problems with syncing?',
func: async () => {
- presentSheet({
- title: 'Syncing your data',
- paragraph: 'Please wait while we sync all your data.',
- progress: true
- });
+ Progress.present();
await Sync.run('global', true);
eSendEvent(eCloseProgressDialog);
},