diff --git a/lib/dialogs.ts b/lib/dialogs.ts index 2342545ee5..7a6a7ae6d0 100644 --- a/lib/dialogs.ts +++ b/lib/dialogs.ts @@ -16,6 +16,7 @@ export default function createDialogs(channel: Channel, ids: IdsAPI): DialogsAPI openConfirm: openSimpleDialog.bind(null, 'confirm'), openPrompt: openSimpleDialog.bind(null, 'prompt'), openExtension: openExtensionDialog, + openApp: openAppDialog, openCurrentApp: openCurrentAppDialog, openCurrent: openCurrentDialog, selectSingleEntry: openEntitySelector.bind(null, 'Entry', false), @@ -57,6 +58,19 @@ export default function createDialogs(channel: Channel, ids: IdsAPI): DialogsAPI } } + function openAppDialog(options?: OpenCustomWidgetOptions) { + options = prepareOptions(options) + + // Use provided ID, default to the current app. + options = { ...options, id: options?.id || ids.app } + if (options.id) { + // Force ID of the current app. + return channel.call('openDialog', 'app', options) + } else { + throw new Error('App ID not provided.') + } + } + function openCurrentAppDialog(options?: Omit) { options = prepareOptions(options) if (ids.app) { diff --git a/lib/types/dialogs.types.ts b/lib/types/dialogs.types.ts index 7828a6da9e..47f734d8fb 100644 --- a/lib/types/dialogs.types.ts +++ b/lib/types/dialogs.types.ts @@ -44,6 +44,8 @@ export interface DialogsAPI { ) => Promise /** Opens an extension in a dialog. */ openExtension: (options: OpenCustomWidgetOptions) => Promise + /** Opens an app dialog */ + openApp: (options?: OpenCustomWidgetOptions) => Promise /** Opens the current app in a dialog */ openCurrentApp: (options?: Omit) => Promise /** Opens the current app or extension in a dialog */