File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 22import { useTranslations } from 'next-intl'
33import { Clipboard , ClipboardX } from 'lucide-react'
44import { TooltipButton } from '@/components/tooltip-button'
5- import { useState } from 'react'
5+ import { useState , useEffect } from 'react'
66import { Store } from '@tauri-apps/plugin-store'
77
88export function ClipboardMonitor ( ) {
99 const t = useTranslations ( 'record.chat.input.clipboardMonitor' )
1010 const [ isEnabled , setIsEnabled ] = useState ( true )
11+
12+ // Sync with store.json on mount
13+ useEffect ( ( ) => {
14+ const syncWithStore = async ( ) => {
15+ try {
16+ const store = await Store . load ( 'store.json' )
17+ const storedValue = await store . get < boolean > ( 'clipboardMonitor' )
18+
19+ // Only update if the stored value exists and is different from the current state
20+ if ( storedValue !== undefined && storedValue !== isEnabled ) {
21+ setIsEnabled ( storedValue )
22+ }
23+ } catch ( error ) {
24+ console . error ( 'Failed to load clipboard monitor state from store:' , error )
25+ }
26+ }
27+
28+ syncWithStore ( )
29+ } , [ ] )
30+
1131
1232 const toggleClipboardMonitor = async ( ) => {
1333 const newState = ! isEnabled
You can’t perform that action at this time.
0 commit comments