-
Notifications
You must be signed in to change notification settings - Fork 299
feat: add channels [WPB-15758] #18852
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
Conversation
* feat: add channel avatars [WPB-15756] * PR feedback changes
| {isChannel && | ||
| (isChannelsEnabled ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an edgecase we need to worry about where channels exist but are not enabled on the client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, including both sides (BE and FE) feature flags.
| @@ -0,0 +1,55 @@ | |||
| /* | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| @@ -0,0 +1,49 @@ | |||
| /* | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| @@ -17,8 +17,6 @@ | |||
| * | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| @@ -19,16 +19,19 @@ | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| @@ -439,7 +439,7 @@ export const Conversation = ({ | |||
| if (conversationEntity.is1to1()) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| @@ -0,0 +1,89 @@ | |||
| /* | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| @@ -0,0 +1,72 @@ | |||
| /* | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
| /** Feature to enable channels */ | ||
| FEATURE_ENABLE_CHANNELS: string; | ||
|
|
||
| /** Feature to enable channels history sharing */ | ||
| FEATURE_ENABLE_CHANNELS_HISTORY_SHARING: string; | ||
|
|
||
| /** Feature to enable channels public channels */ | ||
| FEATURE_ENABLE_PUBLIC_CHANNELS: string; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different feature flag for each feature to follow the rollout strategy.
| this.isGroupOrChannel = ko.pureComputed(() => { | ||
| return this.isGroup() || this.isChannel(); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole app was designed to support group conversations before, Channel is also a group conversation.
But now we treat Channels separately, we introduced another property isGroupOrChannel to refer all types of group conversations.
| import {create} from 'zustand'; | ||
|
|
||
| import {User} from 'src/script/entity/User'; | ||
|
|
||
| import { | ||
| ConversationAccess, | ||
| ConversationModerator, | ||
| ChatHistory, | ||
| ConversationType, | ||
| ConversationCreationStep, | ||
| HistorySharingUnit, | ||
| } from '../types'; | ||
|
|
||
| /** | ||
| * Type representing the state of the Create Conversation Modal. | ||
| */ | ||
| type CreateConversationModalState = { | ||
| isOpen?: boolean; | ||
| conversationName: string; | ||
| access: ConversationAccess; | ||
| moderator: ConversationModerator; | ||
| chatHistory: ChatHistory; | ||
| conversationType: ConversationType; | ||
| conversationCreationStep: ConversationCreationStep; | ||
| error: string; | ||
| isReadReceiptsEnabled: boolean; | ||
| isGuestsEnabled: boolean; | ||
| selectedContacts: User[]; | ||
| historySharingQuantity: number; | ||
| historySharingUnit: HistorySharingUnit; | ||
| isCustomHistoryModalOpen: boolean; | ||
| isConfirmConversationTypeModalOpen: boolean; | ||
| isCreateTeamModalOpen: boolean; | ||
| isUpgradeTeamModalOpen: boolean; | ||
| isServicesEnabled: boolean; | ||
|
|
||
| showModal: () => void; | ||
| hideModal: () => void; | ||
| setConversationName: (name: string) => void; | ||
| setAccess: (access: ConversationAccess) => void; | ||
| setModerator: (access: ConversationModerator) => void; | ||
| setChatHistory: (history: ChatHistory) => void; | ||
| setConversationType: (type: ConversationType) => void; | ||
| setConversationCreationStep: (step: ConversationCreationStep) => void; | ||
| gotoNextStep: () => void; | ||
| gotoPreviousStep: () => void; | ||
| setError: (error: string) => void; | ||
| setIsReadReceiptsEnabled: (isReadReceiptsEnabled: boolean) => void; | ||
| setIsGuestsEnabled: (isGuestsEnabled: boolean) => void; | ||
| setSelectedContacts: (contacts: User[]) => void; | ||
| setHistorySharingQuantity: (quantity: number) => void; | ||
| setHistorySharingUnit: (unit: HistorySharingUnit) => void; | ||
| setIsCustomHistoryModalOpen: (isOpen: boolean) => void; | ||
| setIsConfirmConversationTypeModalOpen: (isOpen: boolean) => void; | ||
| setIsCreateTeamModalOpen: (isOpen: boolean) => void; | ||
| setIsUpgradeTeamModalOpen: (isOpen: boolean) => void; | ||
| gotoLastStep: () => void; | ||
| setIsServicesEnabled: (isServicesEnabled: boolean) => void; | ||
| }; | ||
|
|
||
| /** | ||
| * Initial state of the Create Conversation Modal. | ||
| */ | ||
| const initialState = { | ||
| isOpen: false, | ||
| conversationName: '', | ||
| access: ConversationAccess.Private, | ||
| moderator: ConversationModerator.AdminsAndMembers, | ||
| chatHistory: ChatHistory.Off, | ||
| conversationType: ConversationType.Channel, | ||
| conversationCreationStep: ConversationCreationStep.ConversationDetails, | ||
| error: '', | ||
| isReadReceiptsEnabled: true, | ||
| isServicesEnabled: true, | ||
| isGuestsEnabled: true, | ||
| selectedContacts: [] as User[], | ||
| historySharingUnit: HistorySharingUnit.Days, | ||
| historySharingQuantity: 1, | ||
| isCustomHistoryModalOpen: false, | ||
| isConfirmConversationTypeModalOpen: false, | ||
| isCreateTeamModalOpen: false, | ||
| isUpgradeTeamModalOpen: false, | ||
| }; | ||
|
|
||
| /** | ||
| * Hook to manage the state of the Create Conversation Modal. | ||
| */ | ||
| export const useCreateConversationModal = create<CreateConversationModalState>(set => ({ | ||
| ...initialState, | ||
| showModal: () => set(state => ({...state, isOpen: true})), | ||
| hideModal: () => set({...initialState}), | ||
| setConversationName: (name: string) => set({conversationName: name}), | ||
| setAccess: (access: ConversationAccess) => | ||
| set(state => ({ | ||
| access, | ||
| manager: access === ConversationAccess.Public ? ConversationModerator.AdminsAndMembers : state.moderator, | ||
| })), | ||
| setModerator: (moderator: ConversationModerator) => set({moderator}), | ||
| setChatHistory: (history?: ChatHistory) => set({chatHistory: history || ChatHistory.Off}), | ||
| setConversationType: (type: ConversationType) => set({conversationType: type}), | ||
| setConversationCreationStep: (step: ConversationCreationStep) => set({conversationCreationStep: step}), | ||
| gotoNextStep: () => set(state => ({...state, conversationCreationStep: state.conversationCreationStep + 1})), | ||
| gotoLastStep: () => set({conversationCreationStep: ConversationCreationStep.ParticipantsSelection}), | ||
| gotoPreviousStep: () => set(state => ({...state, conversationCreationStep: state.conversationCreationStep - 1})), | ||
| setError: (error: string) => set({error}), | ||
| setIsReadReceiptsEnabled: (isReadReceiptsEnabled: boolean) => set({isReadReceiptsEnabled}), | ||
| setIsGuestsEnabled: (isGuestsEnabled: boolean) => set({isGuestsEnabled}), | ||
| setSelectedContacts: (contacts: User[]) => set({selectedContacts: contacts}), | ||
| setHistorySharingQuantity: (quantity: number) => set({historySharingQuantity: quantity}), | ||
| setHistorySharingUnit: (unit: HistorySharingUnit) => set({historySharingUnit: unit}), | ||
| setIsCustomHistoryModalOpen: (isOpen: boolean) => set({isCustomHistoryModalOpen: isOpen}), | ||
| setIsConfirmConversationTypeModalOpen: (isOpen: boolean) => set({isConfirmConversationTypeModalOpen: isOpen}), | ||
| setIsCreateTeamModalOpen: (isOpen: boolean) => set({isCreateTeamModalOpen: isOpen}), | ||
| setIsUpgradeTeamModalOpen: (isOpen: boolean) => set({isUpgradeTeamModalOpen: isOpen}), | ||
| setIsServicesEnabled: (isServicesEnabled: boolean) => set({isServicesEnabled}), | ||
| })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an encapsulated state of CreateConversationModal, including all the inputs taken during the flow.
src/script/components/Modals/CreateConversation/CreateConversation.styles.ts
Show resolved
Hide resolved
src/script/components/Modals/CreateConversation/CreateConversation.styles.ts
Outdated
Show resolved
Hide resolved
...als/CreateConversation/CreateConversationSteps/ConversationDetails/ConversationNameInput.tsx
Show resolved
Hide resolved
...ipt/components/Modals/CreateConversation/CreateConversationSteps/CreateConversationSteps.tsx
Outdated
Show resolved
Hide resolved
src/script/components/Modals/CreateConversation/CreateConversationSubmit.tsx
Outdated
Show resolved
Hide resolved
src/script/components/Modals/CreateConversation/hooks/useCreateConversation.ts
Show resolved
Hide resolved
| return access; | ||
| }; | ||
|
|
||
| const onSubmit = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: there's a lot logic in here, I would consider splitting it to multiple functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just moved this functionality, will look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have a look.
|



Description
Added conversation creation flow
Checklist