fix: tweak autosuggest error logging and resetting (#1572)
This commit is contained in:
parent
d580a9b7e8
commit
2bafaa455e
|
@ -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 {
|
||||||
|
|
|
@ -33,12 +33,16 @@ export function doHashtagSearch (searchText) {
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduleIdleTask(async () => {
|
scheduleIdleTask(async () => {
|
||||||
|
try {
|
||||||
const results = await requestThrottler.request()
|
const results = await requestThrottler.request()
|
||||||
store.setForCurrentAutosuggest({
|
store.setForCurrentAutosuggest({
|
||||||
autosuggestType: 'hashtag',
|
autosuggestType: 'hashtag',
|
||||||
autosuggestSelected: 0,
|
autosuggestSelected: 0,
|
||||||
autosuggestSearchResults: results
|
autosuggestSearchResults: results
|
||||||
})
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('ignored autosuggest error', err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue