added 260907 version of worker toolkit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
const {
|
||||
get,
|
||||
set,
|
||||
inject: {
|
||||
service,
|
||||
},
|
||||
Mixin
|
||||
} = Ember;
|
||||
|
||||
export default Mixin.create({
|
||||
ajax: service(),
|
||||
notifications: service(),
|
||||
store: service(),
|
||||
|
||||
updatePostNotifications(post) {
|
||||
const ajax = get(this, 'ajax');
|
||||
|
||||
if (get(post, 'notifications.reaction') && get(this, 'updateNotifications')) {
|
||||
const id = get(post, 'id');
|
||||
const store = get(this, 'store');
|
||||
|
||||
ajax
|
||||
.put(`notifications/post/${id}`)
|
||||
.then(({ notifications }) => {
|
||||
notifications.forEach((n) => {
|
||||
const model = store.peekRecord('notification', n.id);
|
||||
|
||||
if(model){
|
||||
set(model, 'unread', false);
|
||||
}
|
||||
});
|
||||
set(post, 'notifications', {});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user