Add openExternal IPC handler and integrate with UI components

- Introduce `openExternal` IPC handler in `electron/main.ts` for opening external links via the default browser or native app.
- Update typings in `electron.d.ts` and `preload.ts` to include `openExternal`.
- Refactor `ComposerRightBar` and `LeftBar` components to leverage `electron.openExternal` for external link actions (e.g., Facebook, Discord).
- Add offline mode logic to filter navigation options in `ComposerRightBar` and `LeftBar`.
- Enhance footer bar to display book titles when chapters are unavailable.
This commit is contained in:
natreex
2025-11-26 17:44:55 -05:00
parent ac95e00127
commit 736b9a3609
6 changed files with 37 additions and 18 deletions

View File

@@ -12,6 +12,7 @@ import LocationComponent from "@/components/book/settings/locations/LocationComp
import CharacterComponent from "@/components/book/settings/characters/CharacterComponent";
import QuillSense from "@/components/quillsense/QuillSenseComponent";
import {useTranslations} from "next-intl";
import OfflineContext, {OfflineContextType} from "@/context/OfflineContext";
export default function ComposerRightBar() {
const {book} = useContext(BookContext);
@@ -19,20 +20,16 @@ export default function ComposerRightBar() {
const t = useTranslations();
const {isCurrentlyOffline} = useContext<OfflineContextType>(OfflineContext)
const [panelHidden, setPanelHidden] = useState<boolean>(false);
const [currentPanel, setCurrentPanel] = useState<PanelComponent | undefined>()
const [showAbout, setShowAbout] = useState<boolean>(false);
const worldRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{
handleSave: () => Promise<void>
}>(null);
const locationRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{
handleSave: () => Promise<void>
}>(null);
const characterRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{
handleSave: () => Promise<void>
}>(null);
const worldRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{ handleSave: () => Promise<void> }>(null);
const locationRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{ handleSave: () => Promise<void> }>(null);
const characterRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{ handleSave: () => Promise<void> }>(null);
async function handleSaveClick(): Promise<void> {
switch (currentPanel?.id) {
@@ -114,7 +111,7 @@ export default function ComposerRightBar() {
description: t("composerRightBar.homeComponents.facebook.description"),
badge: t("composerRightBar.homeComponents.facebook.badge"),
icon: faFacebook,
action: () => window.open('https://www.facebook.com/profile.php?id=61562628720878', '_blank')
action: ():Promise<void> => window.electron.openExternal('https://www.facebook.com/profile.php?id=61562628720878')
},
{
id: 3,
@@ -122,7 +119,7 @@ export default function ComposerRightBar() {
description: t("composerRightBar.homeComponents.discord.description"),
badge: t("composerRightBar.homeComponents.discord.badge"),
icon: faDiscord,
action: () => window.open('https://discord.gg/CHXRPvmaXm', '_blank')
action: () => window.electron.openExternal('https://discord.gg/CHXRPvmaXm')
}
]
@@ -166,7 +163,11 @@ export default function ComposerRightBar() {
</div>
)}
<div className="bg-tertiary border-l border-secondary/50 p-3 flex flex-col space-y-3 shadow-xl">
{book ? editorComponents.map((component: PanelComponent) => (
{book ? editorComponents
.filter((component: PanelComponent):boolean => {
return !(isCurrentlyOffline() && component.id === 1);
})
.map((component: PanelComponent) => (
<button
key={component.id}
disabled={disabled(component.id)}