mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-29 10:49:04 +01:00
Update emoji reaction patches
This commit is contained in:
parent
48cfb27b7c
commit
8eff35ad53
9 changed files with 41 additions and 27 deletions
|
@ -119,7 +119,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
||||||
|
|
||||||
handleEmojiPick = data => {
|
handleEmojiPick = data => {
|
||||||
this.props.onReactionAdd(this.props.status.get('id'), data.native.replace(/:/g, ''), data.imageUrl);
|
this.props.onReactionAdd(this.props.status.get('id'), data.native.replace(/:/g, ''), data.imageUrl);
|
||||||
}
|
};
|
||||||
|
|
||||||
handleReblogClick = e => {
|
handleReblogClick = e => {
|
||||||
const { signedIn } = this.context.identity;
|
const { signedIn } = this.context.identity;
|
||||||
|
@ -202,7 +202,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
||||||
this.props.onAddFilter(this.props.status);
|
this.props.onAddFilter(this.props.status);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleNoOp = () => {} // hack for reaction add button
|
handleNoOp = () => {}; // hack for reaction add button
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { status, intl, withDismiss, withCounters, showReplyCount, scrollKey } = this.props;
|
const { status, intl, withDismiss, withCounters, showReplyCount, scrollKey } = this.props;
|
||||||
|
@ -332,7 +332,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
||||||
<IconButton className={classNames('status__action-bar-button', { reblogPrivate })} disabled={!publicStatus && !reblogPrivate} active={status.get('reblogged')} title={reblogTitle} icon={reblogIcon} onClick={this.handleReblogClick} counter={withCounters ? status.get('reblogs_count') : undefined} />
|
<IconButton className={classNames('status__action-bar-button', { reblogPrivate })} disabled={!publicStatus && !reblogPrivate} active={status.get('reblogged')} title={reblogTitle} icon={reblogIcon} onClick={this.handleReblogClick} counter={withCounters ? status.get('reblogs_count') : undefined} />
|
||||||
<IconButton className='status__action-bar-button star-icon' animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} counter={withCounters ? status.get('favourites_count') : undefined} />
|
<IconButton className='status__action-bar-button star-icon' animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} counter={withCounters ? status.get('favourites_count') : undefined} />
|
||||||
{
|
{
|
||||||
signedIn
|
permissions
|
||||||
? <EmojiPickerDropdown className='status__action-bar-button' onPickEmoji={this.handleEmojiPick} button={reactButton} disabled={!canReact} />
|
? <EmojiPickerDropdown className='status__action-bar-button' onPickEmoji={this.handleEmojiPick} button={reactButton} disabled={!canReact} />
|
||||||
: reactButton
|
: reactButton
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,7 +390,7 @@ class EmojiPickerDropdown extends React.PureComponent {
|
||||||
/>}
|
/>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Overlay show={active} placement={'bottom'} target={this.findTarget} popperConfig={{ strategy: 'fixed' }}>
|
<Overlay show={active} placement={'bottom'} flip target={this.findTarget} popperConfig={{ strategy: 'fixed' }}>
|
||||||
{({ props, placement })=> (
|
{({ props, placement })=> (
|
||||||
<div {...props} style={{ ...props.style, width: 299 }}>
|
<div {...props} style={{ ...props.style, width: 299 }}>
|
||||||
<div className={`dropdown-animation ${placement}`}>
|
<div className={`dropdown-animation ${placement}`}>
|
||||||
|
|
|
@ -304,11 +304,11 @@ class Status extends ImmutablePureComponent {
|
||||||
if (signedIn) {
|
if (signedIn) {
|
||||||
dispatch(addReaction(statusId, name, url));
|
dispatch(addReaction(statusId, name, url));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
handleReactionRemove = (statusId, name) => {
|
handleReactionRemove = (statusId, name) => {
|
||||||
this.props.dispatch(removeReaction(statusId, name));
|
this.props.dispatch(removeReaction(statusId, name));
|
||||||
}
|
};
|
||||||
|
|
||||||
handlePin = (status) => {
|
handlePin = (status) => {
|
||||||
if (status.get('pinned')) {
|
if (status.get('pinned')) {
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
"keyboard_shortcuts.bookmark": "to bookmark",
|
"keyboard_shortcuts.bookmark": "to bookmark",
|
||||||
"keyboard_shortcuts.secondary_toot": "to send toot using secondary privacy setting",
|
"keyboard_shortcuts.secondary_toot": "to send toot using secondary privacy setting",
|
||||||
"keyboard_shortcuts.toggle_collapse": "to collapse/uncollapse toots",
|
"keyboard_shortcuts.toggle_collapse": "to collapse/uncollapse toots",
|
||||||
|
"tooltips.reactions": "Reactions",
|
||||||
"layout.auto": "Auto",
|
"layout.auto": "Auto",
|
||||||
"layout.desktop": "Desktop",
|
"layout.desktop": "Desktop",
|
||||||
"layout.hint.auto": "Automatically chose layout based on “Enable advanced web interface” setting and screen size.",
|
"layout.hint.auto": "Automatically chose layout based on “Enable advanced web interface” setting and screen size.",
|
||||||
|
@ -74,6 +75,8 @@
|
||||||
"navigation_bar.keyboard_shortcuts": "Keyboard shortcuts",
|
"navigation_bar.keyboard_shortcuts": "Keyboard shortcuts",
|
||||||
"navigation_bar.misc": "Misc",
|
"navigation_bar.misc": "Misc",
|
||||||
"notification.markForDeletion": "Mark for deletion",
|
"notification.markForDeletion": "Mark for deletion",
|
||||||
|
"notification.reaction": "{name} reacted to your post",
|
||||||
|
"notifications.column_settings.reaction": "Reactions:",
|
||||||
"notification_purge.btn_all": "Select\nall",
|
"notification_purge.btn_all": "Select\nall",
|
||||||
"notification_purge.btn_apply": "Clear\nselected",
|
"notification_purge.btn_apply": "Clear\nselected",
|
||||||
"notification_purge.btn_invert": "Invert\nselection",
|
"notification_purge.btn_invert": "Invert\nselection",
|
||||||
|
@ -135,6 +138,7 @@
|
||||||
"settings.deprecated_setting": "This setting is now controlled from Mastodon's {settings_page_link}",
|
"settings.deprecated_setting": "This setting is now controlled from Mastodon's {settings_page_link}",
|
||||||
"settings.enable_collapsed": "Enable collapsed toots",
|
"settings.enable_collapsed": "Enable collapsed toots",
|
||||||
"settings.enable_collapsed_hint": "Collapsed posts have parts of their contents hidden to take up less screen space. This is distinct from the Content Warning feature",
|
"settings.enable_collapsed_hint": "Collapsed posts have parts of their contents hidden to take up less screen space. This is distinct from the Content Warning feature",
|
||||||
|
"settings.enter_amount_prompt": "Enter an amount",
|
||||||
"settings.enable_content_warnings_auto_unfold": "Automatically unfold content-warnings",
|
"settings.enable_content_warnings_auto_unfold": "Automatically unfold content-warnings",
|
||||||
"settings.general": "General",
|
"settings.general": "General",
|
||||||
"settings.hicolor_privacy_icons": "High color privacy icons",
|
"settings.hicolor_privacy_icons": "High color privacy icons",
|
||||||
|
@ -148,6 +152,7 @@
|
||||||
"settings.layout_opts": "Layout options",
|
"settings.layout_opts": "Layout options",
|
||||||
"settings.media": "Media",
|
"settings.media": "Media",
|
||||||
"settings.media_fullwidth": "Full-width media previews",
|
"settings.media_fullwidth": "Full-width media previews",
|
||||||
|
"settings.num_visible_reactions": "Number of visible reactions",
|
||||||
"settings.media_letterbox": "Letterbox media",
|
"settings.media_letterbox": "Letterbox media",
|
||||||
"settings.media_letterbox_hint": "Scale down and letterbox media to fill the image containers instead of stretching and cropping them",
|
"settings.media_letterbox_hint": "Scale down and letterbox media to fill the image containers instead of stretching and cropping them",
|
||||||
"settings.media_reveal_behind_cw": "Reveal sensitive media behind a CW by default",
|
"settings.media_reveal_behind_cw": "Reveal sensitive media behind a CW by default",
|
||||||
|
@ -190,6 +195,7 @@
|
||||||
"settings.wide_view": "Wide view (Desktop mode only)",
|
"settings.wide_view": "Wide view (Desktop mode only)",
|
||||||
"settings.wide_view_hint": "Stretches columns to better fill the available space.",
|
"settings.wide_view_hint": "Stretches columns to better fill the available space.",
|
||||||
"status.collapse": "Collapse",
|
"status.collapse": "Collapse",
|
||||||
|
"status.react": "React",
|
||||||
"status.has_audio": "Features attached audio files",
|
"status.has_audio": "Features attached audio files",
|
||||||
"status.has_pictures": "Features attached pictures",
|
"status.has_pictures": "Features attached pictures",
|
||||||
"status.has_preview_card": "Features an attached preview card",
|
"status.has_preview_card": "Features an attached preview card",
|
||||||
|
|
|
@ -20,13 +20,13 @@ class Notification < ApplicationRecord
|
||||||
include Paginable
|
include Paginable
|
||||||
|
|
||||||
LEGACY_TYPE_CLASS_MAP = {
|
LEGACY_TYPE_CLASS_MAP = {
|
||||||
'Mention' => :mention,
|
'Mention' => :mention,
|
||||||
'Status' => :reblog,
|
'Status' => :reblog,
|
||||||
'Follow' => :follow,
|
'Follow' => :follow,
|
||||||
'FollowRequest' => :follow_request,
|
'FollowRequest' => :follow_request,
|
||||||
'Favourite' => :favourite,
|
'Favourite' => :favourite,
|
||||||
'StatusReaction' => :reaction,
|
'StatusReaction' => :reaction,
|
||||||
'Poll' => :poll,
|
'Poll' => :poll,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
TYPES = %i(
|
TYPES = %i(
|
||||||
|
|
|
@ -3,19 +3,21 @@
|
||||||
class UnreactService < BaseService
|
class UnreactService < BaseService
|
||||||
include Payloadable
|
include Payloadable
|
||||||
|
|
||||||
def call(account, status, name)
|
def call(account, status, emoji)
|
||||||
reaction = StatusReaction.find_by(account: account, status: status, name: name)
|
name, domain = emoji.split('@')
|
||||||
return if reaction.nil?
|
custom_emoji = CustomEmoji.find_by(shortcode: name, domain: domain)
|
||||||
|
reaction = StatusReaction.find_by(account: account, status: status, name: name, custom_emoji: custom_emoji)
|
||||||
|
return if reaction.nil?
|
||||||
|
|
||||||
reaction.destroy!
|
reaction.destroy!
|
||||||
|
|
||||||
json = Oj.dump(serialize_payload(reaction, ActivityPub::UndoEmojiReactionSerializer))
|
json = Oj.dump(serialize_payload(reaction, ActivityPub::UndoEmojiReactionSerializer))
|
||||||
if status.account.local?
|
if status.account.local?
|
||||||
ActivityPub::RawDistributionWorker.perform_async(json, status.account.id)
|
ActivityPub::RawDistributionWorker.perform_async(json, status.account.id)
|
||||||
else
|
else
|
||||||
ActivityPub::DeliveryWorker.perform_async(json, reaction.account_id, status.account.inbox_url)
|
ActivityPub::DeliveryWorker.perform_async(json, reaction.account_id, status.account.inbox_url)
|
||||||
|
end
|
||||||
|
|
||||||
|
reaction
|
||||||
end
|
end
|
||||||
|
|
||||||
reaction
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,3 +45,8 @@ en:
|
||||||
body: "%{name} reacted to your post:"
|
body: "%{name} reacted to your post:"
|
||||||
subject: "%{name} reacted to your post"
|
subject: "%{name} reacted to your post"
|
||||||
title: New reaction
|
title: New reaction
|
||||||
|
notification_mailer:
|
||||||
|
reaction:
|
||||||
|
body: "%{name} reacted to your post:"
|
||||||
|
subject: "%{name} reacted to your post"
|
||||||
|
title: New reaction
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
class CreateStatusReactions < ActiveRecord::Migration[6.1]
|
class CreateStatusReactions < ActiveRecord::Migration[6.1]
|
||||||
def change
|
def change
|
||||||
create_table :status_reactions do |t|
|
create_table :status_reactions do |t|
|
||||||
t.references :account, null: false, foreign_key: true
|
t.references :account, null: false, foreign_key: { on_delete: :cascade }
|
||||||
t.references :status, null: false, foreign_key: true
|
t.references :status, null: false, foreign_key: { on_delete: :cascade }
|
||||||
t.string :name, null: false, default: ''
|
t.string :name, null: false, default: ''
|
||||||
t.references :custom_emoji, null: true, foreign_key: true
|
t.references :custom_emoji, null: true, foreign_key: { on_delete: :cascade }
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@ class FixForeignKeysStatusReactions < ActiveRecord::Migration[6.1]
|
||||||
disable_ddl_transaction!
|
disable_ddl_transaction!
|
||||||
|
|
||||||
def change
|
def change
|
||||||
|
# Fixes an oversight in a previous version of the CreateStatusReactions migration
|
||||||
remove_foreign_key :status_reactions, :accounts
|
remove_foreign_key :status_reactions, :accounts
|
||||||
add_foreign_key :status_reactions, :accounts, on_delete: :cascade, validate: false
|
add_foreign_key :status_reactions, :accounts, on_delete: :cascade, validate: false
|
||||||
validate_foreign_key :status_reactions, :accounts
|
validate_foreign_key :status_reactions, :accounts
|
||||||
|
|
Loading…
Reference in a new issue