Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<span class="grey--darken-2 grey--text">{{ $tr('reviewMode') }}</span>
</ToolBar>
<MainNavigationDrawer v-model="drawer" />
<LoadingText v-if="isLoading || isDeploying" />
<LoadingText v-if="isLoading || isDeploying || isPublishingDraft" />
<VContent v-else-if="isEmpty">
<VLayout
justify-center
Expand Down Expand Up @@ -647,6 +647,7 @@
this.isPublishingDraft = true;

this.publishDraftChannel()
.then(publishDraftchange => Channel.waitForPublishingDraft(publishDraftchange))
.then(() => {
this.isPublishingDraft = false;
this.showSnackbar({
Expand Down
31 changes: 31 additions & 0 deletions contentcuration/contentcuration/frontend/shared/data/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},
});
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down