fix: tweak autosuggest error logging and resetting (#1572)

This commit is contained in:
Nolan Lawson 2019-10-13 13:53:48 -07:00 committed by GitHub
parent d580a9b7e8
commit 2bafaa455e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 9 deletions

View file

@ -73,13 +73,17 @@ export function doAccountSearch (searchText) {
}) })
} }
function onError (err) {
console.warn('ignored autosuggest error', err)
}
scheduleIdleTask(() => { scheduleIdleTask(() => {
if (canceled) { if (canceled) {
return return
} }
// run the two searches in parallel // run the two searches in parallel
searchAccountsLocally().then(onNewResults) searchAccountsLocally().then(onNewResults).catch(onError)
searchAccountsRemotely().then(onNewResults) searchAccountsRemotely().then(onNewResults).catch(onError)
}) })
return { return {

View file

@ -33,12 +33,16 @@ export function doHashtagSearch (searchText) {
} }
scheduleIdleTask(async () => { scheduleIdleTask(async () => {
const results = await requestThrottler.request() try {
store.setForCurrentAutosuggest({ const results = await requestThrottler.request()
autosuggestType: 'hashtag', store.setForCurrentAutosuggest({
autosuggestSelected: 0, autosuggestType: 'hashtag',
autosuggestSearchResults: results autosuggestSelected: 0,
}) autosuggestSearchResults: results
})
} catch (err) {
console.warn('ignored autosuggest error', err)
}
}) })
return { return {

View file

@ -24,10 +24,10 @@ export function autosuggestObservers () {
const { composeFocused } = store.get() const { composeFocused } = store.get()
const autosuggestSelecting = store.getForCurrentAutosuggest('autosuggestSelecting') const autosuggestSelecting = store.getForCurrentAutosuggest('autosuggestSelecting')
if (!composeFocused || !autosuggestSearchText || autosuggestSelecting) { if (!composeFocused || !autosuggestSearchText || autosuggestSelecting) {
resetAutosuggest()
return return
} }
resetAutosuggest()
if (autosuggestSearchText.startsWith(':')) { // emoji if (autosuggestSearchText.startsWith(':')) { // emoji
lastSearch = doEmojiSearch(autosuggestSearchText) lastSearch = doEmojiSearch(autosuggestSearchText)
} else if (autosuggestSearchText.startsWith('#')) { // hashtag } else if (autosuggestSearchText.startsWith('#')) { // hashtag