mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-16 01:09:55 +00:00
[Glitch] Force modern emoji experimental to be dev mode only
Port dfaca794bf to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -3,8 +3,8 @@ import { useCallback } from 'react';
|
|||||||
import { useLinks } from 'flavours/glitch/hooks/useLinks';
|
import { useLinks } from 'flavours/glitch/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,9 +13,10 @@ import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react'
|
|||||||
import { Icon } from 'flavours/glitch/components/icon';
|
import { Icon } from 'flavours/glitch/components/icon';
|
||||||
import { Poll } from 'flavours/glitch/components/poll';
|
import { Poll } from 'flavours/glitch/components/poll';
|
||||||
import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context';
|
import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context';
|
||||||
import { autoPlayGif, isFeatureEnabled, languages as preloadedLanguages } from 'flavours/glitch/initial_state';
|
import { autoPlayGif, languages as preloadedLanguages } from 'flavours/glitch/initial_state';
|
||||||
import { decode as decodeIDNA } from 'flavours/glitch/utils/idna';
|
import { decode as decodeIDNA } from 'flavours/glitch/utils/idna';
|
||||||
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)
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ const isLinkMisleading = (link) => {
|
|||||||
* @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 '@/flavours/glitch/api_types/custom_emoji';
|
import type { ApiCustomEmojiJSON } from '@/flavours/glitch/api_types/custom_emoji';
|
||||||
import { isFeatureEnabled } from '@/flavours/glitch/initial_state';
|
|
||||||
import type { CustomEmoji } from '@/flavours/glitch/models/custom_emoji';
|
import type { CustomEmoji } from '@/flavours/glitch/models/custom_emoji';
|
||||||
|
import { isModernEmojiEnabled } from '@/flavours/glitch/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}
|
||||||
|
|||||||
@@ -168,12 +168,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,16 +4,16 @@ import { Globals } from '@react-spring/web';
|
|||||||
|
|
||||||
import { setupBrowserNotifications } from 'flavours/glitch/actions/notifications';
|
import { setupBrowserNotifications } from 'flavours/glitch/actions/notifications';
|
||||||
import Mastodon from 'flavours/glitch/containers/mastodon';
|
import Mastodon from 'flavours/glitch/containers/mastodon';
|
||||||
import {
|
import { me, reduceMotion } from 'flavours/glitch/initial_state';
|
||||||
isFeatureEnabled,
|
|
||||||
me,
|
|
||||||
reduceMotion,
|
|
||||||
} from 'flavours/glitch/initial_state';
|
|
||||||
import * as perf from 'flavours/glitch/performance';
|
import * as perf from 'flavours/glitch/performance';
|
||||||
import ready from 'flavours/glitch/ready';
|
import ready from 'flavours/glitch/ready';
|
||||||
import { store } from 'flavours/glitch/store';
|
import { store } from 'flavours/glitch/store';
|
||||||
|
|
||||||
import { isProduction, isDevelopment } from './utils/environment';
|
import {
|
||||||
|
isProduction,
|
||||||
|
isDevelopment,
|
||||||
|
isModernEmojiEnabled,
|
||||||
|
} from './utils/environment';
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
perf.start('main()');
|
perf.start('main()');
|
||||||
@@ -33,7 +33,7 @@ function main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFeatureEnabled('modern_emojis')) {
|
if (isModernEmojiEnabled()) {
|
||||||
const { initializeEmoji } = await import(
|
const { initializeEmoji } = await import(
|
||||||
'@/flavours/glitch/features/emoji'
|
'@/flavours/glitch/features/emoji'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user