feat: Add notification actions

This commit is contained in:
2024-01-26 08:48:27 +01:00
parent 2d2d47f55f
commit 0507722ecf
24 changed files with 1967 additions and 172 deletions

View File

@@ -1,4 +1,43 @@
import { Notification } from "./types";
import { GithubDiscussion, GithubPullRequest } from "./integrations/github/types";
import { MutatePromise } from "@raycast/utils";
import { Page } from "./types";
import { Task } from "./task";
export interface Notification {
id: string;
title: string;
source_id: string;
status: NotificationStatus;
metadata: NotificationMetadata;
updated_at: Date;
last_read_at?: Date;
snoozed_until?: Date;
user_id: string;
task?: Task;
details?: NotificationDetails;
}
export type NotificationMetadata = {
type: "Github" | "Linear" | "GoogleMail" | "Todoist";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
content: any;
};
export type NotificationDetails =
| { type: "GithubPullRequest"; content: GithubPullRequest }
| { type: "GithubDiscussion"; content: GithubDiscussion };
export enum NotificationStatus {
Unread = "Unread",
Read = "Read",
Deleted = "Deleted",
Unsubscribed = "Unsubscribed",
}
export type NotificationListItemProps = {
notification: Notification;
mutate: MutatePromise<Page<Notification> | undefined>;
};
export function getNotificationHtmlUrl(notification: Notification) {
switch (notification.details?.type) {
@@ -12,3 +51,7 @@ export function getNotificationHtmlUrl(notification: Notification) {
}
}
}
export function isNotificationBuiltFromTask(notification: Notification) {
return notification.metadata.type === "Todoist";
}