diff --git a/src/client/webapp/data-types.ts b/src/client/webapp/data-types.ts index 28e9239..56c17f3 100644 --- a/src/client/webapp/data-types.ts +++ b/src/client/webapp/data-types.ts @@ -354,7 +354,7 @@ export class Token implements WithEquals { 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 { 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}`; } diff --git a/src/client/webapp/elements/displays/display-guild-invites.tsx b/src/client/webapp/elements/displays/display-guild-invites.tsx index 2e5d25c..9e955ca 100644 --- a/src/client/webapp/elements/displays/display-guild-invites.tsx +++ b/src/client/webapp/elements/displays/display-guild-invites.tsx @@ -78,8 +78,8 @@ const GuildInvitesDisplay: FC = (props: GuildInvitesDi
{token.token}
-
Created {moment(token.created).fromNow()}
-
Expires {moment(token.expires).fromNow()}
+
{'Created ' + moment(token.created).fromNow()}
+
{token.expires ? 'Expires ' + moment(token.expires).fromNow() : 'Never expires'}
diff --git a/src/client/webapp/elements/require/guild-subscriptions.ts b/src/client/webapp/elements/require/guild-subscriptions.ts index b5813b1..324f41c 100644 --- a/src/client/webapp/elements/require/guild-subscriptions.ts +++ b/src/client/webapp/elements/require/guild-subscriptions.ts @@ -337,7 +337,7 @@ export default class GuildSubscriptions { removedEventArgsMap: (removedTokens: Token[]) => removedTokens, conflictEventName: 'conflict-tokens', conflictEventArgsMap: (changesType: AutoVerifierChangesType, changes: Changes) => changes, - sortFunc: Token.sortFurthestExpiresFirst + sortFunc: Token.sortRecentCreatedFirst }, fetchTokensFunc); } }