UNPKG

botbuilder-dialogs

Version:

A dialog stack based conversation manager for Microsoft BotBuilder.

48 lines 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DialogClassMemoryScope = void 0; /** * @module botbuilder-dialogs */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ const classMemoryScope_1 = require("./classMemoryScope"); const scopePath_1 = require("../scopePath"); const dialogContainer_1 = require("../../dialogContainer"); /** * DialogClassMemoryScope maps "dialogClass" -> dc.parent.activeDialog.properties */ class DialogClassMemoryScope extends classMemoryScope_1.ClassMemoryScope { /** * Initializes a new instance of the [DialogClassMemoryScope](xref:botbuilder-dialogs.DialogClassMemoryScope) class. */ constructor() { super(scopePath_1.ScopePath.dialogClass); } /** * @protected * @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) object for this turn. * @returns The current [Dialog](xref:botbuilder-dialogs.Dialog). */ onFindDialog(dc) { // Is the active dialog a container? const dialog = dc.findDialog(dc.activeDialog.id); if (dialog && dialog instanceof dialogContainer_1.DialogContainer) { return dialog; } // Return parent dialog if there is one? const parent = dc.parent; if (parent && parent.activeDialog) { const parentDialog = parent.findDialog(parent.activeDialog.id); if (parentDialog) { return parentDialog; } } // Fallback to returning current dialog return dialog; } } exports.DialogClassMemoryScope = DialogClassMemoryScope; //# sourceMappingURL=dialogClassMemoryScope.js.map