From 8a7eda4f3c293e1c7fb051f160fb58982358f9d4 Mon Sep 17 00:00:00 2001 From: David Rousselie Date: Mon, 5 Feb 2024 15:12:44 +0100 Subject: [PATCH] feat: Add Linear Project and Team icons --- CHANGELOG.md | 4 ++++ package-lock.json | 4 ++-- src/integrations/linear/accessories.ts | 1 - .../LinearIssueNotificationListItem.tsx | 18 +++++++++++++----- .../LinearProjectNotificationListItem.tsx | 10 ++++++++-- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa36495..c4eba9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- Add Linear Project and Team icons + ## [0.1.3] - 2024-02-05 ### Added diff --git a/package-lock.json b/package-lock.json index 0dda209..3f79b8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "universal-inbox", - "version": "0.1.0", + "version": "0.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "universal-inbox", - "version": "0.1.0", + "version": "0.1.3", "license": "MIT", "dependencies": { "@raycast/api": "^1.65.1", diff --git a/src/integrations/linear/accessories.ts b/src/integrations/linear/accessories.ts index 3c5c184..162e5eb 100644 --- a/src/integrations/linear/accessories.ts +++ b/src/integrations/linear/accessories.ts @@ -15,7 +15,6 @@ export function getLinearUserAccessory(user?: LinearUser): List.Item.Accessory { export function getLinearNotificationReasonAccessory(notification_type: string): List.Item.Accessory { const reason = match(notification_type) - .with("") .with("issueAddedToTriage", () => "Added To Triage") .with("issueAddedToView", () => "Added To View") .with("issueAssignedToYou", () => "Assigned To You") diff --git a/src/integrations/linear/listitem/LinearIssueNotificationListItem.tsx b/src/integrations/linear/listitem/LinearIssueNotificationListItem.tsx index cc1cc42..86fff9d 100644 --- a/src/integrations/linear/listitem/LinearIssueNotificationListItem.tsx +++ b/src/integrations/linear/listitem/LinearIssueNotificationListItem.tsx @@ -5,8 +5,8 @@ import { LinearIssuePreview } from "../preview/LinearIssuePreview"; import { Notification } from "../../../notification"; import { MutatePromise } from "@raycast/utils"; import { Page } from "../../../types"; +import { match, P } from "ts-pattern"; import { List } from "@raycast/api"; -import { match } from "ts-pattern"; interface LinearIssueNotificationListItemProps { notification: Notification; @@ -19,10 +19,18 @@ export function LinearIssueNotificationListItem({ linearIssueNotification, mutate, }: LinearIssueNotificationListItemProps) { - const projectSubtitle = linearIssueNotification.issue.project - ? `/ ${linearIssueNotification.issue.project.name} ` - : ""; - const subtitle = `${linearIssueNotification.issue.team.name} ${projectSubtitle}#${linearIssueNotification.issue.identifier}`; + const projectSubtitle = match(linearIssueNotification.issue.project) + .with({ name: P.select(), icon: P.nullish }, (project_name) => `/ ${project_name}`) + .with( + { name: P.select("project_name"), icon: P.select("icon") }, + ({ project_name, icon }) => `/ ${icon} ${project_name}`, + ) + .otherwise(() => ""); + const teamSubtitle = match(linearIssueNotification.issue.team) + .with({ name: P.select(), icon: P.nullish }, (team_name) => `${team_name}`) + .with({ name: P.select("team_name"), icon: P.select("icon") }, ({ team_name, icon }) => `${icon} ${team_name}`) + .otherwise(() => ""); + const subtitle = `${teamSubtitle} ${projectSubtitle} #${linearIssueNotification.issue.identifier}`; const state = getLinearIssueStateAccessory(linearIssueNotification.issue.state); const assignee = getLinearUserAccessory(linearIssueNotification.issue.assignee); diff --git a/src/integrations/linear/listitem/LinearProjectNotificationListItem.tsx b/src/integrations/linear/listitem/LinearProjectNotificationListItem.tsx index 97b2f64..520e241 100644 --- a/src/integrations/linear/listitem/LinearProjectNotificationListItem.tsx +++ b/src/integrations/linear/listitem/LinearProjectNotificationListItem.tsx @@ -6,7 +6,7 @@ import { Notification } from "../../../notification"; import { MutatePromise } from "@raycast/utils"; import { List, Color } from "@raycast/api"; import { Page } from "../../../types"; -import { match } from "ts-pattern"; +import { match, P } from "ts-pattern"; interface LinearProjectNotificationListItemProps { notification: Notification; @@ -19,7 +19,13 @@ export function LinearProjectNotificationListItem({ linearProjectNotification, mutate, }: LinearProjectNotificationListItemProps) { - const subtitle = linearProjectNotification.project.name; + const subtitle = match(linearProjectNotification.project) + .with({ name: P.select(), icon: P.nullish }, (project_name) => `${project_name}`) + .with( + { name: P.select("project_name"), icon: P.select("icon") }, + ({ project_name, icon }) => `${icon} ${project_name}`, + ) + .otherwise(() => ""); const state = getLinearProjectStateAccessory(linearProjectNotification.project); const lead = getLinearUserAccessory(linearProjectNotification.project.lead);