Indicate if no member found

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-07-21 18:34:55 +05:30
parent 05f05bb577
commit 3aeb0c4d98
2 changed files with 4 additions and 1 deletions

View file

@ -226,6 +226,9 @@ export class BaseRoom extends EventEmitter {
} }
// Miss, load from storage and set in map // Miss, load from storage and set in map
const member = await loadMember({roomId: this._roomId, userId, storage: this._storage}); const member = await loadMember({roomId: this._roomId, userId, storage: this._storage});
if (!member) {
return false;
}
const observableMember = new RetainedObservableValue(member, () => this._observedMembers.delete(userId)); const observableMember = new RetainedObservableValue(member, () => this._observedMembers.delete(userId));
this._observedMembers.set(userId, observableMember); this._observedMembers.set(userId, observableMember);
return observableMember; return observableMember;

View file

@ -94,5 +94,5 @@ export async function fetchOrLoadMembers(options, logger) {
export async function loadMember({roomId, userId, storage}) { export async function loadMember({roomId, userId, storage}) {
const txn = await storage.readTxn([storage.storeNames.roomMembers,]); const txn = await storage.readTxn([storage.storeNames.roomMembers,]);
const member = await txn.roomMembers.get(roomId, userId); const member = await txn.roomMembers.get(roomId, userId);
return new RoomMember(member); return member? new RoomMember(member) : undefined;
} }