Skip to content

Commit

Permalink
minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
jbilcke-hf committed Aug 22, 2024
1 parent 736f725 commit 61183d2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
4 changes: 4 additions & 0 deletions packages/app/src/app/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { FilterEditor } from '@/components/editors/FilterEditor'
import { useUI, useIO, useTheme, useMonitor } from '@/services'
import { useRenderLoop } from '@/services/renderer'
import { useDynamicWorkflows } from '@/services/editors/workflow-editor/useDynamicWorkflows'

import { useQueryStringLoader } from '@/components/toolbars/top-menu/file/useQueryStringLoader'
import { useSetupIframeOnce } from './embed/useSetupIframeOnce'

export enum ClapperIntegrationMode {
Expand All @@ -54,6 +56,8 @@ function MainContent({ mode }: { mode: ClapperIntegrationMode }) {

const isIframe = mode === ClapperIntegrationMode.IFRAME

useQueryStringLoader()

// this has to be done at the root of the app, that way it can
// perform its routine even when the monitor component is hidden
useRenderLoop()
Expand Down
16 changes: 0 additions & 16 deletions packages/app/src/components/toolbars/top-menu/file/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ import { newClap } from '@aitube/clap'
import { getDemoGame } from '@/experiments/samples/demo'

export function TopMenuFile() {
const { clapUrl } = useQueryStringParams({
// clapUrl: `/samples/test.clap`,
// clapUrl: `/samples/Afterglow%20v10%20X%20Rewrite%20Bryan%20E.%20Harris%202023.clap`,
clapUrl: '',
})

const isTimelineLoading: boolean = useTimeline((s) => s.isLoading)
const clap = useTimeline((s) => s.clap)
const setClap = useTimeline((s) => s.setClap)
Expand All @@ -49,16 +43,6 @@ export function TopMenuFile() {
const showWelcomeScreen = useUI((s) => s.showWelcomeScreen)
const setShowWelcomeScreen = useUI((s) => s.setShowWelcomeScreen)

useEffect(() => {
;(async () => {
if (!clapUrl) {
console.log('No clap URL provided')
return
}
await openClapUrl(clapUrl)
})()
}, [openClapUrl, clapUrl])

// const setShowSettings = useUISettings(s => s.setShowSettings)
useHotkeys('ctrl+o', () => openFilePicker(), { preventDefault: true }, [])
useHotkeys('meta+o', () => openFilePicker(), { preventDefault: true }, [])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use client'

import { useEffect } from 'react'

import { useQueryStringParams } from '@/lib/hooks'
import { useIO } from '@/services'

export function useQueryStringLoader() {
const { clapUrl } = useQueryStringParams({
// clapUrl: `/samples/test.clap`,
// clapUrl: `/samples/Afterglow%20v10%20X%20Rewrite%20Bryan%20E.%20Harris%202023.clap`,
clapUrl: '',
})
const openClapUrl = useIO((s) => s.openClapUrl)

useEffect(() => {
;(async () => {
if (!clapUrl) {
console.log('No clap URL provided')
return
}
await openClapUrl(clapUrl)
})()
}, [openClapUrl, clapUrl])

}

0 comments on commit 61183d2

Please sign in to comment.