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
mobile: fix rerender crash
ammarahm-ede6d547251476
diff --git a/apps/mobile/app/components/attachments/attachment-item.js b/apps/mobile/app/components/attachments/attachment-item.jsindex c32286f9f..80e20713f 100644--- a/apps/mobile/app/components/attachments/attachment-item.js+++ b/apps/mobile/app/components/attachments/attachment-item.js@@ -22,7 +22,6 @@ import { TouchableOpacity, View } from "react-native";import Icon from "react-native-vector-icons/MaterialCommunityIcons";import { db } from "../../common/database";import { useAttachmentProgress } from "../../hooks/use-attachment-progress";-import { useAttachmentStore } from "../../stores/use-attachment-store";import { useThemeStore } from "../../stores/use-theme-store";import { formatBytes } from "../../utils";import { SIZE } from "../../utils/size";@@ -47,9 +46,7 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {attachment,encryption);- const encryptionProgress = useAttachmentStore(- (state) => state.encryptionProgress- );+const onPress = () => {Actions.present(attachment, setAttachments, attachment.metadata.hash);};@@ -125,9 +122,7 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {</View></View>- {currentProgress ||- (encryptionProgress && encryptionProgress !== "0.00") ||- encryption ? (+ {currentProgress ? (<TouchableOpacityactiveOpacity={0.9}onPress={() => {@@ -144,13 +139,7 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {><ProgressCircleComponentsize={SIZE.xxl}- progress={- encryptionProgress- ? encryptionProgress- : currentProgress?.value- ? currentProgress?.value / 100- : 0- }+ progress={currentProgress?.value ? currentProgress?.value / 100 : 0}showsTexttextStyle={{fontSize: 10diff --git a/apps/mobile/app/hooks/use-actions.js b/apps/mobile/app/hooks/use-actions.jsindex 827847ec3..42759c2c8 100644--- a/apps/mobile/app/hooks/use-actions.js+++ b/apps/mobile/app/hooks/use-actions.js@@ -520,7 +520,7 @@ export const useActions = ({ close = () => null, item }) => {}async function showAttachments() {- AttachmentDialog.present();+ AttachmentDialog.present(item);}async function exportNote() {diff --git a/apps/mobile/app/hooks/use-attachment-progress.ts b/apps/mobile/app/hooks/use-attachment-progress.tsindex a47bbfad5..3c3a8c122 100644--- a/apps/mobile/app/hooks/use-attachment-progress.ts+++ b/apps/mobile/app/hooks/use-attachment-progress.ts@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { useState } from "react";+import { useEffect, useState } from "react";import { useAttachmentStore } from "../stores/use-attachment-store";type AttachmentProgress = {@@ -41,22 +41,24 @@ export const useAttachmentProgress = (: undefined);- const attachmentProgress = progress?.[attachment.metadata.hash];- if (attachmentProgress) {- const type = attachmentProgress.type;- const loaded =- attachmentProgress.type === "download"- ? attachmentProgress.recieved- : attachmentProgress.sent;- const value = loaded / attachmentProgress.total;- setCurrentProgress({- value: value * 100,- percent: (value * 100).toFixed(0) + "%",- type: type- });- } else {- setCurrentProgress(undefined);- }+ useEffect(() => {+ const attachmentProgress = progress?.[attachment.metadata.hash];+ if (attachmentProgress) {+ const type = attachmentProgress.type;+ const loaded =+ attachmentProgress.type === "download"+ ? attachmentProgress.recieved+ : attachmentProgress.sent;+ const value = loaded / attachmentProgress.total;+ setCurrentProgress({+ value: value * 100,+ percent: (value * 100).toFixed(0) + "%",+ type: type+ });+ } else {+ setCurrentProgress(undefined);+ }+ }, [attachment.metadata.hash, progress]);return [currentProgress, setCurrentProgress];};