feat: Add filter per notification kind
This commit is contained in:
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.1.1] - 2024-02-31
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Add filter per notification kind
|
||||||
|
|
||||||
## [0.1.0] - 2024-01-29
|
## [0.1.0] - 2024-01-29
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "universal-inbox",
|
"name": "universal-inbox",
|
||||||
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "universal-inbox",
|
"name": "universal-inbox",
|
||||||
|
"version": "0.1.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@raycast/api": "^1.65.1",
|
"@raycast/api": "^1.65.1",
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
"icon": "ui-logo-transparent.png",
|
"icon": "ui-logo-transparent.png",
|
||||||
"author": "dax42",
|
"author": "dax42",
|
||||||
"owner": "universal-inbox",
|
"owner": "universal-inbox",
|
||||||
"version": "0.1.0",
|
"access": "public",
|
||||||
|
"version": "0.1.1",
|
||||||
"categories": [
|
"categories": [
|
||||||
"Productivity"
|
"Productivity"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Notification, NotificationListItemProps } from "./notification";
|
|||||||
import { NotificationActions } from "./action/NotificationActions";
|
import { NotificationActions } from "./action/NotificationActions";
|
||||||
import { Page, UniversalInboxPreferences } from "./types";
|
import { Page, UniversalInboxPreferences } from "./types";
|
||||||
import { useFetch } from "@raycast/utils";
|
import { useFetch } from "@raycast/utils";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function Command() {
|
export default function Command() {
|
||||||
const preferences = getPreferenceValues<UniversalInboxPreferences>();
|
const preferences = getPreferenceValues<UniversalInboxPreferences>();
|
||||||
@@ -29,8 +30,11 @@ export default function Command() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [notificationKind, setNotificationKind] = useState("");
|
||||||
const { isLoading, data, mutate } = useFetch<Page<Notification>>(
|
const { isLoading, data, mutate } = useFetch<Page<Notification>>(
|
||||||
`${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: {
|
headers: {
|
||||||
Authorization: `Bearer ${preferences.apiKey}`,
|
Authorization: `Bearer ${preferences.apiKey}`,
|
||||||
@@ -39,10 +43,24 @@ export default function Command() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List isLoading={isLoading}>
|
<List
|
||||||
{data?.content.map((notification: Notification) => {
|
isLoading={isLoading}
|
||||||
return <NotificationListItem key={notification.id} notification={notification} mutate={mutate} />;
|
searchBarPlaceholder="Filter notifications..."
|
||||||
})}
|
searchBarAccessory={
|
||||||
|
<NotificationKindDropdown value={notificationKind} onNotificationKindChange={setNotificationKind} />
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{data?.content.length === 0 ? (
|
||||||
|
<List.EmptyView
|
||||||
|
icon={{ source: "ui-logo-transparent.png" }}
|
||||||
|
title="Congrats! You have reach zero inbox 🎉"
|
||||||
|
description="You don't have any new notifications."
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
data?.content.map((notification: Notification) => {
|
||||||
|
return <NotificationListItem key={notification.id} notification={notification} mutate={mutate} />;
|
||||||
|
})
|
||||||
|
)}
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -78,3 +96,22 @@ function DefaultNotificationListItem({ notification, mutate }: NotificationListI
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface NotificationKindDropdownProps {
|
||||||
|
value: string;
|
||||||
|
onNotificationKindChange: (newValue: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function NotificationKindDropdown({ value, onNotificationKindChange }: NotificationKindDropdownProps) {
|
||||||
|
return (
|
||||||
|
<List.Dropdown tooltip="Select Notification Kind" value={value} onChange={onNotificationKindChange}>
|
||||||
|
<List.Dropdown.Section title="Notification kind">
|
||||||
|
<List.Dropdown.Item key="0" title="" value="" />
|
||||||
|
<List.Dropdown.Item key="Github" title="Github" value="Github" />
|
||||||
|
<List.Dropdown.Item key="Linear" title="Linear" value="Linear" />
|
||||||
|
<List.Dropdown.Item key="GoogleMail" title="Google Mail" value="GoogleMail" />
|
||||||
|
<List.Dropdown.Item key="Todoist" title="Todoist" value="Todoist" />
|
||||||
|
</List.Dropdown.Section>
|
||||||
|
</List.Dropdown>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user