From c5307fcdcc9b1e0efa542e78b39b207423b459fd Mon Sep 17 00:00:00 2001 From: upsiflu Date: Mon, 9 Dec 2024 13:31:44 +0100 Subject: [PATCH] fix(front) [WIP] Comment out jQuery `search` until we find the correct version --- front/src/components/audio/SearchBar.vue | 188 ++++++++++++----------- 1 file changed, 95 insertions(+), 93 deletions(-) diff --git a/front/src/components/audio/SearchBar.vue b/front/src/components/audio/SearchBar.vue index d3576c4db..85dbcc5bc 100644 --- a/front/src/components/audio/SearchBar.vue +++ b/front/src/components/audio/SearchBar.vue @@ -65,7 +65,8 @@ const el = useCurrentElement() const query = ref() const enter = () => { - jQuery(el.value).search('cancel query') + // TODO: Find out what jQuery version supports `search` + // jQuery(el.value).search('cancel query') // Cancel any API search request to backend… return router.push(`/search?q=${query.value}&type=artists`) @@ -136,107 +137,108 @@ const objectId = computed(() => { }) onMounted(() => { - jQuery(el.value).search({ - type: 'category', - minCharacters: 3, - showNoResults: true, - error: { - // @ts-expect-error Semantic is broken - noResultsHeader: t('components.audio.SearchBar.header.noResults'), - noResults: t('components.audio.SearchBar.empty.noResults') - }, + // TODO: Find out what jQuery version supports `search` + // jQuery(el.value).search({ + // type: 'category', + // minCharacters: 3, + // showNoResults: true, + // error: { + // // @ts-expect-error Semantic is broken + // noResultsHeader: t('components.audio.SearchBar.header.noResults'), + // noResults: t('components.audio.SearchBar.empty.noResults') + // }, - onSelect (result, response) { - jQuery(el.value).search('set value', query.value) - router.push(result.routerUrl) - jQuery(el.value).search('hide results') - return false - }, - onSearchQuery (value) { - // query.value = value - emit('search') - }, - apiSettings: { - url: store.getters['instance/absoluteUrl']('api/v1/search?query={query}'), - beforeXHR: function (xhrObject) { - if (!store.state.auth.authenticated) { - return xhrObject - } + // onSelect (result, response) { + // jQuery(el.value).search('set value', query.value) + // router.push(result.routerUrl) + // jQuery(el.value).search('hide results') + // return false + // }, + // onSearchQuery (value) { + // // query.value = value + // emit('search') + // }, + // apiSettings: { + // url: store.getters['instance/absoluteUrl']('api/v1/search?query={query}'), + // beforeXHR: function (xhrObject) { + // if (!store.state.auth.authenticated) { + // return xhrObject + // } - if (store.state.auth.oauth.accessToken) { - xhrObject.setRequestHeader('Authorization', store.getters['auth/header']) - } + // if (store.state.auth.oauth.accessToken) { + // xhrObject.setRequestHeader('Authorization', store.getters['auth/header']) + // } - return xhrObject - }, - onResponse: function (initialResponse) { - const id = objectId.value - const results: Partial> = {} + // return xhrObject + // }, + // onResponse: function (initialResponse) { + // const id = objectId.value + // const results: Partial> = {} - let resultsEmpty = true - for (const category of categories.value) { - results[category.code] = { - name: category.name, - results: [] - } + // let resultsEmpty = true + // for (const category of categories.value) { + // results[category.code] = { + // name: category.name, + // results: [] + // } - if (category.code === 'federation' && id) { - resultsEmpty = false - results[category.code]?.results.push({ - title: t('components.audio.SearchBar.link.fediverse'), - routerUrl: { - name: 'search', - query: { id } - } - }) - } + // if (category.code === 'federation' && id) { + // resultsEmpty = false + // results[category.code]?.results.push({ + // title: t('components.audio.SearchBar.link.fediverse'), + // routerUrl: { + // name: 'search', + // query: { id } + // } + // }) + // } - if (category.code === 'podcasts' && id) { - resultsEmpty = false - results[category.code]?.results.push({ - title: t('components.audio.SearchBar.link.rss'), - routerUrl: { - name: 'search', - query: { id, type: 'rss' } - } - }) - } + // if (category.code === 'podcasts' && id) { + // resultsEmpty = false + // results[category.code]?.results.push({ + // title: t('components.audio.SearchBar.link.rss'), + // routerUrl: { + // name: 'search', + // query: { id, type: 'rss' } + // } + // }) + // } - if (category.code === 'more') { - results[category.code]?.results.push({ - title: t('components.audio.SearchBar.link.more'), - routerUrl: { - name: 'search', - query: { type: 'artists', q: query.value } - } - }) - } + // if (category.code === 'more') { + // results[category.code]?.results.push({ + // title: t('components.audio.SearchBar.link.more'), + // routerUrl: { + // name: 'search', + // query: { type: 'artists', q: query.value } + // } + // }) + // } - if (isCategoryGuard(category)) { - for (const result of initialResponse[category.code]) { - resultsEmpty = false - const id = category.getId(result) - results[category.code]?.results.push({ - title: category.getTitle(result), - id, - routerUrl: { - name: category.route, - params: { id } - }, - description: category.getDescription(result) - }) - } - } - } + // if (isCategoryGuard(category)) { + // for (const result of initialResponse[category.code]) { + // resultsEmpty = false + // const id = category.getId(result) + // results[category.code]?.results.push({ + // title: category.getTitle(result), + // id, + // routerUrl: { + // name: category.route, + // params: { id } + // }, + // description: category.getDescription(result) + // }) + // } + // } + // } - return { - results: resultsEmpty - ? {} - : results - } - } - } - }) + // return { + // results: resultsEmpty + // ? {} + // : results + // } + // } + // } + // }) })