Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/renderer/views/SearchPage/SearchPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
:data="shownResults"
/>
<FtAutoLoadNextPageWrapper
v-if="!isNextPageLoading"
@load-next-page="nextPage"
>
<div
Expand Down Expand Up @@ -66,6 +67,7 @@ const { t } = useI18n()
const route = useRoute()

const isLoading = ref(false)
const isNextPageLoading = ref(false)
const apiUsed = ref('local')
const searchSettings = ref({})
const searchPage = ref(1)
Expand Down Expand Up @@ -226,7 +228,7 @@ async function performSearchLocal(payload) {

if (backendPreference.value === 'local' && backendFallback.value) {
showToast(t('Falling back to Invidious API'))
performSearchInvidious(payload)
await performSearchInvidious(payload)
} else {
isLoading.value = false
}
Expand Down Expand Up @@ -267,7 +269,7 @@ async function getNextpageLocal(payload) {

if (backendPreference.value === 'local' && backendFallback.value) {
showToast(t('Falling back to Invidious API'))
performSearchInvidious(payload)
await performSearchInvidious(payload)
} else {
isLoading.value = false
}
Expand Down Expand Up @@ -322,15 +324,19 @@ async function performSearchInvidious(payload, options = { resetSearchPage: fals

if (process.env.SUPPORTS_LOCAL_API && backendPreference.value === 'invidious' && backendFallback.value) {
showToast(t('Falling back to Local API'))
performSearchLocal(payload)
await performSearchLocal(payload)
} else {
isLoading.value = false
// TODO: Show toast with error message
}
}
}

function nextPage() {
async function nextPage() {
if (isNextPageLoading.value) return

isNextPageLoading.value = true

const payload = {
query: processedQuery.value,
searchSettings: searchSettings.value,
Expand All @@ -342,14 +348,16 @@ function nextPage() {
if (apiUsed.value === 'local') {
if (nextPageRef.value !== null) {
showToast(t('Search Filters["Fetching results. Please wait"]'))
getNextpageLocal(payload)
await getNextpageLocal(payload)
} else {
showToast(t('Search Filters.There are no more results for this search'))
}
} else {
showToast(t('Search Filters["Fetching results. Please wait"]'))
performSearchInvidious(payload)
await performSearchInvidious(payload)
}

isNextPageLoading.value = false
}

function replaceShownResults(history) {
Expand Down