mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 02:11:10 +01:00
Fixed asset:// loading and tweak curl stuff
This commit is contained in:
@@ -1,18 +1,25 @@
|
||||
import { readText, writeText } from '@tauri-apps/plugin-clipboard-manager';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useWindowFocus } from './useWindowFocus';
|
||||
import { createGlobalState } from 'react-use';
|
||||
|
||||
const useClipboardTextState = createGlobalState<string>('');
|
||||
|
||||
export function useClipboardText() {
|
||||
const [value, setValue] = useState<string>('');
|
||||
const [value, setValue] = useClipboardTextState();
|
||||
const focused = useWindowFocus();
|
||||
|
||||
useEffect(() => {
|
||||
readText().then(setValue);
|
||||
}, [focused]);
|
||||
}, [focused, setValue]);
|
||||
|
||||
const setText = useCallback((text: string) => {
|
||||
writeText(text).catch(console.error);
|
||||
}, []);
|
||||
const setText = useCallback(
|
||||
(text: string) => {
|
||||
writeText(text).catch(console.error);
|
||||
setValue(text);
|
||||
},
|
||||
[setValue],
|
||||
);
|
||||
|
||||
return [value, setText] as const;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user