mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
Force modern emoji experimental to be dev mode only (#35505)
This commit is contained in:
parent
6fc77a545b
commit
dfaca794bf
|
@ -3,8 +3,8 @@ import { useCallback } from 'react';
|
||||||
import { useLinks } from 'mastodon/hooks/useLinks';
|
import { useLinks } from 'mastodon/hooks/useLinks';
|
||||||
|
|
||||||
import { EmojiHTML } from '../features/emoji/emoji_html';
|
import { EmojiHTML } from '../features/emoji/emoji_html';
|
||||||
import { isFeatureEnabled } from '../initial_state';
|
|
||||||
import { useAppSelector } from '../store';
|
import { useAppSelector } from '../store';
|
||||||
|
import { isModernEmojiEnabled } from '../utils/environment';
|
||||||
|
|
||||||
interface AccountBioProps {
|
interface AccountBioProps {
|
||||||
className: string;
|
className: string;
|
||||||
|
@ -32,9 +32,7 @@ export const AccountBio: React.FC<AccountBioProps> = ({
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return isFeatureEnabled('modern_emojis')
|
return isModernEmojiEnabled() ? account.note : account.note_emojified;
|
||||||
? account.note
|
|
||||||
: account.note_emojified;
|
|
||||||
});
|
});
|
||||||
const extraEmojis = useAppSelector((state) => {
|
const extraEmojis = useAppSelector((state) => {
|
||||||
const account = state.accounts.get(accountId);
|
const account = state.accounts.get(accountId);
|
||||||
|
|
|
@ -13,8 +13,9 @@ import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react'
|
||||||
import { Icon } from 'mastodon/components/icon';
|
import { Icon } from 'mastodon/components/icon';
|
||||||
import { Poll } from 'mastodon/components/poll';
|
import { Poll } from 'mastodon/components/poll';
|
||||||
import { identityContextPropShape, withIdentity } from 'mastodon/identity_context';
|
import { identityContextPropShape, withIdentity } from 'mastodon/identity_context';
|
||||||
import { autoPlayGif, isFeatureEnabled, languages as preloadedLanguages } from 'mastodon/initial_state';
|
import { autoPlayGif, languages as preloadedLanguages } from 'mastodon/initial_state';
|
||||||
import { EmojiHTML } from '../features/emoji/emoji_html';
|
import { EmojiHTML } from '../features/emoji/emoji_html';
|
||||||
|
import { isModernEmojiEnabled } from '../utils/environment';
|
||||||
|
|
||||||
const MAX_HEIGHT = 706; // 22px * 32 (+ 2px padding at the top)
|
const MAX_HEIGHT = 706; // 22px * 32 (+ 2px padding at the top)
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ const MAX_HEIGHT = 706; // 22px * 32 (+ 2px padding at the top)
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function getStatusContent(status) {
|
export function getStatusContent(status) {
|
||||||
if (isFeatureEnabled('modern_emojis')) {
|
if (isModernEmojiEnabled()) {
|
||||||
return status.getIn(['translation', 'content']) || status.get('content');
|
return status.getIn(['translation', 'content']) || status.get('content');
|
||||||
}
|
}
|
||||||
return status.getIn(['translation', 'contentHtml']) || status.get('contentHtml');
|
return status.getIn(['translation', 'contentHtml']) || status.get('contentHtml');
|
||||||
|
|
|
@ -5,8 +5,8 @@ import type { List as ImmutableList } from 'immutable';
|
||||||
import { isList } from 'immutable';
|
import { isList } from 'immutable';
|
||||||
|
|
||||||
import type { ApiCustomEmojiJSON } from '@/mastodon/api_types/custom_emoji';
|
import type { ApiCustomEmojiJSON } from '@/mastodon/api_types/custom_emoji';
|
||||||
import { isFeatureEnabled } from '@/mastodon/initial_state';
|
|
||||||
import type { CustomEmoji } from '@/mastodon/models/custom_emoji';
|
import type { CustomEmoji } from '@/mastodon/models/custom_emoji';
|
||||||
|
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
|
||||||
|
|
||||||
import { useEmojiAppState } from './hooks';
|
import { useEmojiAppState } from './hooks';
|
||||||
import { emojifyElement } from './render';
|
import { emojifyElement } from './render';
|
||||||
|
@ -25,7 +25,7 @@ export const EmojiHTML: React.FC<EmojiHTMLProps> = ({
|
||||||
extraEmojis,
|
extraEmojis,
|
||||||
...props
|
...props
|
||||||
}) => {
|
}) => {
|
||||||
if (isFeatureEnabled('modern_emojis')) {
|
if (isModernEmojiEnabled()) {
|
||||||
return (
|
return (
|
||||||
<ModernEmojiHTML
|
<ModernEmojiHTML
|
||||||
htmlString={htmlString}
|
htmlString={htmlString}
|
||||||
|
|
|
@ -142,12 +142,4 @@ export function getAccessToken() {
|
||||||
return getMeta('access_token');
|
return getMeta('access_token');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} feature
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
export function isFeatureEnabled(feature) {
|
|
||||||
return initialState?.features?.includes(feature) || false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default initialState;
|
export default initialState;
|
||||||
|
|
|
@ -4,12 +4,16 @@ import { Globals } from '@react-spring/web';
|
||||||
|
|
||||||
import { setupBrowserNotifications } from 'mastodon/actions/notifications';
|
import { setupBrowserNotifications } from 'mastodon/actions/notifications';
|
||||||
import Mastodon from 'mastodon/containers/mastodon';
|
import Mastodon from 'mastodon/containers/mastodon';
|
||||||
import { isFeatureEnabled, me, reduceMotion } from 'mastodon/initial_state';
|
import { me, reduceMotion } from 'mastodon/initial_state';
|
||||||
import * as perf from 'mastodon/performance';
|
import * as perf from 'mastodon/performance';
|
||||||
import ready from 'mastodon/ready';
|
import ready from 'mastodon/ready';
|
||||||
import { store } from 'mastodon/store';
|
import { store } from 'mastodon/store';
|
||||||
|
|
||||||
import { isProduction, isDevelopment } from './utils/environment';
|
import {
|
||||||
|
isProduction,
|
||||||
|
isDevelopment,
|
||||||
|
isModernEmojiEnabled,
|
||||||
|
} from './utils/environment';
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
perf.start('main()');
|
perf.start('main()');
|
||||||
|
@ -29,7 +33,7 @@ function main() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFeatureEnabled('modern_emojis')) {
|
if (isModernEmojiEnabled()) {
|
||||||
const { initializeEmoji } = await import('@/mastodon/features/emoji');
|
const { initializeEmoji } = await import('@/mastodon/features/emoji');
|
||||||
await initializeEmoji();
|
await initializeEmoji();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import initialState from '../initial_state';
|
||||||
|
|
||||||
export function isDevelopment() {
|
export function isDevelopment() {
|
||||||
if (typeof process !== 'undefined')
|
if (typeof process !== 'undefined')
|
||||||
return process.env.NODE_ENV === 'development';
|
return process.env.NODE_ENV === 'development';
|
||||||
|
@ -9,3 +11,13 @@ export function isProduction() {
|
||||||
return process.env.NODE_ENV === 'production';
|
return process.env.NODE_ENV === 'production';
|
||||||
else return import.meta.env.PROD;
|
else return import.meta.env.PROD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Features = 'modern_emojis';
|
||||||
|
|
||||||
|
export function isFeatureEnabled(feature: Features) {
|
||||||
|
return initialState?.features.includes(feature) ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isModernEmojiEnabled() {
|
||||||
|
return isFeatureEnabled('modern_emojis') && isDevelopment();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user