Skip to content

Commit

Permalink
feat: Store chosen sort column in local storage (#3646)
Browse files Browse the repository at this point in the history
* feat: Store chosen sort column in local storage

* feat: Allow sort column to be defined in route params

* chore: Fix typecheck
  • Loading branch information
garethfuller authored Jul 6, 2023
1 parent bd9a333 commit 489b567
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/constants/local-storage.keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default {
EthereumTxType: 'app.ethereumTxType',
SupportSignatures: 'app.supportSignatures',
TermsAccepted: 'app.termsAccepted',
PoolSorting: 'app.poolSorting',
},
Swap: {
Gasless: 'swap.gasless',
Expand Down
16 changes: 15 additions & 1 deletion src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ import usePoolFilters from '@/composables/pools/usePoolFilters';
import useBreakpoints from '@/composables/useBreakpoints';
import useNetwork from '@/composables/useNetwork';
import usePools from '@/composables/pools/usePools';
import { lsGet, lsSet } from '@/lib/utils';
import LS_KEYS from '@/constants/local-storage.keys';
// COMPOSABLES
/**
* STATE
*/
const route = useRoute();
const urlSortParam = route.query?.sort as string | undefined;
const initSortCol =
urlSortParam || lsGet(LS_KEYS.App.PoolSorting) || 'totalLiquidity';
/**
* COMPOSABLES
*/
const router = useRouter();
const { appNetworkConfig } = useNetwork();
const isElementSupported = appNetworkConfig.supportsElementPools;
Expand All @@ -37,6 +49,7 @@ function navigateToCreatePool() {
function onColumnSort(columnId: string) {
poolsSortField.value = columnId;
lsSet(LS_KEYS.App.PoolSorting, columnId);
}
</script>

Expand Down Expand Up @@ -91,6 +104,7 @@ function onColumnSort(columnId: string) {
:isLoading="isLoading"
:selectedTokens="selectedTokens"
class="mb-8"
:sortColumn="initSortCol"
:hiddenColumns="['migrate', 'actions', 'lockEndDate']"
:isLoadingMore="poolsIsFetchingNextPage"
:isPaginated="isPaginated"
Expand Down

1 comment on commit 489b567

@vercel
Copy link

@vercel vercel bot commented on 489b567 Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.