Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ulugmer committed Dec 4, 2023
1 parent 17da58e commit 7c75910
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 163 deletions.
7 changes: 1 addition & 6 deletions src/components/left/LeftColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import { useStateRef } from '../../hooks/useStateRef';
import useSyncEffect from '../../hooks/useSyncEffect';

import Transition from '../ui/Transition';
import UluGoBackButton from '../ui/UluGoBackButton';
import UluGoForwardButton from '../ui/UluGoForwardButton';
import ArchivedChats from './ArchivedChats.async';
import LeftMain from './main/LeftMain';
import NewChat from './newChat/NewChat.async';
Expand Down Expand Up @@ -559,10 +557,7 @@ function LeftColumn({

return (
<div>
<div className="electron-header">
<UluGoBackButton />
<UluGoForwardButton />
</div>
<div className="electron-header" />
<Transition
ref={ref}
name={shouldSkipHistoryAnimations ? 'none' : LAYERS_ANIMATION_NAME}
Expand Down
47 changes: 0 additions & 47 deletions src/components/ui/UluGoBackButton.tsx

This file was deleted.

48 changes: 0 additions & 48 deletions src/components/ui/UluGoForwardButton.tsx

This file was deleted.

26 changes: 1 addition & 25 deletions src/electron/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'v8-compile-cache';

import {
app, BrowserWindow, ipcMain, nativeImage,
app, /* BrowserWindow, ipcMain, */ nativeImage,
} from 'electron';
import contextMenu from 'electron-context-menu';
import path from 'path';
Expand All @@ -10,30 +10,6 @@ import { initDeeplink } from './deeplink';
import { IS_MAC_OS, IS_WINDOWS } from './utils';
import { createWindow, setupCloseHandlers, setupElectronActionHandlers } from './window';

ipcMain.handle('can-go-back', () => {
const webContents = BrowserWindow.getFocusedWindow()?.webContents;
return webContents && !webContents.isDestroyed() ? webContents.canGoBack() : false;
});

ipcMain.handle('can-go-forward', () => {
const webContents = BrowserWindow.getFocusedWindow()?.webContents;
return webContents && !webContents.isDestroyed() ? webContents.canGoForward() : false;
});

ipcMain.on('go-back', () => {
const webContents = BrowserWindow.getFocusedWindow()?.webContents;
if (webContents?.canGoBack()) {
webContents.goBack();
}
});

ipcMain.on('go-forward', () => {
const webContents = BrowserWindow.getFocusedWindow()?.webContents;
if (webContents?.canGoForward()) {
webContents.goForward();
}
});

initDeeplink();

contextMenu({
Expand Down
4 changes: 0 additions & 4 deletions src/electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ const electronApi: ElectronApi = {
setIsTrayIconEnabled: (value: boolean) => ipcRenderer.invoke(ElectronAction.SET_IS_TRAY_ICON_ENABLED, value),
getIsTrayIconEnabled: () => ipcRenderer.invoke(ElectronAction.GET_IS_TRAY_ICON_ENABLED),
restoreLocalStorage: () => ipcRenderer.invoke(ElectronAction.RESTORE_LOCAL_STORAGE),
canGoBack: () => ipcRenderer.invoke(ElectronAction.CAN_GO_BACK),
canGoForward: () => ipcRenderer.invoke(ElectronAction.CAN_GO_FORWARD),
goBack: () => ipcRenderer.send(ElectronAction.GO_BACK),
goForward: () => ipcRenderer.send(ElectronAction.GO_FORWARD),

on: (eventName: ElectronEvent, callback) => {
const subscription = (event: IpcRendererEvent, ...args: any) => callback(...args);
Expand Down
26 changes: 1 addition & 25 deletions src/electron/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { processDeeplink } from './deeplink';
import { captureLocalStorage, restoreLocalStorage } from './localStorage';
import tray from './tray';
import {
forceQuit, getAppTitle, getCurrentWebContents,
forceQuit, getAppTitle,
getCurrentWindow, getLastWindow, hasExtraWindows, IS_FIRST_RUN, IS_MAC_OS,
IS_PREVIEW, IS_WINDOWS, reloadWindows, store, TRAFFIC_LIGHT_POSITION, windows,
} from './utils';
Expand Down Expand Up @@ -174,30 +174,6 @@ export function setupElectronActionHandlers() {
getCurrentWindow()?.isFullScreen();
});

ipcMain.handle(ElectronAction.CAN_GO_BACK, () => {
const webContents = getCurrentWebContents();
return webContents ? webContents.canGoBack() : false;
});

ipcMain.handle(ElectronAction.CAN_GO_FORWARD, () => {
const webContents = getCurrentWebContents();
return webContents ? webContents.canGoForward() : false;
});

ipcMain.on(ElectronAction.GO_BACK, () => {
const webContents = getCurrentWebContents();
if (webContents && webContents.canGoBack()) {
webContents.goBack();
}
});

ipcMain.on(ElectronAction.GO_FORWARD, () => {
const webContents = getCurrentWebContents();
if (webContents && webContents.canGoForward()) {
webContents.goForward();
}
});

ipcMain.handle(ElectronAction.HANDLE_DOUBLE_CLICK, () => {
const currentWindow = getCurrentWindow();
const doubleClickAction = systemPreferences.getUserDefault('AppleActionOnDoubleClick', 'string');
Expand Down
9 changes: 1 addition & 8 deletions src/types/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export enum ElectronAction {
SET_IS_TRAY_ICON_ENABLED = 'set-is-tray-icon-enabled',
GET_IS_TRAY_ICON_ENABLED = 'get-is-tray-icon-enabled',
RESTORE_LOCAL_STORAGE = 'restore-local-storage',
CAN_GO_BACK = 'can-go-back',
CAN_GO_FORWARD = 'can-go-forward',
GO_BACK = 'go-back',
GO_FORWARD = 'go-forward',
}

export type TrafficLightPosition = 'standard' | 'lowered';
Expand All @@ -38,10 +34,7 @@ export interface ElectronApi {
setIsTrayIconEnabled: (value: boolean) => Promise<void>;
getIsTrayIconEnabled: () => Promise<boolean>;
restoreLocalStorage: () => Promise<void>;
canGoBack: () => Promise<boolean>;
canGoForward: () => Promise<boolean>;
goBack: () => void;
goForward: () => void;

on: (eventName: ElectronEvent, callback: any) => VoidFunction;
}

Expand Down

0 comments on commit 7c75910

Please sign in to comment.