Files
universal-inbox-raycast/src/third_party_item.ts
T
david 9e51e0df6c feat: add missing integrations and rich notification previews
Add TickTick, Google Calendar, Google Drive and API (WebPage) notification
types, which the backend already supported but the extension ignored.

Fill the previously empty notification previews with content modeled on the
web app: a metadata sidebar (status, priority, assignee, labels, dates,
channel, etc.) plus a markdown body and comment/message threads. Add shared
helpers: PreviewDetail wrapper, TaskMetadata, Slack mrkdwn renderer, GitHub
check/review emoji, and date/HTML utils (cleanHtml strips raw HTML from
GitHub bodies).

The preview metadata "Type" row shows the source item type (Linear Issue,
GitHub Pull Request, Slack Thread, etc.).

Swap list-screen shortcuts: Enter shows details, Cmd+Enter opens in browser.
2026-06-08 11:23:06 +02:00

113 lines
4.2 KiB
TypeScript

import {
getSlackReactionHtmlUrl,
getSlackStarHtmlUrl,
getSlackThreadHtmlUrl,
SlackReaction,
SlackStar,
SlackThread,
} from "./integrations/slack/types";
import {
getLinearIssueHtmlUrl,
getLinearNotificationHtmlUrl,
LinearIssue,
LinearNotification,
} from "./integrations/linear/types";
import { getGoogleCalendarEventHtmlUrl, GoogleCalendarEvent } from "./integrations/google-calendar/types";
import { getGoogleDriveCommentHtmlUrl, GoogleDriveComment } from "./integrations/google-drive/types";
import { getGithubNotificationHtmlUrl, GithubNotification } from "./integrations/github/types";
import { getTickTickItemHtmlUrl, TickTickItem } from "./integrations/ticktick/types";
import { getWebPageHtmlUrl, WebPage } from "./integrations/api/types";
import { GoogleMailThread } from "./integrations/google-mail/types";
import { TodoistItem } from "./integrations/todoist/types";
export interface ThirdPartyItem {
id: string;
source_id: string;
data: ThirdPartyItemData;
created_at: Date;
updated_at: Date;
user_id: string;
integration_connection_id: string;
}
export type ThirdPartyItemData =
| { type: "TodoistItem"; content: TodoistItem }
| { type: "TickTickItem"; content: TickTickItem }
| { type: "SlackStar"; content: SlackStar }
| { type: "SlackReaction"; content: SlackReaction }
| { type: "SlackThread"; content: SlackThread }
| { type: "LinearIssue"; content: LinearIssue }
| { type: "LinearNotification"; content: LinearNotification }
| { type: "GithubNotification"; content: GithubNotification }
| { type: "GoogleMailThread"; content: GoogleMailThread }
| { type: "GoogleCalendarEvent"; content: GoogleCalendarEvent }
| { type: "GoogleDriveComment"; content: GoogleDriveComment }
| { type: "WebPage"; content: WebPage };
/** Human-readable label for the notification's source item type (e.g. "Linear Issue", "GitHub Pull Request"). */
export function getThirdPartyItemSourceLabel(thirdPartyItem: ThirdPartyItem): string {
switch (thirdPartyItem.data.type) {
case "TodoistItem":
return "Todoist Task";
case "TickTickItem":
return "TickTick Task";
case "SlackStar":
return "Slack Star";
case "SlackReaction":
return "Slack Reaction";
case "SlackThread":
return "Slack Thread";
case "LinearIssue":
return "Linear Issue";
case "LinearNotification":
return thirdPartyItem.data.content.type === "ProjectNotification" ? "Linear Project" : "Linear Issue";
case "GithubNotification": {
switch (thirdPartyItem.data.content.item?.type) {
case "GithubPullRequest":
return "GitHub Pull Request";
case "GithubDiscussion":
return "GitHub Discussion";
default:
return "GitHub";
}
}
case "GoogleMailThread":
return "Google Mail";
case "GoogleCalendarEvent":
return "Google Calendar Event";
case "GoogleDriveComment":
return "Google Drive Comment";
case "WebPage":
return "Web Page";
}
}
export function getThirdPartyItemHtmlUrl(thirdPartyItem: ThirdPartyItem): string {
switch (thirdPartyItem.data.type) {
case "TodoistItem":
return `https://todoist.com/showTask?id=${thirdPartyItem.data.content.id}`;
case "SlackStar":
return getSlackStarHtmlUrl(thirdPartyItem.data.content);
case "SlackReaction":
return getSlackReactionHtmlUrl(thirdPartyItem.data.content);
case "SlackThread":
return getSlackThreadHtmlUrl(thirdPartyItem.data.content);
case "LinearIssue":
return getLinearIssueHtmlUrl(thirdPartyItem.data.content);
case "LinearNotification":
return getLinearNotificationHtmlUrl(thirdPartyItem.data.content);
case "GithubNotification":
return getGithubNotificationHtmlUrl(thirdPartyItem.data.content);
case "GoogleMailThread":
return `https://mail.google.com/mail/u/0/#inbox/${thirdPartyItem.data.content.id}`;
case "TickTickItem":
return getTickTickItemHtmlUrl(thirdPartyItem.data.content);
case "GoogleCalendarEvent":
return getGoogleCalendarEventHtmlUrl(thirdPartyItem.data.content);
case "GoogleDriveComment":
return getGoogleDriveCommentHtmlUrl(thirdPartyItem.data.content);
case "WebPage":
return getWebPageHtmlUrl(thirdPartyItem.data.content);
}
}