'how to detect efficiently currentUser / me is connected with another user / connectionUser __ firebase __ flutter

lets say I am currentUser and in the waitingList, the connectionUser find me in the waitingList and get currentUserId and then build a chatRoom = currentUserId + connectionUserId;

so connectionUser can send message to this chatRoom, but since I / currentUser didnt get notified, my question is how to efficiently get this chatRoomId, shall I query the whole chatRoomList and get chatRoomId which contains currentUserId.

or let connectionUser update the value of currentUser status and send his connectionUserId to the currentUser snapshot? Is it safe?

Or do we have a better solution? Thanks for any clue!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source