mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-18 13:26:00 -04:00
Merge branch 'main' into eng-1828-migration-to-new-cloud-api-system
This commit is contained in:
@@ -78,11 +78,7 @@ pub fn setup_menu(app: &AppHandle) -> tauri::Result<Menu<Wry>> {
|
||||
.build(),
|
||||
))
|
||||
.separator()
|
||||
.item(
|
||||
&MenuItemBuilder::with_id(MenuEvent::NewLibrary, "New Library")
|
||||
.accelerator("Cmd+Shift+T")
|
||||
.build(app)?,
|
||||
)
|
||||
.item(&MenuItemBuilder::with_id(MenuEvent::NewLibrary, "New Library").build(app)?)
|
||||
// .item(
|
||||
// &SubmenuBuilder::new(app, "Libraries")
|
||||
// // TODO: Implement this
|
||||
@@ -194,12 +190,13 @@ pub fn setup_menu(app: &AppHandle) -> tauri::Result<Menu<Wry>> {
|
||||
|
||||
let window_menu = SubmenuBuilder::new(app, "Window")
|
||||
.minimize()
|
||||
.item(
|
||||
&MenuItemBuilder::with_id(MenuEvent::NewWindow, "New Window")
|
||||
.accelerator("CmdOrCtrl+Shift+N")
|
||||
.build(app)?,
|
||||
)
|
||||
.close_window()
|
||||
// Disabling this fixes the new "Duplicate current tab" shortcut on macOS clients
|
||||
// ...and at the time I'm committing this we don't support multi-window so... ¯\_(ツ)_/¯
|
||||
// .item(
|
||||
// &MenuItemBuilder::with_id(MenuEvent::NewWindow, "New Window")
|
||||
// .accelerator("CmdOrCtrl+Shift+N")
|
||||
// .build(app)?,
|
||||
// )
|
||||
.fullscreen()
|
||||
.item(
|
||||
&MenuItemBuilder::with_id(MenuEvent::ReloadWebview, "Reload Webview")
|
||||
|
||||
@@ -114,7 +114,7 @@ const TAB_CREATE_DELAY = 150;
|
||||
|
||||
const routes = createRoutes(platform);
|
||||
|
||||
type redirect = { pathname: string; search: string | undefined };
|
||||
type RedirectPath = { pathname: string; search: string | undefined };
|
||||
|
||||
function AppInner() {
|
||||
const [tabs, setTabs] = useState(() => [createTab()]);
|
||||
@@ -122,7 +122,7 @@ function AppInner() {
|
||||
|
||||
const selectedTab = tabs[selectedTabIndex]!;
|
||||
|
||||
function createTab(redirect?: redirect) {
|
||||
function createTab(redirect?: RedirectPath) {
|
||||
const history = createMemoryHistory();
|
||||
const router = createMemoryRouterWithHistory({ routes, history });
|
||||
|
||||
@@ -211,7 +211,7 @@ function AppInner() {
|
||||
tabIndex: selectedTabIndex,
|
||||
setTabIndex: setSelectedTabIndex,
|
||||
tabs: tabs.map(({ router, title }) => ({ router, title })),
|
||||
createTab(redirect?: redirect) {
|
||||
createTab(redirect?: RedirectPath) {
|
||||
createTabPromise.current = createTabPromise.current.then(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
@@ -230,6 +230,27 @@ function AppInner() {
|
||||
})
|
||||
);
|
||||
},
|
||||
duplicateTab() {
|
||||
createTabPromise.current = createTabPromise.current.then(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
startTransition(() => {
|
||||
setTabs((tabs) => {
|
||||
const { pathname, search } =
|
||||
selectedTab.router.state.location;
|
||||
const newTab = createTab({ pathname, search });
|
||||
const newTabs = [...tabs, newTab];
|
||||
|
||||
setSelectedTabIndex(newTabs.length - 1);
|
||||
|
||||
return newTabs;
|
||||
});
|
||||
});
|
||||
|
||||
setTimeout(res, TAB_CREATE_DELAY);
|
||||
})
|
||||
);
|
||||
},
|
||||
removeTab(index: number) {
|
||||
startTransition(() => {
|
||||
setTabs((tabs) => {
|
||||
|
||||
@@ -8,6 +8,7 @@ export const TabsContext = createContext<{
|
||||
tabs: { router: Router; title: string }[];
|
||||
createTab(redirect?: { pathname: string; search: string | undefined }): void;
|
||||
removeTab(index: number): void;
|
||||
duplicateTab(): void;
|
||||
} | null>(null);
|
||||
|
||||
export function useTabsContext() {
|
||||
|
||||
@@ -24,10 +24,10 @@ export default () => {
|
||||
const navigate = useNavigate();
|
||||
const symbols = useKeysMatcher(['Meta', 'Shift']);
|
||||
|
||||
useShortcut('navToSettings', (e) => {
|
||||
e.stopPropagation();
|
||||
navigate('settings/client/general');
|
||||
});
|
||||
// useShortcut('navToSettings', (e) => {
|
||||
// e.stopPropagation();
|
||||
// navigate('settings/client/general');
|
||||
// });
|
||||
|
||||
const updater = usePlatform().updater;
|
||||
const updaterState = updater?.useSnapshot();
|
||||
|
||||
@@ -181,10 +181,15 @@ function useTabKeybinds(props: { addTab(): void; removeTab(index: number): void
|
||||
|
||||
useShortcut('newTab', (e) => {
|
||||
e.stopPropagation();
|
||||
if (e.shiftKey) return; //to prevent colliding with 'navToSettings' shortcut
|
||||
if (e.shiftKey) return; //to prevent colliding with other shortcuts
|
||||
props.addTab();
|
||||
});
|
||||
|
||||
useShortcut('duplicateTab', (e) => {
|
||||
e.stopPropagation();
|
||||
ctx.duplicateTab();
|
||||
});
|
||||
|
||||
useShortcut('closeTab', (e) => {
|
||||
e.stopPropagation();
|
||||
props.removeTab(ctx.tabIndex);
|
||||
|
||||
@@ -30,7 +30,8 @@ export const Component = () => {
|
||||
{ shortcut: 'closeTab', description: t('close_current_tab') },
|
||||
{ shortcut: 'newTab', description: t('switch_to_next_tab') },
|
||||
{ shortcut: 'previousTab', description: t('switch_to_previous_tab') },
|
||||
{ shortcut: 'toggleSidebar', description: t('toggle_sidebar') }
|
||||
{ shortcut: 'toggleSidebar', description: t('toggle_sidebar') },
|
||||
{ shortcut: 'duplicateTab', description: t('duplicate_current_tab') }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -43,8 +44,8 @@ export const Component = () => {
|
||||
description: t('page_shortcut_description'),
|
||||
shortcuts: [
|
||||
{ shortcut: 'navBackwardHistory', description: t('navigate_backwards') },
|
||||
{ shortcut: 'navForwardHistory', description: t('navigate_forwards') },
|
||||
{ shortcut: 'navToSettings', description: t('navigate_to_settings_page') }
|
||||
{ shortcut: 'navForwardHistory', description: t('navigate_forwards') }
|
||||
// { shortcut: 'navToSettings', description: t('navigate_to_settings_page') }
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -18,6 +18,10 @@ const shortcuts = {
|
||||
macOS: ['Meta', 'KeyW'],
|
||||
all: ['Control', 'KeyW']
|
||||
},
|
||||
duplicateTab: {
|
||||
macOS: ['Meta', 'Shift', 'KeyT'],
|
||||
all: ['Control', 'Shift', 'KeyT']
|
||||
},
|
||||
nextTab: {
|
||||
macOS: ['Meta', 'Alt', 'ArrowRight'],
|
||||
all: ['Control', 'Alt', 'ArrowRight']
|
||||
@@ -49,10 +53,11 @@ const shortcuts = {
|
||||
macOS: ['Meta', ']'],
|
||||
all: ['Control', ']']
|
||||
},
|
||||
navToSettings: {
|
||||
macOS: ['Shift', 'Meta', 'KeyT'],
|
||||
all: ['Shift', 'Control', 'KeyT']
|
||||
},
|
||||
// I plan to change this to the OS-standard cmd-comma later -ilynxcat
|
||||
// navToSettings: {
|
||||
// macOS: ['Shift', 'Meta', 'KeyT'],
|
||||
// all: ['Shift', 'Control', 'KeyT']
|
||||
// },
|
||||
gridView: {
|
||||
macOS: ['Meta', '1'],
|
||||
all: ['Control', '1']
|
||||
|
||||
Reference in New Issue
Block a user