Skip to content

Commit

Permalink
Fixed menu being unavailable on first startup (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcouch-sil authored Mar 24, 2024
2 parents 7d22964 + 35da747 commit 2c0c2f2
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 2c0c2f2

Please sign in to comment.