added 260907 version of worker toolkit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
const {
|
||||
get,
|
||||
computed,
|
||||
computed: {
|
||||
alias,
|
||||
},
|
||||
Component,
|
||||
} = Ember;
|
||||
|
||||
export default Component.extend({
|
||||
classNames: ['flaredown-white-box'],
|
||||
classNameBindings: ['unreadClass:unreadNotification'],
|
||||
|
||||
notificationAnchor: computed('notification.kind', function() {
|
||||
if( get(this, 'notification.kind') === 'reaction' && get(this, 'notification.notificateableType') === 'post') {
|
||||
return 'emoji-reactions';
|
||||
} else {
|
||||
return `anchor-${get(this, 'notification.notificateableId')}`;
|
||||
}
|
||||
}),
|
||||
|
||||
people: computed('notification.count', function() {
|
||||
const count = get(this, 'notification.count');
|
||||
|
||||
return `${count} ${count > 1 ? 'people' : 'person'}`;
|
||||
}),
|
||||
|
||||
didWhat: computed('notification.kind', function() {
|
||||
return get(this, 'notification.kind') === 'comment' ? 'responded' : 'reacted';
|
||||
}),
|
||||
|
||||
fullResponse: computed('people', 'notification.{kind,notifier_username}', function() {
|
||||
if(get(this, 'notification.kind') === 'mention') {
|
||||
|
||||
return (`<b>${get(this, 'notification.notifier_username')}</b> mentioned you in a comment` ).htmlSafe();
|
||||
} else {
|
||||
const response = get(this, 'notification.kind') === 'comment' ? 'responded' : 'reacted';
|
||||
|
||||
return (`<b>${get(this, 'people')}</b> ${response} to ${get(this, 'notification.postTitle')}`).htmlSafe();
|
||||
}
|
||||
}),
|
||||
|
||||
unreadClass: alias('notification.unread'),
|
||||
});
|
||||
@@ -0,0 +1,69 @@
|
||||
import Ember from 'ember';
|
||||
import InViewportMixin from 'ember-in-viewport';
|
||||
|
||||
const {
|
||||
get,
|
||||
set,
|
||||
observer,
|
||||
Component,
|
||||
getProperties,
|
||||
run: {
|
||||
schedule,
|
||||
},
|
||||
inject: {
|
||||
service,
|
||||
},
|
||||
} = Ember;
|
||||
|
||||
export default Component.extend(InViewportMixin, {
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
const commentId = get(this, 'comment.id');
|
||||
|
||||
if (commentId) {
|
||||
set(this, 'elementId', `anchor-${commentId}`);
|
||||
}
|
||||
},
|
||||
|
||||
visited: false,
|
||||
|
||||
ajax: service(),
|
||||
notifications: service(),
|
||||
|
||||
didEnterViewport() {
|
||||
schedule('afterRender', this, this.setVisited);
|
||||
},
|
||||
|
||||
setVisited() {
|
||||
set(this, 'visited', true);
|
||||
},
|
||||
|
||||
destroyNotifications: observer('visited', 'comment.body', function() {
|
||||
const {
|
||||
ajax,
|
||||
comment,
|
||||
visited,
|
||||
} = getProperties(this, 'ajax', 'comment', 'visited');
|
||||
|
||||
const { id, hasNotifications } = getProperties(comment, 'id', 'hasNotifications');
|
||||
|
||||
if (visited && hasNotifications) {
|
||||
const store = get(this, 'store');
|
||||
|
||||
ajax
|
||||
.put(`notifications/comment/${id}`)
|
||||
.then(({notifications}) => {
|
||||
|
||||
notifications.forEach((n) => {
|
||||
const model = store.peekRecord('notification', n.id);
|
||||
|
||||
if(model){
|
||||
set(model, 'unread', false);
|
||||
}
|
||||
});
|
||||
set(comment, 'notifications', {});
|
||||
});
|
||||
}
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
const {
|
||||
Component,
|
||||
} = Ember;
|
||||
|
||||
export default Component.extend({
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import Ember from 'ember';
|
||||
import UserNameable from 'flaredown/mixins/user-nameable';
|
||||
|
||||
const {
|
||||
computed: {
|
||||
alias
|
||||
},
|
||||
Component,
|
||||
} = Ember;
|
||||
|
||||
export default Component.extend(UserNameable, {
|
||||
classNames: ['profile-circle'],
|
||||
pictureLetter: alias('session.actualUser.profile.screenName.0'),
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
import Ember from 'ember';
|
||||
import InViewportMixin from 'ember-in-viewport';
|
||||
|
||||
const {
|
||||
set,
|
||||
Component,
|
||||
getProperties,
|
||||
inject: {
|
||||
service,
|
||||
},
|
||||
} = Ember;
|
||||
|
||||
export default Component.extend(InViewportMixin, {
|
||||
classNames: ['flaredown-white-box'],
|
||||
|
||||
ajax: service(),
|
||||
|
||||
didEnterViewport() {
|
||||
const { ajax, comment } = getProperties(this, 'ajax', 'comment');
|
||||
const { id, hasNotifications } = getProperties(comment, 'id', 'hasNotifications');
|
||||
|
||||
if (hasNotifications) {
|
||||
ajax
|
||||
.put(`notifications/comment/${id}`)
|
||||
.then(() => set(comment, 'notifications', {}));
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import Ember from 'ember';
|
||||
import InViewportMixin from 'ember-in-viewport';
|
||||
import UpdateNotifications from 'flaredown/mixins/update-notifications';
|
||||
|
||||
const {
|
||||
get,
|
||||
Component,
|
||||
run: {
|
||||
schedule,
|
||||
},
|
||||
inject: {
|
||||
service,
|
||||
},
|
||||
} = Ember;
|
||||
|
||||
export default Component.extend(InViewportMixin, UpdateNotifications, {
|
||||
classNames: ['flaredown-white-box post'],
|
||||
|
||||
ajax: service(),
|
||||
notifications: service(),
|
||||
elipsis: 125,
|
||||
|
||||
didEnterViewport() {
|
||||
schedule('afterRender', this, this.updatePostNotifications, get(this, 'post'));
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user