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 selection is not reset when switching topics
Ammar Ahmed7bac3c132621
diff --git a/apps/mobile/app/common/filesystem/io.js b/apps/mobile/app/common/filesystem/io.jsindex e51600452..de2086a2c 100644--- a/apps/mobile/app/common/filesystem/io.js+++ b/apps/mobile/app/common/filesystem/io.js@@ -153,7 +153,10 @@ export async function migrateFilesFromCache() {await createCacheDir();const migratedFilesPath = cacheDir + "/.migrated_1";const migrated = await RNFetchBlob.fs.exists(migratedFilesPath);- if (migrated) return;+ if (migrated) {+ console.log("Files migrated already");+ return;+ }let files = await RNFetchBlob.fs.ls(cacheDir);console.log("Files to migrate:", files.join(","));diff --git a/apps/mobile/app/components/list/card.js b/apps/mobile/app/components/list/card.jsindex 446893243..72904213c 100644--- a/apps/mobile/app/components/list/card.js+++ b/apps/mobile/app/components/list/card.js@@ -93,7 +93,7 @@ export const Card = ({ color, warning }) => {</Paragraph><Paragraphstyle={{- flexWrap: "no-wrap",+ flexWrap: "nowrap",flexShrink: 1}}color={colors.primary.heading}diff --git a/apps/mobile/app/components/sheets/topic-sheet/index.tsx b/apps/mobile/app/components/sheets/topic-sheet/index.tsxindex b7a2178c3..fb6ecedf6 100644--- a/apps/mobile/app/components/sheets/topic-sheet/index.tsx+++ b/apps/mobile/app/components/sheets/topic-sheet/index.tsx@@ -16,6 +16,7 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/+import { useThemeColors } from "@notesnook/theme";import qclone from "qclone";import React, {createContext,@@ -26,7 +27,7 @@ import React, {useRef,useState} from "react";-import { RefreshControl, View } from "react-native";+import { RefreshControl, useWindowDimensions, View } from "react-native";import ActionSheet, {ActionSheetRef,FlatList@@ -45,7 +46,6 @@ import {import useNavigationStore, {NotebookScreenParams} from "../../../stores/use-navigation-store";-import { useThemeColors } from "@notesnook/theme";import {eOnNewTopicAdded,eOnTopicSheetUpdate,@@ -54,18 +54,17 @@ import {import { normalize, SIZE } from "../../../utils/size";import { GroupHeader, NotebookType, TopicType } from "../../../utils/types";+import { getTotalNotes } from "@notesnook/common";import { groupArray } from "@notesnook/core/dist/utils/grouping";import Config from "react-native-config";import Icon from "react-native-vector-icons/MaterialCommunityIcons";import { notesnook } from "../../../../e2e/test.ids";import { MMKV } from "../../../common/database/mmkv";import { openEditor } from "../../../screens/notes/common";-import { getTotalNotes } from "@notesnook/common";+import { useSelectionStore } from "../../../stores/use-selection-store";import { deleteItems } from "../../../utils/functions";-import { presentDialog } from "../../dialog/functions";import { Properties } from "../../properties";import Sort from "../sort";-import { useSelectionStore } from "../../../stores/use-selection-store";type ConfigItem = { id: string; type: string };class TopicSheetConfig {@@ -108,7 +107,8 @@ export const TopicsSheet = () => {): []);-+ const currentItem = useRef<string>();+ const { fontScale } = useWindowDimensions();const [groupOptions, setGroupOptions] = useState(db.settings?.getGroupOptions("topics"));@@ -206,6 +206,11 @@ export const TopicsSheet = () => {if (canShow) {setTimeout(() => {const id = isTopic ? currentScreen?.notebookId : currentScreen?.id;+ if (currentItem.current !== id) {+ setSelection([]);+ setEnabled(false);+ }+ currentItem.id = id;const notebook = db.notebooks?.notebook(id as string)?.data;const snapPoint = isTopic? 0@@ -226,6 +231,8 @@ export const TopicsSheet = () => {}}, 300);} else {+ setSelection([]);+ setEnabled(false);ref.current?.hide();}}, [@@ -329,7 +336,9 @@ export const TopicsSheet = () => {{enabled ? (<IconButtoncustomStyle={{- marginLeft: 10+ marginLeft: 10,+ width: 40 * fontScale,+ height: 40 * fontScale}}onPress={async () => {//@ts-ignore@@ -365,8 +374,8 @@ export const TopicsSheet = () => {color={colors.primary.icon}size={22}customStyle={{- width: 40,- height: 40+ width: 40 * fontScale,+ height: 40 * fontScale}}/><IconButton@@ -376,8 +385,8 @@ export const TopicsSheet = () => {color={colors.primary.icon}size={22}customStyle={{- width: 40,- height: 40+ width: 40 * fontScale,+ height: 40 * fontScale}}/>@@ -395,8 +404,8 @@ export const TopicsSheet = () => {color={colors.primary.icon}size={22}customStyle={{- width: 40,- height: 40+ width: 40 * fontScale,+ height: 40 * fontScale}}/></>@@ -470,6 +479,7 @@ const TopicItem = ({selection.selection.findIndex((selected) => selected.id === item.id) > -1;const isFocused = screen.id === item.id;const notesCount = getTotalNotes(item);+ const { fontScale } = useWindowDimensions();return (<PressableButton@@ -506,6 +516,10 @@ const TopicItem = ({<IconButtonsize={SIZE.lg}color={isSelected ? colors.selected.icon : colors.primary.icon}+ top={0}+ left={0}+ bottom={0}+ right={0}name={isSelected? "check-circle-outline"@@ -525,8 +539,8 @@ const TopicItem = ({<IconButtonname="dots-horizontal"customStyle={{- width: 40,- height: 40+ width: 40 * fontScale,+ height: 40 * fontScale}}testID={notesnook.ids.notebook.menu}onPress={() => {diff --git a/apps/mobile/app/stores/use-selection-store.ts b/apps/mobile/app/stores/use-selection-store.tsindex e14cae42a..f904b8e60 100644--- a/apps/mobile/app/stores/use-selection-store.ts+++ b/apps/mobile/app/stores/use-selection-store.ts@@ -56,7 +56,7 @@ export const useSelectionStore = create<SelectionStore>((set, get) => ({set({selectedItemsList: selectedItems,- selectionMode: get().selectionMode+ selectionMode: selectedItems.length === 0 ? false : get().selectionMode});},clearSelection: () => {diff --git a/apps/mobile/native/ios/Podfile.lock b/apps/mobile/native/ios/Podfile.lockindex dde9801be..fc8aea1e8 100644--- a/apps/mobile/native/ios/Podfile.lock+++ b/apps/mobile/native/ios/Podfile.lock@@ -347,7 +347,7 @@ PODS:- ReactCommon/turbomodule/core- react-native-share-extension (2.5.6):- React- - react-native-sodium (1.5.2):+ - react-native-sodium (1.5.4):- React- react-native-webview (11.26.1):- React-Core@@ -882,7 +882,7 @@ SPEC CHECKSUMS:react-native-pdf: 33c622cbdf776a649929e8b9d1ce2d313347c4fareact-native-safe-area-context: 36cc67648134e89465663b8172336a19eeda493dreact-native-share-extension: df66a2ee48a62277d79898375e2142bde0782063- react-native-sodium: 7d2bbb9ca840dc58d63f661b2ff733a38170fec5+ react-native-sodium: 955bb0dc3ea05f8ea06d5e96cb89d1be7b5d7681react-native-webview: 9f111dfbcfc826084d6c507f569e5e03342ee1c1React-NativeModulesApple: 1d81d927ef1a67a3545a01e14c2e98500bf9b199React-perflogger: 684a11499a0589cc42135d6d5cc04d0e4e0e261a