This commit is contained in:
parent
e5eaa5b6e7
commit
ed18d3cc22
@ -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();
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user