Skip to content

Commit

Permalink
Andri/last used (#2683)
Browse files Browse the repository at this point in the history
* start replacing DeviceData with DeviceWithUsage

* finish replacing DeviceData with DeviceWithUsage, display last_usage formatted in devices list if available

* remove unnecessary console log

* BigInt in types -> bigint

* adjust formatting

* rearrange and use relative time format

* format

* create time format helper utility and tests

* format

* fix showcase

* add mock data for showcase
  • Loading branch information
LXIF authored Nov 21, 2024
1 parent 0281b44 commit 3334e71
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/frontend/src/flows/manage/authenticatorsSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const authenticatorItem = ({
let lastUsageTimeStamp: Date | undefined;
let lastUsageFormattedString: string | undefined;

if (last_usage.length > 0 && typeof last_usage[0] === "bigint") {
if (last_usage?.length > 0 && typeof last_usage[0] === "bigint") {
lastUsageTimeStamp = new Date(Number(last_usage[0] / BigInt(1000000)));
}

Expand Down
3 changes: 3 additions & 0 deletions src/showcase/src/pages/displayManage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@ import Screen from "../layouts/Screen.astro";
alias: "Chrome on iPhone",
remove: () => toast.info("remove"),
rename: () => toast.info("rename"),
last_usage: [BigInt(Date.now() * 1000000)],
},
{
alias: "Yubikey Blue",
remove: () => toast.info("remove"),
rename: () => toast.info("rename"),
last_usage: [BigInt(Date.now() * 1000000 - 1_000_000_000 * 60 * 60 * 24 * 7)],
},
{
alias: "Yubikey Blue",
remove: () => toast.info("remove"),
rename: () => toast.info("rename"),
last_usage: [BigInt(Date.now() * 1000000 - 1_000_000_000 * 60 * 60 * 24 * 30)],
warn: html`Something is rotten in the state of Device`,
},
],
Expand Down
1 change: 1 addition & 0 deletions src/showcase/src/pages/displayManageSingle.astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Screen from "../layouts/Screen.astro";
{
alias: "Chrome on iPhone",
rename: () => toast.info("rename"),
last_usage: [BigInt(Date.now() * 1000000)],
},
],
recoveries: {},
Expand Down

0 comments on commit 3334e71

Please sign in to comment.