Skip to content

Commit

Permalink
Chore: Split useUserInfoActions into small hooks (#25747)
Browse files Browse the repository at this point in the history
<!-- This is a pull request template, you do not need to uncomment or remove the comments, they won't show up in the PR text. -->

<!-- Your Pull Request name should start with one of the following tags
  [NEW] For new features
  [IMPROVE] For an improvement (performance or little improvements) in existing features
  [FIX] For bug fixes that affect the end-user
  [BREAK] For pull requests including breaking changes
  Chore: For small tasks
  Doc: For documentation
-->

<!-- Checklist!!! If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code. 
  - I have read the Contributing Guide - https://github.com/RocketChat/Rocket.Chat/blob/develop/.github/CONTRIBUTING.md#contributing-to-rocketchat doc
  - I have signed the CLA - https://cla-assistant.io/RocketChat/Rocket.Chat
  - Lint and unit tests pass locally with my changes
  - I have added tests that prove my fix is effective or that my feature works (if applicable)
  - I have added necessary documentation (if applicable)
  - Any dependent changes have been merged and published in downstream modules
-->

## Proposed changes (including videos or screenshots)
<!-- CHANGELOG -->
<!--
  Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
  If it fixes a bug or resolves a feature request, be sure to link to that issue below.
  This description will appear in the release notes if we accept the contribution.
-->

<!-- END CHANGELOG -->

## Issue(s)
<!-- Link the issues being closed by or related to this PR. For example, you can use #594 if this PR closes issue number 594 -->

## Steps to test or reproduce
<!-- Mention how you would reproduce the bug if not mentioned on the issue page already. Also mention which screens are going to have the changes if applicable -->

## Further comments
<!-- If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... -->
  • Loading branch information
dougfabris committed Jun 17, 2022
1 parent 06043f5 commit b46cb69
Show file tree
Hide file tree
Showing 20 changed files with 725 additions and 424 deletions.
14 changes: 7 additions & 7 deletions apps/meteor/client/views/hooks/useActionSpread.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useMemo } from 'react';
import { useMemo, ReactNode } from 'react';

type Action = {
label: string;
icon: string;
action: () => any;
export type Action = {
label: ReactNode;
icon?: string;
action: () => void;
};

type MenuOption = {
label: { label: string; icon: string };
action: Function;
label: { label: ReactNode; icon?: string };
action: () => void;
};

const mapOptions = ([key, { action, label, icon }]: [string, Action]): [string, MenuOption] => [
Expand Down
8 changes: 8 additions & 0 deletions apps/meteor/client/views/room/hooks/useUserHasRoomRole.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IRole, IRoom, IUser } from '@rocket.chat/core-typings';
import { useCallback } from 'react';

import { RoomRoles } from '../../../../app/models/client';
import { useReactiveValue } from '../../../hooks/useReactiveValue';

export const useUserHasRoomRole = (uid: IUser['_id'], rid: IRoom['_id'], role: IRole['name']): boolean =>
useReactiveValue(useCallback(() => !!RoomRoles.findOne({ rid, 'u._id': uid, 'roles': role }), [uid, rid, role]));
Loading

0 comments on commit b46cb69

Please sign in to comment.