Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed menu being unavailable on first startup #804

Merged
merged 1 commit into from
Mar 24, 2024
Merged
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
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
Loading