frontend-rw #1
5 changed files with 7 additions and 12 deletions
|
@ -9,12 +9,11 @@ import { getTextDirection } from 'pl-fe/utils/rtl';
|
||||||
import AnnouncementContent from './announcement-content';
|
import AnnouncementContent from './announcement-content';
|
||||||
import ReactionsBar from './reactions-bar';
|
import ReactionsBar from './reactions-bar';
|
||||||
|
|
||||||
import type { Map as ImmutableMap } from 'immutable';
|
|
||||||
import type { Announcement as AnnouncementEntity, CustomEmoji } from 'pl-api';
|
import type { Announcement as AnnouncementEntity, CustomEmoji } from 'pl-api';
|
||||||
|
|
||||||
interface IAnnouncement {
|
interface IAnnouncement {
|
||||||
announcement: AnnouncementEntity;
|
announcement: AnnouncementEntity;
|
||||||
emojiMap: ImmutableMap<string, CustomEmoji>;
|
emojiMap: Record<string, CustomEmoji>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Announcement: React.FC<IAnnouncement> = ({ announcement, emojiMap }) => {
|
const Announcement: React.FC<IAnnouncement> = ({ announcement, emojiMap }) => {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { Map as ImmutableMap } from 'immutable';
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import ReactSwipeableViews from 'react-swipeable-views';
|
import ReactSwipeableViews from 'react-swipeable-views';
|
||||||
|
@ -16,7 +15,7 @@ import Announcement from './announcement';
|
||||||
import type { CustomEmoji } from 'pl-api';
|
import type { CustomEmoji } from 'pl-api';
|
||||||
import type { RootState } from 'pl-fe/store';
|
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 AnnouncementsPanel = () => {
|
||||||
const emojiMap = useAppSelector(state => customEmojiMap(state));
|
const emojiMap = useAppSelector(state => customEmojiMap(state));
|
||||||
|
|
|
@ -4,12 +4,11 @@ import unicodeMapping from 'pl-fe/features/emoji/mapping';
|
||||||
import { useSettings } from 'pl-fe/hooks/use-settings';
|
import { useSettings } from 'pl-fe/hooks/use-settings';
|
||||||
import { joinPublicPath } from 'pl-fe/utils/static';
|
import { joinPublicPath } from 'pl-fe/utils/static';
|
||||||
|
|
||||||
import type { Map as ImmutableMap } from 'immutable';
|
|
||||||
import type { CustomEmoji } from 'pl-api';
|
import type { CustomEmoji } from 'pl-api';
|
||||||
|
|
||||||
interface IEmoji {
|
interface IEmoji {
|
||||||
emoji: string;
|
emoji: string;
|
||||||
emojiMap: ImmutableMap<string, CustomEmoji>;
|
emojiMap: Record<string, CustomEmoji>;
|
||||||
hovered: boolean;
|
hovered: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,8 +30,8 @@ const Emoji: React.FC<IEmoji> = ({ emoji, emojiMap, hovered }) => {
|
||||||
src={joinPublicPath(`packs/emoji/${filename}.svg`)}
|
src={joinPublicPath(`packs/emoji/${filename}.svg`)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (emojiMap.get(emoji)) {
|
} else if (emojiMap[emoji]) {
|
||||||
const filename = (autoPlayGif || hovered) ? emojiMap.getIn([emoji, 'url']) : emojiMap.getIn([emoji, 'static_url']);
|
const filename = (autoPlayGif || hovered) ? emojiMap[emoji].url : emojiMap[emoji].static_url;
|
||||||
const shortCode = `:${emoji}:`;
|
const shortCode = `:${emoji}:`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -7,13 +7,12 @@ import unicodeMapping from 'pl-fe/features/emoji/mapping';
|
||||||
|
|
||||||
import Emoji from './emoji';
|
import Emoji from './emoji';
|
||||||
|
|
||||||
import type { Map as ImmutableMap } from 'immutable';
|
|
||||||
import type { AnnouncementReaction, CustomEmoji } from 'pl-api';
|
import type { AnnouncementReaction, CustomEmoji } from 'pl-api';
|
||||||
|
|
||||||
interface IReaction {
|
interface IReaction {
|
||||||
announcementId: string;
|
announcementId: string;
|
||||||
reaction: AnnouncementReaction;
|
reaction: AnnouncementReaction;
|
||||||
emojiMap: ImmutableMap<string, CustomEmoji>;
|
emojiMap: Record<string, CustomEmoji>;
|
||||||
style: React.CSSProperties;
|
style: React.CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,13 @@ import { useSettings } from 'pl-fe/hooks/use-settings';
|
||||||
|
|
||||||
import Reaction from './reaction';
|
import Reaction from './reaction';
|
||||||
|
|
||||||
import type { Map as ImmutableMap } from 'immutable';
|
|
||||||
import type { AnnouncementReaction, CustomEmoji } from 'pl-api';
|
import type { AnnouncementReaction, CustomEmoji } from 'pl-api';
|
||||||
import type { Emoji, NativeEmoji } from 'pl-fe/features/emoji';
|
import type { Emoji, NativeEmoji } from 'pl-fe/features/emoji';
|
||||||
|
|
||||||
interface IReactionsBar {
|
interface IReactionsBar {
|
||||||
announcementId: string;
|
announcementId: string;
|
||||||
reactions: Array<AnnouncementReaction>;
|
reactions: Array<AnnouncementReaction>;
|
||||||
emojiMap: ImmutableMap<string, CustomEmoji>;
|
emojiMap: Record<string, CustomEmoji>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReactionsBar: React.FC<IReactionsBar> = ({ announcementId, reactions, emojiMap }) => {
|
const ReactionsBar: React.FC<IReactionsBar> = ({ announcementId, reactions, emojiMap }) => {
|
||||||
|
|
Loading…
Reference in a new issue