From abe9454e9a3f1050f01b78a1d346b141d5ba7e0b Mon Sep 17 00:00:00 2001 From: Shreyas Gupta Date: Fri, 13 Dec 2024 15:28:52 +0530 Subject: [PATCH] Added last modified info (#15829) * added last modified date * updated changelog --- extensions/figma-files/CHANGELOG.md | 4 +++ extensions/figma-files/README.md | 4 +-- .../src/components/FileGridItem.tsx | 27 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/extensions/figma-files/CHANGELOG.md b/extensions/figma-files/CHANGELOG.md index a6dd2bc6a98..a8678e8d392 100644 --- a/extensions/figma-files/CHANGELOG.md +++ b/extensions/figma-files/CHANGELOG.md @@ -1,5 +1,9 @@ # Figma Files Changelog +## [Adds last edited timestamp] - 2024-12-12 + +- You can now see when was the Figma file last edited ("last edited 2 days ago"), to better understand how stale the file is. + ## [Adds support for OAuth] - 2024-04-15 - The extension now has OAuth support, so you don't have to create personal access tokens for giving Raycast access to Figma. diff --git a/extensions/figma-files/README.md b/extensions/figma-files/README.md index a74e74a7b46..1a5ac26841b 100644 --- a/extensions/figma-files/README.md +++ b/extensions/figma-files/README.md @@ -10,11 +10,11 @@ Figma file search helps you quickly open a Figma file from anywhere on your mac. 4. Support for opening a specific page of a file 5. Menu Bar command for quick access to files -Note - Currently, this extension only works with team accounts. Draft files are not supported due to a Figma API limitation. +Note - Currently, this extension only works with team accounts. Draft files are not supported due to a Figma API limitation. Figma slides are not supported for the same reason, so you won't see them in Raycast. ## Setting up the Extension -1. Locate your team IDs. Do this by visiting Figma.com and click the team name you wish to use. In the URL, copy the ID that comes BETWEEN the word `/team/` and BEFORE your actual team name. You can also right-click on the team name in the Figma Desktop app sidebar and copy the link. +1. Locate your team ID/s. Do this by visiting Figma.com and click the team name you wish to use. In the URL, copy the ID that comes BETWEEN the word `/team/` and BEFORE your actual team name, or `/all-projects`. You can also right-click on the team name in the Figma Desktop app sidebar and copy the link. > Example - https://www.figma.com/files/team/12345678987654321/NameOfTeam... diff --git a/extensions/figma-files/src/components/FileGridItem.tsx b/extensions/figma-files/src/components/FileGridItem.tsx index 1e8d2bbb423..c59b155a4cc 100644 --- a/extensions/figma-files/src/components/FileGridItem.tsx +++ b/extensions/figma-files/src/components/FileGridItem.tsx @@ -28,6 +28,7 @@ export default function FileGridItem(props: { ); } + +function getRelativeTime(timestamp: number): string { + const now = Date.now(); + const diff = now - timestamp; + + const seconds = Math.floor(diff / 1000); + const minutes = Math.floor(seconds / 60); + const hours = Math.floor(minutes / 60); + const days = Math.floor(hours / 24); + const months = Math.floor(days / 30); + const years = Math.floor(days / 365); + + if (seconds < 60) { + return "Edited just now"; + } else if (minutes < 60) { + return `Edited ${minutes} ${minutes === 1 ? "minute" : "minutes"} ago`; + } else if (hours < 24) { + return `Edited ${hours} ${hours === 1 ? "hour" : "hours"} ago`; + } else if (days < 30) { + return `Edited ${days} ${days === 1 ? "day" : "days"} ago`; + } else if (months < 12) { + return `Edited ${months} ${months === 1 ? "month" : "months"} ago`; + } else { + return `Edited ${years} ${years === 1 ? "year" : "years"} ago`; + } +}