Add workaround for error update

This commit is contained in:
Paulo Gustavo Veiga 2022-02-17 18:04:28 -08:00
parent a50ee13589
commit a5847c64d4
3 changed files with 25 additions and 11 deletions

View File

@ -30,9 +30,16 @@ import Topic from './Topic';
abstract class ActionDispatcher extends Events { abstract class ActionDispatcher extends Events {
private static _instance: ActionDispatcher; private static _instance: ActionDispatcher;
private _commandContext: CommandContext;
constructor(commandContext: CommandContext) { constructor(commandContext: CommandContext) {
$assert(commandContext, 'commandContext can not be null'); $assert(commandContext, 'commandContext can not be null');
super(); super();
this._commandContext = commandContext;
}
getCommandContext(): CommandContext {
return this._commandContext;
} }
abstract addRelationship(model: RelationshipModel, mindmap: Mindmap): void; abstract addRelationship(model: RelationshipModel, mindmap: Mindmap): void;

View File

@ -40,7 +40,6 @@ class CommandContext {
this._designer = value; this._designer = value;
} }
/** */
findTopics(topicIds: number[]): Topic[] { findTopics(topicIds: number[]): Topic[] {
$assert($defined(topicIds), 'topicsIds can not be null'); $assert($defined(topicIds), 'topicsIds can not be null');
const topicsIds = Array.isArray(topicIds) ? topicIds : [topicIds]; const topicsIds = Array.isArray(topicIds) ? topicIds : [topicIds];

View File

@ -22,6 +22,7 @@ import initHotKeyPluggin from '../../../../libraries/jquery.hotkeys';
import Events from './Events'; import Events from './Events';
import ActionDispatcher from './ActionDispatcher'; import ActionDispatcher from './ActionDispatcher';
import Topic from './Topic'; import Topic from './Topic';
import { Designer } from '..';
initHotKeyPluggin($); initHotKeyPluggin($);
@ -255,12 +256,19 @@ class MultilineTextEditor extends Events {
close(update: boolean): void { close(update: boolean): void {
if (this.isVisible() && this._topic) { if (this.isVisible() && this._topic) {
if (!$defined(update) || update) { if (!$defined(update) || update) {
const actionDispatcher = ActionDispatcher.getInstance();
// Workaround. For some reason, close is triggered but the topic has been removed. Temporally, try to validate if exits.
try {
actionDispatcher
.getCommandContext()
.findTopics([this._topic.getId()]);
this._updateModel(); this._updateModel();
}
// Let make the visible text in the node visible again ... // Let make the visible text in the node ...
this._topic.getTextShape().setVisibility(true); this._topic.getTextShape().setVisibility(true);
} catch (e) {
console.log(e);
}
// Remove it form the screen ... // Remove it form the screen ...
this._containerElem.remove(); this._containerElem.remove();
this._containerElem = null; this._containerElem = null;
@ -268,5 +276,5 @@ class MultilineTextEditor extends Events {
this._topic = null; this._topic = null;
} }
} }
}
export default MultilineTextEditor; export default MultilineTextEditor;