Skip to content

Commit

Permalink
Merge pull request #342 from MOV-AI/bugfix/BP-1200/fix-subscription-t…
Browse files Browse the repository at this point in the history
…o-doc-updates

BP-1200: Fix subscription to doc updates
[FP-2946](https://movai.atlassian.net/browse/FP-2946): Deleting the "Label" filter from lib-ide BaseStore results in a 500 response in certain conditions
  • Loading branch information
diasnad authored Sep 13, 2024
2 parents 9a617c1 + 623b467 commit 693d48f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# TBD

- [FP-2946](https://movai.atlassian.net/browse/FP-2946): Deleting the "Label" filter from lib-ide BaseStore results in a 500 response in certain conditions

# v1.2.7

- [FP-2787](https://movai.atlassian.net/browse/FP-2787): IDE - Topics - Can't open multiple Topics tabs
Expand Down
17 changes: 14 additions & 3 deletions src/store/BaseStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BaseStore extends StorePluginManager {
this._scope = model.SCOPE;
this._name = name || "Store";
this._title = title || "Generic Store";
this.pattern = pattern || { Scope: this.scope, Name: "*", Label: "*" };
this.pattern = pattern || { Scope: this.scope, Name: "*"}
this.observer = observer;
this.docManager = docManager;
this.protectedDocs = [];
Expand Down Expand Up @@ -171,9 +171,20 @@ class BaseStore extends StorePluginManager {
}

_onSetDoc(doc) {
if (!this.getDoc(doc.name)) {
this.newDoc(doc.name);
const docInst = this.getDoc(doc.name);
if (!docInst) {
const newDoc = this.newDoc(doc.name);
newDoc
.enableObservables(false)
.setIsNew(false)
.setIsLoaded(false)
.setDirty(false)
.enableObservables(true);
}

// if the doc is existing and not dirty, we should update
// it but that is non-trivial. We should open a new issue
// for it
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/store/DBSubscriber/DBSubscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ class DBSubscriber extends StoreAbstractPlugin {
onUpdate(data) {
clearTimeout(this[symbols.timer]);

let docName = Object.keys(data["key"][this.scope])[0];
this[symbols.timer] = setTimeout(
() => this.updateDocument(data.patterns[0].Name),
() => this.updateDocument(docName),
DEBOUNCE_TIME
);
}
Expand Down

0 comments on commit 693d48f

Please sign in to comment.