mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-17 14:29:46 +02:00
Request actions (#65)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import React, { createContext, useContext, useMemo, useRef, useState } from 'react';
|
||||
import type { ShowToastRequest } from '../../plugin-runtime-types/src';
|
||||
import { useListenToTauriEvent } from '../hooks/useListenToTauriEvent';
|
||||
import type { ToastProps } from './core/Toast';
|
||||
import { Toast } from './core/Toast';
|
||||
import { generateId } from '../lib/generateId';
|
||||
@@ -61,6 +63,10 @@ export const ToastProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
[],
|
||||
);
|
||||
|
||||
useListenToTauriEvent<ShowToastRequest>('show_toast', (event) => {
|
||||
actions.show({ ...event.payload });
|
||||
});
|
||||
|
||||
const state: State = { toasts, actions };
|
||||
return <ToastContext.Provider value={state}>{children}</ToastContext.Provider>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user