diff --git a/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.vue b/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.vue
index 6c7240e25f..6939d232fc 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.vue
@@ -25,7 +25,7 @@
{{ $tr('reviewMode') }}
-
+
Channel.waitForPublishingDraft(publishDraftchange))
.then(() => {
this.isPublishingDraft = false;
this.showSnackbar({
diff --git a/contentcuration/contentcuration/frontend/shared/data/resources.js b/contentcuration/contentcuration/frontend/shared/data/resources.js
index 17e3431cb7..09ee1490e7 100644
--- a/contentcuration/contentcuration/frontend/shared/data/resources.js
+++ b/contentcuration/contentcuration/frontend/shared/data/resources.js
@@ -1242,6 +1242,37 @@ export const Channel = new CreateModelResource({
});
return this.transaction({ mode: 'rw' }, CHANGES_TABLE, () => {
return this._saveAndQueueChange(change);
+ }).then(() => change);
+ },
+
+ waitForPublishingDraft(publishDraftChange) {
+ const observable = liveQuery(() => {
+ return db[CHANGES_TABLE].where('rev')
+ .equals(publishDraftChange.rev)
+ .and(change => change.type === publishDraftChange.type)
+ .and(change => change.channel_id === publishDraftChange.channel_id)
+ .toArray();
+ });
+
+ return new Promise((resolve, reject) => {
+ const subscription = observable.subscribe({
+ next(result) {
+ // Successfully applied change will be removed.
+ if (result.length === 0) {
+ subscription.unsubscribe();
+ resolve();
+ } else {
+ if (result[0].disallowed || result[0].errored) {
+ subscription.unsubscribe();
+ reject('Publish draft failed');
+ }
+ }
+ },
+ error() {
+ subscription.unsubscribe();
+ reject('Live query failed');
+ },
+ });
});
},
diff --git a/contentcuration/contentcuration/frontend/shared/data/serverSync.js b/contentcuration/contentcuration/frontend/shared/data/serverSync.js
index 72c8c60e4c..35a5db2a83 100644
--- a/contentcuration/contentcuration/frontend/shared/data/serverSync.js
+++ b/contentcuration/contentcuration/frontend/shared/data/serverSync.js
@@ -136,6 +136,7 @@ function handleErrors(response) {
return db[CHANGES_TABLE].where('server_rev')
.anyOf(Object.keys(errorMap).map(Number))
.modify(obj => {
+ obj['errored'] = true;
for (const key in errorMap[obj.server_rev]) {
if (!noModifyKeys[key] || typeof obj[key] === 'undefined') {
obj[key] = errorMap[obj.server_rev][key];