Note to Self

This commit is contained in:
Scott Nonnenberg 2019-01-30 17:45:58 -08:00
parent 681ca363fe
commit a43a78731a
15 changed files with 411 additions and 148 deletions

View file

@ -1,6 +1,4 @@
/* global ConversationController: false */
/* global i18n: false */
/* global Whisper: false */
/* global ConversationController, i18n, textsecure, Whisper */
// eslint-disable-next-line func-names
(function() {
@ -81,9 +79,19 @@
/* eslint-disable more/no-then */
this.pending = this.pending.then(() =>
this.typeahead.search(query).then(() => {
this.typeahead_view.collection.reset(
this.typeahead.filter(isSearchable)
);
let results = this.typeahead.filter(isSearchable);
const noteToSelf = i18n('noteToSelf');
if (noteToSelf.toLowerCase().indexOf(query.toLowerCase()) !== -1) {
const ourNumber = textsecure.storage.user.getNumber();
const conversation = ConversationController.get(ourNumber);
if (conversation) {
// ensure that we don't have duplicates in our results
results = results.filter(item => item.id !== ourNumber);
results.unshift(conversation);
}
}
this.typeahead_view.collection.reset(results);
})
);
/* eslint-enable more/no-then */