Merge remote-tracking branch 'origin/kb_development' into kb_migration
This commit is contained in:
commit
3d53a47905
20 changed files with 63 additions and 16 deletions
|
@ -277,7 +277,7 @@ export function uploadCompose(files) {
|
|||
dispatch(uploadComposeRequest());
|
||||
|
||||
for (const [i, file] of Array.from(files).entries()) {
|
||||
if (media.size + i > 3) break;
|
||||
if (media.size + i >= 4) break;
|
||||
|
||||
const data = new FormData();
|
||||
data.append('file', file);
|
||||
|
|
|
@ -66,7 +66,7 @@ export function normalizeStatus(status, normalOldStatus) {
|
|||
normalStatus.filtered = status.filtered.map(normalizeFilterResult);
|
||||
}
|
||||
|
||||
if (status.emoji_reactions && normalOldStatus) {
|
||||
if (status.emoji_reactions && normalOldStatus && normalOldStatus.get('emoji_reactions')) {
|
||||
normalStatus.emoji_reactions = normalizeEmojiReactions(normalOldStatus.get('emoji_reactions').toArray());
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import { is } from 'immutable';
|
|||
import IconButton from './icon_button';
|
||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||
import classNames from 'classnames';
|
||||
import { autoPlayGif, cropImages, displayMedia, useBlurhash } from '../initial_state';
|
||||
import { autoPlayGif, cropImages, displayMedia, displayMediaExpand, useBlurhash } from '../initial_state';
|
||||
import { debounce } from 'lodash';
|
||||
import Blurhash from 'mastodon/components/blurhash';
|
||||
|
||||
|
@ -96,6 +96,16 @@ class Item extends React.PureComponent {
|
|||
height = 50;
|
||||
}
|
||||
|
||||
if (size === 5 || size === 6) {
|
||||
height = 33;
|
||||
}
|
||||
if (size === 7 || size === 8) {
|
||||
height = 25;
|
||||
}
|
||||
if ((size === 5 && index === 4) || (size === 7 && index === 6)) {
|
||||
width = 100;
|
||||
}
|
||||
|
||||
if (size === 2) {
|
||||
if (index === 0) {
|
||||
right = '2px';
|
||||
|
@ -128,6 +138,21 @@ class Item extends React.PureComponent {
|
|||
} else {
|
||||
top = '2px';
|
||||
}
|
||||
} else {
|
||||
if (index % 2 === 0) {
|
||||
right = '2px';
|
||||
}
|
||||
|
||||
if (index % 2 === 1) {
|
||||
left = '2px';
|
||||
}
|
||||
|
||||
if (index >= 2) {
|
||||
top = '2px';
|
||||
}
|
||||
if (index < size - 1) {
|
||||
bottom = '2px';
|
||||
}
|
||||
}
|
||||
|
||||
let thumbnail = '';
|
||||
|
@ -331,13 +356,16 @@ class MediaGallery extends React.PureComponent {
|
|||
style.height = height;
|
||||
}
|
||||
|
||||
const size = media.take(4).size;
|
||||
const maxSize = displayMediaExpand ? 8 : 4;
|
||||
console.log(displayMediaExpand);
|
||||
|
||||
const size = media.take(maxSize).size;
|
||||
const uncached = media.every(attachment => attachment.get('type') === 'unknown');
|
||||
|
||||
if (standalone && this.isFullSizeEligible()) {
|
||||
children = <Item standalone autoplay={autoplay} onClick={this.handleClick} attachment={media.get(0)} lang={lang} displayWidth={width} visible={visible} />;
|
||||
} else {
|
||||
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} autoplay={autoplay} onClick={this.handleClick} attachment={attachment} index={i} lang={lang} size={size} displayWidth={width} visible={visible || uncached} />);
|
||||
children = media.take(maxSize).map((attachment, i) => <Item key={attachment.get('id')} autoplay={autoplay} onClick={this.handleClick} attachment={attachment} index={i} lang={lang} size={size} displayWidth={width} visible={visible || uncached} />);
|
||||
}
|
||||
|
||||
if (uncached) {
|
||||
|
|
|
@ -3,7 +3,7 @@ import UploadButton from '../components/upload_button';
|
|||
import { uploadCompose } from '../../../actions/compose';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size + state.getIn(['compose', 'pending_media_attachments']) > 3 || state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')))),
|
||||
disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size + state.getIn(['compose', 'pending_media_attachments']) >= 4 || state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')))),
|
||||
unavailable: state.getIn(['compose', 'poll']) !== null,
|
||||
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
||||
});
|
||||
|
|
|
@ -42,6 +42,7 @@ const messages = defineMessages({
|
|||
unmute: { id: 'account.unmute', defaultMessage: 'Unmute @{name}' },
|
||||
unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
|
||||
openOriginalPage: { id: 'account.open_original_page', defaultMessage: 'Open original page' },
|
||||
pickEmoji: { id: 'status.emoji_reaction.pick', defaultMessage: 'Pick emoji' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, { status }) => ({
|
||||
|
@ -268,7 +269,7 @@ class ActionBar extends React.PureComponent {
|
|||
);
|
||||
|
||||
const emojiPickerButton = (
|
||||
<IconButton icon='smile-o' onClick={this.handleEmojiPickInnerButton} />
|
||||
<IconButton icon='smile-o' onClick={this.handleEmojiPickInnerButton} title={intl.formatMessage(messages.pickEmoji)} />
|
||||
);
|
||||
|
||||
let replyIcon;
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
* @property {boolean=} disable_swiping
|
||||
* @property {string=} disabled_account_id
|
||||
* @property {string} display_media
|
||||
* @property {boolean} display_media_expand
|
||||
* @property {string} domain
|
||||
* @property {boolean=} expand_spoilers
|
||||
* @property {boolean} limited_federation_mode
|
||||
|
@ -108,6 +109,7 @@ export const deleteModal = getMeta('delete_modal');
|
|||
export const disableSwiping = getMeta('disable_swiping');
|
||||
export const disabledAccountId = getMeta('disabled_account_id');
|
||||
export const displayMedia = getMeta('display_media');
|
||||
export const displayMediaExpand = getMeta('display_media_expand');
|
||||
export const domain = getMeta('domain');
|
||||
export const expandSpoilers = getMeta('expand_spoilers');
|
||||
export const forceSingleColumn = !getMeta('advanced_layout');
|
||||
|
|
|
@ -131,7 +131,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
searchability: searchability,
|
||||
thread: replied_to_status,
|
||||
conversation: conversation_from_uri(@object['conversation']),
|
||||
media_attachment_ids: process_attachments.take(4).map(&:id),
|
||||
media_attachment_ids: process_attachments.take(MediaAttachment::ACTIVITYPUB_STATUS_ATTACHMENT_MAX).map(&:id),
|
||||
poll: process_poll,
|
||||
}
|
||||
end
|
||||
|
@ -263,7 +263,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
as_array(@object['attachment']).each do |attachment|
|
||||
media_attachment_parser = ActivityPub::Parser::MediaAttachmentParser.new(attachment)
|
||||
|
||||
next if media_attachment_parser.remote_url.blank? || media_attachments.size >= 4
|
||||
next if media_attachment_parser.remote_url.blank? || media_attachments.size >= MediaAttachment::ACTIVITYPUB_STATUS_ATTACHMENT_MAX
|
||||
|
||||
begin
|
||||
media_attachment = MediaAttachment.create(
|
||||
|
|
|
@ -59,6 +59,10 @@ module HasUserSettings
|
|||
settings['web.display_media']
|
||||
end
|
||||
|
||||
def setting_display_media_expand
|
||||
settings['web.display_media_expand']
|
||||
end
|
||||
|
||||
def setting_expand_spoilers
|
||||
settings['web.expand_content_warnings']
|
||||
end
|
||||
|
|
|
@ -35,6 +35,9 @@ class MediaAttachment < ApplicationRecord
|
|||
include Attachmentable
|
||||
include RoutingHelper
|
||||
|
||||
LOCAL_STATUS_ATTACHMENT_MAX = 4
|
||||
ACTIVITYPUB_STATUS_ATTACHMENT_MAX = 8
|
||||
|
||||
enum type: { :image => 0, :gifv => 1, :video => 2, :unknown => 3, :audio => 4 }
|
||||
enum processing: { :queued => 0, :in_progress => 1, :complete => 2, :failed => 3 }, _prefix: true
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ class UserSettings
|
|||
setting :reduce_motion, default: false
|
||||
setting :expand_content_warnings, default: false
|
||||
setting :display_media, default: 'default', in: %w(default show_all hide_all)
|
||||
setting :display_media_expand, default: false
|
||||
setting :auto_play, default: false
|
||||
end
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
|||
store[:delete_modal] = object.current_account.user.setting_delete_modal
|
||||
store[:auto_play_gif] = object.current_account.user.setting_auto_play_gif
|
||||
store[:display_media] = object.current_account.user.setting_display_media
|
||||
store[:display_media_expand]=object.current_account.user.setting_display_media_expand
|
||||
store[:expand_spoilers] = object.current_account.user.setting_expand_spoilers
|
||||
store[:reduce_motion] = object.current_account.user.setting_reduce_motion
|
||||
store[:disable_swiping] = object.current_account.user.setting_disable_swiping
|
||||
|
|
|
@ -54,7 +54,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||
|
||||
statuses: {
|
||||
max_characters: StatusLengthValidator::MAX_CHARS,
|
||||
max_media_attachments: 4,
|
||||
max_media_attachments: MediaAttachment::LOCAL_STATUS_ATTACHMENT_MAX,
|
||||
characters_reserved_per_url: StatusLengthValidator::URL_PLACEHOLDER_CHARS,
|
||||
},
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
|||
|
||||
statuses: {
|
||||
max_characters: StatusLengthValidator::MAX_CHARS,
|
||||
max_media_attachments: 4,
|
||||
max_media_attachments: MediaAttachment::LOCAL_STATUS_ATTACHMENT_MAX,
|
||||
characters_reserved_per_url: StatusLengthValidator::URL_PLACEHOLDER_CHARS,
|
||||
},
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||
as_array(@json['attachment']).each do |attachment|
|
||||
media_attachment_parser = ActivityPub::Parser::MediaAttachmentParser.new(attachment)
|
||||
|
||||
next if media_attachment_parser.remote_url.blank? || @next_media_attachments.size > 4
|
||||
next if media_attachment_parser.remote_url.blank? || @next_media_attachments.size > MediaAttachment::ACTIVITYPUB_STATUS_ATTACHMENT_MAX
|
||||
|
||||
begin
|
||||
media_attachment = previous_media_attachments.find { |previous_media_attachment| previous_media_attachment.remote_url == media_attachment_parser.remote_url }
|
||||
|
|
|
@ -150,9 +150,9 @@ class PostStatusService < BaseService
|
|||
return
|
||||
end
|
||||
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 || @options[:poll].present?
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > MediaAttachment::LOCAL_STATUS_ATTACHMENT_MAX || @options[:poll].present?
|
||||
|
||||
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i))
|
||||
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(MediaAttachment::LOCAL_STATUS_ATTACHMENT_MAX).map(&:to_i))
|
||||
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if @media.size > 1 && @media.find(&:audio_or_video?)
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_ready') if @media.any?(&:not_processed?)
|
||||
|
|
|
@ -71,9 +71,9 @@ class UpdateStatusService < BaseService
|
|||
def validate_media!
|
||||
return [] if @options[:media_ids].blank? || !@options[:media_ids].is_a?(Enumerable)
|
||||
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 || @options[:poll].present?
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > MediaAttachment::LOCAL_STATUS_ATTACHMENT_MAX || @options[:poll].present?
|
||||
|
||||
media_attachments = @status.account.media_attachments.where(status_id: [nil, @status.id]).where(scheduled_status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i)).to_a
|
||||
media_attachments = @status.account.media_attachments.where(status_id: [nil, @status.id]).where(scheduled_status_id: nil).where(id: @options[:media_ids].take(MediaAttachment::LOCAL_STATUS_ATTACHMENT_MAX).map(&:to_i)).to_a
|
||||
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if media_attachments.size > 1 && media_attachments.find(&:audio_or_video?)
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_ready') if media_attachments.any?(&:not_processed?)
|
||||
|
|
|
@ -56,6 +56,9 @@
|
|||
.fields-group
|
||||
= ff.input :'web.display_media', collection: ['default', 'show_all', 'hide_all'],label_method: lambda { |item| t("simple_form.hints.defaults.setting_display_media_#{item}") }, hint: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label, label: I18n.t('simple_form.labels.defaults.setting_display_media')
|
||||
|
||||
.fields-group
|
||||
= ff.input :'web.display_media_expand', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_display_media_expand'), hint: I18n.t('simple_form.hints.defaults.setting_display_media_expand')
|
||||
|
||||
.fields-group
|
||||
= ff.input :'web.use_blurhash', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_use_blurhash'), hint: I18n.t('simple_form.hints.defaults.setting_use_blurhash')
|
||||
|
||||
|
|
|
@ -212,6 +212,7 @@ en:
|
|||
setting_disable_swiping: Disable swiping motions
|
||||
setting_display_media: Media display
|
||||
setting_display_media_default: Default
|
||||
setting_display_media_expand: Show more medias
|
||||
setting_display_media_hide_all: Hide all
|
||||
setting_display_media_show_all: Show all
|
||||
setting_expand_spoilers: Always expand posts marked with content warnings
|
||||
|
|
|
@ -58,6 +58,7 @@ ja:
|
|||
setting_display_media_hide_all: メディアを常に隠す
|
||||
setting_display_media_show_all: メディアを常に表示する
|
||||
setting_hide_network: フォローとフォロワーの情報がプロフィールページで見られないようにします
|
||||
setting_display_media_expand: Misskeyなどは4個を超えて投稿可能です。その追加分を最大8個まで表示します。kmyblueからアップロードはできません
|
||||
setting_noindex: 公開プロフィールおよび各投稿ページに影響します
|
||||
setting_show_application: 投稿するのに使用したアプリが投稿の詳細ビューに表示されるようになります
|
||||
setting_use_blurhash: ぼかしはメディアの色を元に生成されますが、細部は見えにくくなっています
|
||||
|
@ -212,6 +213,7 @@ ja:
|
|||
setting_disable_swiping: スワイプでの切り替えを無効にする
|
||||
setting_display_media: メディアの表示
|
||||
setting_display_media_default: 標準
|
||||
setting_display_media_expand: 5個目以降のメディアも表示する (最大8)
|
||||
setting_display_media_hide_all: 非表示
|
||||
setting_display_media_show_all: 表示
|
||||
setting_expand_spoilers: 閲覧注意としてマークされた投稿を常に展開する
|
||||
|
|
|
@ -16,6 +16,7 @@ class MoveUserSettings < ActiveRecord::Migration[6.1]
|
|||
delete_modal: 'web.delete_modal',
|
||||
auto_play_gif: 'web.auto_play',
|
||||
display_media: 'web.display_media',
|
||||
display_media_expand: 'web.display_media_expand',
|
||||
expand_spoilers: 'web.expand_content_warnings',
|
||||
reduce_motion: 'web.reduce_motion',
|
||||
disable_swiping: 'web.disable_swiping',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue