Skip to content

Commit

Permalink
fix: pre load confilt to talk emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
bbb169 committed Oct 22, 2023
1 parent 3c65580 commit 841e081
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/component/chatRoom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export default function ChatRoom (): React.JSX.Element {
}
`}>
<TypedPicker
className='asda'
locale='zh'
categories='people'
data={data} onEmojiSelect={(icon: any) => {
Expand Down
24 changes: 24 additions & 0 deletions src/component/preLoadEmojiPicker/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { css } from '@emotion/react';
import data from '@emoji-mart/data';
import Picker from '@emoji-mart/react';
import React, { useEffect, useState } from 'react';
const TypedPicker = Picker as unknown as (props: any) => React.JSX.Element;

export default function PreLoadEmojiPicker () {
const [loadPicker, setLoadPicker] = useState(true);

useEffect(() => {
setLoadPicker(false);
}, []);

return loadPicker ? <div css={css`
position: absolute;
visibility: hidden;
`}><TypedPicker
locale='zh'
categories='people'
data={data}
previewPosition='none'
perLine={5}
searchPosition='none'/></div> : <></>;
}
14 changes: 3 additions & 11 deletions src/pages/playRoom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ import { SettleMoal } from './component/settleMoal/index.js';
import { CustomFloatButton } from './component/customFloatButton/index.js';
import { isEmpty } from '@/utils/index.js';
import { CardType } from './type.js';
import data from '@emoji-mart/data';
import Picker from '@emoji-mart/react';
import { css } from '@emotion/react';
import React from 'react';
const TypedPicker = Picker as unknown as (props: any) => React.JSX.Element;
import PreLoadEmojiPicker from '@/component/preLoadEmojiPicker/index.js';

export function PlayRoom () {
const [otherPlayers, player, room, victoryPlayers, socket] = useInfosFromSocket();
const isButtonPosition = Boolean(room && player && room.buttonIndex === player.position);
const isButtonPosition = Boolean(room && player && room.buttonIndex === player.position);

return <infoContext.Provider value={{
room,
Expand All @@ -26,11 +22,7 @@ export function PlayRoom () {
victoryPlayers,
socket,
}}>
{/* pre load */}
<div css={css`
position: absolute;
visibility: hidden;
`}><TypedPicker data={data}/></div>
<PreLoadEmojiPicker />
<div css={palyRoomPageCss}>
<CustomFloatButton/>
<SettleMoal/>
Expand Down

0 comments on commit 841e081

Please sign in to comment.