mirror of
https://github.com/morten-olsen/refocus.dev.git
synced 2026-02-08 00:46:25 +01:00
feat: markdown, github file and UI improvements
This commit is contained in:
@@ -12,6 +12,7 @@ type BoardsContextValue = {
|
||||
selected?: string;
|
||||
boards: Boards;
|
||||
addBoard: (name: string) => void;
|
||||
setName: (id: string, name: string) => void;
|
||||
selectBoard: (id: string) => void;
|
||||
removeBoard: (id: string) => void;
|
||||
addWidget: (boardId: string, type: string, data: string) => void;
|
||||
@@ -46,6 +47,16 @@ const BoardsProvider: React.FC<BoardsProviderProps> = ({
|
||||
}));
|
||||
}, []);
|
||||
|
||||
const setName = useCallback((id: string, name: string) => {
|
||||
setBoards((currentBoards) => ({
|
||||
...currentBoards,
|
||||
[id]: {
|
||||
...currentBoards[id],
|
||||
name,
|
||||
},
|
||||
}));
|
||||
}, []);
|
||||
|
||||
const removeBoard = useCallback((id: string) => {
|
||||
setBoards((currentBoards) => {
|
||||
const copy = { ...currentBoards };
|
||||
@@ -116,6 +127,7 @@ const BoardsProvider: React.FC<BoardsProviderProps> = ({
|
||||
addBoard,
|
||||
removeBoard,
|
||||
addWidget,
|
||||
setName,
|
||||
removeWidget,
|
||||
selectBoard,
|
||||
updateWidget,
|
||||
@@ -126,6 +138,7 @@ const BoardsProvider: React.FC<BoardsProviderProps> = ({
|
||||
addBoard,
|
||||
removeBoard,
|
||||
addWidget,
|
||||
setName,
|
||||
removeWidget,
|
||||
selectBoard,
|
||||
updateWidget,
|
||||
|
||||
@@ -65,6 +65,14 @@ const useUpdateWidget = () => {
|
||||
return context.updateWidget;
|
||||
};
|
||||
|
||||
const useSetBoardName = () => {
|
||||
const context = useContext(BoardsContext);
|
||||
if (!context) {
|
||||
throw new Error('useSetBoardName must be used within a BoardsProvider');
|
||||
}
|
||||
return context.setName;
|
||||
};
|
||||
|
||||
export {
|
||||
useBoards,
|
||||
useSelectedBoard,
|
||||
@@ -74,4 +82,5 @@ export {
|
||||
useRemoveBoard,
|
||||
useSelectBoard,
|
||||
useUpdateWidget,
|
||||
useSetBoardName,
|
||||
};
|
||||
|
||||
@@ -8,5 +8,6 @@ export {
|
||||
useRemoveBoard,
|
||||
useSelectBoard,
|
||||
useUpdateWidget,
|
||||
useSetBoardName,
|
||||
} from './hooks';
|
||||
export * from './types';
|
||||
|
||||
@@ -47,7 +47,7 @@ const WidgetProvider = ({
|
||||
const addGlobalNotification = useNotificationAdd();
|
||||
const dissmissGlobalNotification = useNotificationDismiss();
|
||||
const notifications = useMemo(() => {
|
||||
return globalNotifications.filter((n) => n.view !== ref.current);
|
||||
return globalNotifications.filter((n) => n.view === ref.current);
|
||||
}, [globalNotifications]);
|
||||
|
||||
const addNotification = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user