Skip to content

Commit

Permalink
feat: add f1 shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ionov committed Dec 28, 2023
1 parent 6da8647 commit 1982550
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src-tauri/src/utils/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn get_tmp_dir() -> Result<String> {
if let Err(res) = res {
error!("Error: {:?}", res);
}
return Ok(temp_dir.to_str().unwrap().to_string());
return Ok(temp_dir.to_str().unwrap_or("").to_string());
}

pub fn get_app_path() -> String {
Expand Down
5 changes: 5 additions & 0 deletions src/components/CommandPalette/CommandPaletteContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface ActionsContext {

export const CommandPaletteContext = (props: { children: JSX.Element }) => {
const {
app: { setComponent },
connections: { addContentTab, removeContentTab, setContentIdx, contentStore },
} = useAppSelector();

Expand All @@ -19,6 +20,10 @@ export const CommandPaletteContext = (props: { children: JSX.Element }) => {
removeContentTab(contentStore.idx);
});

createShortcut(['F1'], () => {
setComponent(s => (s === 2 ? 0 : 2));
});

createShortcut(['Meta', 't'], () => {
addContentTab();
});
Expand Down
5 changes: 2 additions & 3 deletions src/components/Screens/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { invoke } from '@tauri-apps/api';
import { ThemeSwitch } from 'components/UI/ThemeSwitch';
import { CloseIcon, HomeIcon, QuestionMark, UserSettings } from 'components/UI/Icons';
import { useAppSelector } from 'services/Context';
import { createSignal, For, Match, Show, Switch } from 'solid-js';
import { For, Match, Show, Switch } from 'solid-js';
import { Console } from './Console/Console';
import { Home } from './Home/Home';
import { Settings } from './Settings/Settings';
Expand All @@ -12,11 +12,10 @@ import { Help } from './Help/Help';

export const Main = () => {
const {
app: { setComponent, component },
connections: { removeConnectionTab, connectionStore, setConnectionStore },
} = useAppSelector();

const [component, setComponent] = createSignal(0);

const handleCloseConnection = async (id: string) => {
await invoke<string>('disconnect', { id });
await removeConnectionTab(id);
Expand Down
3 changes: 1 addition & 2 deletions src/components/UI/Keymaps.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { For } from 'solid-js';

const keymaps = [
// TODO:
// { action: 'Help', keys: ['F1'] },
{ action: 'Help', keys: ['F1'] },
{ action: 'Execute query', keys: ['Ctrl', 'e'] },
{ action: 'Select tab', keys: ['Meta', 'number'] },
{ action: 'New tab', keys: ['Meta', 'w'] },
Expand Down
5 changes: 5 additions & 0 deletions src/services/App.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createSignal } from 'solid-js';
import { createStore } from 'solid-js/store';
import { Store } from 'tauri-plugin-store-api';
import { debounce } from 'utils/utils';
Expand Down Expand Up @@ -27,6 +28,8 @@ export const AppService = () => {
vimModeOn: true,
});

const [component, setComponent] = createSignal(0);

const updateStore = debounce(async () => {
await store.set(APP_KEY, JSON.stringify(appStore));
await store.save();
Expand All @@ -51,5 +54,7 @@ export const AppService = () => {
vimModeOn,
toggleVimModeOn,
restoreAppStore,
component,
setComponent,
};
};

0 comments on commit 1982550

Please sign in to comment.