Skip to content

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

fix search

ammarahm-ed3b06df17f7b4
diff --git a/apps/mobile/src/components/SearchInput/index.js b/apps/mobile/src/components/SearchInput/index.js
index 3738b6678..e821f0717 100644
--- a/apps/mobile/src/components/SearchInput/index.js
+++ b/apps/mobile/src/components/SearchInput/index.js
@@ -52,7 +52,6 @@ export const SearchInput = (props) => {
paddingVertical: 0,
paddingHorizontal: 0,
margin: 0,
- marginBottom: Platform.OS === 'ios' ? 5 : 0,
}}
textAlignVertical="center"
onChangeText={onChangeText}
diff --git a/apps/mobile/src/provider/Actions.js b/apps/mobile/src/provider/Actions.js
index 50d89a409..6536d8070 100644
--- a/apps/mobile/src/provider/Actions.js
+++ b/apps/mobile/src/provider/Actions.js
@@ -35,5 +35,6 @@ export const Actions = {
LAST_SYNC:"lastSynced",
INTENT_MODE: "intentMode",
SEARCHING:'searching',
- PREMIUM:'premium'
+ PREMIUM:'premium',
+ SEARCH_STATUS: 'searchStatus'
};
diff --git a/apps/mobile/src/provider/DefaultState.js b/apps/mobile/src/provider/DefaultState.js
index d7380c825..7675417c5 100644
--- a/apps/mobile/src/provider/DefaultState.js
+++ b/apps/mobile/src/provider/DefaultState.js
@@ -84,5 +84,6 @@ export const defaultState = {
menuPins:[],
lastSynced:"Never",
intentMode:true,
- searching:false
+ searching:false,
+ searchStatus:null
};
diff --git a/apps/mobile/src/provider/Reducer.js b/apps/mobile/src/provider/Reducer.js
index 0601ae84e..6a84bc088 100644
--- a/apps/mobile/src/provider/Reducer.js
+++ b/apps/mobile/src/provider/Reducer.js
@@ -279,7 +279,8 @@ export const reducer = (state, action) => {
case Actions.SEARCHING: {
return {
...state,
- searching: action.searching,
+ searching: action.searching.isSearching,
+ searchStatus:action.searching.status
};
}
case Actions.PREMIUM: {
diff --git a/apps/mobile/src/services/SearchService.js b/apps/mobile/src/services/SearchService.js
index d3957b445..77a6e7806 100644
--- a/apps/mobile/src/services/SearchService.js
+++ b/apps/mobile/src/services/SearchService.js
@@ -1,10 +1,9 @@
import {updateEvent} from '../components/DialogManager/recievers';
import {Actions} from '../provider/Actions';
import {db} from '../utils/DB';
-import {ToastEvent} from './EventManager';
let searchInformation = {
- placeholder: 'Search all notes',
+ placeholder: 'Search in all notes',
data: [],
type: 'notes',
};
@@ -16,7 +15,7 @@ function update(data) {
}
function setTerm(term) {
- keyword = term
+ keyword = term;
}
async function search() {
@@ -28,20 +27,39 @@ async function search() {
});
return;
}
- updateEvent({type:Actions.SEARCHING, searching:true})
+ updateEvent({
+ type: Actions.SEARCHING,
+ searching: {
+ isSearching: true,
+ status: `Searching for "${term}" in ${searchInformation.title}`,
+ },
+ });
let results;
if (!searchInformation.type) return;
-
+
results = await db.lookup[searchInformation.type](
searchInformation.data,
term,
);
if (!results || results.length === 0) {
- ToastEvent.show('No search results found for ' + term, 'error');
+ updateEvent({type: Actions.SEARCHING, searching: false});
+ updateEvent({
+ type: Actions.SEARCHING,
+ searching: {
+ isSearching: false,
+ status: `No search results found for "${term}" in ${searchInformation.title}`,
+ },
+ });
return;
}
- updateEvent({type:Actions.SEARCHING, searching:false})
+ updateEvent({
+ type: Actions.SEARCHING,
+ searching: {
+ isSearching: false,
+ status: null,
+ },
+ });
updateEvent({
type: Actions.SEARCH_RESULTS,
results: results,
@@ -56,5 +74,5 @@ export default {
update,
getSearchInformation,
search,
- setTerm
+ setTerm,
};
diff --git a/apps/mobile/src/views/Favorites/index.js b/apps/mobile/src/views/Favorites/index.js
index 9e661fc1b..86b861d6d 100644
--- a/apps/mobile/src/views/Favorites/index.js
+++ b/apps/mobile/src/views/Favorites/index.js
@@ -70,6 +70,7 @@ export const Favorites = ({route, navigation}) => {
placeholder: 'Search in favorites',
data: favorites,
type: 'notes',
+ title:"Favorites"
});
};
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index 456a078bf..ccbd8e381 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -72,6 +72,7 @@ export const Folders = ({route, navigation}) => {
placeholder: 'Type a keyword to search in notebooks',
data: notebooks,
type: 'notebooks',
+ title:"Notebooks"
});
};
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index a3a237669..3d01a1369 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -81,6 +81,7 @@ export const Home = ({route, navigation}) => {
placeholder: 'Type a keyword to search in notes',
data: db?.notes?.all,
type: 'notes',
+ title:'Notes'
});
};
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index 714ddadc6..93b4fd6d7 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -90,6 +90,7 @@ export const Notebook = ({route, navigation}) => {
placeholder: `Search in "${params.title}"`,
data: topics,
type: 'topics',
+ title:params.title
});
};
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index c96c46505..ca2bebc04 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -183,6 +183,10 @@ export const Notes = ({route, navigation}) => {
noSearch: false,
type: 'notes',
color: params.type === 'color' ? params.title : null,
+ title:
+ params.type === 'tag'
+ ? '#' + params.title
+ : params.title.slice(0, 1).toUpperCase() + params.title.slice(1),
});
};
diff --git a/apps/mobile/src/views/Search/index.js b/apps/mobile/src/views/Search/index.js
index e892dd30b..33916a499 100644
--- a/apps/mobile/src/views/Search/index.js
+++ b/apps/mobile/src/views/Search/index.js
@@ -8,8 +8,8 @@ import {sleep} from '../../utils/TimeUtils';
export const Search = ({route, navigation}) => {
const [state, dispatch] = useTracked();
- const {searchResults,searching} = state;
-
+ const {searchResults, searching, searchStatus} = state;
+
let pageIsLoaded = false;
const onFocus = useCallback(() => {
@@ -33,6 +33,17 @@ export const Search = ({route, navigation}) => {
navigation.addListener('focus', onFocus);
return () => {
pageIsLoaded = false;
+ dispatch({
+ type: Actions.SEARCH_RESULTS,
+ results: [],
+ });
+ dispatch({
+ type: Actions.SEARCHING,
+ searching: {
+ isSearching: false,
+ status: null,
+ },
+ });
navigation.removeListener('focus', onFocus);
};
}, []);
@@ -49,9 +60,10 @@ export const Search = ({route, navigation}) => {
CustomHeader={true}
placeholderData={{
heading: 'Search',
- paragraph: SearchService.getSearchInformation().placeholder,
+ paragraph:
+ searchStatus || SearchService.getSearchInformation().placeholder,
button: null,
- loading:"Searching..."
+ loading: 'Searching...',
}}
/>
</>
diff --git a/apps/mobile/src/views/Tags/index.js b/apps/mobile/src/views/Tags/index.js
index 9a7ce9c83..a881a080e 100644
--- a/apps/mobile/src/views/Tags/index.js
+++ b/apps/mobile/src/views/Tags/index.js
@@ -69,6 +69,7 @@ export const Tags = ({route, navigation}) => {
placeholder: 'Search in tags',
data: tags,
type: 'tags',
+ title:"Tags"
});
};
diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.js
index 45827690e..1c3272aa7 100644
--- a/apps/mobile/src/views/Trash/index.js
+++ b/apps/mobile/src/views/Trash/index.js
@@ -72,6 +72,7 @@ export const Trash = ({route, navigation}) => {
placeholder: 'Search in trash',
data: trash,
type: 'trash',
+ title: "Trash"
});
};