feat: desktop version

This commit is contained in:
Morten Olsen
2023-06-20 12:17:40 +02:00
parent fec30cc430
commit 6477b56ade
17 changed files with 2337 additions and 65 deletions

View File

@@ -1,4 +1,10 @@
import { createContext, useCallback, useMemo, useState } from 'react';
import {
createContext,
useCallback,
useEffect,
useMemo,
useState,
} from 'react';
import type { Notification } from './types';
type NotificationsContextValue = {
@@ -9,6 +15,7 @@ type NotificationsContextValue = {
type NotificationsProviderProps = {
children: React.ReactNode;
onNotificationsUpdate?: (notification: Notification[]) => void;
};
const NotificationsContext = createContext<NotificationsContextValue | null>(
@@ -19,6 +26,7 @@ let nextId = 0;
const NotificationsProvider: React.FC<NotificationsProviderProps> = ({
children,
onNotificationsUpdate,
}) => {
const [notifications, setNotifications] = useState<Notification[]>([]);
@@ -55,6 +63,10 @@ const NotificationsProvider: React.FC<NotificationsProviderProps> = ({
[notifications, add, dismiss],
);
useEffect(() => {
onNotificationsUpdate?.(notifications);
}, [notifications, onNotificationsUpdate]);
return (
<NotificationsContext.Provider value={value}>
{children}

View File

@@ -6,7 +6,7 @@ import {
SlackLogin,
} from './clients';
import { Widget, WidgetsProvider } from './widgets';
import { NotificationsProvider } from './notifications';
import { NotificationsProvider, Notification } from './notifications';
import { BoardsLoad, BoardsProvider, BoardsSave } from './boards';
type DashboardProviderProps = {
@@ -14,6 +14,7 @@ type DashboardProviderProps = {
widgets?: Widget<TSchema>[];
load: BoardsLoad;
save: BoardsSave;
onNotificationsUpdate?: (notifications: Notification[]) => void;
logins: {
github: GithubLogin;
linear: LinearLogin;
@@ -27,10 +28,11 @@ const DashboardProvider: React.FC<DashboardProviderProps> = ({
load,
save,
logins,
onNotificationsUpdate,
}) => (
<WidgetsProvider widgets={widgets}>
<BoardsProvider load={load} save={save}>
<NotificationsProvider>
<NotificationsProvider onNotificationsUpdate={onNotificationsUpdate}>
<ClientProvider logins={logins}>{children}</ClientProvider>
</NotificationsProvider>
</BoardsProvider>