* Initial setup for new keyboard * fix the offset calculation onMove by adding isKeyboardFullyOpened * Done with the keyboard handling implementation * Handled keyboard focus and blured state using context * Added default height for input container * Android support * Tablet state handling * Fix for refreshing offset in list * Created a default context for mention post list * Fix linter errors * Fix tests * Minor * Fix the height issue for tablet view * Review comments * Dependency fix * Reveiw comment * keyboard animation only enabled with screen on top navigation * added tests * Added extra keyboard component for emoji picker (#9328) * Added extra keyboard component * handled swipe geature for extra keyboard * scroll to bottom visible on emoji picker * Check for stale event for keyboard geature area * fix keyboard stale event for mid-gesture change swipe direction * Closing emoji picker when message priority is opened * changing to thread view closes emoji picker * Close emoij picker and keyboard when attachment icons are clicked * handle android emoji picker behaviour * Remove emoji picker code * fix tests * Address reviev comments * Test fixes * usePreventDoubleTab for race condition and corrected comment on isInputAccessoryViewMode flag * File attachments option in bottom sheet quick action (#9331) * Added extra keyboard component * handled swipe geature for extra keyboard * File attachments option in bottom sheet quick action * Updated tests * i18n * fix test * Added tests * Review comment * fix tests * Integrated Emoji picker to Extra keyboard component. (#9339) * Added extra keyboard component * handled swipe geature for extra keyboard * scroll to bottom visible on emoji picker * Fix the post input container height change issue * Added emoji picker with search functionality * keyboard height not recorded fallback to default height, set search to false closing emoji picker * fix search funcitonality in android * scroll to end bottom dismissed with pressed * Fixed the scroll issue for android * fix the flickering post input issue * Wired up the emoji picker * Added keyboard and spaceback in emoji picker * intl extract * initial cursor position and simple calculation review comment * separated grapheme to utils file * Review comments * nitpick * Fix the bottom safe area and navigation stack restore fix * Fix test * disabled emoji picker in edit post screen * change the name of the variable to name it clarier * fix the tab gap issue in andriod * disabled the emoji skin tone change on andriod * fix the input container jump issue * fix the failing test * UX review * added white space after the attachment icon * When @ or / is press open keyboard on andriod also fix the scroll issue when keyboard is open * back bottom closes emoji picker and opening keyboard jump fix * reverted code * fixed the flickering issue of input and scroll position fix * Added BoR button * Fix the gap issue in thread * fix the warning reaminated issue when opening a channel * Fix the extra space issue between input and emoij picker * Minor fix for extra space between input and emoji picker * WIP * Fix thread view bottom safe area and gap between keyboard and searched emojis * WIP * refactor: make borConfig optional in BoRAction component * refactor: remove optional borConfig and simplify state initialization * Fix the keyboard issue in tablet * Fix the warning issue react-native-keyboard-controller * Fix tests * Fix the tablet search hight issue * Replaced the ExtraKeyboardProvider with KeyboardProvider from rnkc for permalink * WIP * Successfully toggeled bor status * Displayed bor chip in draft editor * Send bor post * Displayed bor chip in draft editor with wrapping * Added read receipt * Bottom sheet jump issue resolved * Search do not close after selecting emoji in search list * Added the bottom inset height in search emoji for android * integrated bor receipt count * fix buid issue * Added margin * Handled updating receipts on sync * test: add comprehensive tests for updateDraftBoRConfig * test: add initial test file for burn on read label component * test: add tests for BoRLabel component * test: update BoRLabel tests to use toBeVisible and remove formatTime mock * test: update BoR label tests to use renderWithIntl * refactor: remove getBaseProps and specify props inline in BoRLabel tests * refactor: improve test component formatting for readability * test: add validation for BoRLabel time display formats * test: add comprehensive tests for Burst on Read (BoR) functionality * WIP * test: add unit tests for BOR quick action component * test: add comprehensive tests for BoR quick action component * test: add missing props to QuickActions test setup * test: add tests for BoR quick action rendering * test: mock BoRQuickAction component for testing * test: add comprehensive tests for observeIsBoREnabled function * test: add initial test file for BOR read receipts screen * test: add comprehensive tests for BORReadReceipts component * test: add test cases for BOR read receipts display * test: add comprehensive tests for humanReadable format in formatTime * Added tests * lint fix * cleanup * cleanup * cleanup * cleanup * cleanup * i18n fix * Fix the cancel state to emoji picker * Prevented displaying BoR quick action in threads * Fixed a test * lint fix * review fixes * review fixes * i18n fix * fixed tests * review fixes * lint fix * restored podfile * Fixed WS event handling for receiving bor post receipnt * Fixed a test * fixed TS * Implemented burn post now for sender and receiver (#9401) * Implemented burn post now for sender and receiver * test: add tests for burnPostNow function * test: add test for delete post option * test: add comprehensive tests for DeletePostOption component * Added tests * Lint fix * minor improvemenmts * lint fix * reset unintended changes * reset unintended changes * Bor delete when read by all (#9407) * WIP * Updated for all read * cleanup * test: add comprehensive tests for handleBoRPostAllRevealed * test: add tests for BOR events in websocket event handler * feat: add comprehensive tests for shouldUpdateForBoRPost function * Added tests * Lint fix * fixed TS * fixed padding * UX fixes --------- Co-authored-by: Rajat Dabade <a-rajat.dabade@mattermost.com> Co-authored-by: Rajat Dabade <rajatdabade1997@gmail.com> Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Rahim Rahman <rahim.rahman@mattermost.com>
329 lines
13 KiB
TypeScript
329 lines
13 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {handleAgentPostUpdate} from '@agents/actions/websocket';
|
|
|
|
import * as bookmark from '@actions/local/channel_bookmark';
|
|
import {
|
|
handleBoRPostAllRevealed,
|
|
handleBoRPostBurnedEvent,
|
|
handleBoRPostRevealedEvent,
|
|
} from '@actions/websocket/burn_on_read';
|
|
import * as scheduledPost from '@actions/websocket/scheduled_post';
|
|
import * as calls from '@calls/connection/websocket_event_handlers';
|
|
import {WebsocketEvents} from '@constants';
|
|
import {handlePlaybookEvents} from '@playbooks/actions/websocket/events';
|
|
|
|
import * as category from './category';
|
|
import * as channel from './channel';
|
|
import * as group from './group';
|
|
import {handleOpenDialogEvent} from './integrations';
|
|
import * as posts from './posts';
|
|
import * as preferences from './preferences';
|
|
import {handleAddCustomEmoji, handleReactionRemovedFromPostEvent, handleReactionAddedToPostEvent} from './reactions';
|
|
import {handleUserRoleUpdatedEvent, handleTeamMemberRoleUpdatedEvent, handleRoleUpdatedEvent} from './roles';
|
|
import {handleLicenseChangedEvent, handleConfigChangedEvent} from './system';
|
|
import * as teams from './teams';
|
|
import {handleThreadUpdatedEvent, handleThreadReadChangedEvent, handleThreadFollowChangedEvent} from './threads';
|
|
import {handleUserUpdatedEvent, handleUserTypingEvent, handleStatusChangedEvent, handleCustomProfileAttributesValuesUpdatedEvent, handleCustomProfileAttributesFieldUpdatedEvent, handleCustomProfileAttributesFieldDeletedEvent} from './users';
|
|
|
|
export async function handleWebSocketEvent(serverUrl: string, msg: WebSocketMessage) {
|
|
switch (msg.event) {
|
|
case WebsocketEvents.POSTED:
|
|
case WebsocketEvents.EPHEMERAL_MESSAGE:
|
|
posts.handleNewPostEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.POST_EDITED:
|
|
posts.handlePostEdited(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.POST_DELETED:
|
|
posts.handlePostDeleted(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.POST_UNREAD:
|
|
posts.handlePostUnread(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.POST_ACKNOWLEDGEMENT_ADDED:
|
|
posts.handlePostAcknowledgementAdded(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.POST_ACKNOWLEDGEMENT_REMOVED:
|
|
posts.handlePostAcknowledgementRemoved(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.LEAVE_TEAM:
|
|
teams.handleLeaveTeamEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.UPDATE_TEAM:
|
|
teams.handleUpdateTeamEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.ADDED_TO_TEAM:
|
|
teams.handleUserAddedToTeamEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.DELETE_TEAM:
|
|
teams.handleTeamArchived(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.RESTORE_TEAM:
|
|
teams.handleTeamRestored(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.USER_ADDED:
|
|
channel.handleUserAddedToChannelEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.USER_REMOVED:
|
|
channel.handleUserRemovedFromChannelEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.USER_UPDATED:
|
|
handleUserUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.ROLE_UPDATED:
|
|
handleRoleUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.USER_ROLE_UPDATED:
|
|
handleUserRoleUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.MEMBERROLE_UPDATED:
|
|
handleTeamMemberRoleUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.CATEGORY_CREATED:
|
|
category.handleCategoryCreatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CATEGORY_UPDATED:
|
|
category.handleCategoryUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CATEGORY_ORDER_UPDATED:
|
|
category.handleCategoryOrderUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CATEGORY_DELETED:
|
|
category.handleCategoryDeletedEvent(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.CHANNEL_CREATED:
|
|
channel.handleChannelCreatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CHANNEL_DELETED:
|
|
channel.handleChannelDeletedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CHANNEL_UNARCHIVED:
|
|
channel.handleChannelUnarchiveEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CHANNEL_UPDATED:
|
|
channel.handleChannelUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CHANNEL_CONVERTED:
|
|
channel.handleChannelConvertedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CHANNEL_VIEWED:
|
|
channel.handleChannelViewedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.MULTIPLE_CHANNELS_VIEWED:
|
|
channel.handleMultipleChannelsViewedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CHANNEL_MEMBER_UPDATED:
|
|
channel.handleChannelMemberUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CHANNEL_SCHEME_UPDATED:
|
|
// Do nothing, handled by CHANNEL_UPDATED due to changes in the channel scheme.
|
|
break;
|
|
case WebsocketEvents.DIRECT_ADDED:
|
|
case WebsocketEvents.GROUP_ADDED:
|
|
channel.handleDirectAddedEvent(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.PREFERENCE_CHANGED:
|
|
preferences.handlePreferenceChangedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.PREFERENCES_CHANGED:
|
|
preferences.handlePreferencesChangedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.PREFERENCES_DELETED:
|
|
preferences.handlePreferencesDeletedEvent(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.STATUS_CHANGED:
|
|
handleStatusChangedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.TYPING:
|
|
handleUserTypingEvent(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.REACTION_ADDED:
|
|
handleReactionAddedToPostEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.REACTION_REMOVED:
|
|
handleReactionRemovedFromPostEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.EMOJI_ADDED:
|
|
handleAddCustomEmoji(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.LICENSE_CHANGED:
|
|
handleLicenseChangedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CONFIG_CHANGED:
|
|
handleConfigChangedEvent(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.OPEN_DIALOG:
|
|
handleOpenDialogEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.APPS_FRAMEWORK_REFRESH_BINDINGS:
|
|
break;
|
|
|
|
case WebsocketEvents.THREAD_UPDATED:
|
|
handleThreadUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.THREAD_READ_CHANGED:
|
|
handleThreadReadChangedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.THREAD_FOLLOW_CHANGED:
|
|
handleThreadFollowChangedEvent(serverUrl, msg);
|
|
break;
|
|
|
|
// Calls ws events:
|
|
case WebsocketEvents.CALLS_CHANNEL_ENABLED:
|
|
calls.handleCallChannelEnabled(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_CHANNEL_DISABLED:
|
|
calls.handleCallChannelDisabled(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_USER_JOINED:
|
|
calls.handleCallUserJoined(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_USER_LEFT:
|
|
calls.handleCallUserLeft(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_USER_MUTED:
|
|
calls.handleCallUserMuted(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_USER_UNMUTED:
|
|
calls.handleCallUserUnmuted(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_USER_VOICE_ON:
|
|
calls.handleCallUserVoiceOn(msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_USER_VOICE_OFF:
|
|
calls.handleCallUserVoiceOff(msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_CALL_START:
|
|
calls.handleCallStarted(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_SCREEN_ON:
|
|
calls.handleCallScreenOn(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_SCREEN_OFF:
|
|
calls.handleCallScreenOff(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_USER_RAISE_HAND:
|
|
calls.handleCallUserRaiseHand(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_USER_UNRAISE_HAND:
|
|
calls.handleCallUserUnraiseHand(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_CALL_END:
|
|
calls.handleCallEnded(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_USER_REACTED:
|
|
calls.handleCallUserReacted(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_JOB_STATE:
|
|
calls.handleCallJobState(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_HOST_CHANGED:
|
|
calls.handleCallHostChanged(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_USER_DISMISSED_NOTIFICATION:
|
|
calls.handleUserDismissedNotification(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_CAPTION:
|
|
calls.handleCallCaption(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_HOST_MUTE:
|
|
calls.handleHostMute(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_HOST_LOWER_HAND:
|
|
calls.handleHostLowerHand(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_HOST_REMOVED:
|
|
calls.handleHostRemoved(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CALLS_CALL_STATE:
|
|
calls.handleCallState(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.GROUP_RECEIVED:
|
|
group.handleGroupReceivedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.GROUP_MEMBER_ADD:
|
|
group.handleGroupMemberAddEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.GROUP_MEMBER_DELETE:
|
|
group.handleGroupMemberDeleteEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.GROUP_ASSOCIATED_TO_TEAM:
|
|
group.handleGroupTeamAssociatedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.GROUP_DISSOCIATED_TO_TEAM:
|
|
group.handleGroupTeamDissociateEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.GROUP_ASSOCIATED_TO_CHANNEL:
|
|
break;
|
|
case WebsocketEvents.GROUP_DISSOCIATED_TO_CHANNEL:
|
|
break;
|
|
|
|
// Plugins
|
|
case WebsocketEvents.PLUGIN_STATUSES_CHANGED:
|
|
case WebsocketEvents.PLUGIN_ENABLED:
|
|
case WebsocketEvents.PLUGIN_DISABLED:
|
|
// Do nothing, this event doesn't need logic in the mobile app
|
|
break;
|
|
|
|
// bookmarks
|
|
case WebsocketEvents.CHANNEL_BOOKMARK_CREATED:
|
|
case WebsocketEvents.CHANNEL_BOOKMARK_DELETED:
|
|
bookmark.handleBookmarkAddedOrDeleted(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CHANNEL_BOOKMARK_UPDATED:
|
|
bookmark.handleBookmarkEdited(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CHANNEL_BOOKMARK_SORTED:
|
|
bookmark.handleBookmarkSorted(serverUrl, msg);
|
|
break;
|
|
|
|
// scheduled posts
|
|
case WebsocketEvents.SCHEDULED_POST_CREATED:
|
|
case WebsocketEvents.SCHEDULED_POST_UPDATED:
|
|
scheduledPost.handleCreateOrUpdateScheduledPost(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.SCHEDULED_POST_DELETED:
|
|
scheduledPost.handleDeleteScheduledPost(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.CUSTOM_PROFILE_ATTRIBUTES_VALUES_UPDATED:
|
|
handleCustomProfileAttributesValuesUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.CUSTOM_PROFILE_ATTRIBUTES_FIELD_UPDATED:
|
|
case WebsocketEvents.CUSTOM_PROFILE_ATTRIBUTES_FIELD_CREATED:
|
|
handleCustomProfileAttributesFieldUpdatedEvent(serverUrl, msg);
|
|
break;
|
|
|
|
case WebsocketEvents.CUSTOM_PROFILE_ATTRIBUTES_FIELD_DELETED:
|
|
handleCustomProfileAttributesFieldDeletedEvent(serverUrl, msg);
|
|
break;
|
|
|
|
// Agents
|
|
case WebsocketEvents.AGENTS_POST_UPDATE:
|
|
handleAgentPostUpdate(msg);
|
|
break;
|
|
|
|
// Burn on Read Events
|
|
case WebsocketEvents.BOR_POST_REVEALED:
|
|
handleBoRPostRevealedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.BOR_POST_BURNED:
|
|
handleBoRPostBurnedEvent(serverUrl, msg);
|
|
break;
|
|
case WebsocketEvents.BURN_ON_READ_ALL_REVEALED:
|
|
handleBoRPostAllRevealed(serverUrl, msg);
|
|
break;
|
|
}
|
|
handlePlaybookEvents(serverUrl, msg);
|
|
}
|