Skip to content

Commit

Permalink
fix: try fix flash on mobile friend page
Browse files Browse the repository at this point in the history
  • Loading branch information
OXeu committed Aug 4, 2024
1 parent ff2b0c8 commit 87fb5fd
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions client/src/page/friends.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import i18next from "i18next";
import { useCallback, useContext, useEffect, useRef, useState } from "react";
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
import { Helmet } from 'react-helmet';
import { useTranslation } from "react-i18next";
import Modal from 'react-modal';
Expand Down Expand Up @@ -86,9 +86,6 @@ export function FriendsPage() {
})
ref.current = true
}, [])
function publishButton() {
publish({ name, desc, avatar, url, showAlert })
}
return (<>
<Helmet>
<title>{`${t('friends.title')} - ${process.env.NAME}`}</title>
Expand Down Expand Up @@ -117,7 +114,7 @@ export function FriendsPage() {
<Input value={avatar} setValue={setAvatar} placeholder={t('avatar.url')} className="mt-2" />
<Input value={url} setValue={setUrl} placeholder={t('url')} className="my-2" />
<div className='flex flex-row justify-center'>
<button onClick={publishButton} className='basis-1/2 bg-theme text-white py-4 rounded-full shadow-xl shadow-light'>{t('create.title')}</button>
<button onClick={() => publish({ name, desc, avatar, url, showAlert })} className='basis-1/2 bg-theme text-white py-4 rounded-full shadow-xl shadow-light'>{t('create.title')}</button>
</div>
</div>
</div>
Expand All @@ -130,7 +127,7 @@ export function FriendsPage() {
}

function FriendList({ title, show, friends }: { title: string, show: boolean, friends: FriendItem[] }) {
return (<>
return useMemo(() => <>
{
show && <>
<div className="wauto text-start py-4">
Expand All @@ -145,7 +142,7 @@ function FriendList({ title, show, friends }: { title: string, show: boolean, fr
</div>
</>
}
</>)
</>, [title, show, friends])
}

function Friend({ friend }: { friend: FriendItem }) {
Expand Down Expand Up @@ -199,11 +196,11 @@ function Friend({ friend }: { friend: FriendItem }) {
})
}, [avatar, name, desc, url, status])

const statusOption = [
const statusOption = useMemo(()=>[
{ value: -1, label: t('friends.review.rejected') },
{ value: 0, label: t('friends.review.waiting') },
{ value: 1, label: t('friends.review.accepted') }
]
],[])
return (
<>
<a title={friend.name} href={friend.url} target="_blank" className="bg-button w-full bg-w rounded-xl p-4 flex flex-col justify-center items-center relative ani-show">
Expand Down

0 comments on commit 87fb5fd

Please sign in to comment.