Skip to content
Snippets Groups Projects
Commit b159bdd6 authored by chris's avatar chris
Browse files

if no results move to next available view

parent 36b800fd
No related branches found
No related tags found
1 merge request!231Connect funcionality
...@@ -183,7 +183,6 @@ const FindComponent = ({ ...@@ -183,7 +183,6 @@ const FindComponent = ({
}; };
const findNext = () => { const findNext = () => {
console.log('activeViewId', activeViewId);
lastActiveViewId = activeViewId; lastActiveViewId = activeViewId;
lastSelection = view[activeViewId].state.selection; lastSelection = view[activeViewId].state.selection;
const results = helpers.getAllResultsByView( const results = helpers.getAllResultsByView(
...@@ -206,10 +205,8 @@ const FindComponent = ({ ...@@ -206,10 +205,8 @@ const FindComponent = ({
), ),
); );
view[findViewWithMatches].focus(); view[findViewWithMatches].focus();
setTimeout(() => { lastActiveViewId = findViewWithMatches;
lastActiveViewId = findViewWithMatches; lastSelection = view[lastActiveViewId].state.selection;
lastSelection = view[lastActiveViewId].state.selection;
}, 50);
} }
const found = helpers.getClosestMatch( const found = helpers.getClosestMatch(
...@@ -234,13 +231,11 @@ const FindComponent = ({ ...@@ -234,13 +231,11 @@ const FindComponent = ({
lastSelection.from === found && lastSelection.from === found &&
position === resultsFrom[lastActiveViewId].length - 1 position === resultsFrom[lastActiveViewId].length - 1
) { ) {
console.log('hereee?');
/* End of results in notes move to main if results exist */ /* End of results in notes move to main if results exist */
if ( if (
notesIds.indexOf(lastActiveViewId) === notesIds.length - 1 && notesIds.indexOf(lastActiveViewId) === notesIds.length - 1 &&
results.main.length > 0 results.main.length > 0
) { ) {
console.log('im main');
setTimeout(() => { setTimeout(() => {
lastActiveViewId = findViewWithMatches; lastActiveViewId = findViewWithMatches;
lastSelection = view[lastActiveViewId].state.selection; lastSelection = view[lastActiveViewId].state.selection;
...@@ -248,7 +243,6 @@ const FindComponent = ({ ...@@ -248,7 +243,6 @@ const FindComponent = ({
helpers.moveToMatch(view, 'main', results, 0); helpers.moveToMatch(view, 'main', results, 0);
helpers.clearViewSelection(view, lastActiveViewId); helpers.clearViewSelection(view, lastActiveViewId);
} else { } else {
console.log('hohoho');
for (let i = 0; i < notesIds.length; i += 1) { for (let i = 0; i < notesIds.length; i += 1) {
if ( if (
results[notesIds[i]].length > 0 && results[notesIds[i]].length > 0 &&
...@@ -256,20 +250,19 @@ const FindComponent = ({ ...@@ -256,20 +250,19 @@ const FindComponent = ({
) { ) {
helpers.clearViewSelection(view, lastActiveViewId); helpers.clearViewSelection(view, lastActiveViewId);
helpers.moveToMatch(view, notesIds[i], results, 0); helpers.moveToMatch(view, notesIds[i], results, 0);
lastActiveViewId = findViewWithMatches;
lastSelection = view[lastActiveViewId].state.selection;
break; break;
} }
} }
setTimeout(() => {
lastActiveViewId = findViewWithMatches;
lastSelection = view[lastActiveViewId].state.selection;
}, 50);
} }
} }
}; };
const findPrevious = () => { const findPrevious = () => {
view[lastActiveViewId].focus(); lastActiveViewId = activeViewId;
lastSelection = view[activeViewId].state.selection;
const results = helpers.getAllResultsByView( const results = helpers.getAllResultsByView(
view, view,
searchValue, searchValue,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment