Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing a bug #919

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
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
21 changes: 19 additions & 2 deletions src/components/AppSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,29 @@ const sortCriteria = (a: SearchResult, b: SearchResult): number => {
}
};

const getSearchResultRaw = (result: SearchResultRaw[] | string): SearchResultRaw[] => {
if (typeof result === 'string') {
try {
const obj = JSON.parse(result);
return obj as SearchResultRaw[];
} catch (e) {
return [{
type: 'unknown',
address: result,
}] as never as SearchResultRaw[];
}
} else {
return result as SearchResultRaw[];
}
};


const goToFirstResultNow = (query: string) => {
const endpoint = useChainStore().currentChain.settings.getIndexerApiEndpoint();
const url = `${endpoint}/api?module=search&action=search&query=${query}&offset=1`;
loading.value = true;
axios.get(url).then((response) => {
const result = response.data.result.map((entry: SearchResultRaw) => convertRawToProcessedResult(entry));
const result = getSearchResultRaw(response.data.result).map((entry: SearchResultRaw) => convertRawToProcessedResult(entry));
loading.value = false;
handleResultClick(result[0]);
}).catch((error) => {
Expand All @@ -236,7 +253,7 @@ const fetchResults = (query: string): Observable<SearchResult[]> => {
return new Observable<SearchResult[]>((observer) => {
loading.value = true;
axios.get(url).then((response) => {
const result = response.data.result.map((entry: SearchResultRaw) => convertRawToProcessedResult(entry));
const result = getSearchResultRaw(response.data.result).map((entry: SearchResultRaw) => convertRawToProcessedResult(entry));
result.sort(sortCriteria);
loading.value = false;
observer.next(result);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/HomeInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function fetchLatestBlock() {

async function fetchTotalTransactions() {
const indexerApi = useChainStore().currentChain.settings.getIndexerApi();
const response = await indexerApi.get('/v1/transactions?limit=0&next=-1&offset=0&includeAbi=false&includePagination=true&includeTransfers=false&full=false');
const response = await indexerApi.get('/v1/transactions?limit=1&offset=0&includeAbi=false&includePagination=true&includeTransfers=false&full=false');
transactionsCount.value = response.data.total_count;
}

Expand Down
Loading