frontend-rw #1

Merged
marcin merged 347 commits from frontend-rw into develop 2024-12-05 15:32:18 -08:00
5 changed files with 7 additions and 12 deletions
Showing only changes of commit f560896311 - Show all commits

View file

@ -9,12 +9,11 @@ import { getTextDirection } from 'pl-fe/utils/rtl';
import AnnouncementContent from './announcement-content';
import ReactionsBar from './reactions-bar';
import type { Map as ImmutableMap } from 'immutable';
import type { Announcement as AnnouncementEntity, CustomEmoji } from 'pl-api';
interface IAnnouncement {
announcement: AnnouncementEntity;
emojiMap: ImmutableMap<string, CustomEmoji>;
emojiMap: Record<string, CustomEmoji>;
}
const Announcement: React.FC<IAnnouncement> = ({ announcement, emojiMap }) => {

View file

@ -1,5 +1,4 @@
import clsx from 'clsx';
import { Map as ImmutableMap } from 'immutable';
import React, { useState } from 'react';
import { FormattedMessage } from 'react-intl';
import ReactSwipeableViews from 'react-swipeable-views';
@ -16,7 +15,7 @@ import Announcement from './announcement';
import type { CustomEmoji } from 'pl-api';
import type { RootState } from 'pl-fe/store';
const customEmojiMap = createSelector([(state: RootState) => state.custom_emojis], items => items.reduce((map, emoji) => map.set(emoji.shortcode, emoji), ImmutableMap<string, CustomEmoji>()));
const customEmojiMap = createSelector([(state: RootState) => state.custom_emojis], items => items.reduce<Record<string, CustomEmoji>>((map, emoji) => (map[emoji.shortcode] = emoji, map), {}));
const AnnouncementsPanel = () => {
const emojiMap = useAppSelector(state => customEmojiMap(state));

View file

@ -4,12 +4,11 @@ import unicodeMapping from 'pl-fe/features/emoji/mapping';
import { useSettings } from 'pl-fe/hooks/use-settings';
import { joinPublicPath } from 'pl-fe/utils/static';
import type { Map as ImmutableMap } from 'immutable';
import type { CustomEmoji } from 'pl-api';
interface IEmoji {
emoji: string;
emojiMap: ImmutableMap<string, CustomEmoji>;
emojiMap: Record<string, CustomEmoji>;
hovered: boolean;
}
@ -31,8 +30,8 @@ const Emoji: React.FC<IEmoji> = ({ emoji, emojiMap, hovered }) => {
src={joinPublicPath(`packs/emoji/${filename}.svg`)}
/>
);
} else if (emojiMap.get(emoji)) {
const filename = (autoPlayGif || hovered) ? emojiMap.getIn([emoji, 'url']) : emojiMap.getIn([emoji, 'static_url']);
} else if (emojiMap[emoji]) {
const filename = (autoPlayGif || hovered) ? emojiMap[emoji].url : emojiMap[emoji].static_url;
const shortCode = `:${emoji}:`;
return (

View file

@ -7,13 +7,12 @@ import unicodeMapping from 'pl-fe/features/emoji/mapping';
import Emoji from './emoji';
import type { Map as ImmutableMap } from 'immutable';
import type { AnnouncementReaction, CustomEmoji } from 'pl-api';
interface IReaction {
announcementId: string;
reaction: AnnouncementReaction;
emojiMap: ImmutableMap<string, CustomEmoji>;
emojiMap: Record<string, CustomEmoji>;
style: React.CSSProperties;
}

View file

@ -8,14 +8,13 @@ import { useSettings } from 'pl-fe/hooks/use-settings';
import Reaction from './reaction';
import type { Map as ImmutableMap } from 'immutable';
import type { AnnouncementReaction, CustomEmoji } from 'pl-api';
import type { Emoji, NativeEmoji } from 'pl-fe/features/emoji';
interface IReactionsBar {
announcementId: string;
reactions: Array<AnnouncementReaction>;
emojiMap: ImmutableMap<string, CustomEmoji>;
emojiMap: Record<string, CustomEmoji>;
}
const ReactionsBar: React.FC<IReactionsBar> = ({ announcementId, reactions, emojiMap }) => {