different token sort order, support null expirey time
This commit is contained in:
parent
84d0a0e542
commit
7820853def
@ -354,7 +354,7 @@ export class Token implements WithEquals<Token> {
|
||||
dataToken.token,
|
||||
dataToken.member_id ? { id: dataToken.member_id } : null,
|
||||
new Date(dataToken.created),
|
||||
new Date(dataToken.expires),
|
||||
dataToken.expires ? new Date(dataToken.expires) : null,
|
||||
dataToken
|
||||
);
|
||||
}
|
||||
@ -374,14 +374,18 @@ export class Token implements WithEquals<Token> {
|
||||
if (a.expires && b.expires) {
|
||||
return b.expires.getTime() - a.expires.getTime();
|
||||
} else if (a.expires) {
|
||||
return -1;
|
||||
} else if (b.expires) {
|
||||
return 1;
|
||||
} else if (b.expires) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static sortRecentCreatedFirst(a: Token, b: Token) {
|
||||
return b.created.getTime() - a.created.getTime();
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `t#${this.id}/${this.token}`;
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ const GuildInvitesDisplay: FC<GuildInvitesDisplayProps> = (props: GuildInvitesDi
|
||||
<div className="token">{token.token}</div>
|
||||
</div>
|
||||
<div className="created-expires">
|
||||
<div className="created">Created {moment(token.created).fromNow()}</div>
|
||||
<div className="expires">Expires {moment(token.expires).fromNow()}</div>
|
||||
<div className="created">{'Created ' + moment(token.created).fromNow()}</div>
|
||||
<div className="expires">{token.expires ? 'Expires ' + moment(token.expires).fromNow() : 'Never expires'}</div>
|
||||
</div>
|
||||
<div className="actions">
|
||||
<Button colorType={ButtonColorType.BRAND}>{BaseElements.DOWNLOAD}</Button>
|
||||
|
@ -337,7 +337,7 @@ export default class GuildSubscriptions {
|
||||
removedEventArgsMap: (removedTokens: Token[]) => removedTokens,
|
||||
conflictEventName: 'conflict-tokens',
|
||||
conflictEventArgsMap: (changesType: AutoVerifierChangesType, changes: Changes<Token>) => changes,
|
||||
sortFunc: Token.sortFurthestExpiresFirst
|
||||
sortFunc: Token.sortRecentCreatedFirst
|
||||
}, fetchTokensFunc);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user