Save dismissed friend requests from room to room

This commit is contained in:
Bill 2022-08-01 12:17:05 -04:00
parent b21fce3e06
commit 5d48efff3e
2 changed files with 3 additions and 3 deletions

View File

@ -9,6 +9,7 @@ const useFriendsState = () =>
const [ friends, setFriends ] = useState<MessengerFriend[]>([]);
const [ requests, setRequests ] = useState<MessengerRequest[]>([]);
const [ sentRequests, setSentRequests ] = useState<number[]>([]);
const [ dismissedRequestIds, setDismissedRequestIds ] = useState<number[]>([]);
const [ settings, setSettings ] = useState<MessengerSettings>(null);
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);

View File

@ -7,8 +7,7 @@ import { useUserAddedEvent, useUserRemovedEvent } from '../engine';
const useFriendRequestWidgetState = () =>
{
const [ activeRequests, setActiveRequests ] = useState<{ roomIndex: number, request: MessengerRequest }[]>([]);
const [ dismissedRequestIds, setDismissedRequestIds ] = useState<number[]>([]);
const { requests = [] } = useFriends();
const { requests = [], dismissedRequestIds = [], setDismissedRequestIds = null } = useFriends();
const displayedRequests = useMemo(() => activeRequests.filter(request => (dismissedRequestIds.indexOf(request.request.requesterUserId) === -1)), [ activeRequests, dismissedRequestIds ]);