Skip to content

Commit

Permalink
fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Polyakov committed Mar 5, 2024
1 parent 375de5a commit 8da8c49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/components/pages/Swap/Widget/Transactions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ type TableItem = {
links: WALLET_CONSTS.ExplorerLink[];
};
type RequestVariables = Partial<{
filter: any;
first: number;
offset: number;
}>;
const UPDATE_INTERVAL = 15_000;
@Component({
Expand Down Expand Up @@ -213,7 +219,7 @@ export default class SwapTransactionsWidget extends Mixins(ScrollableTableMixin)
get assetsAddresses(): string[] {
const filtered = [this.tokenFrom, this.tokenTo].filter((token) => !!token) as AccountAsset[];
return filtered.map((token) => token.address).sort();
return filtered.map((token) => token.address).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));

Check warning on line 222 in src/components/pages/Swap/Widget/Transactions.vue

View check run for this annotation

Soramitsu-Sonar-PR-decoration / polkaswap-exchange-web Sonarqube Results

src/components/pages/Swap/Widget/Transactions.vue#L222

Extract this nested ternary operation into an independent statement.
}
private createFilter(timestamp?: number) {
Expand Down Expand Up @@ -250,7 +256,7 @@ export default class SwapTransactionsWidget extends Mixins(ScrollableTableMixin)
private async fetchData(): Promise<void> {
const { pageAmount, currentPage } = this;
const variables = {
const variables: RequestVariables = {
filter: this.createFilter(this.fromTimestamp),
first: pageAmount,
offset: pageAmount * (currentPage - 1),
Expand All @@ -267,14 +273,14 @@ export default class SwapTransactionsWidget extends Mixins(ScrollableTableMixin)
}
private async fetchDataUpdates(): Promise<void> {
const variables = { filter: this.createFilter(this.intervalTimestamp) };
const variables: RequestVariables = { filter: this.createFilter(this.intervalTimestamp) };
const { transactions, totalCount } = await this.requestData(variables);
this.transactions = [...transactions, ...this.transactions].slice(0, this.pageAmount);
this.totalCount = this.totalCount + totalCount;
this.updateIntervalTimestamp();
}
private async requestData(variables): Promise<{ transactions: HistoryItem[]; totalCount: number }> {
private async requestData(variables: RequestVariables): Promise<{ transactions: HistoryItem[]; totalCount: number }> {
const indexer = getCurrentIndexer();
const response = await indexer.services.explorer.account.getHistory(variables);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export const soraExplorerLinks = (
if (!soraNetwork) return [];

const baseLinks = getExplorerLinks(soraNetwork);
const txId = transactionHash || blockHash;
const txId = transactionHash ?? blockHash;

if (!(baseLinks.length && txId)) {
return [];
Expand Down

0 comments on commit 8da8c49

Please sign in to comment.