UNPKG

@towns-protocol/react-sdk

Version:

React Hooks for Towns Protocol SDK

17 lines 667 B
import { isChannelStreamId, isDMChannelStreamId, isGDMChannelStreamId, isSpaceStreamId, spaceIdFromChannelId, } from '@towns-protocol/sdk'; export const getRoom = (sync, streamId) => { if (isChannelStreamId(streamId)) { return sync.spaces.getSpace(spaceIdFromChannelId(streamId)).getChannel(streamId); } if (isGDMChannelStreamId(streamId)) { return sync.gdms.getGdm(streamId); } if (isDMChannelStreamId(streamId)) { return sync.dms.getDm(streamId); } if (isSpaceStreamId(streamId)) { return sync.spaces.getSpace(streamId); } throw new Error('Invalid room type'); }; //# sourceMappingURL=utils.js.map