Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/desktop/src/common/constants/ipcChannels.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
},
"INTEGRATION": {
"DISCORD_SET_ACTIVITY": "integration-discordSetActivity"
}
},
"GET_PLATFORM": "getPlatform"
}
3 changes: 3 additions & 0 deletions apps/desktop/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const createWindows = async () => {
minWidth: 250,
minHeight: 150,
frame: false,
titleBarStyle: "hiddenInset",
icon: getAssetPath('icon.png'),
webPreferences: {
nodeIntegration: true,
Expand Down Expand Up @@ -228,6 +229,8 @@ ipcMain.handle(ipcChannels.APP.READ_ENTIRE_FILE, (_event, filepath: string) => {
return fs.readFileSync(filepath).toString();
});

ipcMain.handle(ipcChannels.GET_PLATFORM, () => process.platform);

if (process.platform === 'win32') {
app.commandLine.appendSwitch('high-dpi-support', '1');
app.commandLine.appendSwitch('force-device-scale-factor', '1');
Expand Down
6 changes: 6 additions & 0 deletions apps/desktop/src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
runningState,
} from './state/downloaderStates';
import { autoCheckForUpdatesState } from './state/settingStates';
import { platformState } from './state/applicationStates';
import library from './services/library';
import {
createRendererIpcHandlers,
Expand Down Expand Up @@ -51,6 +52,7 @@ export default function App() {
const setCurrentTask = useSetRecoilState(currentTaskState);
const setDownloadErrors = useSetRecoilState(downloadErrorsState);
const autoCheckForUpdates = useRecoilValue(autoCheckForUpdatesState);
const setPlatform = useSetRecoilState(platformState);

useEffect(() => {
if (loading) {
Expand All @@ -60,6 +62,10 @@ export default function App() {
* Add any additional preload steps here (e.g. data migration, verifications, etc)
*/

ipcRenderer.invoke(ipcChannels.GET_PLATFORM).then((p) => {
setPlatform(p);
});

createRendererIpcHandlers(
(updateInfo) => {
setUpdateInfo(updateInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function DashboardSidebar({ ...props }: React.ComponentProps<typeof Sideb

return (
<Sidebar {...props}>
<SidebarHeader className="pt-4" />
<SidebarHeader className="pt-4 h-[28px]" />
<SidebarContent>
<NewCategoryDialog
open={showingNewCategoryDialog}
Expand Down
59 changes: 35 additions & 24 deletions apps/desktop/src/renderer/components/general/Titlebar.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,51 @@
import { titlebarTextState } from '@/renderer/state/libraryStates';
import { platformState } from '@/renderer/state/applicationStates';
import { useRecoilValue } from 'recoil';
import packageJson from '../../../../package.json';
const { ipcRenderer } = require('electron');
import ipcChannels from '@/common/constants/ipcChannels.json';
import { MinusIcon, SquareIcon, XIcon } from 'lucide-react';
import React, { useEffect, useState } from "react";

export const Titlebar: React.FC = () => {
const text = useRecoilValue(titlebarTextState);
const platform = useRecoilValue(platformState);

if (platform === null) {
return null;
}

const formattedText = text ? `${packageJson.productName} - ${text}` : packageJson.productName;

return (
<div className="bg-background text-foreground select-none flex justify-between items-center fixed top-0 h-[24px] w-full p-0.5 z-50 overflow-hidden">
<div className="ml-2 overflow-hidden text-xs font-sans font-bold tracking-tighter text-muted-foreground line-clamp-1">
<span>{formattedText}</span>
</div>
<div className="flex justify-end">
<button
className="hover:!bg-foreground hover:!text-background h-[24px] w-[46px] flex items-center justify-center"
onClick={() => ipcRenderer.invoke(ipcChannels.WINDOW.MINIMIZE)}
>
<MinusIcon width={14} height={14} />
</button>
<button
className="hover:!bg-foreground hover:!text-background h-[24px] w-[46px] flex items-center justify-center"
onClick={() => ipcRenderer.invoke(ipcChannels.WINDOW.MAX_RESTORE)}
>
<SquareIcon width={14} height={14} />
</button>
<button
className="hover:!bg-red-500 hover:!text-white h-[24px] w-[46px] flex items-center justify-center"
onClick={() => ipcRenderer.invoke(ipcChannels.WINDOW.CLOSE)}
>
<XIcon width={18} height={18} />
</button>
</div>
<div className={`${platform !== 'darwin' && 'bg-background' || 'bg-[0]'} text-foreground select-none flex justify-between items-center fixed top-0 h-[24px] w-full p-0.5 z-50 overflow-hidden`}>
{ platform !== "darwin" && (
<>
<div className="ml-2 overflow-hidden text-xs font-sans font-bold tracking-tighter text-muted-foreground line-clamp-1">
<span>{formattedText}</span>
</div>
<div className="flex justify-end">
<button
className="hover:!bg-foreground hover:!text-background h-[24px] w-[46px] flex items-center justify-center"
onClick={() => ipcRenderer.invoke(ipcChannels.WINDOW.MINIMIZE)}
>
<MinusIcon width={14} height={14} />
</button>
<button
className="hover:!bg-foreground hover:!text-background h-[24px] w-[46px] flex items-center justify-center"
onClick={() => ipcRenderer.invoke(ipcChannels.WINDOW.MAX_RESTORE)}
>
<SquareIcon width={14} height={14} />
</button>
<button
className="hover:!bg-red-500 hover:!text-white h-[24px] w-[46px] flex items-center justify-center"
onClick={() => ipcRenderer.invoke(ipcChannels.WINDOW.CLOSE)}
>
<XIcon width={18} height={18} />
</button>
</div>
</>
)}
</div>
);
};
21 changes: 12 additions & 9 deletions apps/desktop/src/renderer/components/reader/ReaderSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ export const ReaderSidebar: React.FC<Props> = (props: Props) => {
return (
<Sidebar collapsible="offcanvas">
<SidebarHeader className="border-b border-sidebar-border">
<SidebarMenuItem>
<SidebarMenuButton
className="max-w-full flex space-x-1 px-1 py-6"
onClick={() => props.exitPage()}
>
<XIcon className="opacity-50" />
<h3 className="truncate font-semibold text-wrap line-clamp-2">{readerSeries.title}</h3>
</SidebarMenuButton>
</SidebarMenuItem>
<div className="h-[20px]" />
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton
className="max-w-full flex space-x-1 px-1 py-6"
onClick={() => props.exitPage()}
>
<XIcon className="opacity-50" />
<h3 className="truncate font-semibold text-wrap line-clamp-2">{readerSeries.title}</h3>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarHeader>
<SidebarContent>
<SidebarGroup className="pt-4">
Expand Down
6 changes: 6 additions & 0 deletions apps/desktop/src/renderer/state/applicationStates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { atom } from 'recoil';

export const platformState = atom<string | undefined>({
key: 'platformState',
default: undefined
});