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

Fix explore books sorting #1299

Merged
merged 3 commits into from
Feb 8, 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
6 changes: 3 additions & 3 deletions src/components/mixins/ExplorePageMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default class ExplorePageMixin extends Mixins(ScrollableTableMixin, Trans
@getter.assets.assetDataByAddress public getAsset!: (addr?: string) => Nullable<RegisteredAccountAsset>;
@getter.assets.whitelistAssets public whitelistAssets!: Array<Asset>;

order = '';
property = '';
order = SortDirection.DESC;
property = 'tvl';

get loadingState(): boolean {
return this.parentLoading || this.loading;
Expand Down Expand Up @@ -90,7 +90,7 @@ export default class ExplorePageMixin extends Mixins(ScrollableTableMixin, Trans
await this.updateExploreData();
}

changeSort({ order = '', property = '' } = {}): void {
changeSort({ order = SortDirection.DESC, property = '' } = {}): void {
this.order = order;
this.property = property;
}
Expand Down
8 changes: 2 additions & 6 deletions src/views/Explore/Books.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@

<script lang="ts">
import { FPNumber } from '@sora-substrate/util';
import { SortDirection } from '@soramitsu/soramitsu-js-ui/lib/components/Table/consts';
import { components } from '@soramitsu/soraneo-wallet-web';
import { Component, Mixins } from 'vue-property-decorator';

Expand Down Expand Up @@ -165,12 +164,9 @@ type TableItem = {
},
})
export default class ExploreBooks extends Mixins(ExplorePageMixin) {
orderBooks: readonly OrderBookWithStats[] = [];
// override ExplorePageMixin
order = SortDirection.DESC;
property = 'tvl';
private orderBooks: readonly OrderBookWithStats[] = [];

get preparedItems(): TableItem[] {
get prefilteredItems(): TableItem[] {
const items = this.orderBooks.reduce<TableItem[]>((buffer, item) => {
const {
id: { base, quote },
Expand Down
2 changes: 0 additions & 2 deletions src/views/Explore/Demeter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@

<script lang="ts">
import { FPNumber } from '@sora-substrate/util';
import { SortDirection } from '@soramitsu/soramitsu-js-ui/lib/components/Table/consts';
import { api, components } from '@soramitsu/soraneo-wallet-web';
import { Component, Mixins, Watch } from 'vue-property-decorator';

Expand Down Expand Up @@ -224,7 +223,6 @@ export default class ExploreDemeter extends Mixins(DemeterBasePageMixin, Explore
}

// override ExplorePageMixin
order = SortDirection.DESC;
property = 'apr';

poolsData: Record<string, PoolData> = {};
Expand Down
15 changes: 2 additions & 13 deletions src/views/Explore/Pools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</template>
</s-table-column>
<!-- APY -->
<s-table-column v-if="hasApyColumnData" key="apy" width="120" header-align="right" align="right">
<s-table-column width="120" header-align="right" align="right">
<template #header>
<sort-button name="apy" :sort="{ order, property }" @change-sort="changeSort">
<span class="explore-table__primary">APY</span>
Expand Down Expand Up @@ -140,7 +140,6 @@

<script lang="ts">
import { FPNumber } from '@sora-substrate/util';
import { SortDirection } from '@soramitsu/soramitsu-js-ui/lib/components/Table/consts';
import { components } from '@soramitsu/soraneo-wallet-web';
import { Component, Mixins } from 'vue-property-decorator';

Expand Down Expand Up @@ -188,13 +187,7 @@ type TableItem = {
export default class ExplorePools extends Mixins(ExplorePageMixin) {
@state.pool.accountLiquidity private accountLiquidity!: Array<AccountLiquidity>;

// override ExplorePageMixin
order = SortDirection.DESC;
property = 'tvl';

poolReserves: Record<string, string[]> = {};

poolsData: readonly PoolData[] = [];
private poolsData: readonly PoolData[] = [];

get items(): TableItem[] {
const items = this.poolsData.reduce<any>((buffer, pool) => {
Expand Down Expand Up @@ -268,10 +261,6 @@ export default class ExplorePools extends Mixins(ExplorePageMixin) {
return this.isAccountItemsOnly ? this.items.filter((item) => item.isAccountItem) : this.items;
}

get hasApyColumnData(): boolean {
return this.items.some((item) => item.apy !== 0);
}

// ExplorePageMixin method implementation
async updateExploreData(): Promise<void> {
await this.withLoading(async () => {
Expand Down
6 changes: 1 addition & 5 deletions src/views/Explore/Tokens.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@

<script lang="ts">
import { FPNumber } from '@sora-substrate/util';
import { SortDirection } from '@soramitsu/soramitsu-js-ui/lib/components/Table/consts';
import { components } from '@soramitsu/soraneo-wallet-web';
import { Component, Mixins } from 'vue-property-decorator';

Expand Down Expand Up @@ -221,10 +220,7 @@ export default class Tokens extends Mixins(ExplorePageMixin) {
this.isSynths = value;
}

tokensData: Record<string, TokenData> = {};
// override ExplorePageMixin
order = SortDirection.DESC;
property = 'tvl';
private tokensData: Record<string, TokenData> = {};

get hasTokensData(): boolean {
return Object.keys(this.tokensData).length !== 0;
Expand Down