Skip to content
Snippets Groups Projects
Commit ed18d3cc authored by syuilo's avatar syuilo
Browse files

#935

parent e5eaa5b6
No related branches found
No related tags found
No related merge requests found
......@@ -198,6 +198,7 @@ export default class MiOS extends EventEmitter {
fetchme(cachedMe.token, freshData => {
Object.assign(cachedMe, freshData);
cachedMe.trigger('updated');
cachedMe.trigger('refreshed');
});
} else {
// Get token from cookie
......
......@@ -193,11 +193,16 @@
this.home = [];
this.bakeHomeData = () => JSON.stringify(this.I.client_settings.home);
this.bakedHomeData = this.bakeHomeData();
this.on('mount', () => {
this.refs.tl.on('loaded', () => {
this.trigger('loaded');
});
this.I.on('refreshed', this.onMeRefreshed);
this.I.client_settings.home.forEach(widget => {
try {
this.setWidget(widget);
......@@ -256,6 +261,8 @@
});
this.on('unmount', () => {
this.I.off('refreshed', this.onMeRefreshed);
this.home.forEach(widget => {
widget.unmount();
});
......@@ -266,6 +273,12 @@
}
});
this.onMeRefreshed = () => {
if (this.bakedHomeData != this.bakeHomeData()) {
alert('別の場所でホームが編集されました。ページを再度読み込みすると編集が反映されます。');
}
};
this.setWidget = (widget, prepend = false) => {
const el = document.createElement(`mk-${widget.name}-home-widget`);
......@@ -366,7 +379,6 @@
this.api('i/update_home', {
home: data
}).then(() => {
this.I.client_settings.home = data;
this.I.update();
});
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment