Merge pull request #3273 from ClearlyClaire/glitch-soc/merge-upstream

Merge upstream changes up to b5a2fe715d
This commit is contained in:
Claire
2025-11-12 09:49:33 +01:00
committed by GitHub
27 changed files with 268 additions and 270 deletions

View File

@@ -2,6 +2,8 @@ import { useCallback, forwardRef } from 'react';
import classNames from 'classnames';
import { usePrevious } from '../hooks/usePrevious';
import { AnimatedNumber } from './animated_number';
import type { IconProp } from './icon';
import { Icon } from './icon';
@@ -95,12 +97,15 @@ export const IconButton = forwardRef<HTMLButtonElement, Props>(
...(active ? activeStyle : {}),
};
const previousActive = usePrevious(active) ?? active;
const shouldAnimate = animate && active !== previousActive;
const classes = classNames(className, 'icon-button', {
active,
disabled,
inverted,
activate: animate && active,
deactivate: animate && !active,
activate: shouldAnimate && active,
deactivate: shouldAnimate && !active,
overlayed: overlay,
'icon-button--with-counter': typeof counter !== 'undefined',
});

View File

@@ -1,5 +1,5 @@
import { flattenEmojiData } from 'emojibase';
import type { CompactEmoji, FlatCompactEmoji } from 'emojibase';
import type { CompactEmoji, FlatCompactEmoji, Locale } from 'emojibase';
import {
putEmojiData,
@@ -43,9 +43,8 @@ async function fetchAndCheckEtag<ResultType extends object[]>(
if (locale === 'custom') {
url.pathname = '/api/v1/custom_emojis';
} else {
// This doesn't use isDevelopment() as that module loads initial state
// which breaks workers, as they cannot access the DOM.
url.pathname = `/packs${import.meta.env.DEV ? '-dev' : ''}/emoji/${locale}.json`;
const modulePath = await localeToPath(locale);
url.pathname = modulePath;
}
const oldEtag = await loadLatestEtag(locale);
@@ -80,3 +79,18 @@ async function fetchAndCheckEtag<ResultType extends object[]>(
return data;
}
const modules = import.meta.glob(
'../../../../../../node_modules/emojibase-data/**/compact.json',
{
as: 'url',
},
);
function localeToPath(locale: Locale) {
const key = `../../../../../../node_modules/emojibase-data/${locale}/compact.json`;
if (!modules[key] || typeof modules[key] !== 'function') {
throw new Error(`Unsupported locale: ${locale}`);
}
return modules[key]();
}