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: upgrade share extension to support organization
ammarahm-ed0a29571ad833
diff --git a/apps/mobile/share/search.js b/apps/mobile/share/search.jsindex 60810bc2a..ac41b5b73 100644--- a/apps/mobile/share/search.js+++ b/apps/mobile/share/search.js@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import React, { useEffect, useRef, useState } from "react";import {ActivityIndicator,- FlatList,Platform,StatusBar,Text,@@ -34,36 +33,186 @@ import Icon from "react-native-vector-icons/MaterialCommunityIcons";import { db } from "../app/common/database";import { getElevation } from "../app/utils";import { useShareStore } from "./store";+import { FlashList } from "@shopify/flash-list";-export const Search = ({ close, getKeyboardHeight, quicknote }) => {+const ListItem = ({ item, mode, close }) => {const colors = useShareStore((state) => state.colors);- const setAppendNote = useShareStore((state) => state.setAppendNote);- const [results, setResults] = useState([]);- const [searching, setSearching] = useState(false);- const searchKeyword = useRef(null);+ const selectedNotebooks = useShareStore((state) => state.selectedNotebooks);+ const selectedTags = useShareStore((state) => state.selectedTags);+ const isSelected =+ mode === "appendNote"+ ? false+ : mode === "selectTags"+ ? selectedTags.indexOf(item.alias) > -1+ : selectedNotebooks.findIndex(+ (selected) => selected.id === item.id && selected.type === item.type+ ) > -1;++ const SearchSetters = React.useMemo(+ () => ({+ appendNote: (item) => {+ useShareStore.getState().setAppendNote(item);+ close();+ },+ selectNotebooks: (item) => {+ const selectedNotebooks = [+ ...useShareStore.getState().selectedNotebooks+ ];+ const currentIndex = selectedNotebooks.findIndex(+ (selected) => selected.id === item.id && selected.type === item.type+ );+ if (currentIndex === -1) {+ selectedNotebooks.push(item);+ } else {+ selectedNotebooks.splice(currentIndex, 1);+ }+ useShareStore.getState().setSelectedNotebooks(selectedNotebooks);+ },+ selectTags: (item) => {+ const selectedTags = [...useShareStore.getState().selectedTags];+ const currentIndex = selectedTags.indexOf(item.alias);+ if (currentIndex === -1) {+ selectedTags.push(item.alias);+ } else {+ selectedTags.splice(currentIndex, 1);+ }+ useShareStore.getState().setSelectedTags(selectedTags);+ }+ }),+ [close]+ );+ const set = React.useMemo(() => SearchSetters[mode], [mode, SearchSetters]);++ const onSelectItem = async (item) => {+ if (item.locked) {+ return;+ }+ set(item);+ };++ return (+ <TouchableOpacity+ activeOpacity={0.7}+ onPress={() => onSelectItem(item)}+ style={{+ flexDirection: "column",+ borderBottomWidth: item.topics?.length > 0 ? 0 : 1,+ borderBottomColor: colors.nav,+ justifyContent: "center",+ paddingVertical: 12+ }}+ >+ <View+ style={{+ flexDirection: "row",+ paddingHorizontal: 12,+ paddingLeft: item.type === "topic" ? 0 : 12+ }}+ >+ {item.type !== "note" ? (+ <Icon+ name={+ !isSelected+ ? "checkbox-blank-circle-outline"+ : "check-circle-outline"+ }+ style={{+ marginRight: 10+ }}+ size={20}+ color={isSelected ? colors.accent : colors.icon}+ />+ ) : null}++ <View+ style={{+ flexDirection: "column"+ }}+ >+ <Text+ numberOfLines={1}+ style={{+ color: colors.pri,+ fontFamily:+ item.type === "topic"+ ? "OpenSans-Regular"+ : "OpenSans-SemiBold",+ fontSize: 15+ }}+ >+ {item.type === "tag" ? "#" : ""}+ {item.alias || item.title}+ </Text>++ {item.type === "note" ? (+ <Text+ numberOfLines={1}+ style={{+ color: colors.icon,+ fontSize: 12,+ fontFamily: "OpenSans-Regular"+ }}+ >+ {item.headline}+ </Text>+ ) : null}+ </View>+ </View>++ {item.type === "notebook" && item.topics && item.topics.length > 0 ? (+ <View+ style={{+ paddingLeft: 40,+ marginTop: 5+ }}+ >+ {item.topics.map((topic) => (+ <ListItem key={topic.id} item={topic} mode={mode} close={close} />+ ))}+ </View>+ ) : null}+ </TouchableOpacity>+ );+};++const SearchGetters = {+ appendNote: () => db.notes.all,+ selectNotebooks: () => db.notebooks.all,+ selectTags: () => db.tags.all+};++const SearchLookup = {+ appendNote: (items, kwd) => db.lookup.notes(items, kwd),+ selectNotebooks: (items, kwd) => db.lookup.notebooks(items, kwd),+ selectTags: (items, kwd) => db.lookup.tags(items, kwd)+};++export const Search = ({ close, getKeyboardHeight, quicknote, mode }) => {+ const colors = useShareStore((state) => state.colors);+const { height } = useWindowDimensions();- const notes = useRef(null);const timer = useRef(null);const inputRef = useRef();++ const [searchResults, setSearchResults] = useState([]);+ const searchableItems = useRef(null);+ const [searching, setSearching] = useState(false);+ const searchKeyword = useRef(null);+const insets =Platform.OS === "android"? { top: StatusBar.currentHeight }: // eslint-disable-next-line react-hooks/rules-of-hooksuseSafeAreaInsets();- const onSelectItem = async (item) => {- if (item.locked) {- return;- }- setAppendNote(item);- close();- };+ const get = SearchGetters[mode];+ const lookup = SearchLookup[mode];const onSearch = async () => {- if (!notes.current) {+ if (!searchableItems.current) {await db.init();await db.notes.init();- notes.current = db.notes.all;+ searchableItems.current = get();}if (timer.current) {clearTimeout(timer.current);@@ -71,12 +220,14 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {}timer.current = setTimeout(async () => {if (!searchKeyword.current) {- setResults([]);- setResults(db.notes.all);+ setSearchResults([]);+ setSearchResults(get());return;}setSearching(true);- setResults(await db.lookup.notes(notes.current, searchKeyword.current));+ setSearchResults(+ await lookup(searchableItems.current, searchKeyword.current)+ );setSearching(false);}, 500);};@@ -85,47 +236,13 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {(async () => {await db.init();await db.notes.init();- notes.current = db.notes.all;- setResults(notes.current);+ searchableItems.current = get();+ setSearchResults(searchableItems.current);})();- setTimeout(() => {- inputRef.current?.focus();- }, 300);- }, []);+ }, [get]);const renderItem = ({ item }) =>- !item.locked ? (- <TouchableOpacity- activeOpacity={0.7}- onPress={() => onSelectItem(item)}- style={{- height: 50,- paddingHorizontal: 12- }}- >- <Text- numberOfLines={1}- style={{- color: colors.pri,- fontFamily: "OpenSans-SemiBold",- fontSize: 15- }}- >- {item.title}- </Text>-- <Text- numberOfLines={1}- style={{- color: colors.icon,- fontSize: 12,- fontFamily: "OpenSans-Regular"- }}- >- {item.headline}- </Text>- </TouchableOpacity>- ) : null;+ !item.locked ? <ListItem item={item} mode={mode} close={close} /> : null;let extra = quicknote? {@@ -133,6 +250,7 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {paddingTop: insets.top}: {};+ const searchHeight = height - getKeyboardHeight();return (<Viewstyle={{@@ -160,7 +278,15 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {height: 50}}>- <Icon name="arrow-left" color={colors.pri} size={25} onPress={close} />+ <Icon+ name="arrow-left"+ color={colors.pri}+ style={{+ marginRight: 10+ }}+ size={25}+ onPress={close}+ /><TextInputref={inputRef}placeholder="Search for a note"@@ -168,10 +294,14 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {style={{fontSize: 15,fontFamily: "OpenSans-Regular",- width: "85%"+ flex: 1}}onChangeText={(value) => {- searchKeyword.current = value;+ if (mode === "selectTags") {+ searchKeyword.current = db.tags.sanitize(value);+ } else {+ searchKeyword.current = value;+ }onSearch();}}onSubmitEditing={onSearch}@@ -188,38 +318,55 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {)}</View>- <FlatList- data={results}+ <Viewstyle={{- maxHeight: height - getKeyboardHeight()+ maxHeight: searchHeight > 550 ? 550 : searchHeight,+ height: searchHeight > 550 ? 550 : searchHeight}}- keyboardShouldPersistTaps="always"- keyboardDismissMode="none"- keyExtractor={(item) => item.id}- renderItem={renderItem}- ListFooterComponent={<View style={{ height: 200 }} />}- ListEmptyComponent={- <View- style={{- flex: 1,- justifyContent: "center",- alignItems: "center",- height: 200- }}- >- <Text+ >+ <FlashList+ data={searchResults}+ keyboardShouldPersistTaps="always"+ keyboardDismissMode="none"+ keyExtractor={(item) => item.id}+ renderItem={renderItem}+ estimatedItemSize={50}+ ListHeaderComponent={+ searchResults.length === 0 && searchKeyword.current ? (+ <ListItem+ item={{+ type: "tag",+ alias: searchKeyword.current+ }}+ mode={mode}+ close={close}+ />+ ) : null+ }+ ListFooterComponent={<View style={{ height: 200 }} />}+ ListEmptyComponent={+ <Viewstyle={{- fontFamily: "OpenSans-Regular",- color: colors.icon+ flex: 1,+ justifyContent: "center",+ alignItems: "center",+ height: 200}}>- {searchKeyword.current- ? `No results found for "${searchKeyword.current}"`- : "Search for a note to append to it."}- </Text>- </View>- }- />+ <Text+ style={{+ fontFamily: "OpenSans-Regular",+ color: colors.icon+ }}+ >+ {searchKeyword.current+ ? `No results found for "${searchKeyword.current}"`+ : "Search for a note to append to it."}+ </Text>+ </View>+ }+ />+ </View></View>);};diff --git a/apps/mobile/share/share.js b/apps/mobile/share/share.jsindex fdddd1d89..45f0b4677 100644--- a/apps/mobile/share/share.js+++ b/apps/mobile/share/share.js@@ -194,7 +194,6 @@ const ShareView = ({ quicknote = false }) => {const appendNote = useShareStore((state) => state.appendNote);const [note, setNote] = useState({ ...defaultNote });const noteContent = useRef();- const [loadingIntent, setLoadingIntent] = useState(true);const [loading, setLoading] = useState(false);const [loadingExtension, setLoadingExtension] = useState(true);const [rawData, setRawData] = useState({@@ -209,9 +208,9 @@ const ShareView = ({ quicknote = false }) => {? { top: StatusBar.currentHeight }: // eslint-disable-next-line react-hooks/rules-of-hooksuseSafeAreaInsets();- const [showSearch, setShowSearch] = useState(false);+ const [searchMode, setSearchMode] = useState(null);+const [kh, setKh] = useState(0);- const editorRef = useRef();const onKeyboardDidShow = (event) => {let kHeight = event.endCoordinates.height;@@ -261,7 +260,6 @@ const ShareView = ({ quicknote = false }) => {setRawData({value: ""});- setLoadingIntent(false);return;}let note = { ...defaultNote };@@ -281,7 +279,6 @@ const ShareView = ({ quicknote = false }) => {} catch (e) {console.error(e);}- setLoadingIntent(false);}, [onLoad]);const onLoad = useCallback(() => {@@ -300,13 +297,12 @@ const ShareView = ({ quicknote = false }) => {//await loadDatabase();setLoadingExtension(false);loadData();- useShareStore.getState().restoreAppendNote();+ useShareStore.getState().restore();})();}, [loadData]);const close = async () => {setNote({ ...defaultNote });- setLoadingIntent(true);setLoadingExtension(true);if (quicknote) {ShareExtension.openURL("ShareMedia://MainApp");@@ -332,7 +328,7 @@ const ShareView = ({ quicknote = false }) => {let raw = await db.content.raw(appendNote.contentId);_note = {content: {- data: raw.data + "\n" + noteContent.current,+ data: raw.data + noteContent.current,type: "tiptap"},id: appendNote.id,@@ -340,10 +336,28 @@ const ShareView = ({ quicknote = false }) => {};} else {_note = { ...note };+ _note.tags = useShareStore.getState().selectedTags || [];+_note.content.data = noteContent.current;_note.sessionId = Date.now();}- await db.notes.add(_note);++ let id = await db.notes.add(_note);+ if (!appendNote) {+ for (const item of useShareStore.getState().selectedNotebooks) {+ if (item.type === "notebook") {+ db.relations.add(item, { id, type: "note" });+ } else {+ db.notes.addToNotebook(+ {+ id: item.notebookId,+ topic: item.id+ },+ id+ );+ }+ }+ }await Storage.write("notesAddedFromIntent", "added");close();setLoading(false);@@ -398,7 +412,7 @@ const ShareView = ({ quicknote = false }) => {justifyContent: quicknote ? "flex-start" : "flex-end"}}>- {quicknote && !showSearch ? (+ {quicknote && !searchMode ? (<Viewstyle={{width: "100%",@@ -417,8 +431,8 @@ const ShareView = ({ quicknote = false }) => {icon="close"iconColor={colors.pri}onPress={() => {- if (showSearch) {- setShowSearch(false);+ if (searchMode) {+ setSearchMode(null);} else {close();}@@ -458,8 +472,8 @@ const ShareView = ({ quicknote = false }) => {<TouchableOpacityactiveOpacity={1}onPress={() => {- if (showSearch) {- setShowSearch(false);+ if (searchMode) {+ setSearchMode(null);} else {close();}@@ -482,28 +496,30 @@ const ShareView = ({ quicknote = false }) => {</TouchableOpacity>)}- {showSearch ? (+ {searchMode ? (<Searchquicknote={quicknote}getKeyboardHeight={() => keyboardHeight.current}+ mode={searchMode}close={() => {- setShowSearch(false);+ setSearchMode(null);}}/>) : null}<Viewstyle={{- paddingVertical: 25,- backgroundColor: "transparent",- marginBottom: insets.top,- display: showSearch ? "none" : "flex"+ paddingVertical: 12,+ backgroundColor: colors.bg,+ display: searchMode ? "none" : "flex",+ borderTopRightRadius: 15,+ borderTopLeftRadius: 15}}><Viewstyle={{- maxHeight: "100%",- paddingHorizontal: 12+ maxHeight: "100%"+ //paddingHorizontal: 12}}><View@@ -513,20 +529,55 @@ const ShareView = ({ quicknote = false }) => {><Viewstyle={{- marginTop: 10,minHeight: 100,- borderRadius: 10,- ...getElevation(quicknote ? 1 : 5),backgroundColor: colors.bg,overflow: "hidden"}}>+ <View+ style={{+ justifyContent: "space-between",+ flexDirection: "row",+ alignItems: "center",+ borderBottomWidth: 1,+ paddingBottom: 12,+ borderBottomColor: colors.nav,+ paddingHorizontal: 12+ }}+ >+ <Text+ style={{+ fontSize: 20,+ fontFamily: "OpenSans-SemiBold"+ }}+ >+ Save to Notesnook+ </Text>++ <Button+ title="Done"+ style={{+ backgroundColor: colors.accent,+ height: 40,+ paddingHorizontal: 15,+ marginBottom: 0+ }}+ loading={loading}+ onPress={onPress}+ textStyle={{+ fontSize: 16,+ marginLeft: 0+ }}+ />+ </View><Viewstyle={{width: "100%",- height: height * 0.3,+ height: 200,paddingBottom: 15,- borderRadius: 10+ marginBottom: 10,+ borderBottomColor: colors.nav,+ borderBottomWidth: 1}}><SafeAreaProvider@@ -574,59 +625,47 @@ const ShareView = ({ quicknote = false }) => {style={{flexDirection: "row",paddingHorizontal: 12,- alignItems: "flex-end",- justifyContent: "space-between",- width: "100%"+ width: "100%",+ alignItems: "center"}}>- <View+ <Textstyle={{- flexDirection: "row"+ color: colors.pri,+ marginRight: 10}}>- {rawData.value && isURL(rawData.value) ? (- <Button- color={mode == 2 ? colors.shade : colors.nav}- icon={modes[2].icon}- onPress={() => changeMode(2)}- title={modes[2].title}- iconSize={18}- iconColor={mode == 2 ? accent.color : colors.icon}- textColor={mode == 2 ? accent.color : colors.icon}- type="rounded"- style={{ paddingHorizontal: 12 }}- />- ) : null}- <Button- color={mode == 1 ? colors.shade : colors.nav}- icon={modes[1].icon}- onPress={() => changeMode(1)}- title={modes[1].title}- iconSize={18}- iconColor={mode == 1 ? accent.color : colors.icon}- textColor={mode == 1 ? accent.color : colors.icon}- type="rounded"- style={{ paddingHorizontal: 12 }}- />- </View>-- {!quicknote ? (+ Clip Mode:+ </Text>+ {rawData.value && isURL(rawData.value) ? (<Button- color={accent.color}- onPress={onPress}- loading={loading || loadingIntent}- icon="check"- iconSize={20}- iconColor={colors.light}+ color="transparent"+ icon={mode === 2 ? "radiobox-marked" : "radiobox-blank"}+ onPress={() => changeMode(2)}+ title={modes[2].title}+ iconSize={16}+ fontSize={14}+ iconColor={mode == 2 ? accent.color : colors.icon}+ textColor={mode == 2 ? accent.color : colors.icon}style={{paddingHorizontal: 0,- height: 40,- width: 40,- borderRadius: 100,- minWidth: 0+ height: 30,+ marginRight: 12,+ marginBottom: 0}}/>) : null}+ <Button+ color="transparent"+ icon={mode === 1 ? "radiobox-marked" : "radiobox-blank"}+ onPress={() => changeMode(1)}+ title={modes[1].title}+ iconSize={16}+ fontSize={14}+ iconColor={mode == 1 ? accent.color : colors.icon}+ textColor={mode == 1 ? accent.color : colors.icon}+ style={{ paddingHorizontal: 0, height: 30, marginBottom: 0 }}+ /></View></View></View>@@ -638,7 +677,8 @@ const ShareView = ({ quicknote = false }) => {flexDirection: "column",marginTop: 10,alignSelf: "center",- alignItems: "center"+ alignItems: "center",+ paddingHorizontal: 12}}><Button@@ -656,38 +696,56 @@ const ShareView = ({ quicknote = false }) => {fontSize: 15}}style={{- paddingHorizontal: 0,- ...getElevation(1),+ paddingHorizontal: 12,height: 45,width: "100%",- marginRight: 0+ marginRight: 0,+ borderWidth: 1,+ borderColor: colors.nav,+ justifyContent: "flex-start"}}/><Buttoncolor={colors.bg}onPress={() => {- setShowSearch(true);+ setSearchMode("appendNote");}}icon="text-short"iconSize={18}iconColor={appendNote ? accent.color : colors.icon}- title={`${- appendNote ? appendNote.title.slice(0, 25) : "Append to note"- }`}- textColor={appendNote ? accent.color : colors.icon}+ title={`Append to a note`}+ textColor={colors.icon}type="button"textStyle={{fontSize: 15}}style={{- paddingHorizontal: 0,- ...getElevation(1),+ paddingHorizontal: 12,height: 45,width: "100%",- marginRight: 0+ marginRight: 0,+ borderWidth: 1,+ borderColor: colors.nav,+ justifyContent: "flex-start"}}/>++ {!appendNote ? (+ <AddTags+ onPress={() => {+ setSearchMode("selectTags");+ }}+ />+ ) : null}++ {!appendNote ? (+ <AddNotebooks+ onPress={() => {+ setSearchMode("selectNotebooks");+ }}+ />+ ) : null}</View><View@@ -701,6 +759,217 @@ const ShareView = ({ quicknote = false }) => {);};+const AddNotebooks = ({ onPress }) => {+ const colors = useShareStore((state) => state.colors);+ const notebooks = useShareStore((state) => state.selectedNotebooks);+ return (+ <TouchableOpacity+ onPress={onPress}+ activeOpacity={0.7}+ style={{+ paddingHorizontal: 12,+ width: "100%",+ marginRight: 0,+ borderWidth: 1,+ borderColor: colors.nav,+ justifyContent: "center",+ borderRadius: 5,+ marginBottom: 10,+ paddingVertical: 10,+ paddingTop: 5+ }}+ >+ {!notebooks || !notebooks.length ? (+ <>+ <View+ style={{+ width: "100%",+ flexDirection: "row",+ marginTop: 5+ }}+ >+ <Icon+ name="notebook-outline"+ size={20}+ style={{+ marginRight: 10+ }}+ color={colors.icon}+ />+ <Text+ style={{+ color: colors.icon,+ fontSize: 15+ }}+ >+ Add to notebook+ </Text>+ </View>+ </>+ ) : (+ <View+ style={{+ flexWrap: "wrap",+ width: "100%",+ flexDirection: "row"+ }}+ >+ {notebooks.map((item) => (+ <Text+ style={{+ color: colors.icon,+ marginRight: 5,+ fontSize: 14,+ borderRadius: 4,+ paddingHorizontal: 8,+ backgroundColor: colors.nav,+ paddingVertical: 5,+ marginTop: 5+ }}+ onPress={() => {+ const index = notebooks.findIndex(+ (nb) => nb.id === item.id && nb.type === item.type+ );+ const selectedNotebooks = [...notebooks];+ selectedNotebooks.splice(index, 1);+ useShareStore+ .getState()+ .setSelectedNotebooks(selectedNotebooks);+ }}+ key={item.id}+ >+ <Icon+ name={item.type === "topic" ? "bookmark" : "notebook-outline"}+ size={15}+ />{" "}+ {item.title}+ </Text>+ ))}++ <Text+ style={{+ color: colors.accent,+ marginRight: 5,+ fontSize: 14,+ borderRadius: 4,+ paddingHorizontal: 8,+ backgroundColor: colors.nav,+ paddingVertical: 5,+ marginTop: 5+ }}+ onPress={() => {+ onPress();+ }}+ key="$add-more"+ >+ <Icon name="plus" size={16} /> Add more+ </Text>+ </View>+ )}+ </TouchableOpacity>+ );+};++const AddTags = ({ onPress }) => {+ const colors = useShareStore((state) => state.colors);+ const tags = useShareStore((state) => state.selectedTags);+ return (+ <TouchableOpacity+ onPress={onPress}+ activeOpacity={0.7}+ style={{+ paddingHorizontal: 12,+ height: 45,+ width: "100%",+ marginRight: 0,+ borderWidth: 1,+ borderColor: colors.nav,+ justifyContent: "center",+ borderRadius: 5,+ marginBottom: 10+ }}+ >+ {!tags || !tags.length ? (+ <>+ <View+ style={{+ width: "100%",+ flexDirection: "row"+ }}+ >+ <Icon+ name="pound"+ size={20}+ style={{+ marginRight: 10+ }}+ color={colors.icon}+ />+ <Text+ style={{+ color: colors.icon,+ fontSize: 15+ }}+ >+ Add tags+ </Text>+ </View>+ </>+ ) : (+ <View+ style={{+ flexWrap: "wrap",+ width: "100%",+ flexDirection: "row"+ }}+ >+ {tags.map((tag) => (+ <Text+ style={{+ color: colors.icon,+ marginRight: 5,+ fontSize: 14,+ borderRadius: 4,+ paddingHorizontal: 8,+ backgroundColor: colors.nav,+ paddingVertical: 5+ }}+ onPress={() => {+ const index = tags.indexOf(tag);+ const selectedTags = [...tags];+ selectedTags.splice(index, 1);+ useShareStore.getState().setSelectedTags(selectedTags);+ }}+ key={tag}+ >+ #{tag}+ </Text>+ ))}++ <Text+ style={{+ color: colors.accent,+ marginRight: 5,+ fontSize: 14,+ borderRadius: 4,+ paddingHorizontal: 8,+ backgroundColor: colors.nav,+ paddingVertical: 5+ }}+ onPress={() => {+ onPress();+ }}+ key="$add-tag"+ >+ <Icon name="plus" size={17} />+ Add tag+ </Text>+ </View>+ )}+ </TouchableOpacity>+ );+};+const Button = ({title,onPress,@@ -734,7 +1003,6 @@ const Button = ({alignItems: "center",flexDirection: "row",marginBottom: 10,- minWidth: 80,paddingHorizontal: 20},textStyle: {}@@ -767,11 +1035,9 @@ const Button = ({alignItems: "center",flexDirection: "row",marginBottom: 10,- minWidth: 80,paddingHorizontal: 20},- types[type].style,- style+ { ...types[type].style, ...style }]}>{loading ? <ActivityIndicator color={iconColor} /> : null}diff --git a/apps/mobile/share/store.js b/apps/mobile/share/store.jsindex 11c0d604b..f015ebf1e 100644--- a/apps/mobile/share/store.js+++ b/apps/mobile/share/store.js@@ -26,6 +26,13 @@ import {} from "../app/utils/color-scheme";import { MMKV } from "../app/common/database/mmkv";+const StorageKeys = {+ appendNote: "shareMenuAppendNote",+ selectedNotebooks: "shareMenuSelectedNotebooks",+ selectedTag: "shareMenuSelectedTag",+ appSettings: "appSettings"+};+export const useShareStore = create((set) => ({colors:Appearance.getColorScheme() === "dark"@@ -33,7 +40,7 @@ export const useShareStore = create((set) => ({: COLOR_SCHEME_LIGHT,accent: ACCENT,setAccent: async () => {- let appSettings = MMKV.getString("appSettings");+ let appSettings = MMKV.getString(StorageKeys.appSettings);if (appSettings) {appSettings = JSON.parse(appSettings);@@ -56,14 +63,31 @@ export const useShareStore = create((set) => ({},appendNote: null,setAppendNote: (note) => {- MMKV.setItem("shareMenuAppendNote", JSON.stringify(note));+ MMKV.setItem(StorageKeys.appendNote, JSON.stringify(note));set({ appendNote: note });},- restoreAppendNote: async () => {- let note = MMKV.getString("shareMenuAppendNote");- if (note) {- note = JSON.parse(note);- set({ appendNote: note });- }+ restore: () => {+ let appendNote = MMKV.getString(StorageKeys.appendNote);+ let selectedNotebooks = MMKV.getString(StorageKeys.selectedNotebooks);+ let selectedTags = MMKV.getString(StorageKeys.selectedTag);+ appendNote = JSON.parse(appendNote);+ set({+ appendNote: appendNote ? JSON.parse(appendNote) : null,+ selectedNotebooks: selectedNotebooks ? JSON.parse(selectedNotebooks) : [],+ selectedTag: selectedTags ? JSON.parse(selectedTags) : []+ });+ },+ selectedTags: [],+ selectedNotebooks: [],+ setSelectedNotebooks: (selectedNotebooks) => {+ MMKV.setItem(+ StorageKeys.selectedNotebooks,+ JSON.stringify(selectedNotebooks)+ );+ set({ selectedNotebooks });+ },+ setSelectedTags: (selectedTags) => {+ MMKV.setItem(StorageKeys.selectedTag, JSON.stringify(selectedTags));+ set({ selectedTags });}}));