-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: Room Invited State #6857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: Room Invited State #6857
Changes from 14 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dd395dd
feat: added status and inviter to Subscriptions schema
aleksandernsilva 9bf3b5b
feat: added subscriptions migrations for status and inviter
aleksandernsilva 6d1891c
chore: updated subscription type
aleksandernsilva 4789b85
chore: updated merge to consider invite props
aleksandernsilva ced347c
feat: added status and inviter to schema
aleksandernsilva 1928efc
feat: Added invited state to rooms
aleksandernsilva 7ea0ad1
action: organized translations
aleksandernsilva 2165314
refactor: move logic out of InvitedRoom
aleksandernsilva 622dbde
chore: disable room header for invited rooms
aleksandernsilva 20802e7
refactor: switched text to view
aleksandernsilva c9f7a5e
refactor: moved isInviteSubscription to methods folder
aleksandernsilva 0283fe7
Merge branch 'develop' into feat/invited-room-state
diegolmello 2f3bc23
Fix chip width
diegolmello b384e01
feat: added invitation badge to room item
aleksandernsilva a36ea13
action: organized translations
aleksandernsilva a61df23
Merge branch 'feat/invited-room-state' of github.com:RocketChat/Rocke…
diegolmello 54b7a6a
Fix condensed and add stories
diegolmello ea3312c
Add missing translations
diegolmello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,21 @@ | ||
| import { type IInviteSubscription } from '../../definitions'; | ||
| import I18n from '../../i18n'; | ||
| import { getRoomTitle } from './helpers'; | ||
| import { replyRoomInvite } from './replyRoomInvite'; | ||
|
|
||
| export const getInvitationData = (room: IInviteSubscription) => { | ||
| const title = | ||
| room.t === 'd' | ||
| ? I18n.t('invited_room_title_dm') | ||
| : I18n.t('invited_room_title_channel', { room_name: getRoomTitle(room).slice(0, 30) }); | ||
|
|
||
| const description = room.t === 'd' ? I18n.t('invited_room_description_dm') : I18n.t('invited_room_description_channel'); | ||
|
|
||
| return { | ||
| title, | ||
| description, | ||
| inviter: room.inviter, | ||
| accept: () => replyRoomInvite(room.id, 'accept'), | ||
| reject: () => replyRoomInvite(room.id, 'reject') | ||
| }; | ||
| }; |
This file contains hidden or 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
This file contains hidden or 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,4 @@ | ||
| import { type IInviteSubscription, type ISubscription } from '../../definitions'; | ||
|
|
||
| export const isInviteSubscription = (subscription: ISubscription): subscription is IInviteSubscription => | ||
| subscription?.status === 'INVITED' && !!subscription.inviter; |
This file contains hidden or 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,13 @@ | ||
| import i18n from '../../i18n'; | ||
| import { sendInvitationReply } from '../services/restApi'; | ||
| import { showErrorAlert } from './helpers'; | ||
| import log from './helpers/log'; | ||
|
|
||
| export const replyRoomInvite = async (rid: string, action: 'accept' | 'reject') => { | ||
| try { | ||
| await sendInvitationReply(rid, action); | ||
| } catch (e) { | ||
| showErrorAlert(i18n.t('error-invitation-reply-action')); | ||
| log(e); | ||
| } | ||
| }; | ||
aleksandernsilva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,100 @@ | ||
| import React, { type ReactElement } from 'react'; | ||
| import { StyleSheet, Text, View } from 'react-native'; | ||
|
|
||
| import { useTheme } from '../../../theme'; | ||
| import { CustomIcon } from '../../../containers/CustomIcon'; | ||
| import Button from '../../../containers/Button'; | ||
| import sharedStyles from '../../Styles'; | ||
| import I18n from '../../../i18n'; | ||
| import type { IInviteSubscription } from '../../../definitions'; | ||
| import Chip from '../../../containers/Chip'; | ||
|
|
||
| const GAP = 32; | ||
|
|
||
| type InvitedRoomProps = { | ||
| title: string; | ||
| description: string; | ||
| inviter: IInviteSubscription['inviter']; | ||
| loading?: boolean; | ||
| onAccept: () => Promise<void>; | ||
| onReject: () => Promise<void>; | ||
| }; | ||
|
|
||
| export const InvitedRoom = ({ title, description, inviter, loading, onAccept, onReject }: InvitedRoomProps): ReactElement => { | ||
| const { colors } = useTheme(); | ||
| const styles = useStyle(); | ||
|
|
||
| return ( | ||
| <View style={styles.root}> | ||
| <View style={styles.container}> | ||
| <View style={styles.textView}> | ||
| <View style={styles.icon}> | ||
| <CustomIcon name='mail' size={42} color={colors.fontSecondaryInfo} /> | ||
| </View> | ||
| <Text style={styles.title}>{title}</Text> | ||
| <Text style={styles.description}>{description}</Text> | ||
| <View style={styles.username}> | ||
| <Chip avatar={inviter.username} text={inviter.name || inviter.username} /> | ||
| </View> | ||
| </View> | ||
| <Button title={I18n.t('accept')} loading={loading} onPress={onAccept} /> | ||
| <Button | ||
| title={I18n.t('reject')} | ||
| type='secondary' | ||
| loading={loading} | ||
| backgroundColor={colors.surfaceTint} | ||
| onPress={onReject} | ||
| /> | ||
| </View> | ||
| </View> | ||
| ); | ||
| }; | ||
|
Comment on lines
23
to
51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Loading state is not wired up in the parent component. The
🔎 Example: internal loading state-export const InvitedRoom = ({ title, description, inviter, loading, onAccept, onReject }: InvitedRoomProps): ReactElement => {
+export const InvitedRoom = ({ title, description, inviter, onAccept, onReject }: InvitedRoomProps): ReactElement => {
const { colors } = useTheme();
const styles = useStyle();
+ const [loading, setLoading] = React.useState(false);
+
+ const handleAccept = async () => {
+ setLoading(true);
+ try {
+ await onAccept();
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const handleReject = async () => {
+ setLoading(true);
+ try {
+ await onReject();
+ } finally {
+ setLoading(false);
+ }
+ };
return (
// ...
- <Button title={I18n.t('accept')} loading={loading} onPress={onAccept} />
+ <Button title={I18n.t('accept')} loading={loading} onPress={handleAccept} />
<Button
title={I18n.t('reject')}
type='secondary'
loading={loading}
backgroundColor={colors.surfaceTint}
- onPress={onReject}
+ onPress={handleReject}
/>
// ...
);
};🤖 Prompt for AI Agents |
||
|
|
||
| const useStyle = () => { | ||
| const { colors } = useTheme(); | ||
| const styles = StyleSheet.create({ | ||
| root: { | ||
| flex: 1, | ||
| backgroundColor: colors.surfaceRoom | ||
| }, | ||
| container: { | ||
| flex: 1, | ||
| marginHorizontal: 24, | ||
| justifyContent: 'center' | ||
| }, | ||
| textView: { alignItems: 'center' }, | ||
| icon: { | ||
| width: 58, | ||
| height: 58, | ||
| borderRadius: 30, | ||
| marginBottom: GAP, | ||
| backgroundColor: colors.surfaceNeutral, | ||
| alignItems: 'center', | ||
| justifyContent: 'center' | ||
| }, | ||
| title: { | ||
| ...sharedStyles.textBold, | ||
| fontSize: 24, | ||
| lineHeight: 32, | ||
| textAlign: 'center', | ||
| color: colors.fontTitlesLabels, | ||
| marginBottom: GAP | ||
| }, | ||
| description: { | ||
| ...sharedStyles.textRegular, | ||
| fontSize: 16, | ||
| lineHeight: 24, | ||
| textAlign: 'center', | ||
| color: colors.fontDefault | ||
| }, | ||
| username: { | ||
| ...sharedStyles.textRegular, | ||
| fontSize: 16, | ||
| lineHeight: 24, | ||
| textAlign: 'center', | ||
| color: colors.fontDefault, | ||
| marginBottom: GAP | ||
| } | ||
| }); | ||
| return styles; | ||
| }; | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.