Commit 13877f5e authored by Bryce Johnson's avatar Bryce Johnson

Re-add initOnce on beforeCreate components.

parent b7c61d3b
......@@ -18,6 +18,11 @@
gl.ApprovalsStore.unapprove();
},
},
beforeCreate() {
gl.ApprovalsStore.initStoreOnce().then(() => {
this.loaded = true;
});
},
template: `
<div class='mr-widget-footer approved-by-users approvals-footer clearfix'>
<span class='approvers-prefix'> Approved by </span>
......
......@@ -15,6 +15,25 @@
init(rootStore) {
this.rootStore = rootStore;
this.api = new gl.ApprovalsApi(rootStore.dataset.endpoint);
this.state = {
loading: false,
};
}
initStoreOnce() {
const state = this.state;
if (!state.loading) {
state.loading = true;
return this.fetch()
.then(() => {
state.loading = false;
this.assignToRootStore(false, 'loading');
})
.catch((err) => {
console.error(`Failed to initialize approvals store: ${err}`);
});
}
return Promise.resolve();
}
fetch() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment