A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix progress circle hiding abruptly
ammarahm-ed39d5d77f2356
diff --git a/apps/mobile/src/views/Editor/ProgressCircle.js b/apps/mobile/src/views/Editor/ProgressCircle.jsindex e796f4432..9b616ee3d 100644--- a/apps/mobile/src/views/Editor/ProgressCircle.js+++ b/apps/mobile/src/views/Editor/ProgressCircle.js@@ -1,7 +1,7 @@-import React from 'react';+import React, {useEffect, useRef, useState} from 'react';import {View} from 'react-native';import * as Progress from 'react-native-progress';-import { useTracked } from '../../provider';+import {useTracked} from '../../provider';import {useAttachmentStore} from '../../provider/stores';import {SIZE} from '../../utils/SizeUtils';@@ -9,8 +9,43 @@ export const ProgressCircle = () => {const [state] = useTracked();const {colors} = state;const loading = useAttachmentStore(state => state.loading);+ const [prog, setProg] = useState(0);+ const [visible, setVisible] = useState(false);+ const timer = useRef();- return loading && loading.current !== loading.total ? (+ const formatText = progress => {+ progress = (progress * 100).toFixed(0);+ if (progress === 0) {+ progress = 10;+ }+ return progress + '%';+ };++ useEffect(() => {+ if (loading) {+ if (loading.current !== loading.total) {+ setVisible(true);+ setProg(loading.current / loading.total);+ } else {+ clear();+ }+ } else {+ clear();+ }+ }, [loading]);++ const clear = () => {+ clearTimeout(timer.current);+ timer.current = null;+ timer.current = setTimeout(() => {+ setProg(1);+ setTimeout(() => {+ setVisible(false);+ }, 1000);+ }, 100);+ };++ return visible ? (<Viewstyle={{justifyContent: 'center',@@ -18,13 +53,13 @@ export const ProgressCircle = () => {}}><Progress.Circlesize={SIZE.xxl}- progress={loading.current/loading.total}+ progress={prog}showsTexttextStyle={{- fontSize: 8+ fontSize: 8.5}}color={colors.accent}- formatText={progress => (progress * 100).toFixed(0)}+ formatText={formatText}borderWidth={0}thickness={2}/>