Skip to content

Commit

Permalink
fix: token uuid index issue
Browse files Browse the repository at this point in the history
  • Loading branch information
SolidFaker committed Nov 12, 2024
1 parent 871f88b commit aa09121
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion AppScope/app.json5
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bundleName": "smartcityshenzhen.yylx.totptoken",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"versionName": "1.0.1",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
Expand Down
2 changes: 1 addition & 1 deletion entry/oh-package.json5
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "entry",
"version": "1.0.0",
"version": "1.0.1",
"description": "Please describe the basic information.",
"main": "",
"author": "",
Expand Down
7 changes: 7 additions & 0 deletions entry/src/main/ets/utils/TokenStore.ets
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class TokenStore {

public sortTokens(): void {
this.token_array = this.token_array.sort((a, b) => a.RankScore - b.RankScore);
this.token_uuids = this.token_array.map(token => token.TokenUUID);
this.emitTokenChanged();
}

Expand All @@ -82,15 +83,21 @@ export class TokenStore {
if (up) {
if (index > 0) {
const token_swap = this.token_array[index - 1];
const token_uuid_swap = this.token_uuids[index - 1];
this.token_array[index].RankScore = token_swap.RankScore;
this.token_array[index - 1].RankScore = score;
this.token_uuids[index - 1] = this.token_uuids[index];
this.token_uuids[index] = token_uuid_swap;
this.saveTokenPair(token, token_swap);
}
} else {
if (index < this.token_array.length - 1) {
const token_swap = this.token_array[index + 1];
const token_uuid_swap = this.token_uuids[index + 1];
this.token_array[index].RankScore = token_swap.RankScore;
this.token_array[index + 1].RankScore = score;
this.token_uuids[index + 1] = this.token_uuids[index];
this.token_uuids[index] = token_uuid_swap;
this.saveTokenPair(token, token_swap);
}
}
Expand Down

0 comments on commit aa09121

Please sign in to comment.