Compare commits
3 commits
617d47d949
...
c4fa06d3e7
Author | SHA1 | Date | |
---|---|---|---|
c4fa06d3e7 | |||
aa52a5d807 | |||
4b62692a8e |
5 changed files with 29 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
|||
import { ColorModeProvider, ColorModeScript } from '@kobalte/core'
|
||||
|
||||
import { workerInit } from 'mtcute-repl-worker/client'
|
||||
import { createSignal, lazy, onMount, Show } from 'solid-js'
|
||||
import { createSignal, lazy, onCleanup, onMount, Show } from 'solid-js'
|
||||
import { EditorTabs } from './components/editor/EditorTabs.tsx'
|
||||
import { NavbarMenu } from './components/nav/NavbarMenu.tsx'
|
||||
import { Runner } from './components/runner/Runner.tsx'
|
||||
|
@ -24,6 +24,16 @@ export function App() {
|
|||
|
||||
onMount(() => {
|
||||
workerInit(workerIframe)
|
||||
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.metaKey && e.key === ',') {
|
||||
setShowSettings(true)
|
||||
e.preventDefault()
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', handleKeyDown)
|
||||
onCleanup(() => window.removeEventListener('keydown', handleKeyDown))
|
||||
})
|
||||
|
||||
return (
|
||||
|
|
|
@ -64,6 +64,21 @@ async function focusConsole(tabbedPane) {
|
|||
const injectCss = await waitForElement('#inject-css', document.body);
|
||||
const rootView = await waitForElement('.root-view', document.body);
|
||||
rootView.appendChild(injectCss);
|
||||
|
||||
// forward some keyboard shortcuts to the parent window
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (!(e.metaKey && e.key === ',')) return
|
||||
|
||||
const options = {
|
||||
key: e.key,
|
||||
ctrlKey: e.ctrlKey,
|
||||
metaKey: e.metaKey,
|
||||
}
|
||||
const keyboardEvent = new KeyboardEvent('keydown', options)
|
||||
window.parent.dispatchEvent(keyboardEvent)
|
||||
|
||||
e.preventDefault()
|
||||
}, true)
|
||||
})();
|
||||
`
|
||||
|
||||
|
|
|
@ -299,7 +299,7 @@ function OtpStep(props: StepProps<'otp'>) {
|
|||
|
||||
const [innerInputRef, setInnerInputRef] = createSignal<HTMLInputElement | undefined>()
|
||||
|
||||
createEffect(() => {
|
||||
onMount(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key >= '0' && e.key <= '9') {
|
||||
innerInputRef()?.focus()
|
||||
|
|
|
@ -59,6 +59,7 @@ export async function importAccount(
|
|||
dcId: asNonNull(session.primaryDcs).main.id,
|
||||
}
|
||||
} catch (e) {
|
||||
await client.close()
|
||||
await deleteAccount(accountId)
|
||||
if (is404) {
|
||||
throw new Error('Invalid session (auth key not found)')
|
||||
|
|
|
@ -45,6 +45,7 @@ async function handleAuthSuccess(accountId: string, user: User) {
|
|||
const testMode = client.params.testMode ?? false
|
||||
|
||||
if ($accounts.get().some(it => it.telegramId === user.id)) {
|
||||
await client.close()
|
||||
await deleteAccount(accountId)
|
||||
throw new Error(`Account already exists (user ID: ${user.id})`)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue