Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: improve share extension search

ammarahm-ed554560903c77
diff --git a/apps/mobile/share/search.js b/apps/mobile/share/search.js
index ac41b5b73..c8c535d91 100644
--- a/apps/mobile/share/search.js
+++ b/apps/mobile/share/search.js
@@ -178,7 +178,25 @@ const ListItem = ({ item, mode, close }) => {
const SearchGetters = {
appendNote: () => db.notes.all,
selectNotebooks: () => db.notebooks.all,
- selectTags: () => db.tags.all
+ selectTags: () => {
+ const selected = useShareStore.getState().selectedTags;
+ const tags = [];
+ if (selected)
+ tags.push(
+ ...selected.map((t) => ({
+ alias: t,
+ type: "tag"
+ }))
+ );
+
+ for (let tag of db.tags.all) {
+ const index = tags.findIndex((t) => t.alias === tag.alias);
+ // Skip selected tags as they are already in the list.
+ if (index > -1) continue;
+ tags.push(tag);
+ }
+ return tags;
+ }
};
const SearchLookup = {
@@ -196,7 +214,6 @@ export const Search = ({ close, getKeyboardHeight, quicknote, mode }) => {
const [searchResults, setSearchResults] = useState([]);
const searchableItems = useRef(null);
- const [searching, setSearching] = useState(false);
const searchKeyword = useRef(null);
const insets =
@@ -224,12 +241,10 @@ export const Search = ({ close, getKeyboardHeight, quicknote, mode }) => {
setSearchResults(get());
return;
}
- setSearching(true);
setSearchResults(
await lookup(searchableItems.current, searchKeyword.current)
);
- setSearching(false);
- }, 500);
+ }, 150);
};
useEffect(() => {
@@ -306,16 +321,8 @@ export const Search = ({ close, getKeyboardHeight, quicknote, mode }) => {
}}
onSubmitEditing={onSearch}
/>
- {searching ? (
- <ActivityIndicator size={25} color={colors.icon} />
- ) : (
- <Icon
- name="magnify"
- color={colors.pri}
- size={25}
- onPress={onSearch}
- />
- )}
+
+ <Icon name="magnify" color={colors.pri} size={25} onPress={onSearch} />
</View>
<View
@@ -328,7 +335,6 @@ export const Search = ({ close, getKeyboardHeight, quicknote, mode }) => {
data={searchResults}
keyboardShouldPersistTaps="always"
keyboardDismissMode="none"
- keyExtractor={(item) => item.id}
renderItem={renderItem}
estimatedItemSize={50}
ListHeaderComponent={
diff --git a/apps/mobile/share/share.js b/apps/mobile/share/share.js
index f475be4f8..94068b2c3 100644
--- a/apps/mobile/share/share.js
+++ b/apps/mobile/share/share.js
@@ -404,6 +404,8 @@ const ShareView = ({ quicknote = false }) => {
loadData();
}, [loadData]);
+ const WrapperView = Platform.OS === "android" ? View : ScrollView;
+
return loadingExtension ? null : (
<SafeAreaView
style={{
@@ -508,13 +510,14 @@ const ShareView = ({ quicknote = false }) => {
/>
) : null}
- <ScrollView
+ <WrapperView
style={{
paddingVertical: 12,
backgroundColor: colors.bg,
display: searchMode ? "none" : "flex",
borderTopRightRadius: Platform.OS === "ios" ? 10 : 15,
- borderTopLeftRadius: Platform.OS === "ios" ? 10 : 15
+ borderTopLeftRadius: Platform.OS === "ios" ? 10 : 15,
+ maxHeight: Platform.OS === "android" ? undefined : "100%"
}}
>
<View
@@ -756,7 +759,7 @@ const ShareView = ({ quicknote = false }) => {
}}
/>
</View>
- </ScrollView>
+ </WrapperView>
</SafeAreaView>
);
};