Example #1
0
  extend(CommentPost.prototype, 'actionItems', function(items) {
    const post = this.props.post;

    if (post.isHidden() || !post.canLike()) return;

    let isLiked = app.session.user && post.likes().some(user => user === app.session.user);

    items.add('like',
      Button.component({
        children: app.trans(isLiked ? 'likes.unlike_action' : 'likes.like_action'),
        className: 'Button Button--link',
        onclick: () => {
          isLiked = !isLiked;

          post.save({isLiked});

          // We've saved the fact that we do or don't like the post, but in order
          // to provide instantaneous feedback to the user, we'll need to add or
          // remove the like from the relationship data manually.
          const data = post.data.relationships.likes.data;
          data.some((like, i) => {
            if (like.id === app.session.user.id()) {
              data.splice(i, 1);
              return true;
            }
          });

          if (isLiked) {
            data.unshift({type: 'users', id: app.session.user.id()});
          }
        }
      })
    );
  });
Example #2
0
extend(NotificationGrid.prototype, 'notificationTypes', function(items) {
  items.add('discussionLocked', {
    name: 'discussionLocked',
    icon: 'lock',
    label: app.trans('lock.notify_discussion_locked')
  });
});
Example #3
0
extend(NotificationGrid.prototype, 'notificationTypes', function(items) {
  items.add('discussionStickied', {
    name: 'discussionStickied',
    icon: 'thumb-tack',
    label: app.trans('sticky.notify_discussion_stickied')
  });
});
Example #4
0
  extend(DiscussionList.prototype, 'view', function(vdom) {
    if (app.pushedUpdates) {
      const count = app.pushedUpdates.length;

      if (count) {
        vdom.children.unshift(
          Button.component({
            className: 'Button Button--block DiscussionList-update',
            onclick: () => {
              this.refresh(false).then(() => {
                this.loadingUpdated = false;
                app.pushedUpdates = [];
                app.setTitleCount(0);
                m.redraw();
              });
              this.loadingUpdated = true;
            },
            loading: this.loadingUpdated,
            children: app.trans('pusher.show_updated_discussions', {count})
          })
        );
      }
    }
  });