Skip to content
Snippets Groups Projects

Connect funcionality

Merged Christos requested to merge connect-funcionality into master
Compare and Show latest version
2 files
+ 52
9
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -178,21 +178,50 @@ const FindComponent = ({ close, expand, setPreviousSearcValue }) => {
const resultsFrom = helpers.getResultsFrom(results);
const notesIds = helpers.getNotesIds(view.main);
console.log(notesIds);
const found = helpers.getClosestMatch(
lastSelection.from,
resultsFrom[lastActiveViewId],
);
let position = resultsFrom[lastActiveViewId].indexOf(found);
const position = resultsFrom[lastActiveViewId].indexOf(found);
/* User selection lesser than found */
if (lastSelection.from < found) {
helpers.moveToMatch(view, lastActiveViewId, results, position);
}
/* User selection greater than found move to next if not already at the end of results for the view */
if (
lastSelection.from >= found &&
position < resultsFrom[lastActiveViewId].length - 1
)
position += 1;
) {
helpers.moveToMatch(view, lastActiveViewId, results, position + 1);
}
helpers.moveToMatch(view, lastActiveViewId, results, position);
/* Last result of the specific view. Move to next view */
if (
lastSelection.from === found &&
position === resultsFrom[lastActiveViewId].length - 1
) {
/* End of results in notes move to main if results exist */
if (
notesIds.indexOf(lastActiveViewId) === notesIds.length - 1 &&
results.main.length > 0
) {
helpers.clearViewSelection(view, lastActiveViewId);
helpers.moveToMatch(view, 'main', results, 0);
} else {
for (let i = 0; i < notesIds.length; i++) {
if (
results[notesIds[i]].length > 0 &&
notesIds[i] !== lastActiveViewId
) {
helpers.clearViewSelection(view, lastActiveViewId);
helpers.moveToMatch(view, notesIds[i], results, 0);
break;
}
}
}
}
};
const findPrevious = () => {
@@ -205,8 +234,6 @@ const FindComponent = ({ close, expand, setPreviousSearcValue }) => {
const resultsFrom = helpers.getResultsFrom(results);
const notesIds = helpers.getNotesIds(view.main);
console.log(notesIds);
const found = helpers.getClosestMatch(
lastSelection.from,
resultsFrom[lastActiveViewId],
@@ -214,7 +241,12 @@ const FindComponent = ({ close, expand, setPreviousSearcValue }) => {
);
let position = resultsFrom[lastActiveViewId].indexOf(found);
if (lastSelection.from <= found) position -= 1;
if (lastSelection.from <= found && position !== 0) position -= 1;
if (lastSelection.from === found && position === 0) {
view.main.focus();
console.log('first in view');
}
helpers.moveToMatch(view, lastActiveViewId, results, position);
};