Merge commit '71db616fed
' into kb_migration
This commit is contained in:
commit
f18fa97f0c
607 changed files with 3491 additions and 2677 deletions
|
@ -21,7 +21,7 @@ class Api::V1::BookmarksController < Api::BaseController
|
|||
end
|
||||
|
||||
def results
|
||||
@_results ||= account_bookmarks.joins(:status).eager_load(:status).to_a_paginated_by_id(
|
||||
@results ||= account_bookmarks.joins(:status).eager_load(:status).to_a_paginated_by_id(
|
||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||
params_slice(:max_id, :since_id, :min_id)
|
||||
)
|
||||
|
|
|
@ -21,7 +21,7 @@ class Api::V1::FavouritesController < Api::BaseController
|
|||
end
|
||||
|
||||
def results
|
||||
@_results ||= account_favourites.joins(:status).eager_load(:status).to_a_paginated_by_id(
|
||||
@results ||= account_favourites.joins(:status).eager_load(:status).to_a_paginated_by_id(
|
||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||
params_slice(:max_id, :since_id, :min_id)
|
||||
)
|
||||
|
|
|
@ -7,7 +7,10 @@ class Api::V1::MarkersController < Api::BaseController
|
|||
before_action :require_user!
|
||||
|
||||
def index
|
||||
@markers = current_user.markers.where(timeline: Array(params[:timeline])).index_by(&:timeline)
|
||||
with_read_replica do
|
||||
@markers = current_user.markers.where(timeline: Array(params[:timeline])).index_by(&:timeline)
|
||||
end
|
||||
|
||||
render json: serialize_map(@markers)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,8 +9,12 @@ class Api::V1::NotificationsController < Api::BaseController
|
|||
DEFAULT_NOTIFICATIONS_LIMIT = 40
|
||||
|
||||
def index
|
||||
@notifications = load_notifications
|
||||
render json: @notifications, each_serializer: REST::NotificationSerializer, relationships: StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id)
|
||||
with_read_replica do
|
||||
@notifications = load_notifications
|
||||
@relationships = StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id)
|
||||
end
|
||||
|
||||
render json: @notifications, each_serializer: REST::NotificationSerializer, relationships: @relationships
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -23,6 +23,6 @@ class Api::V1::ReportsController < Api::BaseController
|
|||
end
|
||||
|
||||
def report_params
|
||||
params.permit(:account_id, :comment, :category, :forward, status_ids: [], rule_ids: [])
|
||||
params.permit(:account_id, :comment, :category, :forward, forward_to_domains: [], status_ids: [], rule_ids: [])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,11 +6,14 @@ class Api::V1::Timelines::HomeController < Api::BaseController
|
|||
after_action :insert_pagination_headers, unless: -> { @statuses.empty? }
|
||||
|
||||
def show
|
||||
@statuses = load_statuses
|
||||
with_read_replica do
|
||||
@statuses = load_statuses
|
||||
@relationships = StatusRelationshipsPresenter.new(@statuses, current_user&.account_id)
|
||||
end
|
||||
|
||||
render json: @statuses,
|
||||
each_serializer: REST::StatusSerializer,
|
||||
relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id),
|
||||
relationships: @relationships,
|
||||
status: account_home_feed.regenerating? ? 206 : 200
|
||||
end
|
||||
|
||||
|
|
|
@ -1,25 +1,36 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::Web::EmbedsController < Api::Web::BaseController
|
||||
before_action :require_user!
|
||||
include Authorization
|
||||
|
||||
def create
|
||||
status = StatusFinder.new(params[:url]).status
|
||||
before_action :set_status
|
||||
|
||||
return not_found if status.hidden?
|
||||
def show
|
||||
return not_found if @status.hidden?
|
||||
|
||||
render json: status, serializer: OEmbedSerializer, width: 400
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
oembed = FetchOEmbedService.new.call(params[:url])
|
||||
if @status.local?
|
||||
render json: @status, serializer: OEmbedSerializer, width: 400
|
||||
else
|
||||
return not_found unless user_signed_in?
|
||||
|
||||
return not_found if oembed.nil?
|
||||
url = ActivityPub::TagManager.instance.url_for(@status)
|
||||
oembed = FetchOEmbedService.new.call(url)
|
||||
return not_found if oembed.nil?
|
||||
|
||||
begin
|
||||
oembed[:html] = Sanitize.fragment(oembed[:html], Sanitize::Config::MASTODON_OEMBED)
|
||||
rescue ArgumentError
|
||||
return not_found
|
||||
begin
|
||||
oembed[:html] = Sanitize.fragment(oembed[:html], Sanitize::Config::MASTODON_OEMBED)
|
||||
rescue ArgumentError
|
||||
return not_found
|
||||
end
|
||||
|
||||
render json: oembed
|
||||
end
|
||||
end
|
||||
|
||||
render json: oembed
|
||||
def set_status
|
||||
@status = Status.find(params[:id])
|
||||
authorize @status, :show?
|
||||
rescue Mastodon::NotPermittedError
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,7 @@ class ApplicationController < ActionController::Base
|
|||
include SessionTrackingConcern
|
||||
include CacheConcern
|
||||
include DomainControlHelper
|
||||
include DatabaseHelper
|
||||
|
||||
helper_method :current_account
|
||||
helper_method :current_session
|
||||
|
|
|
@ -124,7 +124,7 @@ class Auth::SessionsController < Devise::SessionsController
|
|||
redirect_to new_user_session_path, alert: I18n.t('devise.failure.timeout')
|
||||
end
|
||||
|
||||
def set_attempt_session(user)
|
||||
def register_attempt_in_session(user)
|
||||
session[:attempt_user_id] = user.id
|
||||
session[:attempt_user_updated_at] = user.updated_at.to_s
|
||||
end
|
||||
|
|
|
@ -61,7 +61,7 @@ module RateLimitHeaders
|
|||
end
|
||||
|
||||
def request_time
|
||||
@_request_time ||= Time.now.utc
|
||||
@request_time ||= Time.now.utc
|
||||
end
|
||||
|
||||
def reset_period_offset
|
||||
|
|
|
@ -75,7 +75,7 @@ module TwoFactorAuthenticationConcern
|
|||
end
|
||||
|
||||
def prompt_for_two_factor(user)
|
||||
set_attempt_session(user)
|
||||
register_attempt_in_session(user)
|
||||
|
||||
@body_classes = 'lighter'
|
||||
@webauthn_enabled = user.webauthn_enabled?
|
||||
|
|
11
app/helpers/database_helper.rb
Normal file
11
app/helpers/database_helper.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DatabaseHelper
|
||||
def with_read_replica(&block)
|
||||
ApplicationRecord.connected_to(role: :read, prevent_writes: true, &block)
|
||||
end
|
||||
|
||||
def with_primary(&block)
|
||||
ApplicationRecord.connected_to(role: :primary, &block)
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module DomainControlHelper
|
||||
def domain_not_allowed?(uri_or_domain)
|
||||
return if uri_or_domain.blank?
|
||||
return false if uri_or_domain.blank?
|
||||
|
||||
domain = if uri_or_domain.include?('://')
|
||||
Addressable::URI.parse(uri_or_domain).host
|
||||
|
|
|
@ -12,52 +12,48 @@ export const ALERT_DISMISS = 'ALERT_DISMISS';
|
|||
export const ALERT_CLEAR = 'ALERT_CLEAR';
|
||||
export const ALERT_NOOP = 'ALERT_NOOP';
|
||||
|
||||
export function dismissAlert(alert) {
|
||||
return {
|
||||
type: ALERT_DISMISS,
|
||||
alert,
|
||||
};
|
||||
}
|
||||
export const dismissAlert = alert => ({
|
||||
type: ALERT_DISMISS,
|
||||
alert,
|
||||
});
|
||||
|
||||
export function clearAlert() {
|
||||
return {
|
||||
type: ALERT_CLEAR,
|
||||
};
|
||||
}
|
||||
export const clearAlert = () => ({
|
||||
type: ALERT_CLEAR,
|
||||
});
|
||||
|
||||
export function showAlert(title = messages.unexpectedTitle, message = messages.unexpectedMessage, message_values = undefined) {
|
||||
return {
|
||||
type: ALERT_SHOW,
|
||||
title,
|
||||
message,
|
||||
message_values,
|
||||
};
|
||||
}
|
||||
export const showAlert = alert => ({
|
||||
type: ALERT_SHOW,
|
||||
alert,
|
||||
});
|
||||
|
||||
export function showAlertForError(error, skipNotFound = false) {
|
||||
export const showAlertForError = (error, skipNotFound = false) => {
|
||||
if (error.response) {
|
||||
const { data, status, statusText, headers } = error.response;
|
||||
|
||||
// Skip these errors as they are reflected in the UI
|
||||
if (skipNotFound && (status === 404 || status === 410)) {
|
||||
// Skip these errors as they are reflected in the UI
|
||||
return { type: ALERT_NOOP };
|
||||
}
|
||||
|
||||
// Rate limit errors
|
||||
if (status === 429 && headers['x-ratelimit-reset']) {
|
||||
const reset_date = new Date(headers['x-ratelimit-reset']);
|
||||
return showAlert(messages.rateLimitedTitle, messages.rateLimitedMessage, { 'retry_time': reset_date });
|
||||
return showAlert({
|
||||
title: messages.rateLimitedTitle,
|
||||
message: messages.rateLimitedMessage,
|
||||
values: { 'retry_time': new Date(headers['x-ratelimit-reset']) },
|
||||
});
|
||||
}
|
||||
|
||||
let message = statusText;
|
||||
let title = `${status}`;
|
||||
|
||||
if (data.error) {
|
||||
message = data.error;
|
||||
}
|
||||
|
||||
return showAlert(title, message);
|
||||
} else {
|
||||
console.error(error);
|
||||
return showAlert();
|
||||
return showAlert({
|
||||
title: `${status}`,
|
||||
message: data.error || statusText,
|
||||
});
|
||||
}
|
||||
|
||||
console.error(error);
|
||||
|
||||
return showAlert({
|
||||
title: messages.unexpectedTitle,
|
||||
message: messages.unexpectedMessage,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -86,6 +86,8 @@ export const COMPOSE_FOCUS = 'COMPOSE_FOCUS';
|
|||
const messages = defineMessages({
|
||||
uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' },
|
||||
uploadErrorPoll: { id: 'upload_error.poll', defaultMessage: 'File upload not allowed with polls.' },
|
||||
open: { id: 'compose.published.open', defaultMessage: 'Open' },
|
||||
published: { id: 'compose.published.body', defaultMessage: 'Post published.' },
|
||||
});
|
||||
|
||||
export const ensureComposeIsVisible = (getState, routerHistory) => {
|
||||
|
@ -246,6 +248,13 @@ export function submitCompose(routerHistory) {
|
|||
insertIfOnline('public');
|
||||
insertIfOnline(`account:${response.data.account.id}`);
|
||||
}
|
||||
|
||||
dispatch(showAlert({
|
||||
message: messages.published,
|
||||
action: messages.open,
|
||||
dismissAfter: 10000,
|
||||
onClick: () => routerHistory.push(`/@${response.data.account.username}/${response.data.id}`),
|
||||
}));
|
||||
}).catch(function (error) {
|
||||
dispatch(submitComposeFail(error));
|
||||
});
|
||||
|
@ -275,13 +284,14 @@ export function submitComposeFail(error) {
|
|||
export function uploadCompose(files) {
|
||||
return function (dispatch, getState) {
|
||||
const uploadLimit = 4;
|
||||
const media = getState().getIn(['compose', 'media_attachments']);
|
||||
const pending = getState().getIn(['compose', 'pending_media_attachments']);
|
||||
const media = getState().getIn(['compose', 'media_attachments']);
|
||||
const pending = getState().getIn(['compose', 'pending_media_attachments']);
|
||||
const progress = new Array(files.length).fill(0);
|
||||
|
||||
let total = Array.from(files).reduce((a, v) => a + v.size, 0);
|
||||
|
||||
if (files.length + media.size + pending > uploadLimit) {
|
||||
dispatch(showAlert(undefined, messages.uploadErrorLimit));
|
||||
dispatch(showAlert({ message: messages.uploadErrorLimit }));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,10 +86,9 @@ const DIGIT_CHARACTERS = [
|
|||
|
||||
export const decode83 = (str: string) => {
|
||||
let value = 0;
|
||||
let c, digit;
|
||||
let digit;
|
||||
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
c = str[i];
|
||||
for (const c of str) {
|
||||
digit = DIGIT_CHARACTERS.indexOf(c);
|
||||
value = value * 83 + digit;
|
||||
}
|
||||
|
|
|
@ -8,15 +8,15 @@ import { Link } from 'react-router-dom';
|
|||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
|
||||
import { counterRenderer } from 'mastodon/components/common_counter';
|
||||
import { EmptyAccount } from 'mastodon/components/empty_account';
|
||||
import ShortNumber from 'mastodon/components/short_number';
|
||||
import { ShortNumber } from 'mastodon/components/short_number';
|
||||
import { VerifiedBadge } from 'mastodon/components/verified_badge';
|
||||
|
||||
import { me } from '../initial_state';
|
||||
|
||||
import { Avatar } from './avatar';
|
||||
import Button from './button';
|
||||
import { FollowersCounter } from './counters';
|
||||
import { DisplayName } from './display_name';
|
||||
import { IconButton } from './icon_button';
|
||||
import { RelativeTimestamp } from './relative_timestamp';
|
||||
|
@ -162,7 +162,7 @@ class Account extends ImmutablePureComponent {
|
|||
<DisplayName account={account} />
|
||||
{!minimal && (
|
||||
<div className='account__details'>
|
||||
<ShortNumber value={account.get('followers_count')} isHide={account.getIn(['other_settings', 'hide_followers_count']) || false} renderer={counterRenderer('followers')} /> {verification} {muteTimeRemaining}
|
||||
<ShortNumber value={account.get('followers_count')} isHide={account.getIn(['other_settings', 'hide_followers_count']) || false} renderer={FollowersCounter} /> {verification} {muteTimeRemaining}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -4,7 +4,7 @@ import { TransitionMotion, spring } from 'react-motion';
|
|||
|
||||
import { reduceMotion } from '../initial_state';
|
||||
|
||||
import ShortNumber from './short_number';
|
||||
import { ShortNumber } from './short_number';
|
||||
|
||||
const obfuscatedCount = (count: number) => {
|
||||
if (count < 0) {
|
||||
|
@ -32,7 +32,7 @@ export const AnimatedNumber: React.FC<Props> = ({ value, obfuscate }) => {
|
|||
const willEnter = useCallback(() => ({ y: -1 * direction }), [direction]);
|
||||
const willLeave = useCallback(
|
||||
() => ({ y: spring(1 * direction, { damping: 35, stiffness: 400 }) }),
|
||||
[direction]
|
||||
[direction],
|
||||
);
|
||||
|
||||
if (reduceMotion) {
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import ShortNumber from 'mastodon/components/short_number';
|
||||
import { ShortNumber } from 'mastodon/components/short_number';
|
||||
|
||||
interface Props {
|
||||
tag: {
|
||||
name: string;
|
||||
url?: string;
|
||||
history?: Array<{
|
||||
history?: {
|
||||
uses: number;
|
||||
accounts: string;
|
||||
day: string;
|
||||
}>;
|
||||
}[];
|
||||
following?: boolean;
|
||||
type: 'hashtag';
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ import type { Account } from '../../types/resources';
|
|||
import { autoPlayGif } from '../initial_state';
|
||||
|
||||
interface Props {
|
||||
account: Account;
|
||||
account: Account | undefined; // FIXME: remove `undefined` once we know for sure its always there
|
||||
size: number;
|
||||
style?: React.CSSProperties;
|
||||
inline?: boolean;
|
||||
|
|
|
@ -3,8 +3,8 @@ import type { Account } from '../../types/resources';
|
|||
import { autoPlayGif } from '../initial_state';
|
||||
|
||||
interface Props {
|
||||
account: Account;
|
||||
friend: Account;
|
||||
account: Account | undefined; // FIXME: remove `undefined` once we know for sure its always there
|
||||
friend: Account | undefined; // FIXME: remove `undefined` once we know for sure its always there
|
||||
size?: number;
|
||||
baseSize?: number;
|
||||
overlaySize?: number;
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
// @ts-check
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
/**
|
||||
* Returns custom renderer for one of the common counter types
|
||||
* @param {"statuses" | "following" | "followers"} counterType
|
||||
* Type of the counter
|
||||
* @param {boolean} isBold Whether display number must be displayed in bold
|
||||
* @returns {(displayNumber: JSX.Element, pluralReady: number) => JSX.Element}
|
||||
* Renderer function
|
||||
* @throws If counterType is not covered by this function
|
||||
*/
|
||||
export function counterRenderer(counterType, isBold = true) {
|
||||
/**
|
||||
* @type {(displayNumber: JSX.Element) => JSX.Element}
|
||||
*/
|
||||
const renderCounter = isBold
|
||||
? (displayNumber) => <strong>{displayNumber}</strong>
|
||||
: (displayNumber) => displayNumber;
|
||||
|
||||
switch (counterType) {
|
||||
case 'statuses': {
|
||||
return (displayNumber, pluralReady) => (
|
||||
<FormattedMessage
|
||||
id='account.statuses_counter'
|
||||
defaultMessage='{count, plural, one {{counter} Post} other {{counter} Posts}}'
|
||||
values={{
|
||||
count: pluralReady,
|
||||
counter: renderCounter(displayNumber),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case 'following': {
|
||||
return (displayNumber, pluralReady) => (
|
||||
<FormattedMessage
|
||||
id='account.following_counter'
|
||||
defaultMessage='{count, plural, one {{counter} Following} other {{counter} Following}}'
|
||||
values={{
|
||||
count: pluralReady,
|
||||
counter: renderCounter(displayNumber),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case 'followers': {
|
||||
return (displayNumber, pluralReady) => (
|
||||
<FormattedMessage
|
||||
id='account.followers_counter'
|
||||
defaultMessage='{count, plural, one {{counter} Follower} other {{counter} Followers}}'
|
||||
values={{
|
||||
count: pluralReady,
|
||||
counter: renderCounter(displayNumber),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
default: throw Error(`Incorrect counter name: ${counterType}. Ensure it accepted by commonCounter function`);
|
||||
}
|
||||
}
|
45
app/javascript/mastodon/components/counters.tsx
Normal file
45
app/javascript/mastodon/components/counters.tsx
Normal file
|
@ -0,0 +1,45 @@
|
|||
import React from 'react';
|
||||
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
export const StatusesCounter = (
|
||||
displayNumber: React.ReactNode,
|
||||
pluralReady: number,
|
||||
) => (
|
||||
<FormattedMessage
|
||||
id='account.statuses_counter'
|
||||
defaultMessage='{count, plural, one {{counter} Post} other {{counter} Posts}}'
|
||||
values={{
|
||||
count: pluralReady,
|
||||
counter: <strong>{displayNumber}</strong>,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
export const FollowingCounter = (
|
||||
displayNumber: React.ReactNode,
|
||||
pluralReady: number,
|
||||
) => (
|
||||
<FormattedMessage
|
||||
id='account.following_counter'
|
||||
defaultMessage='{count, plural, one {{counter} Following} other {{counter} Following}}'
|
||||
values={{
|
||||
count: pluralReady,
|
||||
counter: <strong>{displayNumber}</strong>,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
export const FollowersCounter = (
|
||||
displayNumber: React.ReactNode,
|
||||
pluralReady: number,
|
||||
) => (
|
||||
<FormattedMessage
|
||||
id='account.followers_counter'
|
||||
defaultMessage='{count, plural, one {{counter} Follower} other {{counter} Followers}}'
|
||||
values={{
|
||||
count: pluralReady,
|
||||
counter: <strong>{displayNumber}</strong>,
|
||||
}}
|
||||
/>
|
||||
);
|
|
@ -1,55 +0,0 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { PureComponent } from 'react';
|
||||
|
||||
import { injectIntl, defineMessages } from 'react-intl';
|
||||
|
||||
import { bannerSettings } from 'mastodon/settings';
|
||||
|
||||
import { IconButton } from './icon_button';
|
||||
|
||||
const messages = defineMessages({
|
||||
dismiss: { id: 'dismissable_banner.dismiss', defaultMessage: 'Dismiss' },
|
||||
});
|
||||
|
||||
class DismissableBanner extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
id: PropTypes.string.isRequired,
|
||||
children: PropTypes.node,
|
||||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
state = {
|
||||
visible: !bannerSettings.get(this.props.id),
|
||||
};
|
||||
|
||||
handleDismiss = () => {
|
||||
const { id } = this.props;
|
||||
this.setState({ visible: false }, () => bannerSettings.set(id, true));
|
||||
};
|
||||
|
||||
render () {
|
||||
const { visible } = this.state;
|
||||
|
||||
if (!visible) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { children, intl } = this.props;
|
||||
|
||||
return (
|
||||
<div className='dismissable-banner'>
|
||||
<div className='dismissable-banner__message'>
|
||||
{children}
|
||||
</div>
|
||||
|
||||
<div className='dismissable-banner__action'>
|
||||
<IconButton icon='times' title={intl.formatMessage(messages.dismiss)} onClick={this.handleDismiss} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default injectIntl(DismissableBanner);
|
47
app/javascript/mastodon/components/dismissable_banner.tsx
Normal file
47
app/javascript/mastodon/components/dismissable_banner.tsx
Normal file
|
@ -0,0 +1,47 @@
|
|||
import type { PropsWithChildren } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
import { bannerSettings } from 'mastodon/settings';
|
||||
|
||||
import { IconButton } from './icon_button';
|
||||
|
||||
const messages = defineMessages({
|
||||
dismiss: { id: 'dismissable_banner.dismiss', defaultMessage: 'Dismiss' },
|
||||
});
|
||||
|
||||
interface Props {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export const DismissableBanner: React.FC<PropsWithChildren<Props>> = ({
|
||||
id,
|
||||
children,
|
||||
}) => {
|
||||
const [visible, setVisible] = useState(!bannerSettings.get(id));
|
||||
const intl = useIntl();
|
||||
|
||||
const handleDismiss = useCallback(() => {
|
||||
setVisible(false);
|
||||
bannerSettings.set(id, true);
|
||||
}, [id]);
|
||||
|
||||
if (!visible) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='dismissable-banner'>
|
||||
<div className='dismissable-banner__message'>{children}</div>
|
||||
|
||||
<div className='dismissable-banner__action'>
|
||||
<IconButton
|
||||
icon='times'
|
||||
title={intl.formatMessage(messages.dismiss)}
|
||||
onClick={handleDismiss}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
|
@ -78,7 +78,7 @@ export class DisplayName extends React.PureComponent<Props> {
|
|||
} else if (account) {
|
||||
let acct = account.get('acct');
|
||||
|
||||
if (acct.indexOf('@') === -1 && localDomain) {
|
||||
if (!acct.includes('@') && localDomain) {
|
||||
acct = `${acct}@${localDomain}`;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ export const GIFV: React.FC<Props> = ({
|
|||
onClick();
|
||||
}
|
||||
},
|
||||
[onClick]
|
||||
[onClick],
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
|
@ -11,7 +11,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||
|
||||
import { Sparklines, SparklinesCurve } from 'react-sparklines';
|
||||
|
||||
import ShortNumber from 'mastodon/components/short_number';
|
||||
import { ShortNumber } from 'mastodon/components/short_number';
|
||||
import { Skeleton } from 'mastodon/components/skeleton';
|
||||
|
||||
class SilentErrorBoundary extends Component {
|
||||
|
|
|
@ -339,7 +339,10 @@ class MediaGallery extends PureComponent {
|
|||
if (uncached) {
|
||||
spoilerButton = (
|
||||
<button type='button' disabled className='spoiler-button__overlay'>
|
||||
<span className='spoiler-button__overlay__label'><FormattedMessage id='status.uncached_media_warning' defaultMessage='Not available' /></span>
|
||||
<span className='spoiler-button__overlay__label'>
|
||||
<FormattedMessage id='status.uncached_media_warning' defaultMessage='Preview not available' />
|
||||
<span className='spoiler-button__overlay__action'><FormattedMessage id='status.media.open' defaultMessage='Click to open' /></span>
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
} else if (visible) {
|
||||
|
@ -347,7 +350,10 @@ class MediaGallery extends PureComponent {
|
|||
} else {
|
||||
spoilerButton = (
|
||||
<button type='button' onClick={this.handleOpen} className='spoiler-button__overlay'>
|
||||
<span className='spoiler-button__overlay__label'>{sensitive ? <FormattedMessage id='status.sensitive_warning' defaultMessage='Sensitive content' /> : <FormattedMessage id='status.media_hidden' defaultMessage='Media hidden' />}</span>
|
||||
<span className='spoiler-button__overlay__label'>
|
||||
{sensitive ? <FormattedMessage id='status.sensitive_warning' defaultMessage='Sensitive content' /> : <FormattedMessage id='status.media_hidden' defaultMessage='Media hidden' />}
|
||||
<span className='spoiler-button__overlay__action'><FormattedMessage id='status.media.show' defaultMessage='Click to show' /></span>
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ export const timeAgoString = (
|
|||
now: number,
|
||||
year: number,
|
||||
timeGiven: boolean,
|
||||
short?: boolean
|
||||
short?: boolean,
|
||||
) => {
|
||||
const delta = now - date.getTime();
|
||||
|
||||
|
@ -118,28 +118,28 @@ export const timeAgoString = (
|
|||
relativeTime = intl.formatMessage(messages.today);
|
||||
} else if (delta < 10 * SECOND) {
|
||||
relativeTime = intl.formatMessage(
|
||||
short ? messages.just_now : messages.just_now_full
|
||||
short ? messages.just_now : messages.just_now_full,
|
||||
);
|
||||
} else if (delta < 7 * DAY) {
|
||||
if (delta < MINUTE) {
|
||||
relativeTime = intl.formatMessage(
|
||||
short ? messages.seconds : messages.seconds_full,
|
||||
{ number: Math.floor(delta / SECOND) }
|
||||
{ number: Math.floor(delta / SECOND) },
|
||||
);
|
||||
} else if (delta < HOUR) {
|
||||
relativeTime = intl.formatMessage(
|
||||
short ? messages.minutes : messages.minutes_full,
|
||||
{ number: Math.floor(delta / MINUTE) }
|
||||
{ number: Math.floor(delta / MINUTE) },
|
||||
);
|
||||
} else if (delta < DAY) {
|
||||
relativeTime = intl.formatMessage(
|
||||
short ? messages.hours : messages.hours_full,
|
||||
{ number: Math.floor(delta / HOUR) }
|
||||
{ number: Math.floor(delta / HOUR) },
|
||||
);
|
||||
} else {
|
||||
relativeTime = intl.formatMessage(
|
||||
short ? messages.days : messages.days_full,
|
||||
{ number: Math.floor(delta / DAY) }
|
||||
{ number: Math.floor(delta / DAY) },
|
||||
);
|
||||
}
|
||||
} else if (date.getFullYear() === year) {
|
||||
|
@ -158,7 +158,7 @@ const timeRemainingString = (
|
|||
intl: IntlShape,
|
||||
date: Date,
|
||||
now: number,
|
||||
timeGiven = true
|
||||
timeGiven = true,
|
||||
) => {
|
||||
const delta = date.getTime() - now;
|
||||
|
||||
|
|
23
app/javascript/mastodon/components/router.tsx
Normal file
23
app/javascript/mastodon/components/router.tsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
import type { PropsWithChildren } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import type { History } from 'history';
|
||||
import { createBrowserHistory } from 'history';
|
||||
import { Router as OriginalRouter } from 'react-router';
|
||||
|
||||
import { layoutFromWindow } from 'mastodon/is_mobile';
|
||||
|
||||
const browserHistory = createBrowserHistory();
|
||||
const originalPush = browserHistory.push.bind(browserHistory);
|
||||
|
||||
browserHistory.push = (path: string, state: History.LocationState) => {
|
||||
if (layoutFromWindow() === 'multi-column' && !path.startsWith('/deck')) {
|
||||
originalPush(`/deck${path}`, state);
|
||||
} else {
|
||||
originalPush(path, state);
|
||||
}
|
||||
};
|
||||
|
||||
export const Router: React.FC<PropsWithChildren> = ({ children }) => {
|
||||
return <OriginalRouter history={browserHistory}>{children}</OriginalRouter>;
|
||||
};
|
|
@ -9,7 +9,7 @@ import { connect } from 'react-redux';
|
|||
|
||||
import { fetchServer } from 'mastodon/actions/server';
|
||||
import { ServerHeroImage } from 'mastodon/components/server_hero_image';
|
||||
import ShortNumber from 'mastodon/components/short_number';
|
||||
import { ShortNumber } from 'mastodon/components/short_number';
|
||||
import { Skeleton } from 'mastodon/components/skeleton';
|
||||
import Account from 'mastodon/containers/account_container';
|
||||
import { domain } from 'mastodon/initial_state';
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { memo } from 'react';
|
||||
|
||||
import { FormattedMessage, FormattedNumber } from 'react-intl';
|
||||
|
||||
import { toShortNumber, pluralReady, DECIMAL_UNITS } from '../utils/numbers';
|
||||
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* @callback ShortNumberRenderer
|
||||
* @param {JSX.Element} displayNumber Number to display
|
||||
* @param {number} pluralReady Number used for pluralization
|
||||
* @returns {JSX.Element} Final render of number
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} ShortNumberProps
|
||||
* @property {number} value Number to display in short variant
|
||||
* @property {ShortNumberRenderer} [renderer]
|
||||
* Custom renderer for numbers, provided as a prop. If another renderer
|
||||
* passed as a child of this component, this prop won't be used.
|
||||
* @property {ShortNumberRenderer} [children]
|
||||
* Custom renderer for numbers, provided as a child. If another renderer
|
||||
* passed as a prop of this component, this one will be used instead.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Component that renders short big number to a shorter version
|
||||
* @param {ShortNumberProps} param0 Props for the component
|
||||
* @returns {JSX.Element} Rendered number
|
||||
*/
|
||||
function ShortNumber({ value, isHide, renderer, children }) {
|
||||
const shortNumber = toShortNumber(value);
|
||||
const [, division] = shortNumber;
|
||||
|
||||
if (children != null && renderer != null) {
|
||||
console.warn('Both renderer prop and renderer as a child provided. This is a mistake and you really should fix that. Only renderer passed as a child will be used.');
|
||||
}
|
||||
|
||||
const customRenderer = children != null ? children : renderer;
|
||||
|
||||
const displayNumber = !isHide ? <ShortNumberCounter value={shortNumber} /> : <span>-</span>;
|
||||
|
||||
return customRenderer != null
|
||||
? customRenderer(displayNumber, pluralReady(value, division))
|
||||
: displayNumber;
|
||||
}
|
||||
|
||||
ShortNumber.propTypes = {
|
||||
value: PropTypes.number.isRequired,
|
||||
isHide: PropTypes.bool,
|
||||
renderer: PropTypes.func,
|
||||
children: PropTypes.func,
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {object} ShortNumberCounterProps
|
||||
* @property {import('../utils/number').ShortNumber} value Short number
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders short number into corresponding localizable react fragment
|
||||
* @param {ShortNumberCounterProps} param0 Props for the component
|
||||
* @returns {JSX.Element} FormattedMessage ready to be embedded in code
|
||||
*/
|
||||
function ShortNumberCounter({ value }) {
|
||||
const [rawNumber, unit, maxFractionDigits = 0] = value;
|
||||
|
||||
const count = (
|
||||
<FormattedNumber
|
||||
value={rawNumber}
|
||||
maximumFractionDigits={maxFractionDigits}
|
||||
/>
|
||||
);
|
||||
|
||||
let values = { count, rawNumber };
|
||||
|
||||
switch (unit) {
|
||||
case DECIMAL_UNITS.THOUSAND: {
|
||||
return (
|
||||
<FormattedMessage
|
||||
id='units.short.thousand'
|
||||
defaultMessage='{count}K'
|
||||
values={values}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case DECIMAL_UNITS.MILLION: {
|
||||
return (
|
||||
<FormattedMessage
|
||||
id='units.short.million'
|
||||
defaultMessage='{count}M'
|
||||
values={values}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case DECIMAL_UNITS.BILLION: {
|
||||
return (
|
||||
<FormattedMessage
|
||||
id='units.short.billion'
|
||||
defaultMessage='{count}B'
|
||||
values={values}
|
||||
/>
|
||||
);
|
||||
}
|
||||
// Not sure if we should go farther - @Sasha-Sorokin
|
||||
default: return count;
|
||||
}
|
||||
}
|
||||
|
||||
ShortNumberCounter.propTypes = {
|
||||
value: PropTypes.arrayOf(PropTypes.number),
|
||||
};
|
||||
|
||||
export default memo(ShortNumber);
|
92
app/javascript/mastodon/components/short_number.tsx
Normal file
92
app/javascript/mastodon/components/short_number.tsx
Normal file
|
@ -0,0 +1,92 @@
|
|||
import { memo } from 'react';
|
||||
|
||||
import { FormattedMessage, FormattedNumber } from 'react-intl';
|
||||
|
||||
import { toShortNumber, pluralReady, DECIMAL_UNITS } from '../utils/numbers';
|
||||
|
||||
type ShortNumberRenderer = (
|
||||
displayNumber: JSX.Element,
|
||||
pluralReady: number,
|
||||
) => JSX.Element;
|
||||
|
||||
interface ShortNumberProps {
|
||||
value: number;
|
||||
isHide: boolean;
|
||||
renderer?: ShortNumberRenderer;
|
||||
children?: ShortNumberRenderer;
|
||||
}
|
||||
|
||||
export const ShortNumberRenderer: React.FC<ShortNumberProps> = ({
|
||||
value,
|
||||
isHide,
|
||||
renderer,
|
||||
children,
|
||||
}) => {
|
||||
const shortNumber = toShortNumber(value);
|
||||
const [, division] = shortNumber;
|
||||
|
||||
if (children && renderer) {
|
||||
console.warn(
|
||||
'Both renderer prop and renderer as a child provided. This is a mistake and you really should fix that. Only renderer passed as a child will be used.',
|
||||
);
|
||||
}
|
||||
|
||||
const customRenderer = children ?? renderer ?? null;
|
||||
|
||||
const displayNumber = !isHide ? <ShortNumberCounter value={shortNumber} /> : <span>-</span>;
|
||||
|
||||
return (
|
||||
customRenderer?.(displayNumber, pluralReady(value, division)) ??
|
||||
displayNumber
|
||||
);
|
||||
};
|
||||
export const ShortNumber = memo(ShortNumberRenderer);
|
||||
|
||||
interface ShortNumberCounterProps {
|
||||
value: number[];
|
||||
}
|
||||
const ShortNumberCounter: React.FC<ShortNumberCounterProps> = ({ value }) => {
|
||||
const [rawNumber, unit, maxFractionDigits = 0] = value;
|
||||
|
||||
const count = (
|
||||
<FormattedNumber
|
||||
value={rawNumber}
|
||||
maximumFractionDigits={maxFractionDigits}
|
||||
/>
|
||||
);
|
||||
|
||||
const values = { count, rawNumber };
|
||||
|
||||
switch (unit) {
|
||||
case DECIMAL_UNITS.THOUSAND: {
|
||||
return (
|
||||
<FormattedMessage
|
||||
id='units.short.thousand'
|
||||
defaultMessage='{count}K'
|
||||
values={values}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case DECIMAL_UNITS.MILLION: {
|
||||
return (
|
||||
<FormattedMessage
|
||||
id='units.short.million'
|
||||
defaultMessage='{count}M'
|
||||
values={values}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case DECIMAL_UNITS.BILLION: {
|
||||
return (
|
||||
<FormattedMessage
|
||||
id='units.short.billion'
|
||||
defaultMessage='{count}B'
|
||||
values={values}
|
||||
/>
|
||||
);
|
||||
}
|
||||
// Not sure if we should go farther - @Sasha-Sorokin
|
||||
default:
|
||||
return count;
|
||||
}
|
||||
};
|
|
@ -264,7 +264,6 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
const { status, relationship, intl, withDismiss, withCounters, scrollKey } = this.props;
|
||||
const { signedIn, permissions } = this.context.identity;
|
||||
|
||||
const anonymousAccess = !signedIn;
|
||||
const publicStatus = ['public', 'unlisted', 'public_unlisted', 'login'].includes(status.get('visibility_ex'));
|
||||
const anonymousStatus = ['public', 'unlisted', 'public_unlisted'].includes(status.get('visibility_ex'));
|
||||
const pinnableStatus = ['public', 'unlisted', 'public_unlisted', 'login', 'private'].includes(status.get('visibility_ex'));
|
||||
|
@ -287,81 +286,83 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
menu.push({ text: intl.formatMessage(messages.share), action: this.handleShareClick });
|
||||
}
|
||||
|
||||
if (anonymousStatus) {
|
||||
if (anonymousStatus && (signedIn || !isRemote)) {
|
||||
menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed });
|
||||
}
|
||||
|
||||
menu.push(null);
|
||||
|
||||
menu.push({ text: intl.formatMessage(status.get('reblogged') ? messages.cancelReblog : messages.reblog), action: this.handleReblogForceModalClick });
|
||||
|
||||
if (publicStatus) {
|
||||
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(status.get('bookmarked') ? messages.removeBookmark : messages.bookmark), action: this.handleBookmarkClick });
|
||||
|
||||
if (writtenByMe && pinnableStatus) {
|
||||
menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick });
|
||||
}
|
||||
|
||||
menu.push(null);
|
||||
|
||||
if (writtenByMe || withDismiss) {
|
||||
menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick });
|
||||
menu.push(null);
|
||||
}
|
||||
|
||||
if (writtenByMe) {
|
||||
menu.push({ text: intl.formatMessage(messages.edit), action: this.handleEditClick });
|
||||
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick, dangerous: true });
|
||||
menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick, dangerous: true });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.mention, { name: account.get('username') }), action: this.handleMentionClick });
|
||||
menu.push({ text: intl.formatMessage(messages.direct, { name: account.get('username') }), action: this.handleDirectClick });
|
||||
if (signedIn) {
|
||||
menu.push(null);
|
||||
|
||||
if (relationship && relationship.get('muting')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.handleMuteClick });
|
||||
menu.push({ text: intl.formatMessage(status.get('reblogged') ? messages.cancelReblog : messages.reblog), action: this.handleReblogForceModalClick });
|
||||
|
||||
if (publicStatus) {
|
||||
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(status.get('bookmarked') ? messages.removeBookmark : messages.bookmark), action: this.handleBookmarkClick });
|
||||
|
||||
if (writtenByMe && pinnableStatus) {
|
||||
menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick });
|
||||
}
|
||||
|
||||
menu.push(null);
|
||||
|
||||
if (writtenByMe || withDismiss) {
|
||||
menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick });
|
||||
menu.push(null);
|
||||
}
|
||||
|
||||
if (writtenByMe) {
|
||||
menu.push({ text: intl.formatMessage(messages.edit), action: this.handleEditClick });
|
||||
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick, dangerous: true });
|
||||
menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick, dangerous: true });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick, dangerous: true });
|
||||
}
|
||||
|
||||
if (relationship && relationship.get('blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.handleBlockClick });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick, dangerous: true });
|
||||
}
|
||||
|
||||
if (!this.props.onFilter) {
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.filter), action: this.handleFilterClick, dangerous: true });
|
||||
menu.push(null);
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: account.get('username') }), action: this.handleReport, dangerous: true });
|
||||
|
||||
if (account.get('acct') !== account.get('username')) {
|
||||
const domain = account.get('acct').split('@')[1];
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.mention, { name: account.get('username') }), action: this.handleMentionClick });
|
||||
menu.push({ text: intl.formatMessage(messages.direct, { name: account.get('username') }), action: this.handleDirectClick });
|
||||
menu.push(null);
|
||||
|
||||
if (relationship && relationship.get('domain_blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblockDomain, { domain }), action: this.handleUnblockDomain });
|
||||
if (relationship && relationship.get('muting')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.handleMuteClick });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.blockDomain, { domain }), action: this.handleBlockDomain, dangerous: true });
|
||||
menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick, dangerous: true });
|
||||
}
|
||||
}
|
||||
|
||||
if ((permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS || (isRemote && (permissions & PERMISSION_MANAGE_FEDERATION) === PERMISSION_MANAGE_FEDERATION)) {
|
||||
menu.push(null);
|
||||
if ((permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS) {
|
||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: account.get('username') }), href: `/admin/accounts/${status.getIn(['account', 'id'])}` });
|
||||
menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
||||
if (relationship && relationship.get('blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.handleBlockClick });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick, dangerous: true });
|
||||
}
|
||||
if (isRemote && (permissions & PERMISSION_MANAGE_FEDERATION) === PERMISSION_MANAGE_FEDERATION) {
|
||||
|
||||
if (!this.props.onFilter) {
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.filter), action: this.handleFilterClick, dangerous: true });
|
||||
menu.push(null);
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: account.get('username') }), action: this.handleReport, dangerous: true });
|
||||
|
||||
if (account.get('acct') !== account.get('username')) {
|
||||
const domain = account.get('acct').split('@')[1];
|
||||
menu.push({ text: intl.formatMessage(messages.admin_domain, { domain: domain }), href: `/admin/instances/${domain}` });
|
||||
|
||||
menu.push(null);
|
||||
|
||||
if (relationship && relationship.get('domain_blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblockDomain, { domain }), action: this.handleUnblockDomain });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.blockDomain, { domain }), action: this.handleBlockDomain, dangerous: true });
|
||||
}
|
||||
}
|
||||
|
||||
if ((permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS || (isRemote && (permissions & PERMISSION_MANAGE_FEDERATION) === PERMISSION_MANAGE_FEDERATION)) {
|
||||
menu.push(null);
|
||||
if ((permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS) {
|
||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: account.get('username') }), href: `/admin/accounts/${status.getIn(['account', 'id'])}` });
|
||||
menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
||||
}
|
||||
if (isRemote && (permissions & PERMISSION_MANAGE_FEDERATION) === PERMISSION_MANAGE_FEDERATION) {
|
||||
const domain = account.get('acct').split('@')[1];
|
||||
menu.push({ text: intl.formatMessage(messages.admin_domain, { domain: domain }), href: `/admin/instances/${domain}` });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -410,7 +411,6 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
<div className='status__action-bar__dropdown'>
|
||||
<DropdownMenuContainer
|
||||
scrollKey={scrollKey}
|
||||
disabled={anonymousAccess}
|
||||
status={status}
|
||||
items={menu}
|
||||
icon='ellipsis-h'
|
||||
|
|
|
@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
|
|||
import { PureComponent } from 'react';
|
||||
|
||||
import { Helmet } from 'react-helmet';
|
||||
import { BrowserRouter, Route } from 'react-router-dom';
|
||||
import { Route } from 'react-router-dom';
|
||||
|
||||
import { Provider as ReduxProvider } from 'react-redux';
|
||||
|
||||
|
@ -13,6 +13,7 @@ import { fetchReactionDeck } from 'mastodon/actions/reaction_deck';
|
|||
import { hydrateStore } from 'mastodon/actions/store';
|
||||
import { connectUserStream } from 'mastodon/actions/streaming';
|
||||
import ErrorBoundary from 'mastodon/components/error_boundary';
|
||||
import { Router } from 'mastodon/components/router';
|
||||
import UI from 'mastodon/features/ui';
|
||||
import initialState, { title as siteTitle } from 'mastodon/initial_state';
|
||||
import { IntlProvider } from 'mastodon/locales';
|
||||
|
@ -77,11 +78,11 @@ export default class Mastodon extends PureComponent {
|
|||
<IntlProvider>
|
||||
<ReduxProvider store={store}>
|
||||
<ErrorBoundary>
|
||||
<BrowserRouter>
|
||||
<Router>
|
||||
<ScrollContext shouldUpdateScroll={this.shouldUpdateScroll}>
|
||||
<Route path='/' component={UI} />
|
||||
</ScrollContext>
|
||||
</BrowserRouter>
|
||||
</Router>
|
||||
|
||||
<Helmet defaultTitle={title} titleTemplate={`%s - ${title}`} />
|
||||
</ErrorBoundary>
|
||||
|
|
|
@ -154,7 +154,7 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
|
|||
dispatch(openModal({
|
||||
modalType: 'EMBED',
|
||||
modalProps: {
|
||||
url: status.get('url'),
|
||||
id: status.get('id'),
|
||||
onError: error => dispatch(showAlertForError(error)),
|
||||
},
|
||||
}));
|
||||
|
|
|
@ -11,10 +11,10 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
|||
|
||||
import { Avatar } from 'mastodon/components/avatar';
|
||||
import Button from 'mastodon/components/button';
|
||||
import { counterRenderer } from 'mastodon/components/common_counter';
|
||||
import { FollowersCounter, FollowingCounter, StatusesCounter } from 'mastodon/components/counters';
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
import { IconButton } from 'mastodon/components/icon_button';
|
||||
import ShortNumber from 'mastodon/components/short_number';
|
||||
import { ShortNumber } from 'mastodon/components/short_number';
|
||||
import DropdownMenuContainer from 'mastodon/containers/dropdown_menu_container';
|
||||
import { autoPlayGif, me, domain } from 'mastodon/initial_state';
|
||||
import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'mastodon/permissions';
|
||||
|
@ -266,14 +266,14 @@ class Header extends ImmutablePureComponent {
|
|||
if (signedIn && !account.get('relationship')) { // Wait until the relationship is loaded
|
||||
actionBtn = '';
|
||||
} else if (account.getIn(['relationship', 'requested'])) {
|
||||
actionBtn = <Button className={classNames('logo-button', { 'button--with-bell': bellBtn !== '' })} text={intl.formatMessage(messages.cancel_follow_request)} title={intl.formatMessage(messages.requested)} onClick={this.props.onFollow} />;
|
||||
actionBtn = <Button className={classNames({ 'button--with-bell': bellBtn !== '' })} text={intl.formatMessage(messages.cancel_follow_request)} title={intl.formatMessage(messages.requested)} onClick={this.props.onFollow} />;
|
||||
} else if (!account.getIn(['relationship', 'blocking'])) {
|
||||
actionBtn = <Button disabled={account.getIn(['relationship', 'blocked_by'])} className={classNames('logo-button', { 'button--destructive': account.getIn(['relationship', 'following']), 'button--with-bell': bellBtn !== '' })} text={intl.formatMessage(account.getIn(['relationship', 'following']) ? messages.unfollow : messages.follow)} onClick={signedIn ? this.props.onFollow : this.props.onInteractionModal} />;
|
||||
actionBtn = <Button disabled={account.getIn(['relationship', 'blocked_by'])} className={classNames({ 'button--destructive': account.getIn(['relationship', 'following']), 'button--with-bell': bellBtn !== '' })} text={intl.formatMessage(account.getIn(['relationship', 'following']) ? messages.unfollow : messages.follow)} onClick={signedIn ? this.props.onFollow : this.props.onInteractionModal} />;
|
||||
} else if (account.getIn(['relationship', 'blocking'])) {
|
||||
actionBtn = <Button className='logo-button' text={intl.formatMessage(messages.unblock, { name: account.get('username') })} onClick={this.props.onBlock} />;
|
||||
actionBtn = <Button text={intl.formatMessage(messages.unblock, { name: account.get('username') })} onClick={this.props.onBlock} />;
|
||||
}
|
||||
} else {
|
||||
actionBtn = <Button className='logo-button' text={intl.formatMessage(messages.edit_profile)} onClick={this.openEditProfile} />;
|
||||
actionBtn = <Button text={intl.formatMessage(messages.edit_profile)} onClick={this.openEditProfile} />;
|
||||
}
|
||||
|
||||
if (account.get('moved') && !account.getIn(['relationship', 'following'])) {
|
||||
|
@ -292,7 +292,6 @@ class Header extends ImmutablePureComponent {
|
|||
|
||||
if (isRemote) {
|
||||
menu.push({ text: intl.formatMessage(messages.openOriginalPage), href: account.get('url') });
|
||||
menu.push(null);
|
||||
}
|
||||
|
||||
if ('share' in navigator) {
|
||||
|
@ -455,7 +454,7 @@ class Header extends ImmutablePureComponent {
|
|||
<ShortNumber
|
||||
value={account.get('statuses_count')}
|
||||
isHide={account.getIn(['other_settings', 'hide_statuses_count']) || false}
|
||||
renderer={counterRenderer('statuses')}
|
||||
renderer={StatusesCounter}
|
||||
/>
|
||||
</NavLink>
|
||||
|
||||
|
@ -463,7 +462,7 @@ class Header extends ImmutablePureComponent {
|
|||
<ShortNumber
|
||||
value={account.get('following_count')}
|
||||
isHide={account.getIn(['other_settings', 'hide_following_count']) || false}
|
||||
renderer={counterRenderer('following')}
|
||||
renderer={FollowingCounter}
|
||||
/>
|
||||
</NavLink>
|
||||
|
||||
|
@ -471,7 +470,7 @@ class Header extends ImmutablePureComponent {
|
|||
<ShortNumber
|
||||
value={account.get('followers_count')}
|
||||
isHide={account.getIn(['other_settings', 'hide_followers_count']) || false}
|
||||
renderer={counterRenderer('followers')}
|
||||
renderer={FollowersCounter}
|
||||
/>
|
||||
</NavLink>
|
||||
</div>
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Helmet } from 'react-helmet';
|
|||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
||||
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
|
||||
import { domain } from 'mastodon/initial_state';
|
||||
|
||||
import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
|
||||
|
|
|
@ -19,7 +19,7 @@ import { openModal } from 'mastodon/actions/modal';
|
|||
import { Avatar } from 'mastodon/components/avatar';
|
||||
import Button from 'mastodon/components/button';
|
||||
import { DisplayName } from 'mastodon/components/display_name';
|
||||
import ShortNumber from 'mastodon/components/short_number';
|
||||
import { ShortNumber } from 'mastodon/components/short_number';
|
||||
import { autoPlayGif, me, unfollowModal } from 'mastodon/initial_state';
|
||||
import { makeGetAccount } from 'mastodon/selectors';
|
||||
|
||||
|
@ -160,16 +160,16 @@ class AccountCard extends ImmutablePureComponent {
|
|||
if (!account.get('relationship')) { // Wait until the relationship is loaded
|
||||
actionBtn = '';
|
||||
} else if (account.getIn(['relationship', 'requested'])) {
|
||||
actionBtn = <Button className={classNames('logo-button')} text={intl.formatMessage(messages.cancel_follow_request)} title={intl.formatMessage(messages.requested)} onClick={this.handleFollow} />;
|
||||
actionBtn = <Button text={intl.formatMessage(messages.cancel_follow_request)} title={intl.formatMessage(messages.requested)} onClick={this.handleFollow} />;
|
||||
} else if (account.getIn(['relationship', 'muting'])) {
|
||||
actionBtn = <Button className='logo-button' text={intl.formatMessage(messages.unmute)} onClick={this.handleMute} />;
|
||||
actionBtn = <Button text={intl.formatMessage(messages.unmute)} onClick={this.handleMute} />;
|
||||
} else if (!account.getIn(['relationship', 'blocking'])) {
|
||||
actionBtn = <Button disabled={account.getIn(['relationship', 'blocked_by'])} className={classNames('logo-button', { 'button--destructive': account.getIn(['relationship', 'following']) })} text={intl.formatMessage(account.getIn(['relationship', 'following']) ? messages.unfollow : messages.follow)} onClick={this.handleFollow} />;
|
||||
actionBtn = <Button disabled={account.getIn(['relationship', 'blocked_by'])} className={classNames({ 'button--destructive': account.getIn(['relationship', 'following']) })} text={intl.formatMessage(account.getIn(['relationship', 'following']) ? messages.unfollow : messages.follow)} onClick={this.handleFollow} />;
|
||||
} else if (account.getIn(['relationship', 'blocking'])) {
|
||||
actionBtn = <Button className='logo-button' text={intl.formatMessage(messages.unblock)} onClick={this.handleBlock} />;
|
||||
actionBtn = <Button text={intl.formatMessage(messages.unblock)} onClick={this.handleBlock} />;
|
||||
}
|
||||
} else {
|
||||
actionBtn = <Button className='logo-button' text={intl.formatMessage(messages.edit_profile)} onClick={this.handleEditProfile} />;
|
||||
actionBtn = <Button text={intl.formatMessage(messages.edit_profile)} onClick={this.handleEditProfile} />;
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -25,12 +25,13 @@ export type SearchData = [
|
|||
BaseEmoji['native'],
|
||||
Emoji['short_names'],
|
||||
Search,
|
||||
Emoji['unified']
|
||||
Emoji['unified'],
|
||||
];
|
||||
|
||||
export interface ShortCodesToEmojiData {
|
||||
[key: ShortCodesToEmojiDataKey]: [FilenameData, SearchData];
|
||||
}
|
||||
export type ShortCodesToEmojiData = Record<
|
||||
ShortCodesToEmojiDataKey,
|
||||
[FilenameData, SearchData]
|
||||
>;
|
||||
export type EmojisWithoutShortCodes = FilenameData[];
|
||||
|
||||
export type EmojiCompressed = [
|
||||
|
@ -38,7 +39,7 @@ export type EmojiCompressed = [
|
|||
Skins,
|
||||
Category[],
|
||||
Data['aliases'],
|
||||
EmojisWithoutShortCodes
|
||||
EmojisWithoutShortCodes,
|
||||
];
|
||||
|
||||
/*
|
||||
|
|
|
@ -9,7 +9,7 @@ import emojiCompressed from './emoji_compressed';
|
|||
import { unicodeToUnifiedName } from './unicode_to_unified_name';
|
||||
|
||||
type Emojis = {
|
||||
[key in keyof ShortCodesToEmojiData]: {
|
||||
[key in NonNullable<keyof ShortCodesToEmojiData>]: {
|
||||
native: BaseEmoji['native'];
|
||||
search: Search;
|
||||
short_names: Emoji['short_names'];
|
||||
|
|
|
@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|||
|
||||
import { Blurhash } from 'mastodon/components/blurhash';
|
||||
import { accountsCountRenderer } from 'mastodon/components/hashtag';
|
||||
import ShortNumber from 'mastodon/components/short_number';
|
||||
import { ShortNumber } from 'mastodon/components/short_number';
|
||||
import { Skeleton } from 'mastodon/components/skeleton';
|
||||
|
||||
export default class Story extends PureComponent {
|
||||
|
|
|
@ -11,7 +11,7 @@ import { connect } from 'react-redux';
|
|||
import Column from 'mastodon/components/column';
|
||||
import ColumnHeader from 'mastodon/components/column_header';
|
||||
import Search from 'mastodon/features/compose/containers/search_container';
|
||||
import { showTrends } from 'mastodon/initial_state';
|
||||
import { trendsEnabled } from 'mastodon/initial_state';
|
||||
|
||||
import Links from './links';
|
||||
import SearchResults from './results';
|
||||
|
@ -26,7 +26,7 @@ const messages = defineMessages({
|
|||
|
||||
const mapStateToProps = state => ({
|
||||
layout: state.getIn(['meta', 'layout']),
|
||||
isSearching: state.getIn(['search', 'submitted']) || !showTrends,
|
||||
isSearching: state.getIn(['search', 'submitted']) || !trendsEnabled,
|
||||
});
|
||||
|
||||
class Explore extends PureComponent {
|
||||
|
|
|
@ -7,7 +7,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||
import { connect } from 'react-redux';
|
||||
|
||||
import { fetchTrendingLinks } from 'mastodon/actions/trends';
|
||||
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
||||
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
|
||||
import { LoadingIndicator } from 'mastodon/components/loading_indicator';
|
||||
|
||||
import Story from './components/story';
|
||||
|
|
|
@ -9,7 +9,7 @@ import { connect } from 'react-redux';
|
|||
import { debounce } from 'lodash';
|
||||
|
||||
import { fetchTrendingStatuses, expandTrendingStatuses } from 'mastodon/actions/trends';
|
||||
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
||||
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
|
||||
import StatusList from 'mastodon/components/status_list';
|
||||
import { getStatusList } from 'mastodon/selectors';
|
||||
|
||||
|
@ -52,6 +52,7 @@ class Statuses extends PureComponent {
|
|||
|
||||
<StatusList
|
||||
trackScroll
|
||||
timelineId='explore'
|
||||
statusIds={statusIds}
|
||||
scrollKey='explore-statuses'
|
||||
hasMore={hasMore}
|
||||
|
|
|
@ -7,7 +7,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||
import { connect } from 'react-redux';
|
||||
|
||||
import { fetchTrendingHashtags } from 'mastodon/actions/trends';
|
||||
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
||||
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
|
||||
import { ImmutableHashtag as Hashtag } from 'mastodon/components/hashtag';
|
||||
import { LoadingIndicator } from 'mastodon/components/loading_indicator';
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { addColumn } from 'mastodon/actions/columns';
|
|||
import { changeSetting } from 'mastodon/actions/settings';
|
||||
import { connectPublicStream, connectCommunityStream } from 'mastodon/actions/streaming';
|
||||
import { expandPublicTimeline, expandCommunityTimeline } from 'mastodon/actions/timelines';
|
||||
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
||||
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
|
||||
import initialState, { domain } from 'mastodon/initial_state';
|
||||
import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ class GettingStarted extends ImmutablePureComponent {
|
|||
|
||||
{!multiColumn && <div className='flex-spacer' />}
|
||||
|
||||
<LinkFooter />
|
||||
<LinkFooter multiColumn />
|
||||
</div>
|
||||
|
||||
{(multiColumn && showTrends) && <TrendsContainer />}
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { PureComponent } from 'react';
|
||||
|
||||
import { injectIntl, FormattedMessage } from 'react-intl';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
|
||||
import SettingToggle from '../../notifications/components/setting_toggle';
|
||||
|
||||
class ColumnSettings extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
settings: ImmutablePropTypes.map.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
render () {
|
||||
const { settings, onChange } = this.props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<span className='column-settings__section'><FormattedMessage id='home.column_settings.basic' defaultMessage='Basic' /></span>
|
||||
|
||||
<div className='column-settings__row'>
|
||||
<SettingToggle prefix='home_timeline' settings={settings} settingPath={['shows', 'reblog']} onChange={onChange} label={<FormattedMessage id='home.column_settings.show_reblogs' defaultMessage='Show boosts' />} />
|
||||
</div>
|
||||
|
||||
<div className='column-settings__row'>
|
||||
<SettingToggle prefix='home_timeline' settings={settings} settingPath={['shows', 'reply']} onChange={onChange} label={<FormattedMessage id='home.column_settings.show_replies' defaultMessage='Show replies' />} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default injectIntl(ColumnSettings);
|
|
@ -0,0 +1,66 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-call,
|
||||
@typescript-eslint/no-unsafe-return,
|
||||
@typescript-eslint/no-unsafe-assignment,
|
||||
@typescript-eslint/no-unsafe-member-access
|
||||
-- the settings store is not yet typed */
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import { useAppSelector, useAppDispatch } from 'mastodon/store';
|
||||
|
||||
import { changeSetting } from '../../../actions/settings';
|
||||
import SettingToggle from '../../notifications/components/setting_toggle';
|
||||
|
||||
export const ColumnSettings: React.FC = () => {
|
||||
const settings = useAppSelector((state) => state.settings.get('home'));
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
const onChange = useCallback(
|
||||
(key: string, checked: boolean) => {
|
||||
dispatch(changeSetting(['home', ...key], checked));
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<span className='column-settings__section'>
|
||||
<FormattedMessage
|
||||
id='home.column_settings.basic'
|
||||
defaultMessage='Basic'
|
||||
/>
|
||||
</span>
|
||||
|
||||
<div className='column-settings__row'>
|
||||
<SettingToggle
|
||||
prefix='home_timeline'
|
||||
settings={settings}
|
||||
settingPath={['shows', 'reblog']}
|
||||
onChange={onChange}
|
||||
label={
|
||||
<FormattedMessage
|
||||
id='home.column_settings.show_reblogs'
|
||||
defaultMessage='Show boosts'
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='column-settings__row'>
|
||||
<SettingToggle
|
||||
prefix='home_timeline'
|
||||
settings={settings}
|
||||
settingPath={['shows', 'reply']}
|
||||
onChange={onChange}
|
||||
label={
|
||||
<FormattedMessage
|
||||
id='home.column_settings.show_replies'
|
||||
defaultMessage='Show replies'
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
|
@ -1,25 +0,0 @@
|
|||
import React from 'react';
|
||||
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import background from 'mastodon/../images/friends-cropped.png';
|
||||
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
||||
|
||||
|
||||
export const ExplorePrompt = () => (
|
||||
<DismissableBanner id='home.explore_prompt'>
|
||||
<img src={background} alt='' className='dismissable-banner__background-image' />
|
||||
|
||||
<h1><FormattedMessage id='home.explore_prompt.title' defaultMessage='This is your home base within Mastodon.' /></h1>
|
||||
<p><FormattedMessage id='home.explore_prompt.body' defaultMessage="Your home feed will have a mix of posts from the hashtags you've chosen to follow, the people you've chosen to follow, and the posts they boost. It's looking pretty quiet right now, so how about:" /></p>
|
||||
|
||||
<div className='dismissable-banner__message__actions__wrapper'>
|
||||
<div className='dismissable-banner__message__actions'>
|
||||
<Link to='/explore' className='button'><FormattedMessage id='home.actions.go_to_explore' defaultMessage="See what's trending" /></Link>
|
||||
<Link to='/explore/suggestions' className='button button-tertiary'><FormattedMessage id='home.actions.go_to_suggestions' defaultMessage='Find people to follow' /></Link>
|
||||
</div>
|
||||
</div>
|
||||
</DismissableBanner>
|
||||
);
|
|
@ -0,0 +1,46 @@
|
|||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import background from 'mastodon/../images/friends-cropped.png';
|
||||
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
|
||||
|
||||
export const ExplorePrompt = () => (
|
||||
<DismissableBanner id='home.explore_prompt'>
|
||||
<img
|
||||
src={background}
|
||||
alt=''
|
||||
className='dismissable-banner__background-image'
|
||||
/>
|
||||
|
||||
<h1>
|
||||
<FormattedMessage
|
||||
id='home.explore_prompt.title'
|
||||
defaultMessage='This is your home base within Mastodon.'
|
||||
/>
|
||||
</h1>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id='home.explore_prompt.body'
|
||||
defaultMessage="Your home feed will have a mix of posts from the hashtags you've chosen to follow, the people you've chosen to follow, and the posts they boost. It's looking pretty quiet right now, so how about:"
|
||||
/>
|
||||
</p>
|
||||
|
||||
<div className='dismissable-banner__message__wrapper'>
|
||||
<div className='dismissable-banner__message__actions'>
|
||||
<Link to='/explore' className='button'>
|
||||
<FormattedMessage
|
||||
id='home.actions.go_to_explore'
|
||||
defaultMessage="See what's trending"
|
||||
/>
|
||||
</Link>
|
||||
<Link to='/explore/suggestions' className='button button-tertiary'>
|
||||
<FormattedMessage
|
||||
id='home.actions.go_to_suggestions'
|
||||
defaultMessage='Find people to follow'
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</DismissableBanner>
|
||||
);
|
|
@ -1,22 +0,0 @@
|
|||
import { connect } from 'react-redux';
|
||||
|
||||
import { changeSetting, saveSettings } from '../../../actions/settings';
|
||||
import ColumnSettings from '../components/column_settings';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
settings: state.getIn(['settings', 'home']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
||||
onChange (key, checked) {
|
||||
dispatch(changeSetting(['home', ...key], checked));
|
||||
},
|
||||
|
||||
onSave () {
|
||||
dispatch(saveSettings());
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings);
|
|
@ -22,8 +22,8 @@ import Column from '../../components/column';
|
|||
import ColumnHeader from '../../components/column_header';
|
||||
import StatusListContainer from '../ui/containers/status_list_container';
|
||||
|
||||
import { ColumnSettings } from './components/column_settings';
|
||||
import { ExplorePrompt } from './components/explore_prompt';
|
||||
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'column.home', defaultMessage: 'Home' },
|
||||
|
@ -191,7 +191,7 @@ class HomeTimeline extends PureComponent {
|
|||
extraButton={announcementsButton}
|
||||
appendContent={hasAnnouncements && showAnnouncements && <AnnouncementsContainer />}
|
||||
>
|
||||
<ColumnSettingsContainer />
|
||||
<ColumnSettings />
|
||||
</ColumnHeader>
|
||||
|
||||
{signedIn ? (
|
||||
|
|
|
@ -32,7 +32,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||
if (permission === 'granted') {
|
||||
dispatch(changePushNotifications(path.slice(1), checked));
|
||||
} else {
|
||||
dispatch(showAlert(undefined, messages.permissionDenied));
|
||||
dispatch(showAlert({ message: messages.permissionDenied }));
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
|
@ -47,7 +47,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||
if (permission === 'granted') {
|
||||
dispatch(changeSetting(['notifications', ...path], checked));
|
||||
} else {
|
||||
dispatch(showAlert(undefined, messages.permissionDenied));
|
||||
dispatch(showAlert({ message: messages.permissionDenied }));
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Helmet } from 'react-helmet';
|
|||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
||||
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
|
||||
import { domain } from 'mastodon/initial_state';
|
||||
|
||||
import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
|
||||
|
|
|
@ -1,87 +1,121 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { PureComponent } from 'react';
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
|
||||
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
|
||||
import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
|
||||
|
||||
import { OrderedSet, List as ImmutableList } from 'immutable';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { shallowEqual } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
import Toggle from 'react-toggle';
|
||||
|
||||
import { fetchAccount } from 'mastodon/actions/accounts';
|
||||
import Button from 'mastodon/components/button';
|
||||
import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
||||
|
||||
const messages = defineMessages({
|
||||
placeholder: { id: 'report.placeholder', defaultMessage: 'Type or paste additional comments' },
|
||||
});
|
||||
|
||||
class Comment extends PureComponent {
|
||||
const selectRepliedToAccountIds = createSelector(
|
||||
[
|
||||
(state) => state.get('statuses'),
|
||||
(_, statusIds) => statusIds,
|
||||
],
|
||||
(statusesMap, statusIds) => statusIds.map((statusId) => statusesMap.getIn([statusId, 'in_reply_to_account_id'])),
|
||||
{
|
||||
resultEqualityCheck: shallowEqual,
|
||||
}
|
||||
);
|
||||
|
||||
static propTypes = {
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
comment: PropTypes.string.isRequired,
|
||||
onChangeComment: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
isSubmitting: PropTypes.bool,
|
||||
forward: PropTypes.bool,
|
||||
isRemote: PropTypes.bool,
|
||||
domain: PropTypes.string,
|
||||
onChangeForward: PropTypes.func.isRequired,
|
||||
};
|
||||
const Comment = ({ comment, domain, statusIds, isRemote, isSubmitting, selectedDomains, onSubmit, onChangeComment, onToggleDomain }) => {
|
||||
const intl = useIntl();
|
||||
|
||||
handleClick = () => {
|
||||
const { onSubmit } = this.props;
|
||||
onSubmit();
|
||||
};
|
||||
const dispatch = useAppDispatch();
|
||||
const loadedRef = useRef(false);
|
||||
|
||||
handleChange = e => {
|
||||
const { onChangeComment } = this.props;
|
||||
onChangeComment(e.target.value);
|
||||
};
|
||||
const handleClick = useCallback(() => onSubmit(), [onSubmit]);
|
||||
const handleChange = useCallback((e) => onChangeComment(e.target.value), [onChangeComment]);
|
||||
const handleToggleDomain = useCallback(e => onToggleDomain(e.target.value, e.target.checked), [onToggleDomain]);
|
||||
|
||||
handleKeyDown = e => {
|
||||
const handleKeyDown = useCallback((e) => {
|
||||
if (e.keyCode === 13 && (e.ctrlKey || e.metaKey)) {
|
||||
this.handleClick();
|
||||
handleClick();
|
||||
}
|
||||
};
|
||||
}, [handleClick]);
|
||||
|
||||
handleForwardChange = e => {
|
||||
const { onChangeForward } = this.props;
|
||||
onChangeForward(e.target.checked);
|
||||
};
|
||||
// Memoize accountIds since we don't want it to trigger `useEffect` on each render
|
||||
const accountIds = useAppSelector((state) => domain ? selectRepliedToAccountIds(state, statusIds) : ImmutableList());
|
||||
|
||||
render () {
|
||||
const { comment, isRemote, forward, domain, isSubmitting, intl } = this.props;
|
||||
// While we could memoize `availableDomains`, it is pretty inexpensive to recompute
|
||||
const accountsMap = useAppSelector((state) => state.get('accounts'));
|
||||
const availableDomains = domain ? OrderedSet([domain]).union(accountIds.map((accountId) => accountsMap.getIn([accountId, 'acct'], '').split('@')[1]).filter(domain => !!domain)) : OrderedSet();
|
||||
|
||||
return (
|
||||
<>
|
||||
<h3 className='report-dialog-modal__title'><FormattedMessage id='report.comment.title' defaultMessage='Is there anything else you think we should know?' /></h3>
|
||||
useEffect(() => {
|
||||
if (loadedRef.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
<textarea
|
||||
className='report-dialog-modal__textarea'
|
||||
placeholder={intl.formatMessage(messages.placeholder)}
|
||||
value={comment}
|
||||
onChange={this.handleChange}
|
||||
onKeyDown={this.handleKeyDown}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
loadedRef.current = true;
|
||||
|
||||
{isRemote && (
|
||||
<>
|
||||
<p className='report-dialog-modal__lead'><FormattedMessage id='report.forward_hint' defaultMessage='The account is from another server. Send an anonymized copy of the report there as well?' /></p>
|
||||
// First, pre-select known domains
|
||||
availableDomains.forEach((domain) => {
|
||||
onToggleDomain(domain, true);
|
||||
});
|
||||
|
||||
<label className='report-dialog-modal__toggle'>
|
||||
<Toggle checked={forward} disabled={isSubmitting} onChange={this.handleForwardChange} />
|
||||
// Then, fetch missing replied-to accounts
|
||||
const unknownAccounts = OrderedSet(accountIds.filter(accountId => accountId && !accountsMap.has(accountId)));
|
||||
unknownAccounts.forEach((accountId) => {
|
||||
dispatch(fetchAccount(accountId));
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<h3 className='report-dialog-modal__title'><FormattedMessage id='report.comment.title' defaultMessage='Is there anything else you think we should know?' /></h3>
|
||||
|
||||
<textarea
|
||||
className='report-dialog-modal__textarea'
|
||||
placeholder={intl.formatMessage(messages.placeholder)}
|
||||
value={comment}
|
||||
onChange={handleChange}
|
||||
onKeyDown={handleKeyDown}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
|
||||
{isRemote && (
|
||||
<>
|
||||
<p className='report-dialog-modal__lead'><FormattedMessage id='report.forward_hint' defaultMessage='The account is from another server. Send an anonymized copy of the report there as well?' /></p>
|
||||
|
||||
{ availableDomains.map((domain) => (
|
||||
<label className='report-dialog-modal__toggle' key={`toggle-${domain}`}>
|
||||
<Toggle checked={selectedDomains.includes(domain)} disabled={isSubmitting} onChange={handleToggleDomain} value={domain} />
|
||||
<FormattedMessage id='report.forward' defaultMessage='Forward to {target}' values={{ target: domain }} />
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className='flex-spacer' />
|
||||
|
||||
<div className='report-dialog-modal__actions'>
|
||||
<Button onClick={this.handleClick} disabled={isSubmitting}><FormattedMessage id='report.submit' defaultMessage='Submit report' /></Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
<div className='flex-spacer' />
|
||||
|
||||
<div className='report-dialog-modal__actions'>
|
||||
<Button onClick={handleClick} disabled={isSubmitting}><FormattedMessage id='report.submit' defaultMessage='Submit report' /></Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default injectIntl(Comment);
|
||||
Comment.propTypes = {
|
||||
comment: PropTypes.string.isRequired,
|
||||
domain: PropTypes.string,
|
||||
statusIds: ImmutablePropTypes.list.isRequired,
|
||||
isRemote: PropTypes.bool,
|
||||
isSubmitting: PropTypes.bool,
|
||||
selectedDomains: ImmutablePropTypes.set.isRequired,
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
onChangeComment: PropTypes.func.isRequired,
|
||||
onToggleDomain: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default Comment;
|
||||
|
|
|
@ -216,21 +216,21 @@ class ActionBar extends PureComponent {
|
|||
|
||||
let menu = [];
|
||||
|
||||
if (publicStatus) {
|
||||
if (isRemote) {
|
||||
menu.push({ text: intl.formatMessage(messages.openOriginalPage), href: status.get('url') });
|
||||
}
|
||||
if (publicStatus && isRemote) {
|
||||
menu.push({ text: intl.formatMessage(messages.openOriginalPage), href: status.get('url') });
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.copy), action: this.handleCopy });
|
||||
menu.push({ text: intl.formatMessage(messages.copy), action: this.handleCopy });
|
||||
|
||||
if ('share' in navigator) {
|
||||
menu.push({ text: intl.formatMessage(messages.share), action: this.handleShare });
|
||||
}
|
||||
if (publicStatus && 'share' in navigator) {
|
||||
menu.push({ text: intl.formatMessage(messages.share), action: this.handleShare });
|
||||
}
|
||||
|
||||
if (anonymousStatus) {
|
||||
menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed });
|
||||
}
|
||||
|
||||
if (anonymousStatus && (signedIn || !isRemote)) {
|
||||
menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed });
|
||||
}
|
||||
|
||||
if (signedIn) {
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.reblog), action: this.handleReblogForceModalClick });
|
||||
|
||||
|
@ -238,59 +238,57 @@ class ActionBar extends PureComponent {
|
|||
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
|
||||
}
|
||||
|
||||
menu.push(null);
|
||||
}
|
||||
if (writtenByMe) {
|
||||
if (pinnableStatus) {
|
||||
menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick });
|
||||
menu.push(null);
|
||||
}
|
||||
|
||||
if (writtenByMe) {
|
||||
if (pinnableStatus) {
|
||||
menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick });
|
||||
menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick });
|
||||
menu.push(null);
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick });
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.edit), action: this.handleEditClick });
|
||||
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick, dangerous: true });
|
||||
menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick, dangerous: true });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
|
||||
menu.push(null);
|
||||
|
||||
if (relationship && relationship.get('muting')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.handleMuteClick });
|
||||
menu.push({ text: intl.formatMessage(messages.edit), action: this.handleEditClick });
|
||||
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick, dangerous: true });
|
||||
menu.push({ text: intl.formatMessage(messages.redraft), action: this.handleRedraftClick, dangerous: true });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick, dangerous: true });
|
||||
}
|
||||
|
||||
if (relationship && relationship.get('blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.handleBlockClick });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick, dangerous: true });
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport, dangerous: true });
|
||||
|
||||
if (account.get('acct') !== account.get('username')) {
|
||||
const domain = account.get('acct').split('@')[1];
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
|
||||
menu.push(null);
|
||||
|
||||
if (relationship && relationship.get('domain_blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblockDomain, { domain }), action: this.handleUnblockDomain });
|
||||
if (relationship && relationship.get('muting')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.handleMuteClick });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.blockDomain, { domain }), action: this.handleBlockDomain, dangerous: true });
|
||||
menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick, dangerous: true });
|
||||
}
|
||||
}
|
||||
|
||||
if ((permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS || (isRemote && (permissions & PERMISSION_MANAGE_FEDERATION) === PERMISSION_MANAGE_FEDERATION)) {
|
||||
menu.push(null);
|
||||
if ((permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS) {
|
||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/admin/accounts/${status.getIn(['account', 'id'])}` });
|
||||
menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
||||
if (relationship && relationship.get('blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.handleBlockClick });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick, dangerous: true });
|
||||
}
|
||||
if (isRemote && (permissions & PERMISSION_MANAGE_FEDERATION) === PERMISSION_MANAGE_FEDERATION) {
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport, dangerous: true });
|
||||
|
||||
if (account.get('acct') !== account.get('username')) {
|
||||
const domain = account.get('acct').split('@')[1];
|
||||
menu.push({ text: intl.formatMessage(messages.admin_domain, { domain: domain }), href: `/admin/instances/${domain}` });
|
||||
|
||||
menu.push(null);
|
||||
|
||||
if (relationship && relationship.get('domain_blocking')) {
|
||||
menu.push({ text: intl.formatMessage(messages.unblockDomain, { domain }), action: this.handleUnblockDomain });
|
||||
} else {
|
||||
menu.push({ text: intl.formatMessage(messages.blockDomain, { domain }), action: this.handleBlockDomain, dangerous: true });
|
||||
}
|
||||
}
|
||||
|
||||
if ((permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS || (isRemote && (permissions & PERMISSION_MANAGE_FEDERATION) === PERMISSION_MANAGE_FEDERATION)) {
|
||||
menu.push(null);
|
||||
if ((permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS) {
|
||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/admin/accounts/${status.getIn(['account', 'id'])}` });
|
||||
menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
||||
}
|
||||
if (isRemote && (permissions & PERMISSION_MANAGE_FEDERATION) === PERMISSION_MANAGE_FEDERATION) {
|
||||
const domain = account.get('acct').split('@')[1];
|
||||
menu.push({ text: intl.formatMessage(messages.admin_domain, { domain: domain }), href: `/admin/instances/${domain}` });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +326,7 @@ class ActionBar extends PureComponent {
|
|||
<div className='detailed-status__button'><EmojiPickerDropdown onPickEmoji={this.handleEmojiPick} button={emojiPickerButton} /></div>
|
||||
|
||||
<div className='detailed-status__action-bar-dropdown'>
|
||||
<DropdownMenuContainer size={18} icon='ellipsis-h' disabled={!signedIn} status={status} items={menu} direction='left' title={intl.formatMessage(messages.more)} />
|
||||
<DropdownMenuContainer size={18} icon='ellipsis-h' status={status} items={menu} direction='left' title={intl.formatMessage(messages.more)} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -128,7 +128,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||
dispatch(openModal({
|
||||
modalType: 'EMBED',
|
||||
modalProps: {
|
||||
url: status.get('url'),
|
||||
id: status.get('id'),
|
||||
onError: error => dispatch(showAlertForError(error)),
|
||||
},
|
||||
}));
|
||||
|
|
|
@ -490,7 +490,7 @@ class Status extends ImmutablePureComponent {
|
|||
handleEmbed = (status) => {
|
||||
this.props.dispatch(openModal({
|
||||
modalType: 'EMBED',
|
||||
modalProps: { url: status.get('url') },
|
||||
modalProps: { id: status.get('id') },
|
||||
}));
|
||||
};
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ const messages = defineMessages({
|
|||
class EmbedModal extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
url: PropTypes.string.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
onError: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
|
@ -26,11 +26,11 @@ class EmbedModal extends ImmutablePureComponent {
|
|||
};
|
||||
|
||||
componentDidMount () {
|
||||
const { url } = this.props;
|
||||
const { id } = this.props;
|
||||
|
||||
this.setState({ loading: true });
|
||||
|
||||
api().post('/api/web/embed', { url }).then(res => {
|
||||
api().get(`/api/web/embeds/${id}`).then(res => {
|
||||
this.setState({ loading: false, oembed: res.data });
|
||||
|
||||
const iframeDocument = this.iframe.contentWindow.document;
|
||||
|
|
|
@ -38,6 +38,7 @@ class LinkFooter extends PureComponent {
|
|||
};
|
||||
|
||||
static propTypes = {
|
||||
multiColumn: PropTypes.bool,
|
||||
onLogout: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
@ -53,6 +54,7 @@ class LinkFooter extends PureComponent {
|
|||
|
||||
render () {
|
||||
const { signedIn, permissions } = this.context.identity;
|
||||
const { multiColumn } = this.props;
|
||||
|
||||
const canInvite = signedIn && ((permissions & PERMISSION_INVITE_USERS) === PERMISSION_INVITE_USERS);
|
||||
const canProfileDirectory = profileDirectory;
|
||||
|
@ -64,7 +66,7 @@ class LinkFooter extends PureComponent {
|
|||
<p>
|
||||
<strong>{domain}</strong>:
|
||||
{' '}
|
||||
<Link to='/about'><FormattedMessage id='footer.about' defaultMessage='About' /></Link>
|
||||
<Link to='/about' target={multiColumn ? '_blank' : undefined}><FormattedMessage id='footer.about' defaultMessage='About' /></Link>
|
||||
{statusPageUrl && (
|
||||
<>
|
||||
{DividingCircle}
|
||||
|
@ -84,7 +86,7 @@ class LinkFooter extends PureComponent {
|
|||
</>
|
||||
)}
|
||||
{DividingCircle}
|
||||
<Link to='/privacy-policy'><FormattedMessage id='footer.privacy_policy' defaultMessage='Privacy policy' /></Link>
|
||||
<Link to='/privacy-policy' target={multiColumn ? '_blank' : undefined}><FormattedMessage id='footer.privacy_policy' defaultMessage='Privacy policy' /></Link>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -7,7 +7,8 @@ import { Link } from 'react-router-dom';
|
|||
|
||||
import { WordmarkLogo } from 'mastodon/components/logo';
|
||||
import NavigationPortal from 'mastodon/components/navigation_portal';
|
||||
import { timelinePreview, showTrends } from 'mastodon/initial_state';
|
||||
import { timelinePreview, trendsEnabled } from 'mastodon/initial_state';
|
||||
import { transientSingleColumn } from 'mastodon/is_mobile';
|
||||
|
||||
import ColumnLink from './column_link';
|
||||
import DisabledAccountBanner from './disabled_account_banner';
|
||||
|
@ -30,6 +31,7 @@ const messages = defineMessages({
|
|||
followsAndFollowers: { id: 'navigation_bar.follows_and_followers', defaultMessage: 'Follows and followers' },
|
||||
about: { id: 'navigation_bar.about', defaultMessage: 'About' },
|
||||
search: { id: 'navigation_bar.search', defaultMessage: 'Search' },
|
||||
advancedInterface: { id: 'navigation_bar.advanced_interface', defaultMessage: 'Open in advanced web interface' },
|
||||
});
|
||||
|
||||
class NavigationPanel extends Component {
|
||||
|
@ -51,7 +53,7 @@ class NavigationPanel extends Component {
|
|||
const { intl } = this.props;
|
||||
const { signedIn, disabledAccountId } = this.context.identity;
|
||||
|
||||
const explorer = (showTrends ? (
|
||||
const explorer = (trendsEnabled ? (
|
||||
<ColumnLink transparent to='/explore' icon='hashtag' text={intl.formatMessage(messages.explore)} />
|
||||
) : (
|
||||
<ColumnLink transparent to='/search' icon='search' text={intl.formatMessage(messages.search)} />
|
||||
|
@ -61,6 +63,12 @@ class NavigationPanel extends Component {
|
|||
<div className='navigation-panel'>
|
||||
<div className='navigation-panel__logo'>
|
||||
<Link to='/' className='column-link column-link--logo'><WordmarkLogo /></Link>
|
||||
|
||||
{transientSingleColumn && (
|
||||
<a href={`/deck${location.pathname}`} className='button button--block'>
|
||||
{intl.formatMessage(messages.advancedInterface)}
|
||||
</a>
|
||||
)}
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
|
|
@ -45,25 +45,26 @@ class ReportModal extends ImmutablePureComponent {
|
|||
state = {
|
||||
step: 'category',
|
||||
selectedStatusIds: OrderedSet(this.props.statusId ? [this.props.statusId] : []),
|
||||
selectedDomains: OrderedSet(),
|
||||
comment: '',
|
||||
category: null,
|
||||
selectedRuleIds: OrderedSet(),
|
||||
forward: true,
|
||||
isSubmitting: false,
|
||||
isSubmitted: false,
|
||||
};
|
||||
|
||||
handleSubmit = () => {
|
||||
const { dispatch, accountId } = this.props;
|
||||
const { selectedStatusIds, comment, category, selectedRuleIds, forward } = this.state;
|
||||
const { selectedStatusIds, selectedDomains, comment, category, selectedRuleIds } = this.state;
|
||||
|
||||
this.setState({ isSubmitting: true });
|
||||
|
||||
dispatch(submitReport({
|
||||
account_id: accountId,
|
||||
status_ids: selectedStatusIds.toArray(),
|
||||
selected_domains: selectedDomains.toArray(),
|
||||
comment,
|
||||
forward,
|
||||
forward: selectedDomains.size > 0,
|
||||
category,
|
||||
rule_ids: selectedRuleIds.toArray(),
|
||||
}, this.handleSuccess, this.handleFail));
|
||||
|
@ -87,13 +88,19 @@ class ReportModal extends ImmutablePureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
handleRuleToggle = (ruleId, checked) => {
|
||||
const { selectedRuleIds } = this.state;
|
||||
|
||||
handleDomainToggle = (domain, checked) => {
|
||||
if (checked) {
|
||||
this.setState({ selectedRuleIds: selectedRuleIds.add(ruleId) });
|
||||
this.setState((state) => ({ selectedDomains: state.selectedDomains.add(domain) }));
|
||||
} else {
|
||||
this.setState({ selectedRuleIds: selectedRuleIds.remove(ruleId) });
|
||||
this.setState((state) => ({ selectedDomains: state.selectedDomains.remove(domain) }));
|
||||
}
|
||||
};
|
||||
|
||||
handleRuleToggle = (ruleId, checked) => {
|
||||
if (checked) {
|
||||
this.setState((state) => ({ selectedRuleIds: state.selectedRuleIds.add(ruleId) }));
|
||||
} else {
|
||||
this.setState((state) => ({ selectedRuleIds: state.selectedRuleIds.remove(ruleId) }));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -105,10 +112,6 @@ class ReportModal extends ImmutablePureComponent {
|
|||
this.setState({ comment });
|
||||
};
|
||||
|
||||
handleChangeForward = forward => {
|
||||
this.setState({ forward });
|
||||
};
|
||||
|
||||
handleNextStep = step => {
|
||||
this.setState({ step });
|
||||
};
|
||||
|
@ -136,8 +139,8 @@ class ReportModal extends ImmutablePureComponent {
|
|||
step,
|
||||
selectedStatusIds,
|
||||
selectedRuleIds,
|
||||
selectedDomains,
|
||||
comment,
|
||||
forward,
|
||||
category,
|
||||
isSubmitting,
|
||||
isSubmitted,
|
||||
|
@ -185,10 +188,11 @@ class ReportModal extends ImmutablePureComponent {
|
|||
isSubmitting={isSubmitting}
|
||||
isRemote={isRemote}
|
||||
comment={comment}
|
||||
forward={forward}
|
||||
domain={domain}
|
||||
onChangeComment={this.handleChangeComment}
|
||||
onChangeForward={this.handleChangeForward}
|
||||
statusIds={selectedStatusIds}
|
||||
selectedDomains={selectedDomains}
|
||||
onToggleDomain={this.handleDomainToggle}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
|
|
|
@ -7,26 +7,27 @@ import { NotificationStack } from 'react-notification';
|
|||
import { dismissAlert } from '../../../actions/alerts';
|
||||
import { getAlerts } from '../../../selectors';
|
||||
|
||||
const mapStateToProps = (state, { intl }) => {
|
||||
const notifications = getAlerts(state);
|
||||
const formatIfNeeded = (intl, message, values) => {
|
||||
if (typeof message === 'object') {
|
||||
return intl.formatMessage(message, values);
|
||||
}
|
||||
|
||||
notifications.forEach(notification => ['title', 'message'].forEach(key => {
|
||||
const value = notification[key];
|
||||
|
||||
if (typeof value === 'object') {
|
||||
notification[key] = intl.formatMessage(value, notification[`${key}_values`]);
|
||||
}
|
||||
}));
|
||||
|
||||
return { notifications };
|
||||
return message;
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
onDismiss: alert => {
|
||||
dispatch(dismissAlert(alert));
|
||||
},
|
||||
};
|
||||
};
|
||||
const mapStateToProps = (state, { intl }) => ({
|
||||
notifications: getAlerts(state).map(alert => ({
|
||||
...alert,
|
||||
action: formatIfNeeded(intl, alert.action, alert.values),
|
||||
title: formatIfNeeded(intl, alert.title, alert.values),
|
||||
message: formatIfNeeded(intl, alert.message, alert.values),
|
||||
})),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onDismiss (alert) {
|
||||
dispatch(dismissAlert(alert));
|
||||
},
|
||||
});
|
||||
|
||||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(NotificationStack));
|
||||
|
|
|
@ -22,7 +22,7 @@ import { clearHeight } from '../../actions/height_cache';
|
|||
import { expandNotifications } from '../../actions/notifications';
|
||||
import { fetchServer, fetchServerTranslationLanguages } from '../../actions/server';
|
||||
import { expandHomeTimeline } from '../../actions/timelines';
|
||||
import initialState, { me, owner, singleUserMode, showTrends, trendsAsLanding } from '../../initial_state';
|
||||
import initialState, { me, owner, singleUserMode, trendsEnabled, trendsAsLanding } from '../../initial_state';
|
||||
|
||||
import BundleColumnError from './components/bundle_column_error';
|
||||
import Header from './components/header';
|
||||
|
@ -132,11 +132,11 @@ class SwitchingColumnsArea extends PureComponent {
|
|||
static propTypes = {
|
||||
children: PropTypes.node,
|
||||
location: PropTypes.object,
|
||||
mobile: PropTypes.bool,
|
||||
singleColumn: PropTypes.bool,
|
||||
};
|
||||
|
||||
UNSAFE_componentWillMount () {
|
||||
if (this.props.mobile) {
|
||||
if (this.props.singleColumn) {
|
||||
document.body.classList.toggle('layout-single-column', true);
|
||||
document.body.classList.toggle('layout-multiple-columns', false);
|
||||
} else {
|
||||
|
@ -150,9 +150,9 @@ class SwitchingColumnsArea extends PureComponent {
|
|||
this.node.handleChildrenContentChange();
|
||||
}
|
||||
|
||||
if (prevProps.mobile !== this.props.mobile) {
|
||||
document.body.classList.toggle('layout-single-column', this.props.mobile);
|
||||
document.body.classList.toggle('layout-multiple-columns', !this.props.mobile);
|
||||
if (prevProps.singleColumn !== this.props.singleColumn) {
|
||||
document.body.classList.toggle('layout-single-column', this.props.singleColumn);
|
||||
document.body.classList.toggle('layout-multiple-columns', !this.props.singleColumn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,30 +163,34 @@ class SwitchingColumnsArea extends PureComponent {
|
|||
};
|
||||
|
||||
render () {
|
||||
const { children, mobile } = this.props;
|
||||
const { children, singleColumn } = this.props;
|
||||
const { signedIn } = this.context.identity;
|
||||
const pathName = this.props.location.pathname;
|
||||
|
||||
let redirect;
|
||||
|
||||
if (signedIn) {
|
||||
if (mobile) {
|
||||
if (singleColumn) {
|
||||
redirect = <Redirect from='/' to='/home' exact />;
|
||||
} else {
|
||||
redirect = <Redirect from='/' to='/getting-started' exact />;
|
||||
redirect = <Redirect from='/' to='/deck/getting-started' exact />;
|
||||
}
|
||||
} else if (singleUserMode && owner && initialState?.accounts[owner]) {
|
||||
redirect = <Redirect from='/' to={`/@${initialState.accounts[owner].username}`} exact />;
|
||||
} else if (showTrends && trendsAsLanding) {
|
||||
} else if (trendsEnabled && trendsAsLanding) {
|
||||
redirect = <Redirect from='/' to='/explore' exact />;
|
||||
} else {
|
||||
redirect = <Redirect from='/' to='/about' exact />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ColumnsAreaContainer ref={this.setRef} singleColumn={mobile}>
|
||||
<ColumnsAreaContainer ref={this.setRef} singleColumn={singleColumn}>
|
||||
<WrappedSwitch>
|
||||
{redirect}
|
||||
|
||||
{singleColumn ? <Redirect from='/deck' to='/home' exact /> : null}
|
||||
{singleColumn && pathName.startsWith('/deck/') ? <Redirect from={pathName} to={pathName.slice(5)} /> : null}
|
||||
|
||||
<WrappedRoute path='/getting-started' component={GettingStarted} content={children} />
|
||||
<WrappedRoute path='/keyboard-shortcuts' component={KeyboardShortcuts} content={children} />
|
||||
<WrappedRoute path='/about' component={About} content={children} />
|
||||
|
@ -592,7 +596,7 @@ class UI extends PureComponent {
|
|||
<div className={classNames('ui', { 'is-composing': isComposing })} ref={this.setRef} style={{ pointerEvents: dropdownMenuIsOpen ? 'none' : null }}>
|
||||
<Header />
|
||||
|
||||
<SwitchingColumnsArea location={location} mobile={layout === 'mobile' || layout === 'single-column'}>
|
||||
<SwitchingColumnsArea location={location} singleColumn={layout === 'mobile' || layout === 'single-column'}>
|
||||
{children}
|
||||
</SwitchingColumnsArea>
|
||||
|
||||
|
|
|
@ -11,13 +11,21 @@ import BundleContainer from '../containers/bundle_container';
|
|||
|
||||
// Small wrapper to pass multiColumn to the route components
|
||||
export class WrappedSwitch extends PureComponent {
|
||||
static contextTypes = {
|
||||
router: PropTypes.object,
|
||||
};
|
||||
|
||||
render () {
|
||||
const { multiColumn, children } = this.props;
|
||||
const { location } = this.context.router.route;
|
||||
|
||||
const decklessLocation = multiColumn && location.pathname.startsWith('/deck')
|
||||
? {...location, pathname: location.pathname.slice(5)}
|
||||
: location;
|
||||
|
||||
return (
|
||||
<Switch>
|
||||
{Children.map(children, child => cloneElement(child, { multiColumn }))}
|
||||
<Switch location={decklessLocation}>
|
||||
{Children.map(children, child => child ? cloneElement(child, { multiColumn }) : null)}
|
||||
</Switch>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -72,12 +72,13 @@
|
|||
* @property {boolean} reduce_motion
|
||||
* @property {string} repository
|
||||
* @property {boolean} search_enabled
|
||||
* @property {boolean} trends_enabled
|
||||
* @property {boolean} single_user_mode
|
||||
* @property {string} source_url
|
||||
* @property {string} streaming_api_base_url
|
||||
* @property {boolean} timeline_preview
|
||||
* @property {string} title
|
||||
* @property {boolean} trends
|
||||
* @property {boolean} show_trends
|
||||
* @property {boolean} trends_as_landing_page
|
||||
* @property {boolean} unfollow_modal
|
||||
* @property {boolean} use_blurhash
|
||||
|
@ -96,6 +97,13 @@ const element = document.getElementById('initial-state');
|
|||
/** @type {InitialState | undefined} */
|
||||
const initialState = element?.textContent && JSON.parse(element.textContent);
|
||||
|
||||
/** @type {string} */
|
||||
const initialPath = document.querySelector("head meta[name=initialPath]")?.getAttribute("content") ?? '';
|
||||
/** @type {boolean} */
|
||||
export const hasMultiColumnPath = initialPath === '/'
|
||||
|| initialPath === '/getting-started'
|
||||
|| initialPath.startsWith('/deck');
|
||||
|
||||
/**
|
||||
* @template {keyof InitialStateMeta} K
|
||||
* @param {K} prop
|
||||
|
@ -127,7 +135,8 @@ export const reduceMotion = getMeta('reduce_motion');
|
|||
export const registrationsOpen = getMeta('registrations_open');
|
||||
export const repository = getMeta('repository');
|
||||
export const searchEnabled = getMeta('search_enabled');
|
||||
export const showTrends = getMeta('trends');
|
||||
export const trendsEnabled = getMeta('trends_enabled');
|
||||
export const showTrends = getMeta('show_trends');
|
||||
export const singleUserMode = getMeta('single_user_mode');
|
||||
export const source_url = getMeta('source_url');
|
||||
export const timelinePreview = getMeta('timeline_preview');
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
import { supportsPassiveEvents } from 'detect-passive-events';
|
||||
|
||||
import { forceSingleColumn } from './initial_state';
|
||||
import { forceSingleColumn, hasMultiColumnPath } from './initial_state';
|
||||
|
||||
const LAYOUT_BREAKPOINT = 630;
|
||||
|
||||
export const isMobile = (width: number) => width <= LAYOUT_BREAKPOINT;
|
||||
|
||||
export const transientSingleColumn = !forceSingleColumn && !hasMultiColumnPath;
|
||||
|
||||
export type LayoutType = 'mobile' | 'single-column' | 'multi-column';
|
||||
export const layoutFromWindow = (): LayoutType => {
|
||||
if (isMobile(window.innerWidth)) {
|
||||
return 'mobile';
|
||||
} else if (forceSingleColumn) {
|
||||
return 'single-column';
|
||||
} else {
|
||||
} else if (!forceSingleColumn && !transientSingleColumn) {
|
||||
return 'multi-column';
|
||||
} else {
|
||||
return 'single-column';
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -140,6 +140,8 @@
|
|||
"community.column_settings.remote_only": "Remote only",
|
||||
"compose.language.change": "Change language",
|
||||
"compose.language.search": "Search languages...",
|
||||
"compose.published.body": "Post published.",
|
||||
"compose.published.open": "Open",
|
||||
"compose_form.direct_message_warning_learn_more": "Learn more",
|
||||
"compose_form.encryption_warning": "Posts on Mastodon are not end-to-end encrypted. Do not share any sensitive information over Mastodon.",
|
||||
"compose_form.hashtag_warning": "This post won't be listed under any hashtag as it is not public. Only public posts can be searched by hashtag.",
|
||||
|
@ -392,6 +394,7 @@
|
|||
"mute_modal.hide_notifications": "Hide notifications from this user?",
|
||||
"mute_modal.indefinite": "Indefinite",
|
||||
"navigation_bar.about": "About",
|
||||
"navigation_bar.advanced_interface": "Open in advanced web interface",
|
||||
"navigation_bar.antennas": "Antenna",
|
||||
"navigation_bar.blocks": "Blocked users",
|
||||
"navigation_bar.bookmarks": "Bookmarks",
|
||||
|
@ -647,6 +650,8 @@
|
|||
"status.history.created": "{name} created {date}",
|
||||
"status.history.edited": "{name} edited {date}",
|
||||
"status.load_more": "Load more",
|
||||
"status.media.open": "Click to open",
|
||||
"status.media.show": "Click to show",
|
||||
"status.media_hidden": "Media hidden",
|
||||
"status.mention": "Mention @{name}",
|
||||
"status.more": "More",
|
||||
|
@ -678,7 +683,7 @@
|
|||
"status.title.with_attachments": "{user} posted {attachmentCount, plural, one {an attachment} other {{attachmentCount} attachments}}",
|
||||
"status.translate": "Translate",
|
||||
"status.translated_from_with": "Translated from {lang} using {provider}",
|
||||
"status.uncached_media_warning": "Not available",
|
||||
"status.uncached_media_warning": "Preview not available",
|
||||
"status.unmute_conversation": "Unmute conversation",
|
||||
"status.unpin": "Unpin from profile",
|
||||
"subscribed_languages.lead": "Only posts in selected languages will appear on your home and list timelines after the change. Select none to receive posts in all languages.",
|
||||
|
|
|
@ -368,6 +368,7 @@
|
|||
"mute_modal.hide_notifications": "Masquer les notifications de cette personne ?",
|
||||
"mute_modal.indefinite": "Indéfinie",
|
||||
"navigation_bar.about": "À propos",
|
||||
"navigation_bar.advanced_interface": "Ouvrir dans l’interface avancée",
|
||||
"navigation_bar.blocks": "Comptes bloqués",
|
||||
"navigation_bar.bookmarks": "Marque-pages",
|
||||
"navigation_bar.community_timeline": "Fil public local",
|
||||
|
|
|
@ -3,15 +3,19 @@ export interface LocaleData {
|
|||
messages: Record<string, string>;
|
||||
}
|
||||
|
||||
let loadedLocale: LocaleData;
|
||||
let loadedLocale: LocaleData | undefined;
|
||||
|
||||
export function setLocale(locale: LocaleData) {
|
||||
loadedLocale = locale;
|
||||
}
|
||||
|
||||
export function getLocale() {
|
||||
if (!loadedLocale && process.env.NODE_ENV === 'development') {
|
||||
throw new Error('getLocale() called before any locale has been set');
|
||||
export function getLocale(): LocaleData {
|
||||
if (!loadedLocale) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
throw new Error('getLocale() called before any locale has been set');
|
||||
} else {
|
||||
return { locale: 'unknown', messages: {} };
|
||||
}
|
||||
}
|
||||
|
||||
return loadedLocale;
|
||||
|
|
|
@ -6,6 +6,7 @@ import { isLocaleLoaded, setLocale } from './global_locale';
|
|||
const localeLoadingSemaphore = new Semaphore(1);
|
||||
|
||||
export async function loadLocale() {
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- we want to match empty strings
|
||||
const locale = document.querySelector<HTMLElement>('html')?.lang || 'en';
|
||||
|
||||
// We use a Semaphore here so only one thing can try to load the locales at
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'core-js/features/symbol';
|
|||
import 'core-js/features/promise/finally';
|
||||
import { decode as decodeBase64 } from '../utils/base64';
|
||||
|
||||
if (!HTMLCanvasElement.prototype.toBlob) {
|
||||
if (!Object.hasOwn(HTMLCanvasElement.prototype, 'toBlob')) {
|
||||
const BASE64_MARKER = ';base64,';
|
||||
|
||||
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
|
||||
|
@ -12,12 +12,12 @@ if (!HTMLCanvasElement.prototype.toBlob) {
|
|||
this: HTMLCanvasElement,
|
||||
callback: BlobCallback,
|
||||
type = 'image/png',
|
||||
quality: unknown
|
||||
quality: unknown,
|
||||
) {
|
||||
const dataURL: string = this.toDataURL(type, quality);
|
||||
let data;
|
||||
|
||||
if (dataURL.indexOf(BASE64_MARKER) >= 0) {
|
||||
if (dataURL.includes(BASE64_MARKER)) {
|
||||
const [, base64] = dataURL.split(BASE64_MARKER);
|
||||
data = decodeBase64(base64);
|
||||
} else {
|
||||
|
|
|
@ -24,6 +24,7 @@ export function loadPolyfills() {
|
|||
// Latest version of Firefox and Safari do not have IntersectionObserver.
|
||||
// Edge does not have requestIdleCallback.
|
||||
// This avoids shipping them all the polyfills.
|
||||
/* eslint-disable @typescript-eslint/no-unnecessary-condition -- those properties might not exist in old browsers, even if they are always here in types */
|
||||
const needsExtraPolyfills = !(
|
||||
window.AbortController &&
|
||||
window.IntersectionObserver &&
|
||||
|
@ -31,6 +32,7 @@ export function loadPolyfills() {
|
|||
'isIntersecting' in IntersectionObserverEntry.prototype &&
|
||||
window.requestIdleCallback
|
||||
);
|
||||
/* eslint-enable @typescript-eslint/no-unnecessary-condition */
|
||||
|
||||
return Promise.all([
|
||||
loadIntlPolyfills(),
|
||||
|
|
|
@ -80,6 +80,7 @@ async function loadIntlPluralRulesPolyfills(locale: string) {
|
|||
// }
|
||||
|
||||
export async function loadIntlPolyfills() {
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- we want to match empty strings
|
||||
const locale = document.querySelector('html')?.lang || 'en';
|
||||
|
||||
// order is important here
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
import { List as ImmutableList } from 'immutable';
|
||||
|
||||
import {
|
||||
ALERT_SHOW,
|
||||
|
@ -8,17 +8,20 @@ import {
|
|||
|
||||
const initialState = ImmutableList([]);
|
||||
|
||||
let id = 0;
|
||||
|
||||
const addAlert = (state, alert) =>
|
||||
state.push({
|
||||
key: id++,
|
||||
...alert,
|
||||
});
|
||||
|
||||
export default function alerts(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case ALERT_SHOW:
|
||||
return state.push(ImmutableMap({
|
||||
key: state.size > 0 ? state.last().get('key') + 1 : 0,
|
||||
title: action.title,
|
||||
message: action.message,
|
||||
message_values: action.message_values,
|
||||
}));
|
||||
return addAlert(state, action.alert);
|
||||
case ALERT_DISMISS:
|
||||
return state.filterNot(item => item.get('key') === action.alert.key);
|
||||
return state.filterNot(item => item.key === action.alert.key);
|
||||
case ALERT_CLEAR:
|
||||
return state.clear();
|
||||
default:
|
||||
|
|
|
@ -29,7 +29,6 @@ import lists from './lists';
|
|||
import markers from './markers';
|
||||
import media_attachments from './media_attachments';
|
||||
import meta from './meta';
|
||||
import { missedUpdatesReducer } from './missed_updates';
|
||||
import { modalReducer } from './modal';
|
||||
import mutes from './mutes';
|
||||
import notifications from './notifications';
|
||||
|
@ -89,7 +88,6 @@ const reducers = {
|
|||
suggestions,
|
||||
polls,
|
||||
trends,
|
||||
missed_updates: missedUpdatesReducer,
|
||||
markers,
|
||||
picture_in_picture,
|
||||
history,
|
||||
|
@ -109,7 +107,7 @@ const initialRootState = Object.fromEntries(
|
|||
reducer(undefined, {
|
||||
// empty action
|
||||
}),
|
||||
])
|
||||
]),
|
||||
);
|
||||
|
||||
const RootStateRecord = ImmutableRecord(initialRootState, 'RootState');
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
import { Record } from 'immutable';
|
||||
|
||||
import type { Action } from 'redux';
|
||||
|
||||
import { focusApp, unfocusApp } from '../actions/app';
|
||||
import { NOTIFICATIONS_UPDATE } from '../actions/notifications';
|
||||
|
||||
interface MissedUpdatesState {
|
||||
focused: boolean;
|
||||
unread: number;
|
||||
}
|
||||
const initialState = Record<MissedUpdatesState>({
|
||||
focused: true,
|
||||
unread: 0,
|
||||
})();
|
||||
|
||||
export function missedUpdatesReducer(
|
||||
state = initialState,
|
||||
action: Action<string>
|
||||
) {
|
||||
switch (action.type) {
|
||||
case focusApp.type:
|
||||
return state.set('focused', true).set('unread', 0);
|
||||
case unfocusApp.type:
|
||||
return state.set('focused', false);
|
||||
case NOTIFICATIONS_UPDATE:
|
||||
return state.get('focused')
|
||||
? state
|
||||
: state.update('unread', (x) => x + 1);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ interface PopModalOption {
|
|||
}
|
||||
const popModal = (
|
||||
state: State,
|
||||
{ modalType, ignoreFocus }: PopModalOption
|
||||
{ modalType, ignoreFocus }: PopModalOption,
|
||||
): State => {
|
||||
if (
|
||||
modalType === undefined ||
|
||||
|
@ -52,12 +52,12 @@ const popModal = (
|
|||
const pushModal = (
|
||||
state: State,
|
||||
modalType: ModalType,
|
||||
modalProps: ModalProps
|
||||
modalProps: ModalProps,
|
||||
): State => {
|
||||
return state.withMutations((record) => {
|
||||
record.set('ignoreFocus', false);
|
||||
record.update('stack', (stack) =>
|
||||
stack.unshift(Modal({ modalType, modalProps }))
|
||||
stack.unshift(Modal({ modalType, modalProps })),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
@ -68,14 +68,14 @@ export function modalReducer(
|
|||
modalType: ModalType;
|
||||
ignoreFocus: boolean;
|
||||
modalProps: Record<string, unknown>;
|
||||
}>
|
||||
}>,
|
||||
) {
|
||||
switch (action.type) {
|
||||
case openModal.type:
|
||||
return pushModal(
|
||||
state,
|
||||
action.payload.modalType,
|
||||
action.payload.modalProps
|
||||
action.payload.modalProps,
|
||||
);
|
||||
case closeModal.type:
|
||||
return popModal(state, action.payload);
|
||||
|
@ -85,8 +85,8 @@ export function modalReducer(
|
|||
return state.update('stack', (stack) =>
|
||||
stack.filterNot(
|
||||
// @ts-expect-error TIMELINE_DELETE action is not typed yet.
|
||||
(modal) => modal.get('modalProps').statusId === action.id
|
||||
)
|
||||
(modal) => modal.get('modalProps').statusId === action.id,
|
||||
),
|
||||
);
|
||||
default:
|
||||
return state;
|
||||
|
|
|
@ -3,12 +3,12 @@ const easingOutQuint = (
|
|||
t: number,
|
||||
b: number,
|
||||
c: number,
|
||||
d: number
|
||||
d: number,
|
||||
) => c * ((t = t / d - 1) * t * t * t * t + 1) + b;
|
||||
const scroll = (
|
||||
node: Element,
|
||||
key: 'scrollTop' | 'scrollLeft',
|
||||
target: number
|
||||
target: number,
|
||||
) => {
|
||||
const startTime = Date.now();
|
||||
const offset = node[key];
|
||||
|
@ -38,11 +38,13 @@ const scroll = (
|
|||
const isScrollBehaviorSupported =
|
||||
'scrollBehavior' in document.documentElement.style;
|
||||
|
||||
export const scrollRight = (node: Element, position: number) =>
|
||||
isScrollBehaviorSupported
|
||||
? node.scrollTo({ left: position, behavior: 'smooth' })
|
||||
: scroll(node, 'scrollLeft', position);
|
||||
export const scrollTop = (node: Element) =>
|
||||
isScrollBehaviorSupported
|
||||
? node.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
: scroll(node, 'scrollTop', 0);
|
||||
export const scrollRight = (node: Element, position: number) => {
|
||||
if (isScrollBehaviorSupported)
|
||||
node.scrollTo({ left: position, behavior: 'smooth' });
|
||||
else scroll(node, 'scrollLeft', position);
|
||||
};
|
||||
|
||||
export const scrollTop = (node: Element) => {
|
||||
if (isScrollBehaviorSupported) node.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
else scroll(node, 'scrollTop', 0);
|
||||
};
|
||||
|
|
|
@ -84,26 +84,16 @@ export const makeGetPictureInPicture = () => {
|
|||
}));
|
||||
};
|
||||
|
||||
const getAlertsBase = state => state.get('alerts');
|
||||
const ALERT_DEFAULTS = {
|
||||
dismissAfter: 5000,
|
||||
style: false,
|
||||
};
|
||||
|
||||
export const getAlerts = createSelector([getAlertsBase], (base) => {
|
||||
let arr = [];
|
||||
|
||||
base.forEach(item => {
|
||||
arr.push({
|
||||
message: item.get('message'),
|
||||
message_values: item.get('message_values'),
|
||||
title: item.get('title'),
|
||||
key: item.get('key'),
|
||||
dismissAfter: 5000,
|
||||
barStyle: {
|
||||
zIndex: 200,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
return arr;
|
||||
});
|
||||
export const getAlerts = createSelector(state => state.get('alerts'), alerts =>
|
||||
alerts.map(item => ({
|
||||
...ALERT_DEFAULTS,
|
||||
...item,
|
||||
})).toArray());
|
||||
|
||||
export const makeGetNotification = () => createSelector([
|
||||
(_, base) => base,
|
||||
|
|
|
@ -30,7 +30,7 @@ export const store = configureStore({
|
|||
.concat(
|
||||
loadingBarMiddleware({
|
||||
promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAIL'],
|
||||
})
|
||||
}),
|
||||
)
|
||||
.concat(errorsMiddleware)
|
||||
.concat(soundsMiddleware()),
|
||||
|
|
|
@ -14,9 +14,9 @@ const defaultTypeSuffixes: Config['promiseTypeSuffixes'] = [
|
|||
];
|
||||
|
||||
export const loadingBarMiddleware = (
|
||||
config: Config = {}
|
||||
config: Config = {},
|
||||
): Middleware<Record<string, never>, RootState> => {
|
||||
const promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypeSuffixes;
|
||||
const promiseTypeSuffixes = config.promiseTypeSuffixes ?? defaultTypeSuffixes;
|
||||
|
||||
return ({ dispatch }) =>
|
||||
(next) =>
|
||||
|
@ -32,7 +32,7 @@ export const loadingBarMiddleware = (
|
|||
if (action.type.match(isPending)) {
|
||||
dispatch(showLoading());
|
||||
} else if (
|
||||
action.type.match(isFulfilled) ||
|
||||
action.type.match(isFulfilled) ??
|
||||
action.type.match(isRejected)
|
||||
) {
|
||||
dispatch(hideLoading());
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import type { Middleware, AnyAction } from 'redux';
|
||||
|
||||
import ready from 'mastodon/ready';
|
||||
import { assetHost } from 'mastodon/utils/config';
|
||||
|
||||
import type { RootState } from '..';
|
||||
|
||||
interface AudioSource {
|
||||
|
@ -35,25 +38,27 @@ export const soundsMiddleware = (): Middleware<
|
|||
Record<string, never>,
|
||||
RootState
|
||||
> => {
|
||||
const soundCache: { [key: string]: HTMLAudioElement } = {
|
||||
boop: createAudio([
|
||||
const soundCache: Record<string, HTMLAudioElement> = {};
|
||||
|
||||
void ready(() => {
|
||||
soundCache.boop = createAudio([
|
||||
{
|
||||
src: '/sounds/boop.ogg',
|
||||
src: `${assetHost}/sounds/boop.ogg`,
|
||||
type: 'audio/ogg',
|
||||
},
|
||||
{
|
||||
src: '/sounds/boop.mp3',
|
||||
src: `${assetHost}/sounds/boop.mp3`,
|
||||
type: 'audio/mpeg',
|
||||
},
|
||||
]),
|
||||
};
|
||||
]);
|
||||
});
|
||||
|
||||
return () =>
|
||||
(next) =>
|
||||
(action: AnyAction & { meta?: { sound?: string } }) => {
|
||||
const sound = action?.meta?.sound;
|
||||
const sound = action.meta?.sound;
|
||||
|
||||
if (sound && soundCache[sound]) {
|
||||
if (sound && Object.hasOwn(soundCache, sound)) {
|
||||
play(soundCache[sound]);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ export const toServerSideType = (columnType: string) => {
|
|||
case 'account':
|
||||
return columnType;
|
||||
default:
|
||||
if (columnType.indexOf('list:') > -1) {
|
||||
if (columnType.includes('list:')) {
|
||||
return 'home';
|
||||
} else {
|
||||
return 'public'; // community, account, hashtag
|
||||
|
|
|
@ -6,7 +6,7 @@ const buildHashtagPatternRegex = () => {
|
|||
try {
|
||||
return new RegExp(
|
||||
`(?:^|[^\\/\\)\\w])#(([${WORD}_][${WORD}${HASHTAG_SEPARATORS}]*[${ALPHA}${HASHTAG_SEPARATORS}][${WORD}${HASHTAG_SEPARATORS}]*[${WORD}_])|([${WORD}_]*[${ALPHA}][${WORD}_]*))`,
|
||||
'iu'
|
||||
'iu',
|
||||
);
|
||||
} catch {
|
||||
return /(?:^|[^/)\w])#(\w*[a-zA-Z·]\w*)/i;
|
||||
|
@ -17,7 +17,7 @@ const buildHashtagRegex = () => {
|
|||
try {
|
||||
return new RegExp(
|
||||
`^(([${WORD}_][${WORD}${HASHTAG_SEPARATORS}]*[${ALPHA}${HASHTAG_SEPARATORS}][${WORD}${HASHTAG_SEPARATORS}]*[${WORD}_])|([${WORD}_]*[${ALPHA}][${WORD}_]*))$`,
|
||||
'iu'
|
||||
'iu',
|
||||
);
|
||||
} catch {
|
||||
return /^(\w*[a-zA-Z·]\w*)$/i;
|
||||
|
|
|
@ -55,7 +55,7 @@ export function toShortNumber(sourceNumber: number): ShortNumber {
|
|||
*/
|
||||
export function pluralReady(
|
||||
sourceNumber: number,
|
||||
division: DecimalUnits
|
||||
division: DecimalUnits | null,
|
||||
): number {
|
||||
if (division == null || division < DECIMAL_UNITS.HUNDRED) {
|
||||
return sourceNumber;
|
||||
|
|
|
@ -4,6 +4,5 @@ export function uuid(a?: string): string {
|
|||
(a as unknown as number) ^
|
||||
((Math.random() * 16) >> ((a as unknown as number) / 4))
|
||||
).toString(16)
|
||||
: // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||
('' + 1e7 + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, uuid);
|
||||
: ('' + 1e7 + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, uuid);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@font-face {
|
||||
font-family: mastodon-font-monospace;
|
||||
src: local('Roboto Mono'),
|
||||
src:
|
||||
local('Roboto Mono'),
|
||||
url('../fonts/roboto-mono/robotomono-regular-webfont.woff2') format('woff2'),
|
||||
url('../fonts/roboto-mono/robotomono-regular-webfont.woff') format('woff'),
|
||||
url('../fonts/roboto-mono/robotomono-regular-webfont.ttf')
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@font-face {
|
||||
font-family: mastodon-font-sans-serif;
|
||||
src: local('Roboto Italic'),
|
||||
src:
|
||||
local('Roboto Italic'),
|
||||
url('../fonts/roboto/roboto-italic-webfont.woff2') format('woff2'),
|
||||
url('../fonts/roboto/roboto-italic-webfont.woff') format('woff'),
|
||||
url('../fonts/roboto/roboto-italic-webfont.ttf') format('truetype'),
|
||||
|
@ -13,7 +14,8 @@
|
|||
|
||||
@font-face {
|
||||
font-family: mastodon-font-sans-serif;
|
||||
src: local('Roboto Bold'),
|
||||
src:
|
||||
local('Roboto Bold'),
|
||||
url('../fonts/roboto/roboto-bold-webfont.woff2') format('woff2'),
|
||||
url('../fonts/roboto/roboto-bold-webfont.woff') format('woff'),
|
||||
url('../fonts/roboto/roboto-bold-webfont.ttf') format('truetype'),
|
||||
|
@ -26,7 +28,8 @@
|
|||
|
||||
@font-face {
|
||||
font-family: mastodon-font-sans-serif;
|
||||
src: local('Roboto Medium'),
|
||||
src:
|
||||
local('Roboto Medium'),
|
||||
url('../fonts/roboto/roboto-medium-webfont.woff2') format('woff2'),
|
||||
url('../fonts/roboto/roboto-medium-webfont.woff') format('woff'),
|
||||
url('../fonts/roboto/roboto-medium-webfont.ttf') format('truetype'),
|
||||
|
@ -39,7 +42,8 @@
|
|||
|
||||
@font-face {
|
||||
font-family: mastodon-font-sans-serif;
|
||||
src: local('Roboto'),
|
||||
src:
|
||||
local('Roboto'),
|
||||
url('../fonts/roboto/roboto-regular-webfont.woff2') format('woff2'),
|
||||
url('../fonts/roboto/roboto-regular-webfont.woff') format('woff'),
|
||||
url('../fonts/roboto/roboto-regular-webfont.ttf') format('truetype'),
|
||||
|
|
|
@ -541,7 +541,7 @@ ul.rules-list {
|
|||
padding-top: 0;
|
||||
}
|
||||
|
||||
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
|
||||
@media only screen and (device-width >= 768px) and (device-width <= 1024px) and (orientation: landscape) {
|
||||
body {
|
||||
min-height: 1024px !important;
|
||||
}
|
||||
|
|
|
@ -636,14 +636,6 @@ html {
|
|||
}
|
||||
}
|
||||
|
||||
.button.logo-button {
|
||||
color: $white;
|
||||
|
||||
svg {
|
||||
fill: $white;
|
||||
}
|
||||
}
|
||||
|
||||
.notification__filter-bar button.active::after,
|
||||
.account__section-headline a.active::after {
|
||||
border-color: transparent transparent $white;
|
||||
|
|
|
@ -31,9 +31,19 @@ body {
|
|||
// Droid Sans => Older Androids (<4.0)
|
||||
// Helvetica Neue => Older macOS <10.11
|
||||
// $font-sans-serif => web-font (Roboto) fallback and newer Androids (>=4.0)
|
||||
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
|
||||
Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
$font-sans-serif, sans-serif;
|
||||
font-family:
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
'Segoe UI',
|
||||
Oxygen,
|
||||
Ubuntu,
|
||||
Cantarell,
|
||||
'Fira Sans',
|
||||
'Droid Sans',
|
||||
'Helvetica Neue',
|
||||
$font-sans-serif,
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
&.app-body {
|
||||
|
|
|
@ -754,7 +754,9 @@ body > [data-popper-placement] {
|
|||
}
|
||||
|
||||
.no-reduce-motion .spoiler-input {
|
||||
transition: height 0.4s ease, opacity 0.4s ease;
|
||||
transition:
|
||||
height 0.4s ease,
|
||||
opacity 0.4s ease;
|
||||
}
|
||||
|
||||
.sign-in-banner {
|
||||
|
@ -1725,10 +1727,6 @@ a.account__display-name {
|
|||
color: inherit;
|
||||
}
|
||||
|
||||
.detailed-status .button.logo-button {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.detailed-status__display-name {
|
||||
color: $darker-text-color;
|
||||
display: flex;
|
||||
|
@ -4013,7 +4011,9 @@ a.status-card.compact:hover {
|
|||
overflow-y: auto;
|
||||
border-bottom: 1px solid lighten($ui-base-color, 8%);
|
||||
color: $darker-text-color;
|
||||
transition: max-height 150ms ease-in-out, opacity 300ms linear;
|
||||
transition:
|
||||
max-height 150ms ease-in-out,
|
||||
opacity 300ms linear;
|
||||
opacity: 1;
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
|
@ -4268,34 +4268,31 @@ a.status-card.compact:hover {
|
|||
}
|
||||
|
||||
&__overlay {
|
||||
display: block;
|
||||
background: transparent;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba($black, 0.5);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
|
||||
&__label {
|
||||
display: inline-block;
|
||||
background: rgba($base-overlay-background, 0.5);
|
||||
border-radius: 8px;
|
||||
padding: 8px 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
flex-direction: column;
|
||||
color: $primary-text-color;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:active {
|
||||
.spoiler-button__overlay__label {
|
||||
background: rgba($base-overlay-background, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
.spoiler-button__overlay__label {
|
||||
background: rgba($base-overlay-background, 0.5);
|
||||
}
|
||||
&__action {
|
||||
font-weight: 400;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5874,6 +5871,7 @@ a.status-card.compact:hover {
|
|||
&__toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
|
||||
& > span {
|
||||
font-size: 17px;
|
||||
|
@ -7045,7 +7043,8 @@ noscript {
|
|||
.navigation-bar {
|
||||
& > a:first-child {
|
||||
will-change: margin-top, margin-inline-start, margin-inline-end, width;
|
||||
transition: margin-top $duration $delay,
|
||||
transition:
|
||||
margin-top $duration $delay,
|
||||
margin-inline-start $duration ($duration + $delay),
|
||||
margin-inline-end $duration ($duration + $delay);
|
||||
}
|
||||
|
@ -7058,12 +7057,15 @@ noscript {
|
|||
.navigation-bar__actions {
|
||||
& > .icon-button.close {
|
||||
will-change: opacity transform;
|
||||
transition: opacity $duration * 0.5 $delay, transform $duration $delay;
|
||||
transition:
|
||||
opacity $duration * 0.5 $delay,
|
||||
transform $duration $delay;
|
||||
}
|
||||
|
||||
& > .compose__action-bar .icon-button {
|
||||
will-change: opacity transform;
|
||||
transition: opacity $duration * 0.5 $delay + $duration * 0.5,
|
||||
transition:
|
||||
opacity $duration * 0.5 $delay + $duration * 0.5,
|
||||
transform $duration $delay;
|
||||
}
|
||||
}
|
||||
|
@ -9214,3 +9216,63 @@ noscript {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.notification-list {
|
||||
position: fixed;
|
||||
bottom: 2rem;
|
||||
inset-inline-start: 0;
|
||||
z-index: 999;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.notification-bar {
|
||||
flex: 0 0 auto;
|
||||
position: relative;
|
||||
inset-inline-start: -100%;
|
||||
width: auto;
|
||||
padding: 15px;
|
||||
margin: 0;
|
||||
color: $white;
|
||||
background: rgba($black, 0.85);
|
||||
backdrop-filter: blur(8px);
|
||||
border: 1px solid rgba(lighten($classic-base-color, 4%), 0.85);
|
||||
border-radius: 8px;
|
||||
box-shadow:
|
||||
0 10px 15px -3px rgba($base-shadow-color, 0.25),
|
||||
0 4px 6px -4px rgba($base-shadow-color, 0.25);
|
||||
cursor: default;
|
||||
transition: 0.5s cubic-bezier(0.89, 0.01, 0.5, 1.1);
|
||||
transform: translateZ(0);
|
||||
font-size: 15px;
|
||||
line-height: 21px;
|
||||
|
||||
&.notification-bar-active {
|
||||
inset-inline-start: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.notification-bar-title {
|
||||
margin-inline-end: 5px;
|
||||
}
|
||||
|
||||
.notification-bar-title,
|
||||
.notification-bar-action {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.notification-bar-action {
|
||||
text-transform: uppercase;
|
||||
margin-inline-start: 10px;
|
||||
cursor: pointer;
|
||||
color: $blurple-300;
|
||||
border-radius: 4px;
|
||||
padding: 0 4px;
|
||||
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:active {
|
||||
background: rgba($ui-base-color, 0.85);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,66 +77,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
.button.logo-button {
|
||||
flex: 0 auto;
|
||||
font-size: 14px;
|
||||
background: darken($ui-highlight-color, 2%);
|
||||
color: $primary-text-color;
|
||||
text-transform: none;
|
||||
line-height: 1.2;
|
||||
.button.logo-button svg {
|
||||
width: 20px;
|
||||
height: auto;
|
||||
min-height: 36px;
|
||||
min-width: 88px;
|
||||
white-space: normal;
|
||||
overflow-wrap: break-word;
|
||||
hyphens: auto;
|
||||
padding: 0 15px;
|
||||
border: 0;
|
||||
|
||||
svg {
|
||||
width: 20px;
|
||||
height: auto;
|
||||
vertical-align: middle;
|
||||
margin-inline-end: 5px;
|
||||
fill: $primary-text-color;
|
||||
}
|
||||
|
||||
&:active,
|
||||
&:focus,
|
||||
&:hover {
|
||||
background: $ui-highlight-color;
|
||||
}
|
||||
|
||||
&:disabled,
|
||||
&.disabled {
|
||||
&:active,
|
||||
&:focus,
|
||||
&:hover {
|
||||
background: $ui-primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
&.button--destructive {
|
||||
&:active,
|
||||
&:focus,
|
||||
&:hover {
|
||||
background: $error-red;
|
||||
}
|
||||
}
|
||||
vertical-align: middle;
|
||||
margin-inline-end: 5px;
|
||||
fill: $primary-text-color;
|
||||
|
||||
@media screen and (max-width: $no-gap-breakpoint) {
|
||||
svg {
|
||||
display: none;
|
||||
}
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
a.button.logo-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.embed {
|
||||
.status__content[data-spoiler='folded'] {
|
||||
.e-content {
|
||||
|
|
|
@ -143,11 +143,11 @@ class ActivityPub::Activity
|
|||
end
|
||||
|
||||
def follow_request_from_object
|
||||
@follow_request ||= FollowRequest.find_by(target_account: @account, uri: object_uri) unless object_uri.nil?
|
||||
@follow_request_from_object ||= FollowRequest.find_by(target_account: @account, uri: object_uri) unless object_uri.nil?
|
||||
end
|
||||
|
||||
def follow_from_object
|
||||
@follow ||= ::Follow.find_by(target_account: @account, uri: object_uri) unless object_uri.nil?
|
||||
@follow_from_object ||= ::Follow.find_by(target_account: @account, uri: object_uri) unless object_uri.nil?
|
||||
end
|
||||
|
||||
def fetch_remote_original_status
|
||||
|
|
|
@ -4,13 +4,14 @@ class ActivityPub::Activity::Flag < ActivityPub::Activity
|
|||
def perform
|
||||
return if skip_reports?
|
||||
|
||||
target_accounts = object_uris.filter_map { |uri| account_from_uri(uri) }.select(&:local?)
|
||||
target_statuses_by_account = object_uris.filter_map { |uri| status_from_uri(uri) }.select(&:local?).group_by(&:account_id)
|
||||
target_accounts = object_uris.filter_map { |uri| account_from_uri(uri) }
|
||||
target_statuses_by_account = object_uris.filter_map { |uri| status_from_uri(uri) }.group_by(&:account_id)
|
||||
|
||||
target_accounts.each do |target_account|
|
||||
target_statuses = target_statuses_by_account[target_account.id]
|
||||
target_statuses = target_statuses_by_account[target_account.id]
|
||||
replied_to_accounts = Account.local.where(id: target_statuses.filter_map(&:in_reply_to_account_id))
|
||||
|
||||
next if target_account.suspended?
|
||||
next if target_account.suspended? || (!target_account.local? && replied_to_accounts.none?)
|
||||
|
||||
ReportService.new.call(
|
||||
@account,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'connection_pool'
|
||||
require_relative './shared_timed_stack'
|
||||
require_relative 'shared_timed_stack'
|
||||
|
||||
class ConnectionPool::SharedConnectionPool < ConnectionPool
|
||||
def initialize(options = {}, &block)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue