The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/client/views/room/contexts/RoomContext.ts

32 lines
750 B

import { createContext, useContext } from 'react';
import { IRoom, IOmnichannelRoom, isOmnichannelRoom } from '../../../../definition/IRoom';
export type RoomContextValue = {
rid: IRoom['_id'];
room: IRoom;
};
export const RoomContext = createContext<RoomContextValue | null>(null);
export const useRoom = (): IRoom => {
const { room } = useContext(RoomContext) || {};
if (!room) {
throw new Error('use useRoom only inside opened rooms');
}
return room;
};
export const useOmnichannelRoom = (): IOmnichannelRoom => {
const { room } = useContext(RoomContext) || {};
[IMPROVE] Add modal to close chats when tags/comments are not required (#22245) * [IMPROVE] Add modal to close chats when tags/comments are not required (#22225) * [IMPROVE] Add modal to close chats when tags/comments are not required * department from subscribe correctly * fix departmentId and department from subscription. * undo sub departmentId change * undo sub departmentId change * fix room type * fix RoomHeader props type * Tags required with asterisk as all default labels of RC. * get deparment from subscription or room. * normalizing subscription and room into useOmnichannelRoom * Get room from useOmnichannelRoom into omnichannel header. * trying to skip build fail * Revert "trying to skip build fail" This reverts commit 2c581a2052fba021f34caf2e15a0bb01bfad9612. Co-authored-by: Martin <martin.schoeler@rocket.chat> Co-authored-by: pierre-lehnen-rc <55164754+pierre-lehnen-rc@users.noreply.github.com> Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com> Co-authored-by: Rafael Ferreira <rafael.ferreira@rocket.chat> Co-authored-by: Tiago Evangelista Pinto <tiago.evangelista@rocket.chat> * Remove subscription interface from output. * remove cache from CI install * Revert "remove cache from CI install" This reverts commit f72ac4472c895099ce320472dc92e5570002c614. Co-authored-by: Martin <martin.schoeler@rocket.chat> Co-authored-by: pierre-lehnen-rc <55164754+pierre-lehnen-rc@users.noreply.github.com> Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com> Co-authored-by: Rafael Ferreira <rafael.ferreira@rocket.chat> Co-authored-by: Tiago Evangelista Pinto <tiago.evangelista@rocket.chat>
4 years ago
if (!room) {
throw new Error('use useRoom only inside opened rooms');
}
if (!isOmnichannelRoom(room)) {
throw new Error('invalid room type');
}
[IMPROVE] Add modal to close chats when tags/comments are not required (#22245) * [IMPROVE] Add modal to close chats when tags/comments are not required (#22225) * [IMPROVE] Add modal to close chats when tags/comments are not required * department from subscribe correctly * fix departmentId and department from subscription. * undo sub departmentId change * undo sub departmentId change * fix room type * fix RoomHeader props type * Tags required with asterisk as all default labels of RC. * get deparment from subscription or room. * normalizing subscription and room into useOmnichannelRoom * Get room from useOmnichannelRoom into omnichannel header. * trying to skip build fail * Revert "trying to skip build fail" This reverts commit 2c581a2052fba021f34caf2e15a0bb01bfad9612. Co-authored-by: Martin <martin.schoeler@rocket.chat> Co-authored-by: pierre-lehnen-rc <55164754+pierre-lehnen-rc@users.noreply.github.com> Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com> Co-authored-by: Rafael Ferreira <rafael.ferreira@rocket.chat> Co-authored-by: Tiago Evangelista Pinto <tiago.evangelista@rocket.chat> * Remove subscription interface from output. * remove cache from CI install * Revert "remove cache from CI install" This reverts commit f72ac4472c895099ce320472dc92e5570002c614. Co-authored-by: Martin <martin.schoeler@rocket.chat> Co-authored-by: pierre-lehnen-rc <55164754+pierre-lehnen-rc@users.noreply.github.com> Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com> Co-authored-by: Rafael Ferreira <rafael.ferreira@rocket.chat> Co-authored-by: Tiago Evangelista Pinto <tiago.evangelista@rocket.chat>
4 years ago
return room;
};