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(() => {
if (canceled) {
return
}
// run the two searches in parallel
searchAccountsLocally().then(onNewResults)
searchAccountsRemotely().then(onNewResults)
searchAccountsLocally().then(onNewResults).catch(onError)
searchAccountsRemotely().then(onNewResults).catch(onError)
})
return {

View file

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

View file

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