Skip to content

Commit

Permalink
Handle the fact that some menu item may still be defined using the le…
Browse files Browse the repository at this point in the history
…gacy method
  • Loading branch information
tsullivan committed Oct 4, 2024
1 parent bc88a3d commit 5b0952f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/plugins/share/public/services/share_menu_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { ShareContext, ShareMenuProvider, ShareMenuProviderV2 } from '../types';
import {
ShareContext,
ShareMenuProvider,
ShareMenuProviderV2,
ShareMenuProviderLegacy,
} from '../types';

export class ShareMenuRegistry {
private readonly shareMenuProviders = new Map<string, ShareMenuProvider>();
Expand Down Expand Up @@ -36,7 +41,10 @@ export class ShareMenuRegistry {
return {
getShareMenuItems: (context: ShareContext) =>
Array.from(this.shareMenuProviders.values()).flatMap((shareActionProvider) =>
(shareActionProvider as ShareMenuProviderV2).getShareMenuItems(context)
(
(shareActionProvider as ShareMenuProviderV2).getShareMenuItems ??
(shareActionProvider as ShareMenuProviderLegacy).getShareMenuItemsLegacy
).call(shareActionProvider, context)
),
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/share/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export interface ShareMenuProviderV2 {
readonly id: string;
getShareMenuItems: (context: ShareContext) => Array<Omit<ShareMenuItemV2, 'intl'>>;
}
interface ShareMenuProviderLegacy {
export interface ShareMenuProviderLegacy {
readonly id: string;
getShareMenuItemsLegacy: (context: ShareContext) => ShareMenuItemLegacy[];
}
Expand Down

0 comments on commit 5b0952f

Please sign in to comment.