mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-18 15:33:52 +01:00
Fade in window contents (Layout)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { readText, writeText } from '@tauri-apps/plugin-clipboard-manager';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useToast } from '../components/ToastContext';
|
||||
import { useWindowFocus } from './useWindowFocus';
|
||||
import { createGlobalState } from 'react-use';
|
||||
|
||||
@@ -8,6 +9,7 @@ const useClipboardTextState = createGlobalState<string>('');
|
||||
export function useClipboardText() {
|
||||
const [value, setValue] = useClipboardTextState();
|
||||
const focused = useWindowFocus();
|
||||
const toast = useToast();
|
||||
|
||||
useEffect(() => {
|
||||
readText().then(setValue);
|
||||
@@ -16,9 +18,14 @@ export function useClipboardText() {
|
||||
const setText = useCallback(
|
||||
(text: string) => {
|
||||
writeText(text).catch(console.error);
|
||||
toast.show({
|
||||
id: 'copied',
|
||||
variant: 'copied',
|
||||
message: 'Copied to clipboard',
|
||||
});
|
||||
setValue(text);
|
||||
},
|
||||
[setValue],
|
||||
[setValue, toast],
|
||||
);
|
||||
|
||||
return [value, setText] as const;
|
||||
|
||||
Reference in New Issue
Block a user