Skip to content

Commit

Permalink
Fixed menu being unavailable on first startup if your machine is too …
Browse files Browse the repository at this point in the history
…slow to get the renderer up before the extension host needs it
  • Loading branch information
tjcouch-sil committed Mar 21, 2024
1 parent 7d22964 commit 35da747
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/renderer/components/platform-bible-toolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import useSetting from '@renderer/hooks/papi-hooks/use-setting.hook';
import logger from '@shared/services/logger.service';
import { Toolbar, RefSelector, ScriptureReference, Button } from 'platform-bible-react';
import { Localized, MultiColumnMenu } from 'platform-bible-utils';
import { handleMenuCommand } from './platform-bible-menu.commands';
import provideMenuData from './platform-bible-menu.data';

Expand All @@ -9,6 +11,22 @@ const defaultScrRef: ScriptureReference = {
verseNum: 1,
};

/**
* Providing empty menu data if the software fails to load fully so we can shift click the menu and
* click Reload Extensions if it fails the first time
*
* @param isSupportAndDevelopment
* @returns
*/
async function getMenuData(isSupportAndDevelopment: boolean): Promise<Localized<MultiColumnMenu>> {
try {
return await provideMenuData(isSupportAndDevelopment);
} catch (e) {
logger.error(`Could not get platform-bible-toolbar menu data! ${e}`);
return { columns: {}, groups: {}, items: [] };
}
}

export default function PlatformBibleToolbar() {
const [scrRef, setScrRef, resetScrRef] = useSetting('platform.verseRef', defaultScrRef);

Expand All @@ -17,7 +35,7 @@ export default function PlatformBibleToolbar() {
};

return (
<Toolbar className="toolbar" menuProvider={provideMenuData} commandHandler={handleMenuCommand}>
<Toolbar className="toolbar" menuProvider={getMenuData} commandHandler={handleMenuCommand}>
<RefSelector handleSubmit={handleReferenceChanged} scrRef={scrRef} />
<Button
onClick={() => {
Expand Down

0 comments on commit 35da747

Please sign in to comment.