mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 05:09:12 +03:00
* sidebar-manager * storage keys * tests * more ai spots * test fix * revert to default * remove ref * Update apps/studio/state/sidebar-manager-state.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix ts * fix * fux * fux query param * clean * fix * more * mock local storage * simplify * remove provider test * remve useopensidebar * fix(new homepage): open ai assistant on advisor card button clicks * Update apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * Update apps/studio/state/sidebar-manager-state.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * refine * editor sidebar manager * reset results * Update apps/studio/components/ui/EditorPanel/EditorPanel.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * connect hotkey * initial prompt * fix(editor sidebar): disable hotkey based on user preference * cleanup(inline editor): add migration for hotkey local storage key --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { useEffect } from 'react'
|
|
|
|
import { LOCAL_STORAGE_KEYS } from 'common'
|
|
import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
|
|
import { useLocalStorageQuery } from './useLocalStorage'
|
|
|
|
const LEGACY_INLINE_EDITOR_HOTKEY_KEY = 'supabase-dashboard-hotkey-inline-editor'
|
|
|
|
/**
|
|
* Migrates the inline editor hotkey preference to the new sidebar editor panel key.
|
|
* Runs when idle (or within 5 seconds) to avoid blocking render.
|
|
*/
|
|
const useLegacyInlineEditorHotkeyMigration = () => {
|
|
const [_inlineEditorEnabled, setInlineEditorEnabled] = useLocalStorageQuery(
|
|
LOCAL_STORAGE_KEYS.HOTKEY_SIDEBAR(SIDEBAR_KEYS.EDITOR_PANEL),
|
|
true
|
|
)
|
|
|
|
useEffect(() => {
|
|
if (typeof window === 'undefined') return
|
|
|
|
const migrate = () => {
|
|
try {
|
|
const legacyValue = window.localStorage.getItem(LEGACY_INLINE_EDITOR_HOTKEY_KEY)
|
|
|
|
if (legacyValue !== null) {
|
|
setInlineEditorEnabled(legacyValue === 'true')
|
|
window.localStorage.removeItem(LEGACY_INLINE_EDITOR_HOTKEY_KEY)
|
|
}
|
|
} catch (error) {
|
|
console.warn('Failed to migrate inline editor hotkey preference', error)
|
|
}
|
|
}
|
|
|
|
if (typeof window.requestIdleCallback === 'function') {
|
|
const idleCallbackId = window.requestIdleCallback(migrate, { timeout: 5000 })
|
|
return () => window.cancelIdleCallback?.(idleCallbackId)
|
|
}
|
|
|
|
const timeoutId = window.setTimeout(migrate, 5000)
|
|
return () => window.clearTimeout(timeoutId)
|
|
}, [setInlineEditorEnabled])
|
|
}
|
|
|
|
export const LegacyInlineEditorHotkeyMigration = () => {
|
|
useLegacyInlineEditorHotkeyMigration()
|
|
return null
|
|
}
|