-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Displaying wrong composer for archived room (#31292)
- Loading branch information
1 parent
631f6a4
commit 132853a
Showing
5 changed files
with
56 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/meteor": patch | ||
--- | ||
|
||
Fixed the problem of displaying the wrong composer for archived room |
16 changes: 16 additions & 0 deletions
16
apps/meteor/client/views/room/composer/ComposerArchived.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { MessageFooterCallout, MessageFooterCalloutContent } from '@rocket.chat/ui-composer'; | ||
import { useTranslation } from '@rocket.chat/ui-contexts'; | ||
import type { ReactElement } from 'react'; | ||
import React from 'react'; | ||
|
||
const ComposerReadOnly = (): ReactElement => { | ||
const t = useTranslation(); | ||
|
||
return ( | ||
<MessageFooterCallout> | ||
<MessageFooterCalloutContent>{t('Room_archived')}</MessageFooterCalloutContent> | ||
</MessageFooterCallout> | ||
); | ||
}; | ||
|
||
export default ComposerReadOnly; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
apps/meteor/client/views/room/composer/hooks/useMessageComposerIsArchived.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { ISubscription } from '@rocket.chat/core-typings'; | ||
import { useCallback } from 'react'; | ||
|
||
import { useReactiveValue } from '../../../../hooks/useReactiveValue'; | ||
import { roomCoordinator } from '../../../../lib/rooms/roomCoordinator'; | ||
|
||
export const useMessageComposerIsArchived = (rid: string, subscription?: ISubscription): boolean => { | ||
const isArchived = useReactiveValue( | ||
useCallback( | ||
() => roomCoordinator.archived(rid) || Boolean(subscription && subscription.t === 'd' && subscription.archived), | ||
[rid, subscription], | ||
), | ||
); | ||
|
||
return Boolean(isArchived); | ||
}; |
15 changes: 6 additions & 9 deletions
15
apps/meteor/client/views/room/composer/hooks/useMessageComposerIsReadOnly.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
import type { ISubscription, IUser } from '@rocket.chat/core-typings'; | ||
import type { IUser } from '@rocket.chat/core-typings'; | ||
import { Meteor } from 'meteor/meteor'; | ||
import { useCallback } from 'react'; | ||
|
||
import { useReactiveValue } from '../../../../hooks/useReactiveValue'; | ||
import { roomCoordinator } from '../../../../lib/rooms/roomCoordinator'; | ||
|
||
export const useMessageComposerIsReadOnly = (rid: string, subscription?: ISubscription): boolean => { | ||
const [isReadOnly, isArchived] = useReactiveValue( | ||
export const useMessageComposerIsReadOnly = (rid: string): boolean => { | ||
const isReadOnly = useReactiveValue( | ||
useCallback( | ||
() => [ | ||
roomCoordinator.readOnly(rid, Meteor.users.findOne(Meteor.userId() as string, { fields: { username: 1 } }) as IUser), | ||
roomCoordinator.archived(rid) || Boolean(subscription && subscription.t === 'd' && subscription.archived), | ||
], | ||
[rid, subscription], | ||
() => roomCoordinator.readOnly(rid, Meteor.users.findOne(Meteor.userId() as string, { fields: { username: 1 } }) as IUser), | ||
[rid], | ||
), | ||
); | ||
|
||
return Boolean(isReadOnly || isArchived); | ||
return Boolean(isReadOnly); | ||
}; |