mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
refactor: navigate calls
This commit is contained in:
parent
6f46e2a3c3
commit
e997811a2f
5 changed files with 23 additions and 31 deletions
|
|
@ -29,22 +29,6 @@ import arrowWhite from '../../images/arrow-white.png';
|
||||||
// @ts-expect-error ts-migrate(2307) FIXME: Cannot find module '../../images/arrow-black.png' ... Remove this comment to see the full error message
|
// @ts-expect-error ts-migrate(2307) FIXME: Cannot find module '../../images/arrow-black.png' ... Remove this comment to see the full error message
|
||||||
import arrowBlack from '../../images/arrow-black.png';
|
import arrowBlack from '../../images/arrow-black.png';
|
||||||
|
|
||||||
import {
|
|
||||||
requestHibernateWorkspace,
|
|
||||||
requestRemoveWorkspace,
|
|
||||||
requestSetActiveWorkspace,
|
|
||||||
requestSetWorkspaces,
|
|
||||||
requestShowAddWorkspaceWindow,
|
|
||||||
requestShowEditWorkspaceWindow,
|
|
||||||
requestShowNotificationsWindow,
|
|
||||||
requestShowPreferencesWindow,
|
|
||||||
requestWakeUpWorkspace,
|
|
||||||
requestReload,
|
|
||||||
requestOpen,
|
|
||||||
getLogFolderPath,
|
|
||||||
requestGetActiveWorkspace,
|
|
||||||
} from '../../senders';
|
|
||||||
|
|
||||||
// https://github.com/sindresorhus/array-move/blob/master/index.js
|
// https://github.com/sindresorhus/array-move/blob/master/index.js
|
||||||
const arrayMove = (array: any, from: any, to: any) => {
|
const arrayMove = (array: any, from: any, to: any) => {
|
||||||
const newArray = array.slice();
|
const newArray = array.slice();
|
||||||
|
|
@ -268,6 +252,7 @@ type MainProps = OwnMainProps & typeof Main.defaultProps;
|
||||||
const Main = ({ classes, didFailLoad, isFullScreen, isLoading, navigationBar, shouldPauseNotifications, sidebar, titleBar, workspaces }: MainProps) => {
|
const Main = ({ classes, didFailLoad, isFullScreen, isLoading, navigationBar, shouldPauseNotifications, sidebar, titleBar, workspaces }: MainProps) => {
|
||||||
const workspacesList = Object.values(workspaces);
|
const workspacesList = Object.values(workspaces);
|
||||||
const showTitleBar = window.remote.getPlatform() === 'darwin' && titleBar && !isFullScreen;
|
const showTitleBar = window.remote.getPlatform() === 'darwin' && titleBar && !isFullScreen;
|
||||||
|
const requestReload = async () => await window.service.window.reload(window.meta.windowName);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.outerRoot}>
|
<div className={classes.outerRoot}>
|
||||||
|
|
@ -339,8 +324,7 @@ const Main = ({ classes, didFailLoad, isFullScreen, isLoading, navigationBar, sh
|
||||||
<ul className={classes.ul}>
|
<ul className={classes.ul}>
|
||||||
<li>
|
<li>
|
||||||
Click{' '}
|
Click{' '}
|
||||||
{/* @ts-expect-error ts-migrate(2322) FIXME: Type 'string' is not assignable to type 'number | ... Remove this comment to see the full error message */}
|
<b onClick={requestReload} onKeyPress={requestReload} role="button" tabIndex={0} style={{ cursor: 'pointer' }}>
|
||||||
<b onClick={requestReload} onKeyPress={requestReload} role="button" tabIndex="0" style={{ cursor: 'pointer' }}>
|
|
||||||
Reload
|
Reload
|
||||||
</b>{' '}
|
</b>{' '}
|
||||||
button below or press <b>CMD_or_Ctrl + R</b> to reload the page.
|
button below or press <b>CMD_or_Ctrl + R</b> to reload the page.
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import SettingsIcon from '@material-ui/icons/SettingsSharp';
|
||||||
import InputBase from '@material-ui/core/InputBase';
|
import InputBase from '@material-ui/core/InputBase';
|
||||||
import connectComponent from '../../helpers/connect-component';
|
import connectComponent from '../../helpers/connect-component';
|
||||||
import isUrl from '../../helpers/is-url';
|
import isUrl from '../../helpers/is-url';
|
||||||
import { requestGoBack, requestGoForward, requestGoHome, requestReload, requestShowNotificationsWindow, requestShowPreferencesWindow } from '../../senders';
|
|
||||||
import { updateAddressBarInfo } from '../../state/general/actions';
|
import { updateAddressBarInfo } from '../../state/general/actions';
|
||||||
const styles = (theme: any) => ({
|
const styles = (theme: any) => ({
|
||||||
root: {
|
root: {
|
||||||
|
|
@ -102,16 +101,32 @@ const NavigationBar = ({
|
||||||
return (
|
return (
|
||||||
<div className={classNames(classes.root, hasTrafficLights && classes.rootWithTrafficLights)}>
|
<div className={classNames(classes.root, hasTrafficLights && classes.rootWithTrafficLights)}>
|
||||||
<div className={classes.left}>
|
<div className={classes.left}>
|
||||||
<IconButton aria-label="Go back" className={classes.iconButton} disabled={!hasWorkspaces || !canGoBack} onClick={requestGoBack}>
|
<IconButton
|
||||||
|
aria-label="Go back"
|
||||||
|
className={classes.iconButton}
|
||||||
|
disabled={!hasWorkspaces || !canGoBack}
|
||||||
|
onClick={async () => await window.service.window.goBack(window.meta.windowName)}>
|
||||||
<ArrowBackIcon className={classes.icon} />
|
<ArrowBackIcon className={classes.icon} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton aria-label="Go forward" className={classes.iconButton} disabled={!hasWorkspaces || !canGoForward} onClick={requestGoForward}>
|
<IconButton
|
||||||
|
aria-label="Go forward"
|
||||||
|
className={classes.iconButton}
|
||||||
|
disabled={!hasWorkspaces || !canGoForward}
|
||||||
|
onClick={async () => await window.service.window.goForward(window.meta.windowName)}>
|
||||||
<ArrowForwardIcon className={classes.icon} />
|
<ArrowForwardIcon className={classes.icon} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton aria-label="Reload" className={classes.iconButton} onClick={requestReload} disabled={!hasWorkspaces}>
|
<IconButton
|
||||||
|
aria-label="Reload"
|
||||||
|
className={classes.iconButton}
|
||||||
|
onClick={async () => await window.service.window.reload(window.meta.windowName)}
|
||||||
|
disabled={!hasWorkspaces}>
|
||||||
<RefreshIcon className={classes.icon} />
|
<RefreshIcon className={classes.icon} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton aria-label="Go home" className={classes.iconButton} onClick={requestGoHome} disabled={!hasWorkspaces}>
|
<IconButton
|
||||||
|
aria-label="Go home"
|
||||||
|
className={classes.iconButton}
|
||||||
|
onClick={async () => await window.service.window.goHome(window.meta.windowName)}
|
||||||
|
disabled={!hasWorkspaces}>
|
||||||
<HomeIcon className={classes.icon} />
|
<HomeIcon className={classes.icon} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ import { contextBridge, remote, ipcRenderer, webFrame, desktopCapturer } from 'e
|
||||||
import { Channels } from '@/constants/channels';
|
import { Channels } from '@/constants/channels';
|
||||||
|
|
||||||
// contextBridge.exposeInMainWorld('remote', {
|
// contextBridge.exposeInMainWorld('remote', {
|
||||||
// closeCurrentWindow: () => {},
|
|
||||||
|
|
||||||
// isFullScreen: () => remote.getCurrentWindow().isFullScreen(),
|
// isFullScreen: () => remote.getCurrentWindow().isFullScreen(),
|
||||||
// ipcRenderer: {
|
// ipcRenderer: {
|
||||||
// on: (channel: Channels, callback: (event: Electron.IpcRendererEvent, ...arguments_: unknown[]) => void) =>
|
// on: (channel: Channels, callback: (event: Electron.IpcRendererEvent, ...arguments_: unknown[]) => void) =>
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,6 @@ export const getShouldUseDarkColors = async (): Promise<void> => {
|
||||||
await ipcRenderer.invoke('get-should-use-dark-colors');
|
await ipcRenderer.invoke('get-should-use-dark-colors');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const requestGoHome = async () => await ipcRenderer.invoke('request-go-home');
|
|
||||||
export const requestGoBack = async () => await ipcRenderer.invoke('request-go-back');
|
|
||||||
export const requestGoForward = async () => await ipcRenderer.invoke('request-go-forward');
|
|
||||||
export const requestReload = async () => await ipcRenderer.invoke('request-reload');
|
|
||||||
|
|
||||||
export const requestCheckForUpdates = async (isSilent: boolean) => await ipcRenderer.invoke('request-check-for-updates', isSilent);
|
export const requestCheckForUpdates = async (isSilent: boolean) => await ipcRenderer.invoke('request-check-for-updates', isSilent);
|
||||||
|
|
||||||
export const requestShowAboutWindow = async () => await ipcRenderer.invoke('request-show-about-window');
|
export const requestShowAboutWindow = async () => await ipcRenderer.invoke('request-show-about-window');
|
||||||
|
|
|
||||||
|
|
@ -442,7 +442,7 @@ export class Window implements IWindowService {
|
||||||
{
|
{
|
||||||
label: 'Home',
|
label: 'Home',
|
||||||
accelerator: 'Shift+CmdOrCtrl+H',
|
accelerator: 'Shift+CmdOrCtrl+H',
|
||||||
click: () => ipcMain.emit('request-go-home'),
|
click: async () => await this.goHome(),
|
||||||
enabled: () => this.workspaceService.countWorkspaces() > 0,
|
enabled: () => this.workspaceService.countWorkspaces() > 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue