Add emoji icon support on notification (expects custom)
This commit is contained in:
parent
b242a89e63
commit
1df6e80ee0
5 changed files with 17 additions and 4 deletions
|
@ -52,7 +52,6 @@ class EmojiReactions extends ImmutablePureComponent {
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { intl, accountIds, multiColumn } = this.props;
|
const { intl, accountIds, multiColumn } = this.props;
|
||||||
console.dir(accountIds);
|
|
||||||
|
|
||||||
if (!accountIds) {
|
if (!accountIds) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -12,6 +12,7 @@ import FollowRequestContainer from '../containers/follow_request_container';
|
||||||
import Icon from 'mastodon/components/icon';
|
import Icon from 'mastodon/components/icon';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import EmojiView from '../../../components/emoji_view';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
favourite: { id: 'notification.favourite', defaultMessage: '{name} favourited your status' },
|
favourite: { id: 'notification.favourite', defaultMessage: '{name} favourited your status' },
|
||||||
|
@ -215,14 +216,16 @@ class Notification extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderEmojiReaction (notification, link) {
|
renderEmojiReaction (notification, link) {
|
||||||
|
console.dir(notification)
|
||||||
const { intl, unread } = this.props;
|
const { intl, unread } = this.props;
|
||||||
|
const emoji_reaction = notification.get('emoji_reaction');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HotKeys handlers={this.getHandlers()}>
|
<HotKeys handlers={this.getHandlers()}>
|
||||||
<div className={classNames('notification notification-emoji_reaction focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.emojiReaction, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}>
|
<div className={classNames('notification notification-emoji_reaction focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.emojiReaction, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}>
|
||||||
<div className='notification__message'>
|
<div className='notification__message'>
|
||||||
<div className='notification__emoji_reaction-icon-wrapper'>
|
<div className='notification__emoji_reaction-icon-wrapper'>
|
||||||
<Icon id='star' className='star-icon' fixedWidth />
|
<EmojiView name={emoji_reaction.get('name')} url={emoji_reaction.get('url')} staticUrl={emoji_reaction.get('static_url')} className='star-icon' fixedWidth />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span title={notification.get('created_at')}>
|
<span title={notification.get('created_at')}>
|
||||||
|
|
|
@ -50,6 +50,7 @@ const notificationToMap = notification => ImmutableMap({
|
||||||
id: notification.id,
|
id: notification.id,
|
||||||
type: notification.type,
|
type: notification.type,
|
||||||
account: notification.account.id,
|
account: notification.account.id,
|
||||||
|
emoji_reaction: ImmutableMap(notification.emoji_reaction),
|
||||||
created_at: notification.created_at,
|
created_at: notification.created_at,
|
||||||
status: notification.status ? notification.status.id : null,
|
status: notification.status ? notification.status.id : null,
|
||||||
report: notification.report ? fromJS(notification.report) : null,
|
report: notification.report ? fromJS(notification.report) : null,
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class REST::EmojiReactionSerializer < ActiveModel::Serializer
|
class REST::EmojiReactionSerializer < ActiveModel::Serializer
|
||||||
attributes :name, :count
|
attributes :name
|
||||||
|
|
||||||
|
attribute :count, if: :count?
|
||||||
attribute :url, if: :custom_emoji?
|
attribute :url, if: :custom_emoji?
|
||||||
attribute :static_url, if: :custom_emoji?
|
attribute :static_url, if: :custom_emoji?
|
||||||
attribute :domain, if: :custom_emoji?
|
attribute :domain, if: :custom_emoji?
|
||||||
attribute :account_ids, if: :account_ids?
|
attribute :account_ids, if: :account_ids?
|
||||||
|
|
||||||
|
def count?
|
||||||
|
object.respond_to?(:count)
|
||||||
|
end
|
||||||
|
|
||||||
def custom_emoji?
|
def custom_emoji?
|
||||||
object.url.present?
|
object.respond_to?(:url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_ids?
|
def account_ids?
|
||||||
|
|
|
@ -6,6 +6,7 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
||||||
belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
|
belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
|
||||||
belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
|
belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
|
||||||
belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer
|
belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer
|
||||||
|
belongs_to :emoji_reaction, if: :emoji_reaction_type?, serializer: REST::EmojiReactionSerializer
|
||||||
|
|
||||||
def id
|
def id
|
||||||
object.id.to_s
|
object.id.to_s
|
||||||
|
@ -18,4 +19,8 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
||||||
def report_type?
|
def report_type?
|
||||||
object.type == :'admin.report'
|
object.type == :'admin.report'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def emoji_reaction_type?
|
||||||
|
object.type == :emoji_reaction
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue