From de491c0015fa42171f63523ae135e7d69150a5fc Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Fri, 12 Jun 2026 12:22:17 +0500 Subject: [PATCH] mobile: add force sync sheets --- .../components/sheets/force-sync/index.tsx | 221 ++++++++++++++++++ .../app/screens/settings/groups/account.ts | 34 +-- .../fonts/notesnook-icons.glyphmap.json | 2 +- packages/icons/svgs/warning.svg | 3 + packages/intl/locale/en.po | 28 +++ packages/intl/locale/pseudo-LOCALE.po | 28 +++ packages/intl/src/strings.ts | 12 +- 7 files changed, 295 insertions(+), 33 deletions(-) create mode 100644 apps/mobile/app/components/sheets/force-sync/index.tsx create mode 100755 packages/icons/svgs/warning.svg diff --git a/apps/mobile/app/components/sheets/force-sync/index.tsx b/apps/mobile/app/components/sheets/force-sync/index.tsx new file mode 100644 index 000000000..e78437148 --- /dev/null +++ b/apps/mobile/app/components/sheets/force-sync/index.tsx @@ -0,0 +1,221 @@ +/* +This file is part of the Notesnook project (https://notesnook.com/) + +Copyright (C) 2023 Streetwriters (Private) Limited + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +import { strings } from "@notesnook/intl"; +import { useThemeColors } from "@notesnook/theme"; +import React, { useState } from "react"; +import { View } from "react-native"; +import { Radius, Spacing } from "../../../common/design/spacing"; +import { Button } from "../../ui/button"; +import AppIcon from "../../ui/AppIcon"; +import { Pressable } from "../../ui/pressable"; +import Heading from "../../ui/typography/heading"; +import Paragraph from "../../ui/typography/paragraph"; +import { AppFontSize } from "../../../utils/size"; +import { presentSheet, eSendEvent } from "../../../services/event-manager"; +import { eCloseSheet } from "../../../utils/events"; +import { sleep } from "../../../utils/time"; +import { Progress } from "../progress"; +import Sync from "../../../services/sync"; + +type ForceSyncMode = "fetch" | "send"; + +type ForceSyncProps = { + mode: ForceSyncMode; + close?: (ctx?: string) => void; +}; + +function ForceSync({ mode, close }: ForceSyncProps) { + const { colors } = useThemeColors(); + const [acknowledged, setAcknowledged] = useState(true); + + const onForceSyncPress = async () => { + if (!acknowledged) return; + + close?.(); + await sleep(300); + Progress.present(); + Sync.run("global", true, mode, () => { + eSendEvent(eCloseSheet); + }); + }; + + const title = + mode === "fetch" ? strings.forcePullChanges() : strings.forcePushChanges(); + const description = + mode === "fetch" + ? strings.forceSyncPullSheetDesc() + : strings.forceSyncPushSheetDesc(); + const actionText = + mode === "fetch" ? strings.forcePullAction() : strings.forcePushAction(); + + return ( + + + + + + + + + {title} + + {description} + + + + + + + + {strings.forceSyncWarningShort()} + + + + {strings.forceSyncNeedHelpContact()} + + + support@streetwriters.co + + + + + setAcknowledged((value) => !value)} + > + + + {strings.forceSyncRiskAcknowledgement()} + + + + +