mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-22 22:30:52 +01:00
Save dismissed friend requests from room to room
This commit is contained in:
parent
b21fce3e06
commit
5d48efff3e
@ -9,6 +9,7 @@ const useFriendsState = () =>
|
|||||||
const [ friends, setFriends ] = useState<MessengerFriend[]>([]);
|
const [ friends, setFriends ] = useState<MessengerFriend[]>([]);
|
||||||
const [ requests, setRequests ] = useState<MessengerRequest[]>([]);
|
const [ requests, setRequests ] = useState<MessengerRequest[]>([]);
|
||||||
const [ sentRequests, setSentRequests ] = useState<number[]>([]);
|
const [ sentRequests, setSentRequests ] = useState<number[]>([]);
|
||||||
|
const [ dismissedRequestIds, setDismissedRequestIds ] = useState<number[]>([]);
|
||||||
const [ settings, setSettings ] = useState<MessengerSettings>(null);
|
const [ settings, setSettings ] = useState<MessengerSettings>(null);
|
||||||
|
|
||||||
const onlineFriends = useMemo(() =>
|
const onlineFriends = useMemo(() =>
|
||||||
@ -257,7 +258,7 @@ const useFriendsState = () =>
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return { friends, requests, sentRequests, settings, onlineFriends, offlineFriends, getFriend, canRequestFriend, requestFriend, requestResponse, followFriend, updateRelationship };
|
return { friends, requests, sentRequests, dismissedRequestIds, setDismissedRequestIds, settings, onlineFriends, offlineFriends, getFriend, canRequestFriend, requestFriend, requestResponse, followFriend, updateRelationship };
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useFriends = () => useBetween(useFriendsState);
|
export const useFriends = () => useBetween(useFriendsState);
|
||||||
|
@ -7,8 +7,7 @@ import { useUserAddedEvent, useUserRemovedEvent } from '../engine';
|
|||||||
const useFriendRequestWidgetState = () =>
|
const useFriendRequestWidgetState = () =>
|
||||||
{
|
{
|
||||||
const [ activeRequests, setActiveRequests ] = useState<{ roomIndex: number, request: MessengerRequest }[]>([]);
|
const [ activeRequests, setActiveRequests ] = useState<{ roomIndex: number, request: MessengerRequest }[]>([]);
|
||||||
const [ dismissedRequestIds, setDismissedRequestIds ] = useState<number[]>([]);
|
const { requests = [], dismissedRequestIds = [], setDismissedRequestIds = null } = useFriends();
|
||||||
const { requests = [] } = useFriends();
|
|
||||||
|
|
||||||
const displayedRequests = useMemo(() => activeRequests.filter(request => (dismissedRequestIds.indexOf(request.request.requesterUserId) === -1)), [ activeRequests, dismissedRequestIds ]);
|
const displayedRequests = useMemo(() => activeRequests.filter(request => (dismissedRequestIds.indexOf(request.request.requesterUserId) === -1)), [ activeRequests, dismissedRequestIds ]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user