From 9fb5af87edba8ce300ac2d486e8304ef7cf20f7a Mon Sep 17 00:00:00 2001 From: David Rousselie Date: Thu, 1 Feb 2024 09:37:40 +0100 Subject: [PATCH] feat: Add filter per notification kind --- CHANGELOG.md | 6 ++++++ package-lock.json | 2 ++ package.json | 3 ++- src/index.tsx | 47 ++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 52 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 686db74..3a3a620 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] +## [0.1.1] - 2024-02-31 + +### Added + +- Add filter per notification kind + ## [0.1.0] - 2024-01-29 ### Added diff --git a/package-lock.json b/package-lock.json index 78219b0..0dda209 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,12 @@ { "name": "universal-inbox", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "universal-inbox", + "version": "0.1.0", "license": "MIT", "dependencies": { "@raycast/api": "^1.65.1", diff --git a/package.json b/package.json index 1ec5335..9bbe1d1 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "icon": "ui-logo-transparent.png", "author": "dax42", "owner": "universal-inbox", - "version": "0.1.0", + "access": "public", + "version": "0.1.1", "categories": [ "Productivity" ], diff --git a/src/index.tsx b/src/index.tsx index 42b216b..a87f4e5 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -7,6 +7,7 @@ import { Notification, NotificationListItemProps } from "./notification"; import { NotificationActions } from "./action/NotificationActions"; import { Page, UniversalInboxPreferences } from "./types"; import { useFetch } from "@raycast/utils"; +import { useState } from "react"; export default function Command() { const preferences = getPreferenceValues(); @@ -29,8 +30,11 @@ export default function Command() { ); } + const [notificationKind, setNotificationKind] = useState(""); const { isLoading, data, mutate } = useFetch>( - `${preferences.universalInboxBaseUrl}/api/notifications?status=Unread,Read&with_tasks=true`, + `${preferences.universalInboxBaseUrl}/api/notifications?status=Unread,Read&with_tasks=true${ + notificationKind ? "¬ification_kind=" + notificationKind : "" + }`, { headers: { Authorization: `Bearer ${preferences.apiKey}`, @@ -39,10 +43,24 @@ export default function Command() { ); return ( - - {data?.content.map((notification: Notification) => { - return ; - })} + + } + > + {data?.content.length === 0 ? ( + + ) : ( + data?.content.map((notification: Notification) => { + return ; + }) + )} ); } @@ -78,3 +96,22 @@ function DefaultNotificationListItem({ notification, mutate }: NotificationListI /> ); } + +interface NotificationKindDropdownProps { + value: string; + onNotificationKindChange: (newValue: string) => void; +} + +function NotificationKindDropdown({ value, onNotificationKindChange }: NotificationKindDropdownProps) { + return ( + + + + + + + + + + ); +}