Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Shailesh351/346e68ac8d67dc2046a3508ead23378a to your computer and use it in GitHub Desktop.
Save Shailesh351/346e68ac8d67dc2046a3508ead23378a to your computer and use it in GitHub Desktop.
Rocket.Chat Custom Script to Add Hide Button in the Toolbar

Rocket.Chat Custom JS Script

1) Go to Admin Setting -> Layout -> Custom Scripts -> Custom Script for Logged In Users

2) Copy and paste below script

const { useContext } = require('react');
const { useMethod } = require('/client/contexts/ServerContext.ts');
const { addAction } = require('/client/views/room/lib/Toolbox/index.tsx');

(() => {
	addAction('hide-livechat-room', () => {
		const hideRoom = useMethod('hideRoom');
		return {
			groups: ['channel', 'group', 'direct', 'direct_multiple', 'live'],
			id: 'hide-livechat-room',
			title: 'Hide',
			icon: 'eye-off',
			order: -2,
			action: async () => {
				const rid = Session.get('openedRoom');
				await hideRoom(rid);
			},
		};
	});
})();

3) Open Livechat Conversation. You will find hide icon in the chat header.

4) Currently it will be shown for all the chat types. You can change the groups array to apply this button on particaular type of chat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment