don't require connection to view guild

This commit is contained in:
Michael Peters 2022-01-24 00:10:58 -06:00
parent afd2939fa1
commit 59856ca197
2 changed files with 13 additions and 26 deletions

View File

@ -20,7 +20,6 @@ const MessageList: FC<MessageListProps> = (props: MessageListProps) => {
const scrollToBottomFunc = useCallback(() => { const scrollToBottomFunc = useCallback(() => {
if (!infiniteScrollElementRef.current) return; if (!infiniteScrollElementRef.current) return;
console.log('scrolling to bottom');
infiniteScrollElementRef.current.scrollTop = 0; // Keep in mind that this is reversed for flex-flow: column-reverse infiniteScrollElementRef.current.scrollTop = 0; // Keep in mind that this is reversed for flex-flow: column-reverse
}, []); }, []);

View File

@ -223,35 +223,23 @@ export default class CombinedGuild extends EventEmitter<Connectable & Conflictab
resourceRAMCache: ResourceRAMCache, resourceRAMCache: ResourceRAMCache,
personalDB: PersonalDB personalDB: PersonalDB
) { ) {
if (guildMetadata.memberId === null) {
throw new Error('trying to launch guild that we have never verified with');
}
const socket = socketio.connect(socketConfig.url, { const socket = socketio.connect(socketConfig.url, {
forceNew: true, forceNew: true,
ca: socketConfig.cert ca: socketConfig.cert
}); });
return new Promise<CombinedGuild>((resolve, reject) => { const socketVerifier = new SocketVerifier(socket, socketConfig.publicKey, socketConfig.privateKey);
const connectFail = (err: unknown) => { return new CombinedGuild(
socket.off('connect', connectSucceed); guildMetadata.id,
reject(new Error('unable to connect: ' + (err as Error).message)); guildMetadata.memberId,
} socket,
const connectSucceed = async () => { socketVerifier,
socket.off('connect_error', connectFail); messageRAMCache,
const socketVerifier = new SocketVerifier(socket, socketConfig.publicKey, socketConfig.privateKey); resourceRAMCache,
const memberId = await socketVerifier.verify(); personalDB
if (guildMetadata.memberId && memberId !== guildMetadata.memberId) { );
reject(new Error('Verified member differs from original member'));
}
resolve(new CombinedGuild(
guildMetadata.id,
memberId,
socket,
socketVerifier,
messageRAMCache,
resourceRAMCache,
personalDB
));
}
socket.once('connect', connectSucceed);
socket.once('connect_error', connectFail);
});
} }
public isSocketVerified(): boolean { public isSocketVerified(): boolean {