Skip to content

Commit

Permalink
Added last modified info (#15829)
Browse files Browse the repository at this point in the history
* added last modified date

* updated changelog
  • Loading branch information
GLaDO8 authored Dec 13, 2024
1 parent 41ad4a7 commit abe9454
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
4 changes: 4 additions & 0 deletions extensions/figma-files/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions extensions/figma-files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
27 changes: 27 additions & 0 deletions extensions/figma-files/src/components/FileGridItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function FileGridItem(props: {
<Grid.Item
id={fileIdentifier}
title={file.name}
subtitle={getRelativeTime(Date.parse(file.last_modified))}
keywords={[searchkeywords ?? ""]}
content={{ tooltip: file.name, value: file.thumbnail_url ?? "Missing thumbnail" }}
accessory={file.branches && accessory}
Expand All @@ -53,3 +54,29 @@ 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`;
}
}

0 comments on commit abe9454

Please sign in to comment.