author int64 658 755k | date stringlengths 19 19 | timezone int64 -46,800 43.2k | hash stringlengths 40 40 | message stringlengths 5 490 | mods list | language stringclasses 20 values | license stringclasses 3 values | repo stringlengths 5 68 | original_message stringlengths 12 491 |
|---|---|---|---|---|---|---|---|---|---|
129,183 | 27.01.2021 08:55:44 | -3,600 | c76d7911461a57ab79c465253f111ed7f26bedf7 | [native] Use threadLabel function in ThreadVisibility
Test Plan: Tested all of thread types and checked if label is displayed correctly
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "native/components/thread-visibility.react.js",
"new_path": "native/components/thread-visibility.react.js",
"diff": "import * as React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\n-import { threadTypes, type ThreadType } from 'lib/types/thread-types';\n+import { threadLabel } from 'lib/shared/thread-utils';\n+import type { ThreadType } from 'lib/types/thread-types';\nimport ThreadIcon from './thread-icon.react';\n@@ -14,15 +15,7 @@ type Props = {|\nfunction ThreadVisibility(props: Props) {\nconst { threadType, color } = props;\nconst visLabelStyle = [styles.visibilityLabel, { color }];\n-\n- let label;\n- if (threadType === threadTypes.CHAT_SECRET) {\n- label = 'Secret';\n- } else if (threadType === threadTypes.PRIVATE) {\n- label = 'Private';\n- } else {\n- label = 'Open';\n- }\n+ const label = threadLabel(threadType);\nreturn (\n<View style={styles.container}>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use threadLabel function in ThreadVisibility
Test Plan: Tested all of thread types and checked if label is displayed correctly
Reviewers: ashoat, palys-swm
Reviewed By: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D659 |
129,183 | 27.01.2021 09:42:51 | -3,600 | 67fa14923ddeec192b658ea18d24621179482573 | [lib] Update robotext message when changing thread type
Test Plan: Tested if robotext is displayed correctly when thread type is changed
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/change-settings-message-spec.js",
"new_path": "lib/shared/messages/change-settings-message-spec.js",
"diff": "@@ -8,6 +8,8 @@ import type {\nChangeSettingsMessageInfo,\nRawChangeSettingsMessageInfo,\n} from '../../types/message/change-settings';\n+import { assertThreadType } from '../../types/thread-types';\n+import { threadLabel } from '../thread-utils';\nimport type { MessageSpec } from './message-spec';\nimport { joinResult } from './utils';\n@@ -56,6 +58,13 @@ export const changeSettingsMessageSpec: MessageSpec<\nlet value;\nif (messageInfo.field === 'color') {\nvalue = `<#${messageInfo.value}|c${messageInfo.threadID}>`;\n+ } else if (messageInfo.field === 'type') {\n+ invariant(\n+ typeof messageInfo.value === 'number',\n+ 'messageInfo.value should be number for thread type change ',\n+ );\n+ const newThreadType = assertThreadType(messageInfo.value);\n+ value = threadLabel(newThreadType);\n} else {\nvalue = messageInfo.value;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Update robotext message when changing thread type
Test Plan: Tested if robotext is displayed correctly when thread type is changed
Reviewers: ashoat, palys-swm
Reviewed By: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D660 |
129,191 | 27.01.2021 14:28:32 | -3,600 | 0188f749caa83cc27df89f020ff332ad66765dc8 | [lib] Allow displaying unsupported message robotext without the creator
Test Plan: Removed SIDEBAR_SOURCE from localUnshimTypes and checked if `first message in sidebar` was displayed (without the creator)
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/sidebar-source-message-spec.js",
"new_path": "lib/shared/messages/sidebar-source-message-spec.js",
"diff": "@@ -90,6 +90,7 @@ export const sidebarSourceMessageSpec: MessageSpec<\ncreatorID: rawMessageInfo.creatorID,\ntime: rawMessageInfo.time,\nrobotext: 'first message in sidebar',\n+ dontPrefixCreator: true,\nunsupportedMessageInfo: rawMessageInfo,\n};\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/unsupported-message-spec.js",
"new_path": "lib/shared/messages/unsupported-message-spec.js",
"diff": "@@ -20,11 +20,15 @@ export const unsupportedMessageSpec: MessageSpec<\ncreator,\ntime: rawMessageInfo.time,\nrobotext: rawMessageInfo.robotext,\n+ dontPrefixCreator: rawMessageInfo.dontPrefixCreator,\nunsupportedMessageInfo: rawMessageInfo.unsupportedMessageInfo,\n};\n},\nrobotext(messageInfo, creator) {\n+ if (messageInfo.dontPrefixCreator) {\n+ return messageInfo.robotext;\n+ }\nreturn `${creator} ${messageInfo.robotext}`;\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/message/unsupported.js",
"new_path": "lib/types/message/unsupported.js",
"diff": "@@ -9,6 +9,7 @@ export type RawUnsupportedMessageInfo = {|\ncreatorID: string,\ntime: number,\nrobotext: string,\n+ dontPrefixCreator?: boolean,\nunsupportedMessageInfo: Object,\n|};\n@@ -19,5 +20,6 @@ export type UnsupportedMessageInfo = {|\ncreator: RelativeUserInfo,\ntime: number,\nrobotext: string,\n+ dontPrefixCreator?: boolean,\nunsupportedMessageInfo: Object,\n|};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Allow displaying unsupported message robotext without the creator
Test Plan: Removed SIDEBAR_SOURCE from localUnshimTypes and checked if `first message in sidebar` was displayed (without the creator)
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D665 |
129,183 | 29.01.2021 13:37:58 | -3,600 | 1424f5426bd5b14383c10464772b99abc5ea6450 | [native] Extract onPressCreateSidebar function
Test Plan: Flow, check if creating sidebars works as before for all message types
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-tooltip-modal.react.js",
"new_path": "native/chat/multimedia-tooltip-modal.react.js",
"diff": "// @flow\n-import invariant from 'invariant';\n-\n-import { createPendingSidebar } from 'lib/shared/thread-utils';\nimport type { MediaInfo } from 'lib/types/media-types';\n-import type {\n- DispatchFunctions,\n- ActionFunc,\n- BoundServerCall,\n-} from 'lib/utils/action-utils';\n-import type { InputState } from '../input/input-state';\nimport { intentionalSaveMedia } from '../media/save-media';\n-import type { AppNavigationProp } from '../navigation/app-navigator.react';\n-import { MessageListRouteName } from '../navigation/route-names';\nimport {\ncreateTooltip,\ntooltipHeight,\n@@ -22,7 +11,7 @@ import {\n} from '../navigation/tooltip.react';\nimport type { ChatMultimediaMessageInfoItem } from './multimedia-message.react';\nimport MultimediaTooltipButton from './multimedia-tooltip-button.react';\n-import { onPressGoToSidebar } from './sidebar-navigation';\n+import { onPressGoToSidebar, onPressCreateSidebar } from './sidebar-navigation';\nexport type MultimediaTooltipModalParams = TooltipParams<{|\n+item: ChatMultimediaMessageInfoItem,\n@@ -38,36 +27,6 @@ function onPressSave(route: TooltipRoute<'MultimediaTooltipModal'>) {\nreturn intentionalSaveMedia(uri, ids);\n}\n-function onPressCreateSidebar(\n- route: TooltipRoute<'MultimediaTooltipModal'>,\n- dispatchFunctions: DispatchFunctions,\n- bindServerCall: (serverCall: ActionFunc) => BoundServerCall,\n- inputState: ?InputState,\n- navigation: AppNavigationProp<'MultimediaTooltipModal'>,\n- viewerID: ?string,\n-) {\n- invariant(\n- viewerID,\n- 'viewerID should be set in MultimediaTooltipModal.onPressCreateSidebar',\n- );\n- const { messageInfo, threadInfo } = route.params.item;\n- const pendingSidebarInfo = createPendingSidebar(\n- messageInfo,\n- threadInfo,\n- viewerID,\n- );\n- const initialMessageID = messageInfo.id;\n-\n- navigation.navigate({\n- name: MessageListRouteName,\n- params: {\n- threadInfo: pendingSidebarInfo,\n- sidebarSourceMessageID: initialMessageID,\n- },\n- key: `${MessageListRouteName}${pendingSidebarInfo.id}`,\n- });\n-}\n-\nconst spec = {\nentries: [\n{ id: 'save', text: 'Save', onPress: onPressSave },\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message-tooltip-modal.react.js",
"new_path": "native/chat/robotext-message-tooltip-modal.react.js",
"diff": "// @flow\n-import invariant from 'invariant';\n-\n-import { createPendingSidebar } from 'lib/shared/thread-utils';\n-import type {\n- DispatchFunctions,\n- ActionFunc,\n- BoundServerCall,\n-} from 'lib/utils/action-utils';\n-\n-import type { InputState } from '../input/input-state';\n-import type { AppNavigationProp } from '../navigation/app-navigator.react';\n-import { MessageListRouteName } from '../navigation/route-names';\nimport {\ncreateTooltip,\ntooltipHeight,\ntype TooltipParams,\n- type TooltipRoute,\n} from '../navigation/tooltip.react';\nimport RobotextMessageTooltipButton from './robotext-message-tooltip-button.react';\nimport type { ChatRobotextMessageInfoItemWithHeight } from './robotext-message.react';\n-import { onPressGoToSidebar } from './sidebar-navigation';\n+import { onPressGoToSidebar, onPressCreateSidebar } from './sidebar-navigation';\nexport type RobotextMessageTooltipModalParams = TooltipParams<{|\n+item: ChatRobotextMessageInfoItemWithHeight,\n+robotext: string,\n|}>;\n-function onPressCreateSidebar(\n- route: TooltipRoute<'RobotextMessageTooltipModal'>,\n- dispatchFunctions: DispatchFunctions,\n- bindServerCall: (serverCall: ActionFunc) => BoundServerCall,\n- inputState: ?InputState,\n- navigation: AppNavigationProp<'RobotextMessageTooltipModal'>,\n- viewerID: ?string,\n-) {\n- invariant(\n- viewerID,\n- 'viewerID should be set in RobotextMessageTooltipModal.onPressCreateSidebar',\n- );\n- const { messageInfo, threadInfo } = route.params.item;\n- const pendingSidebarInfo = createPendingSidebar(\n- messageInfo,\n- threadInfo,\n- viewerID,\n- );\n- const initialMessageID = messageInfo.id;\n-\n- navigation.navigate({\n- name: MessageListRouteName,\n- params: {\n- threadInfo: pendingSidebarInfo,\n- sidebarSourceMessageID: initialMessageID,\n- },\n- key: `${MessageListRouteName}${pendingSidebarInfo.id}`,\n- });\n-}\n-\nconst spec = {\nentries: [\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/sidebar-navigation.js",
"new_path": "native/chat/sidebar-navigation.js",
"diff": "import invariant from 'invariant';\n+import { createPendingSidebar } from 'lib/shared/thread-utils';\nimport type {\nDispatchFunctions,\nActionFunc,\n@@ -48,4 +49,48 @@ function onPressGoToSidebar(\n});\n}\n-export { onPressGoToSidebar };\n+function onPressCreateSidebar(\n+ route:\n+ | TooltipRoute<'RobotextMessageTooltipModal'>\n+ | TooltipRoute<'TextMessageTooltipModal'>\n+ | TooltipRoute<'MultimediaTooltipModal'>,\n+ dispatchFunctions: DispatchFunctions,\n+ bindServerCall: (serverCall: ActionFunc) => BoundServerCall,\n+ inputState: ?InputState,\n+ navigation:\n+ | AppNavigationProp<'RobotextMessageTooltipModal'>\n+ | AppNavigationProp<'TextMessageTooltipModal'>\n+ | AppNavigationProp<'MultimediaTooltipModal'>,\n+ viewerID: ?string,\n+) {\n+ invariant(\n+ viewerID,\n+ 'viewerID should be set in TextMessageTooltipModal.onPressCreateSidebar',\n+ );\n+ let itemFromParams;\n+ // Necessary for Flow...\n+ if (route.name === 'RobotextMessageTooltipModal') {\n+ itemFromParams = route.params.item;\n+ } else {\n+ itemFromParams = route.params.item;\n+ }\n+\n+ const { messageInfo, threadInfo } = itemFromParams;\n+ const pendingSidebarInfo = createPendingSidebar(\n+ messageInfo,\n+ threadInfo,\n+ viewerID,\n+ );\n+ const sourceMessageID = messageInfo.id;\n+\n+ navigation.navigate({\n+ name: MessageListRouteName,\n+ params: {\n+ threadInfo: pendingSidebarInfo,\n+ sidebarSourceMessageID: sourceMessageID,\n+ },\n+ key: `${MessageListRouteName}${pendingSidebarInfo.id}`,\n+ });\n+}\n+\n+export { onPressGoToSidebar, onPressCreateSidebar };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message-tooltip-modal.react.js",
"new_path": "native/chat/text-message-tooltip-modal.react.js",
"diff": "@@ -4,7 +4,6 @@ import Clipboard from '@react-native-community/clipboard';\nimport invariant from 'invariant';\nimport { createMessageReply } from 'lib/shared/message-utils';\n-import { createPendingSidebar } from 'lib/shared/thread-utils';\nimport type {\nDispatchFunctions,\nActionFunc,\n@@ -13,15 +12,13 @@ import type {\nimport type { InputState } from '../input/input-state';\nimport { displayActionResultModal } from '../navigation/action-result-modal';\n-import type { AppNavigationProp } from '../navigation/app-navigator.react';\n-import { MessageListRouteName } from '../navigation/route-names';\nimport {\ncreateTooltip,\ntooltipHeight,\ntype TooltipParams,\ntype TooltipRoute,\n} from '../navigation/tooltip.react';\n-import { onPressGoToSidebar } from './sidebar-navigation';\n+import { onPressGoToSidebar, onPressCreateSidebar } from './sidebar-navigation';\nimport TextMessageTooltipButton from './text-message-tooltip-button.react';\nimport type { ChatTextMessageInfoItemWithHeight } from './text-message.react';\n@@ -49,36 +46,6 @@ function onPressReply(\ninputState.addReply(createMessageReply(route.params.item.messageInfo.text));\n}\n-function onPressCreateSidebar(\n- route: TooltipRoute<'TextMessageTooltipModal'>,\n- dispatchFunctions: DispatchFunctions,\n- bindServerCall: (serverCall: ActionFunc) => BoundServerCall,\n- inputState: ?InputState,\n- navigation: AppNavigationProp<'TextMessageTooltipModal'>,\n- viewerID: ?string,\n-) {\n- invariant(\n- viewerID,\n- 'viewerID should be set in TextMessageTooltipModal.onPressCreateSidebar',\n- );\n- const { messageInfo, threadInfo } = route.params.item;\n- const pendingSidebarInfo = createPendingSidebar(\n- messageInfo,\n- threadInfo,\n- viewerID,\n- );\n- const sourceMessageID = messageInfo.id;\n-\n- navigation.navigate({\n- name: MessageListRouteName,\n- params: {\n- threadInfo: pendingSidebarInfo,\n- sidebarSourceMessageID: sourceMessageID,\n- },\n- key: `${MessageListRouteName}${pendingSidebarInfo.id}`,\n- });\n-}\n-\nconst spec = {\nentries: [\n{ id: 'copy', text: 'Copy', onPress: onPressCopy },\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Extract onPressCreateSidebar function
Test Plan: Flow, check if creating sidebars works as before for all message types
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D674 |
129,183 | 29.01.2021 13:41:09 | -3,600 | b59ac70475d317db1f46facb5086c3bef0cb9db0 | [native] Remove unused param from robotext tooltip params
Summary: I introduced it in D622 but ended up not using it
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message-tooltip-modal.react.js",
"new_path": "native/chat/robotext-message-tooltip-modal.react.js",
"diff": "@@ -11,7 +11,6 @@ import { onPressGoToSidebar, onPressCreateSidebar } from './sidebar-navigation';\nexport type RobotextMessageTooltipModalParams = TooltipParams<{|\n+item: ChatRobotextMessageInfoItemWithHeight,\n- +robotext: string,\n|}>;\nconst spec = {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "@@ -85,7 +85,6 @@ function RobotextMessage(props: Props) {\n);\n}\n- const robotext = item.robotext;\nconst keyboardState = React.useContext(KeyboardContext);\nconst key = messageKey(item.messageInfo);\nconst onPress = React.useCallback(() => {\n@@ -163,18 +162,10 @@ function RobotextMessage(props: Props) {\nlocation,\nmargin,\nitem,\n- robotext,\n},\n});\n},\n- [\n- item,\n- props.navigation,\n- props.route.key,\n- robotext,\n- verticalBounds,\n- visibleEntryIDs,\n- ],\n+ [item, props.navigation, props.route.key, verticalBounds, visibleEntryIDs],\n);\nconst onLongPress = React.useCallback(() => {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Remove unused param from robotext tooltip params
Summary: I introduced it in D622 but ended up not using it
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D675 |
129,191 | 28.01.2021 14:09:23 | -3,600 | 1b214de833f39b456e3848d9e6a0f7ebc431f4fe | [native] Avoid undefined error when logging out with sidebar opened
Test Plan: Open sidebar and log in: the operation should be successful
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "@@ -10,6 +10,7 @@ import { relationshipBlockedInEitherDirection } from 'lib/shared/relationship-ut\nimport { threadHasPermission } from 'lib/shared/thread-utils';\nimport type { RobotextMessageInfo } from 'lib/types/message-types';\nimport { type ThreadInfo, threadPermissions } from 'lib/types/thread-types';\n+import type { UserInfo } from 'lib/types/user-types';\nimport { KeyboardContext } from '../keyboard/keyboard-state';\nimport { OverlayContext } from '../navigation/overlay-context';\n@@ -98,15 +99,15 @@ function RobotextMessage(props: Props) {\nconst overlayContext = React.useContext(OverlayContext);\nconst viewRef = React.useRef<?React.ElementRef<typeof View>>();\n- const messageCreatorUserInfo = useSelector(\n+ const messageCreatorUserInfo: ?UserInfo = useSelector(\n(state) => state.userStore.userInfos[props.item.messageInfo.creator.id],\n);\n+ const creatorRelationship = messageCreatorUserInfo?.relationshipStatus;\nconst visibleEntryIDs = React.useMemo(() => {\nconst canCreateSidebars = threadHasPermission(\nitem.threadInfo,\nthreadPermissions.CREATE_SIDEBARS,\n);\n- const creatorRelationship = messageCreatorUserInfo.relationshipStatus;\nconst creatorRelationshipHasBlock =\ncreatorRelationship &&\nrelationshipBlockedInEitherDirection(creatorRelationship);\n@@ -117,11 +118,7 @@ function RobotextMessage(props: Props) {\nreturn ['create_sidebar'];\n}\nreturn [];\n- }, [\n- item.threadCreatedFromMessage,\n- item.threadInfo,\n- messageCreatorUserInfo.relationshipStatus,\n- ]);\n+ }, [item.threadCreatedFromMessage, item.threadInfo, creatorRelationship]);\nconst openRobotextTooltipModal = React.useCallback(\n(x, y, width, height, pageX, pageY) => {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Avoid undefined error when logging out with sidebar opened
Test Plan: Open sidebar and log in: the operation should be successful
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D670 |
129,184 | 27.01.2021 12:59:21 | 28,800 | 8630d90d87c76129c7269f81faca4fe314ed9afa | Passing onTranscodingProgress down to ffmpeg statistics
Summary: Passing onTranscodingProgress callback down to ffmpeg so statistics can be "accessed" by inputStateContainer
Test Plan: Logged call to onTranscodingProgress and saw visual indication of progress.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub | [
{
"change_type": "MODIFY",
"old_path": "native/input/input-state-container.react.js",
"new_path": "native/input/input-state-container.react.js",
"diff": "@@ -69,6 +69,7 @@ import type { AppState } from '../redux/redux-setup';\nimport {\nInputStateContext,\ntype PendingMultimediaUploads,\n+ type MultimediaProcessingStep,\n} from './input-state';\nlet nextLocalUploadID = 0;\n@@ -504,7 +505,7 @@ class InputStateContainer extends React.PureComponent<Props, State> {\ntry {\nconst processMediaReturn = processMedia(\nselection,\n- this.mediaProcessConfig(),\n+ this.mediaProcessConfig(localMessageID, localID),\n);\nreportPromise = processMediaReturn.reportPromise;\nconst processResult = await processMediaReturn.resultPromise;\n@@ -539,7 +540,7 @@ class InputStateContainer extends React.PureComponent<Props, State> {\n{ ...processedMedia.dimensions, loop: processedMedia.loop },\n{\nonProgress: (percent: number) =>\n- this.setProgress(localMessageID, localID, percent),\n+ this.setProgress(localMessageID, localID, 'upload', percent),\nuploadBlob: this.uploadBlob,\n},\n);\n@@ -632,20 +633,25 @@ class InputStateContainer extends React.PureComponent<Props, State> {\nreturn await finish(mediaMissionResult);\n}\n- mediaProcessConfig() {\n+ mediaProcessConfig(localMessageID: string, localID: string) {\nconst { hasWiFi, viewerID } = this.props;\n+ const onTranscodingProgress = (percent: number) => {\n+ this.setProgress(localMessageID, localID, 'transcode', percent);\n+ };\nif (__DEV__ || (viewerID && isStaff(viewerID))) {\nreturn {\nhasWiFi,\nfinalFileHeaderCheck: true,\n+ onTranscodingProgress,\n};\n}\n- return { hasWiFi };\n+ return { hasWiFi, onTranscodingProgress };\n}\nsetProgress(\nlocalMessageID: string,\nlocalUploadID: string,\n+ processingStep: MultimediaProcessingStep,\nprogressPercent: number,\n) {\nthis.setState((prevState) => {\n@@ -667,6 +673,7 @@ class InputStateContainer extends React.PureComponent<Props, State> {\n[localUploadID]: {\n...pendingUpload,\nprogressPercent,\n+ processingStep,\n},\n};\nreturn {\n@@ -965,6 +972,7 @@ class InputStateContainer extends React.PureComponent<Props, State> {\npendingUploads[id] = {\nfailed: null,\nprogressPercent: 0,\n+ processingStep: null,\n};\n}\nthis.setState((prevState) => ({\n"
},
{
"change_type": "MODIFY",
"old_path": "native/input/input-state.js",
"new_path": "native/input/input-state.js",
"diff": "@@ -6,14 +6,18 @@ import * as React from 'react';\nimport type { NativeMediaSelection } from 'lib/types/media-types';\nimport type { RawTextMessageInfo } from 'lib/types/messages/text';\n+export type MultimediaProcessingStep = 'transcode' | 'upload';\n+\nexport type PendingMultimediaUpload = {|\n- failed: ?string,\n- progressPercent: number,\n+ +failed: ?string,\n+ +progressPercent: number,\n+ +processingStep: ?MultimediaProcessingStep,\n|};\nconst pendingMultimediaUploadPropType = PropTypes.shape({\nfailed: PropTypes.string,\nprogressPercent: PropTypes.number.isRequired,\n+ processingStep: PropTypes.oneOf(['transcode', 'upload']),\n});\nexport type MessagePendingUploads = {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/ffmpeg.js",
"new_path": "native/media/ffmpeg.js",
"diff": "// @flow\n-import invariant from 'invariant';\nimport { RNFFmpeg, RNFFprobe, RNFFmpegConfig } from 'react-native-ffmpeg';\nimport { getHasMultipleFramesProbeCommand } from 'lib/media/video-utils';\n@@ -22,14 +21,6 @@ class FFmpeg {\nqueue: QueuedCommand[] = [];\ncurrentCalls: CallCounter = { process: 0, probe: 0 };\n- // The length of the video that's currently being transcoded in seconds\n- activeCommandInputVideoDuration: ?number;\n- lastStats: ?FFmpegStatistics;\n-\n- constructor() {\n- RNFFmpegConfig.enableStatisticsCallback(this.statisticsCallback);\n- }\n-\nqueueCommand<R>(\ntype: QueuedCommandType,\nwrappedCommand: () => Promise<R>,\n@@ -83,13 +74,24 @@ class FFmpeg {\ntoRun.forEach(({ runCommand }) => runCommand());\n}\n- process(ffmpegCommand: string, inputVideoDuration: number) {\n+ process(\n+ ffmpegCommand: string,\n+ inputVideoDuration: number,\n+ onTranscodingProgress: (percent: number) => void,\n+ ) {\nconst duration = inputVideoDuration > 0 ? inputVideoDuration : 0.001;\nconst wrappedCommand = async () => {\nRNFFmpegConfig.resetStatistics();\n- this.activeCommandInputVideoDuration = duration;\n+ let lastStats;\n+ RNFFmpegConfig.enableStatisticsCallback(\n+ (statisticsData: FFmpegStatistics) => {\n+ lastStats = statisticsData;\n+ const { time } = statisticsData;\n+ onTranscodingProgress(time / 1000 / duration);\n+ },\n+ );\nconst ffmpegResult = await RNFFmpeg.execute(ffmpegCommand);\n- return { ...ffmpegResult, lastStats: this.lastStats };\n+ return { ...ffmpegResult, lastStats };\n};\nreturn this.queueCommand('process', wrappedCommand);\n}\n@@ -133,14 +135,6 @@ class FFmpeg {\nconst numFrames = parseInt(probeOutput.lastCommandOutput);\nreturn numFrames > 1;\n}\n-\n- statisticsCallback = (statisticsData: FFmpegStatistics) => {\n- this.lastStats = statisticsData;\n- const { time } = statisticsData;\n- const videoDuration = this.activeCommandInputVideoDuration;\n- invariant(videoDuration, 'should be set');\n- console.log(time / 1000 / videoDuration);\n- };\n}\nconst ffmpeg = new FFmpeg();\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/media-utils.js",
"new_path": "native/media/media-utils.js",
"diff": "@@ -21,6 +21,7 @@ type MediaProcessConfig = {|\nhasWiFi: boolean,\n// Blocks return until we can confirm result has the correct MIME\nfinalFileHeaderCheck?: boolean,\n+ onTranscodingProgress: (percent: number) => void,\n|};\ntype MediaResult = {|\nsuccess: true,\n@@ -149,14 +150,19 @@ async function innerProcessMedia(\n}\nif (mediaType === 'video') {\n- const { steps: videoSteps, result: videoResult } = await processVideo({\n+ const { steps: videoSteps, result: videoResult } = await processVideo(\n+ {\nuri: initialURI,\nmime,\nfilename: selection.filename,\nfileSize,\ndimensions,\nhasWiFi: config.hasWiFi,\n- });\n+ },\n+ {\n+ onTranscodingProgress: config.onTranscodingProgress,\n+ },\n+ );\nsteps.push(...videoSteps);\nif (!videoResult.success) {\nreturn await finish(videoResult);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/video-utils.js",
"new_path": "native/media/video-utils.js",
"diff": "@@ -32,6 +32,11 @@ type ProcessVideoInfo = {|\ndimensions: Dimensions,\nhasWiFi: boolean,\n|};\n+\n+type VideoProcessConfig = {|\n+ +onTranscodingProgress: (percent: number) => void,\n+|};\n+\ntype ProcessVideoResponse = {|\nsuccess: true,\nuri: string,\n@@ -41,6 +46,7 @@ type ProcessVideoResponse = {|\n|};\nasync function processVideo(\ninput: ProcessVideoInfo,\n+ config: VideoProcessConfig,\n): Promise<{|\nsteps: $ReadOnlyArray<MediaMissionStep>,\nresult: MediaMissionFailure | ProcessVideoResponse,\n@@ -106,7 +112,11 @@ async function processVideo(\nexceptionMessage;\nconst start = Date.now();\ntry {\n- const { rc, lastStats } = await ffmpeg.process(ffmpegCommand, duration);\n+ const { rc, lastStats } = await ffmpeg.process(\n+ ffmpegCommand,\n+ duration,\n+ config.onTranscodingProgress,\n+ );\nsuccess = rc === 0;\nif (success) {\nreturnCode = rc;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Passing onTranscodingProgress down to ffmpeg statistics
Summary: Passing onTranscodingProgress callback down to ffmpeg so statistics can be "accessed" by inputStateContainer
Test Plan: Logged call to onTranscodingProgress and saw visual indication of progress.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub
Differential Revision: https://phabricator.ashoat.com/D668 |
129,191 | 25.01.2021 14:19:56 | -3,600 | 1c93030a987102ea1ebfab5f607c15e94e46481d | move trim text to text-utils
Summary: move trim text from notif-utils to text-utils in order to make it more reusable
Test Plan: use the `trimText` function
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/notif-utils.js",
"new_path": "lib/shared/notif-utils.js",
"diff": "@@ -11,6 +11,7 @@ import {\nimport type { NotifTexts } from '../types/notif-types';\nimport type { ThreadInfo, ThreadType } from '../types/thread-types';\nimport type { RelativeUserInfo } from '../types/user-types';\n+import { trimText } from '../utils/text-utils';\nimport { robotextForMessageInfo, robotextToRawString } from './message-utils';\nimport { messageSpecs } from './messages/message-specs';\nimport { threadNoun } from './thread-utils';\n@@ -22,22 +23,15 @@ function notifTextsForMessageInfo(\n): NotifTexts {\nconst fullNotifTexts = fullNotifTextsForMessageInfo(messageInfos, threadInfo);\nreturn {\n- merged: trimNotifText(fullNotifTexts.merged, 300),\n- body: trimNotifText(fullNotifTexts.body, 300),\n- title: trimNotifText(fullNotifTexts.title, 100),\n+ merged: trimText(fullNotifTexts.merged, 300),\n+ body: trimText(fullNotifTexts.body, 300),\n+ title: trimText(fullNotifTexts.title, 100),\n...(fullNotifTexts.prefix && {\n- prefix: trimNotifText(fullNotifTexts.prefix, 50),\n+ prefix: trimText(fullNotifTexts.prefix, 50),\n}),\n};\n}\n-function trimNotifText(text: string, maxLength: number): string {\n- if (text.length <= maxLength) {\n- return text;\n- }\n- return text.substr(0, maxLength - 3) + '...';\n-}\n-\nconst notifTextForSubthreadCreation = (\ncreator: RelativeUserInfo,\nthreadType: ThreadType,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/text-utils.js",
"new_path": "lib/utils/text-utils.js",
"diff": "@@ -12,4 +12,11 @@ function pluralize(nouns: string[]): string {\n}\n}\n-export { pluralize };\n+function trimText(text: string, maxLength: number): string {\n+ if (text.length <= maxLength) {\n+ return text;\n+ }\n+ return text.substr(0, maxLength - 3) + '...';\n+}\n+\n+export { pluralize, trimText };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | move trim text to text-utils
Summary: move trim text from notif-utils to text-utils in order to make it more reusable
Test Plan: use the `trimText` function
Reviewers: ashoat, palys-swm
Reviewed By: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D672 |
129,191 | 02.02.2021 11:54:22 | -3,600 | 263480781af5be2bf862c3a39a76fdd0538d01e8 | [server] Add replies count column
Test Plan: Run the script and check db schema. Create a new thread and check if the column value was set to 0.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/add-replies-count-column.js",
"diff": "+// @flow\n+\n+import { dbQuery, SQL } from '../database/database';\n+import { main } from './utils';\n+\n+async function addColumn() {\n+ const update = SQL`\n+ ALTER TABLE threads\n+ ADD replies_count INT UNSIGNED NOT NULL DEFAULT 0\n+ `;\n+ await dbQuery(update);\n+}\n+\n+main([addColumn]);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/create-db.js",
"new_path": "server/src/scripts/create-db.js",
"diff": "@@ -153,7 +153,8 @@ async function createTables() {\ncreator bigint(20) NOT NULL,\ncreation_time bigint(20) NOT NULL,\ncolor char(6) COLLATE utf8mb4_bin NOT NULL,\n- source_message bigint(20) DEFAULT NULL\n+ source_message bigint(20) DEFAULT NULL,\n+ replies_count int UNSIGNED NOT NULL DEFAULT 0\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;\nCREATE TABLE updates (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Add replies count column
Test Plan: Run the script and check db schema. Create a new thread and check if the column value was set to 0.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D678 |
129,191 | 02.02.2021 12:41:53 | -3,600 | 3f9fb62783bf145fde630164889f5e00e4a9f327 | [lib] Add a new property to message spec telling if we should include the message in replies count
Test Plan: Flow
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/message-spec.js",
"new_path": "lib/shared/messages/message-spec.js",
"diff": "@@ -84,4 +84,5 @@ export type MessageSpec<Data, RawInfo, Info> = {|\n+userIDs?: (rawMessageInfo: RawInfo) => $ReadOnlyArray<string>,\n+startsThread?: boolean,\n+threadIDs?: (rawMessageInfo: RawInfo) => $ReadOnlyArray<string>,\n+ +includedInRepliesCount?: boolean,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/multimedia-message-spec.js",
"new_path": "lib/shared/messages/multimedia-message-spec.js",
"diff": "@@ -207,6 +207,7 @@ export const multimediaMessageSpec: MessageSpec<\n},\ngeneratesNotifs: true,\n+ includedInRepliesCount: true,\n});\nfunction shimMediaMessageInfo(\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/text-message-spec.js",
"new_path": "lib/shared/messages/text-message-spec.js",
"diff": "@@ -83,4 +83,5 @@ export const textMessageSpec: MessageSpec<\n},\ngeneratesNotifs: true,\n+ includedInRepliesCount: true,\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add a new property to message spec telling if we should include the message in replies count
Test Plan: Flow
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D682 |
129,191 | 02.02.2021 13:52:08 | -3,600 | c379523ea000f3d80d67bf055c1d5251a2ce2eb5 | [lib] Include replies count in thread types and fetch it from the db
Test Plan: Flow, log out, log in, check replies count in threads store using the debugger
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -285,6 +285,7 @@ function createPendingThread({\n},\nunread: false,\n},\n+ repliesCount: 0,\n};\nconst userInfos = Object.fromEntries(\n@@ -412,6 +413,7 @@ function rawThreadInfoFromServerThreadInfo(\nmembers,\nroles: serverThreadInfo.roles,\ncurrentUser,\n+ repliesCount: serverThreadInfo.repliesCount,\n};\nconst sourceMessageID = serverThreadInfo.sourceMessageID;\nif (sourceMessageID) {\n@@ -476,6 +478,7 @@ function threadInfoFromRawThreadInfo(\nmembers: rawThreadInfo.members,\nroles: rawThreadInfo.roles,\ncurrentUser: getCurrentUser(rawThreadInfo, viewerID, userInfos),\n+ repliesCount: rawThreadInfo.repliesCount,\n};\nconst { sourceMessageID } = rawThreadInfo;\nif (sourceMessageID) {\n@@ -562,6 +565,7 @@ function rawThreadInfoFromThreadInfo(threadInfo: ThreadInfo): RawThreadInfo {\nmembers: threadInfo.members,\nroles: threadInfo.roles,\ncurrentUser: threadInfo.currentUser,\n+ repliesCount: threadInfo.repliesCount,\n};\nconst { sourceMessageID } = threadInfo;\nif (sourceMessageID) {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -163,6 +163,7 @@ export type RawThreadInfo = {|\nroles: { [id: string]: RoleInfo },\ncurrentUser: ThreadCurrentUserInfo,\nsourceMessageID?: string,\n+ repliesCount: number,\n|};\nexport type ThreadInfo = {|\n@@ -178,6 +179,7 @@ export type ThreadInfo = {|\nroles: { [id: string]: RoleInfo },\ncurrentUser: ThreadCurrentUserInfo,\nsourceMessageID?: string,\n+ repliesCount: number,\n|};\nexport const threadTypePropType = PropTypes.oneOf([\n@@ -217,6 +219,7 @@ export const rawThreadInfoPropType = PropTypes.shape({\nroles: PropTypes.objectOf(rolePropType).isRequired,\ncurrentUser: currentUserPropType.isRequired,\nsourceMessageID: PropTypes.string,\n+ repliesCount: PropTypes.number.isRequired,\n});\nexport const threadInfoPropType = PropTypes.shape({\n@@ -232,6 +235,7 @@ export const threadInfoPropType = PropTypes.shape({\nroles: PropTypes.objectOf(rolePropType).isRequired,\ncurrentUser: currentUserPropType.isRequired,\nsourceMessageID: PropTypes.string,\n+ repliesCount: PropTypes.number.isRequired,\n});\nexport type ServerMemberInfo = {|\n@@ -253,6 +257,7 @@ export type ServerThreadInfo = {|\nmembers: $ReadOnlyArray<ServerMemberInfo>,\nroles: { [id: string]: RoleInfo },\nsourceMessageID?: string,\n+ repliesCount: number,\n|};\nexport type ThreadStore = {|\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/thread-fetchers.js",
"new_path": "server/src/fetchers/thread-fetchers.js",
"diff": "@@ -19,9 +19,9 @@ async function fetchServerThreadInfos(\nconst query = SQL`\nSELECT t.id, t.name, t.parent_thread_id, t.color, t.description,\n- t.type, t.creation_time, t.default_role, t.source_message, r.id AS role,\n- r.name AS role_name, r.permissions AS role_permissions, m.user,\n- m.permissions, m.subscription,\n+ t.type, t.creation_time, t.default_role, t.source_message, t.replies_count,\n+ r.id AS role, r.name AS role_name, r.permissions AS role_permissions,\n+ m.user, m.permissions, m.subscription,\nm.last_read_message < m.last_message AS unread\nFROM threads t\nLEFT JOIN (\n@@ -53,6 +53,7 @@ async function fetchServerThreadInfos(\n: null,\nmembers: [],\nroles: {},\n+ repliesCount: row.replies_count,\n};\n}\nconst sourceMessageID = row.source_message?.toString();\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Include replies count in thread types and fetch it from the db
Test Plan: Flow, log out, log in, check replies count in threads store using the debugger
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D684 |
129,191 | 02.02.2021 15:13:22 | -3,600 | abd1465166645540942346d74a50feb70efd6f95 | [server] Create migration script which computes replies count for sidebars
Test Plan: Run the script and check that the count was set properly for all the sidebars
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/compute_replies_count.js",
"diff": "+// @flow\n+\n+import { messageSpecs } from 'lib/shared/messages/message-specs';\n+import { messageTypes } from 'lib/types/message-types';\n+import { threadTypes } from 'lib/types/thread-types';\n+\n+import { dbQuery, SQL } from '../database/database';\n+import { main } from './utils';\n+\n+async function computeRepliesCount() {\n+ const includedMessageTypes = Object.keys(messageTypes)\n+ .map((key) => messageTypes[key])\n+ .filter((type) => messageSpecs[type].includedInRepliesCount);\n+\n+ const query = SQL`\n+ UPDATE threads t\n+ INNER JOIN (\n+ SELECT thread AS threadID, COUNT(*) AS count\n+ FROM messages\n+ WHERE type IN (${includedMessageTypes})\n+ GROUP BY thread\n+ ) c ON c.threadID = t.id\n+ SET t.replies_count = c.count\n+ WHERE t.type = ${threadTypes.SIDEBAR}\n+ `;\n+ await dbQuery(query);\n+}\n+\n+main([computeRepliesCount]);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Create migration script which computes replies count for sidebars
Test Plan: Run the script and check that the count was set properly for all the sidebars
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D685 |
129,190 | 29.01.2021 09:53:09 | -3,600 | d425203864bba01eb4c3bb6b0e8ec9498f69c49c | Add a title to the sidebar for text messages
Summary: Add a title to the sidebar for text messages
Test Plan: Add new sidebars and see their titles inside of them and on the main chat screen
Reviewers: ashoat, palys-swm, KatPo
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -18,6 +18,7 @@ import {\ntype MessageTruncationStatus,\ntype MultimediaMessageData,\ntype MessageStore,\n+ type ComposableMessageInfo,\nmessageTypes,\nmessageTruncationStatus,\ntype RawComposableMessageInfo,\n@@ -26,6 +27,7 @@ import type { ImagesMessageData } from '../types/messages/images';\nimport type { MediaMessageData } from '../types/messages/media';\nimport { type ThreadInfo } from '../types/thread-types';\nimport type { RelativeUserInfo, UserInfos } from '../types/user-types';\n+import { trimText } from '../utils/text-utils';\nimport { codeBlockRegex } from './markdown';\nimport { messageSpecs } from './messages/message-specs';\nimport { stringForUser } from './user-utils';\n@@ -349,6 +351,18 @@ function getMostRecentNonLocalMessageID(\nreturn thread?.messageIDs.find((id) => !id.startsWith('local'));\n}\n+function getMessageTitle(\n+ messageInfo: ComposableMessageInfo | RobotextMessageInfo,\n+ threadInfo: ThreadInfo,\n+): string | null {\n+ const { messageTitle } = messageSpecs[messageInfo.type];\n+ if (!messageTitle) {\n+ return null;\n+ }\n+ const name = messageTitle({ messageInfo, threadInfo });\n+ return trimText(name, 30);\n+}\n+\nexport {\nmessageKey,\nmessageID,\n@@ -371,4 +385,5 @@ export {\ntrimMessage,\ncreateMessageReply,\ngetMostRecentNonLocalMessageID,\n+ getMessageTitle,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/message-spec.js",
"new_path": "lib/shared/messages/message-spec.js",
"diff": "@@ -16,6 +16,10 @@ import type { RelativeUserInfo } from '../../types/user-types';\nexport type MessageSpec<Data, RawInfo, Info> = {|\n+messageContent?: (data: Data) => string | null,\n+ +messageTitle?: ({|\n+ +messageInfo: Info,\n+ +threadInfo: ThreadInfo,\n+ |}) => string,\n+rawMessageInfoFromRow?: (\nrow: Object,\nparams: {|\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/multimedia-message-spec.js",
"new_path": "lib/shared/messages/multimedia-message-spec.js",
"diff": "@@ -21,7 +21,7 @@ import type {\nMediaMessageInfo,\nRawMediaMessageInfo,\n} from '../../types/messages/media';\n-import { createMediaMessageInfo } from '../message-utils';\n+import { createMediaMessageInfo, messagePreviewText } from '../message-utils';\nimport { threadIsGroupChat } from '../thread-utils';\nimport { stringForUser } from '../user-utils';\nimport { hasMinCodeVersion } from '../version-utils';\n@@ -38,6 +38,10 @@ export const multimediaMessageSpec: MessageSpec<\nreturn JSON.stringify(mediaIDs);\n},\n+ messageTitle({ messageInfo, threadInfo }) {\n+ return messagePreviewText(messageInfo, threadInfo);\n+ },\n+\nrawMessageInfoFromRow(row, params) {\nconst { localID, media } = params;\ninvariant(media, 'Media should be provided');\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/text-message-spec.js",
"new_path": "lib/shared/messages/text-message-spec.js",
"diff": "@@ -8,6 +8,7 @@ import type {\nTextMessageData,\nTextMessageInfo,\n} from '../../types/messages/text';\n+import { firstLine } from '../../utils/string-utils';\nimport { threadIsGroupChat } from '../thread-utils';\nimport { stringForUser } from '../user-utils';\nimport type { MessageSpec } from './message-spec';\n@@ -22,6 +23,10 @@ export const textMessageSpec: MessageSpec<\nreturn data.text;\n},\n+ messageTitle({ messageInfo }) {\n+ return firstLine(messageInfo.text);\n+ },\n+\nrawMessageInfoFromRow(row, params) {\nconst rawTextMessageInfo: RawTextMessageInfo = {\ntype: messageTypes.TEXT,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -38,6 +38,7 @@ import type {\nUserInfo,\n} from '../types/user-types';\nimport { pluralize } from '../utils/text-utils';\n+import { getMessageTitle } from './message-utils';\nimport { relationshipBlockedInEitherDirection } from './relationship-utils';\nfunction colorIsDark(color: string) {\n@@ -222,6 +223,7 @@ type CreatePendingThreadArgs = {|\n+members?: $ReadOnlyArray<GlobalAccountUserInfo | UserInfo>,\n+parentThreadID?: ?string,\n+threadColor?: ?string,\n+ +name?: ?string,\n|};\nfunction createPendingThread({\n@@ -230,6 +232,7 @@ function createPendingThread({\nmembers,\nparentThreadID,\nthreadColor,\n+ name,\n}: CreatePendingThreadArgs) {\nconst now = Date.now();\nmembers = members ?? [];\n@@ -256,7 +259,7 @@ function createPendingThread({\nconst rawThreadInfo = {\nid: threadID,\ntype: threadType,\n- name: null,\n+ name: name ?? null,\ndescription: null,\ncolor: threadColor ?? generatePendingThreadColor(memberIDs, viewerID),\ncreationTime: now,\n@@ -336,6 +339,7 @@ function createPendingSidebar(\nmembers: [initialMemberUserInfo],\nparentThreadID,\nthreadColor: color,\n+ name: getMessageTitle(messageInfo, threadInfo),\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-input-bar.react.js",
"new_path": "native/chat/chat-input-bar.react.js",
"diff": "@@ -650,6 +650,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\ncolor: threadInfo.color,\nsourceMessageID,\nparentThreadID: threadInfo.parentThreadID,\n+ name: threadInfo.name,\n});\n}\nthis.props.dispatchActionPromise(newThreadActionTypes, resultPromise);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add a title to the sidebar for text messages
Summary: Add a title to the sidebar for text messages
Test Plan: Add new sidebars and see their titles inside of them and on the main chat screen
Reviewers: ashoat, palys-swm, KatPo
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D666 |
129,191 | 04.02.2021 11:34:35 | -3,600 | a58652b6627972af93f3683a3cfed8f00f72aaad | [native] Display number of replies
Test Plan: Open two instances of the app, with different users. Send a message to a sidebar and check if replies count increases in the other app.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/chat/inline-sidebar.react.js",
"new_path": "native/chat/inline-sidebar.react.js",
"diff": "@@ -46,11 +46,15 @@ function InlineSidebar(props: Props) {\n}\nconst unreadStyle = threadInfo.currentUser.unread ? styles.unread : null;\n+ const repliesCount = threadInfo.repliesCount || 1;\n+ const repliesText = `${repliesCount} ${\n+ repliesCount > 1 ? 'replies' : 'reply'\n+ }`;\nreturn (\n<View style={[styles.content, alignStyle]}>\n<Button style={styles.sidebar} onPress={onPress}>\n{nonViewerIcon}\n- <Text style={[styles.name, unreadStyle]}>sidebar</Text>\n+ <Text style={[styles.name, unreadStyle]}>{repliesText}</Text>\n{viewerIcon}\n</Button>\n</View>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Display number of replies
Test Plan: Open two instances of the app, with different users. Send a message to a sidebar and check if replies count increases in the other app.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D692 |
129,191 | 04.02.2021 15:19:38 | -3,600 | f97ca9d9ee1beaea1136ca622b67ed36aa4d56d9 | [server] Add sender column to memberships table
Test Plan: Run the script and check if the column was added.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/add-sender-column.js",
"diff": "+// @flow\n+\n+import { dbQuery, SQL } from '../database/database';\n+import { main } from './utils';\n+\n+async function addColumn() {\n+ const update = SQL`\n+ ALTER TABLE memberships\n+ ADD sender TINYINT(1) UNSIGNED NOT NULL DEFAULT 0\n+ `;\n+ await dbQuery(update);\n+}\n+\n+main([addColumn]);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/create-db.js",
"new_path": "server/src/scripts/create-db.js",
"diff": "@@ -82,7 +82,8 @@ async function createTables() {\ncreation_time bigint(20) NOT NULL,\nsubscription json NOT NULL,\nlast_message bigint(20) NOT NULL DEFAULT 0,\n- last_read_message bigint(20) NOT NULL DEFAULT 0\n+ last_read_message bigint(20) NOT NULL DEFAULT 0,\n+ sender tinyint(1) UNSIGNED NOT NULL DEFAULT 0\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;\nCREATE TABLE messages (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Add sender column to memberships table
Test Plan: Run the script and check if the column was added.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D694 |
129,191 | 04.02.2021 15:44:16 | -3,600 | f4c4c480c6fcc2c294d97a00bdde0d24732995ef | [server] Update sender column
Test Plan: Send a message and check if the column was updated in db
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "server/src/creators/message-creator.js",
"new_path": "server/src/creators/message-creator.js",
"diff": "@@ -186,9 +186,12 @@ async function updateRepliesCount(\nnewMessageDatas: MessageData[],\n) {\nconst updatedThreads = [];\n- const update = SQL`\n+\n+ const updateThreads = SQL`\nUPDATE threads\nSET replies_count = replies_count + (CASE `;\n+\n+ const membershipConditions = [];\nfor (const [threadID, messages] of threadsToMessageIndices.entries()) {\nconst newRepliesIncrease = messages\n.map((i) => newMessageDatas[i].type)\n@@ -197,21 +200,39 @@ async function updateRepliesCount(\ncontinue;\n}\n- update.append(SQL`\n+ updateThreads.append(SQL`\nWHEN id = ${threadID} THEN ${newRepliesIncrease}\n`);\nupdatedThreads.push(threadID);\n+\n+ const senders = messages.map((i) => newMessageDatas[i].creatorID);\n+ membershipConditions.push(\n+ SQL`thread = ${threadID} AND user IN (${senders})`,\n+ );\n}\n- update.append(SQL`\n+ updateThreads.append(SQL`\nELSE 0\nEND)\nWHERE id IN (${updatedThreads})\nAND type = ${threadTypes.SIDEBAR}\n`);\n+\n+ const updateMemberships = SQL`\n+ UPDATE memberships\n+ SET sender = 1\n+ WHERE sender = 0\n+ AND (\n+ `;\n+ updateMemberships.append(mergeOrConditions(membershipConditions));\n+ updateMemberships.append(SQL`\n+ )\n+ `);\n+\nif (updatedThreads.length > 0) {\nconst [{ threadInfos: serverThreadInfos }] = await Promise.all([\nfetchServerThreadInfos(SQL`t.id IN (${updatedThreads})`),\n- dbQuery(update),\n+ dbQuery(updateThreads),\n+ dbQuery(updateMemberships),\n]);\nconst time = Date.now();\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Update sender column
Test Plan: Send a message and check if the column was updated in db
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D695 |
129,191 | 04.02.2021 16:56:02 | -3,600 | 70896659c39fd3174f83a5fcb887511d92a7469e | [lib] Add isSender to membership type and fetch it from db
Test Plan: Log out, log in, check in the debugger if thread store contains correct isSender values
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/user-selectors.js",
"new_path": "lib/selectors/user-selectors.js",
"diff": "@@ -87,6 +87,7 @@ const baseRelativeMemberInfoSelectorForMembersOfThread = (\npermissions: memberInfo.permissions,\nusername,\nisViewer: true,\n+ isSender: memberInfo.isSender,\n});\n} else {\nrelativeMemberInfos.push({\n@@ -95,6 +96,7 @@ const baseRelativeMemberInfoSelectorForMembersOfThread = (\npermissions: memberInfo.permissions,\nusername,\nisViewer: false,\n+ isSender: memberInfo.isSender,\n});\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -269,11 +269,13 @@ function createPendingThread({\nid: viewerID,\nrole: role.id,\npermissions: membershipPermissions,\n+ isSender: false,\n},\n...members.map((member) => ({\nid: member.id,\nrole: role.id,\npermissions: membershipPermissions,\n+ isSender: false,\n})),\n],\nroles: {\n@@ -376,6 +378,7 @@ function rawThreadInfoFromServerThreadInfo(\nid: serverMember.id,\nrole: serverMember.role,\npermissions: serverMember.permissions,\n+ isSender: serverMember.isSender,\n});\nif (serverMember.id === viewerID) {\ncurrentUser = {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -114,14 +114,16 @@ export const threadPermissionsInfoPropType = PropTypes.objectOf(\n);\nexport type MemberInfo = {|\n- id: string,\n- role: ?string,\n- permissions: ThreadPermissionsInfo,\n+ +id: string,\n+ +role: ?string,\n+ +permissions: ThreadPermissionsInfo,\n+ +isSender: boolean,\n|};\nexport const memberInfoPropType = PropTypes.shape({\nid: PropTypes.string.isRequired,\nrole: PropTypes.string,\npermissions: threadPermissionsInfoPropType.isRequired,\n+ isSender: PropTypes.bool.isRequired,\n});\nexport type RelativeMemberInfo = {|\n@@ -135,6 +137,7 @@ export const relativeMemberInfoPropType = PropTypes.shape({\npermissions: threadPermissionsInfoPropType.isRequired,\nusername: PropTypes.string,\nisViewer: PropTypes.bool.isRequired,\n+ isSender: PropTypes.bool.isRequired,\n});\nexport type RoleInfo = {|\n@@ -239,11 +242,12 @@ export const threadInfoPropType = PropTypes.shape({\n});\nexport type ServerMemberInfo = {|\n- id: string,\n- role: ?string,\n- permissions: ThreadPermissionsInfo,\n- subscription: ThreadSubscription,\n- unread: ?boolean,\n+ +id: string,\n+ +role: ?string,\n+ +permissions: ThreadPermissionsInfo,\n+ +subscription: ThreadSubscription,\n+ +unread: ?boolean,\n+ +isSender: boolean,\n|};\nexport type ServerThreadInfo = {|\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/thread-fetchers.js",
"new_path": "server/src/fetchers/thread-fetchers.js",
"diff": "@@ -22,7 +22,7 @@ async function fetchServerThreadInfos(\nt.type, t.creation_time, t.default_role, t.source_message, t.replies_count,\nr.id AS role, r.name AS role_name, r.permissions AS role_permissions,\nm.user, m.permissions, m.subscription,\n- m.last_read_message < m.last_message AS unread\n+ m.last_read_message < m.last_message AS unread, m.sender\nFROM threads t\nLEFT JOIN (\nSELECT thread, id, name, permissions\n@@ -78,6 +78,7 @@ async function fetchServerThreadInfos(\nrole: row.role ? role : null,\nsubscription: row.subscription,\nunread: row.role ? !!row.unread : null,\n+ isSender: !!row.sender,\n});\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add isSender to membership type and fetch it from db
Test Plan: Log out, log in, check in the debugger if thread store contains correct isSender values
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D697 |
129,184 | 01.02.2021 13:29:43 | 28,800 | 95d2bac5987931b291a1c5b1e69d1b39a3be20c7 | Modified validateAndConvert to handle video upload
Test Plan: NA
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/media/file-utils.js",
"new_path": "lib/media/file-utils.js",
"diff": "@@ -8,31 +8,35 @@ import type { MediaType } from '../types/media-types';\ntype ResultMIME = 'image/png' | 'image/jpeg';\ntype MediaConfig = {|\n- mediaType: 'photo' | 'video' | 'photo_or_video',\n- extension: string,\n- serverCanTranscode: boolean,\n- imageConfig?: Shape<{|\n- convertTo: ResultMIME,\n+ +mediaType: 'photo' | 'video' | 'photo_or_video',\n+ +extension: string,\n+ +serverCanHandle: boolean,\n+ +serverTranscodesImage: boolean,\n+ +imageConfig?: Shape<{|\n+ +convertTo: ResultMIME,\n|}>,\n- videoConfig?: Shape<{|\n- loop: boolean,\n+ +videoConfig?: Shape<{|\n+ +loop: boolean,\n|}>,\n|};\nconst mediaConfig: { [mime: string]: MediaConfig } = Object.freeze({\n'image/png': {\nmediaType: 'photo',\nextension: 'png',\n- serverCanTranscode: true,\n+ serverCanHandle: true,\n+ serverTranscodesImage: true,\n},\n'image/jpeg': {\nmediaType: 'photo',\nextension: 'jpg',\n- serverCanTranscode: true,\n+ serverCanHandle: true,\n+ serverTranscodesImage: true,\n},\n'image/gif': {\nmediaType: 'photo_or_video',\nextension: 'gif',\n- serverCanTranscode: true,\n+ serverCanHandle: true,\n+ serverTranscodesImage: true,\nimageConfig: {\nconvertTo: 'image/png',\n},\n@@ -43,7 +47,8 @@ const mediaConfig: { [mime: string]: MediaConfig } = Object.freeze({\n'image/heic': {\nmediaType: 'photo',\nextension: 'heic',\n- serverCanTranscode: false,\n+ serverCanHandle: false,\n+ serverTranscodesImage: false,\nimageConfig: {\nconvertTo: 'image/jpeg',\n},\n@@ -51,7 +56,8 @@ const mediaConfig: { [mime: string]: MediaConfig } = Object.freeze({\n'image/webp': {\nmediaType: 'photo',\nextension: 'webp',\n- serverCanTranscode: true,\n+ serverCanHandle: true,\n+ serverTranscodesImage: true,\nimageConfig: {\nconvertTo: 'image/jpeg',\n},\n@@ -59,7 +65,8 @@ const mediaConfig: { [mime: string]: MediaConfig } = Object.freeze({\n'image/tiff': {\nmediaType: 'photo',\nextension: 'tiff',\n- serverCanTranscode: true,\n+ serverCanHandle: true,\n+ serverTranscodesImage: true,\nimageConfig: {\nconvertTo: 'image/jpeg',\n},\n@@ -67,7 +74,8 @@ const mediaConfig: { [mime: string]: MediaConfig } = Object.freeze({\n'image/svg+xml': {\nmediaType: 'photo',\nextension: 'svg',\n- serverCanTranscode: true,\n+ serverCanHandle: true,\n+ serverTranscodesImage: true,\nimageConfig: {\nconvertTo: 'image/png',\n},\n@@ -75,7 +83,8 @@ const mediaConfig: { [mime: string]: MediaConfig } = Object.freeze({\n'image/bmp': {\nmediaType: 'photo',\nextension: 'bmp',\n- serverCanTranscode: true,\n+ serverCanHandle: true,\n+ serverTranscodesImage: true,\nimageConfig: {\nconvertTo: 'image/png',\n},\n@@ -83,20 +92,29 @@ const mediaConfig: { [mime: string]: MediaConfig } = Object.freeze({\n'video/mp4': {\nmediaType: 'video',\nextension: 'mp4',\n- serverCanTranscode: false,\n+ // serverCanHandle set to false pending future video message progress\n+ serverCanHandle: false,\n+ serverTranscodesImage: false,\n},\n'video/quicktime': {\nmediaType: 'video',\nextension: 'mp4',\n- serverCanTranscode: false,\n+ // serverCanHandle set to false pending future video message progress\n+ serverCanHandle: false,\n+ serverTranscodesImage: false,\n},\n});\nconst serverTranscodableTypes: Set<$Keys<typeof mediaConfig>> = new Set();\n+const serverCanHandleTypes: Set<$Keys<typeof mediaConfig>> = new Set();\n+\nfor (let mime in mediaConfig) {\n- if (mediaConfig[mime].serverCanTranscode) {\n+ if (mediaConfig[mime].serverTranscodesImage) {\nserverTranscodableTypes.add(mime);\n}\n+ if (mediaConfig[mime].serverCanHandle) {\n+ serverCanHandleTypes.add(mime);\n+ }\n}\nfunction getTargetMIME(inputMIME: string): ResultMIME {\n@@ -188,6 +206,7 @@ function filenameFromPathOrURI(pathOrURI: string): ?string {\nexport {\nmediaConfig,\nserverTranscodableTypes,\n+ serverCanHandleTypes,\ngetTargetMIME,\nbytesNeededForFileTypeCheck,\nfileInfoFromData,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/uploads/media-utils.js",
"new_path": "server/src/uploads/media-utils.js",
"diff": "@@ -6,6 +6,7 @@ import sharp from 'sharp';\nimport {\nserverTranscodableTypes,\n+ serverCanHandleTypes,\nreadableFilename,\n} from 'lib/media/file-utils';\nimport { getImageProcessingPlan } from 'lib/media/image-utils';\n@@ -39,11 +40,49 @@ async function validateAndConvert(\nif (!mime || !mediaType) {\nreturn null;\n}\n+\n+ if (!serverCanHandleTypes.has(mime)) {\n+ return null;\n+ }\n+\n+ if (mediaType === 'video') {\n+ invariant(\n+ inputDimensions,\n+ 'inputDimensions should be set in validateAndConvert',\n+ );\n+ return {\n+ mime: mime,\n+ mediaType: mediaType,\n+ name: initialName,\n+ buffer: initialBuffer,\n+ dimensions: inputDimensions,\n+ loop: inputLoop,\n+ };\n+ }\n+\nif (!serverTranscodableTypes.has(mime)) {\n// This should've gotten converted on the client\nreturn null;\n}\n+ return convertImage(\n+ initialBuffer,\n+ mime,\n+ initialName,\n+ inputDimensions,\n+ inputLoop,\n+ size,\n+ );\n+}\n+\n+async function convertImage(\n+ initialBuffer: Buffer,\n+ mime: string,\n+ initialName: string,\n+ inputDimensions: ?Dimensions,\n+ inputLoop: boolean,\n+ size: number,\n+): Promise<?UploadInput> {\nlet sharpImage, metadata;\ntry {\nsharpImage = initializeSharp(initialBuffer, mime);\n@@ -72,7 +111,7 @@ async function validateAndConvert(\ninvariant(name, `should be able to construct filename for ${mime}`);\nreturn {\nmime,\n- mediaType,\n+ mediaType: 'photo',\nname,\nbuffer: initialBuffer,\ndimensions: initialDimensions,\n@@ -112,7 +151,7 @@ async function validateAndConvert(\n!convertedMIME ||\n!convertedMediaType ||\nconvertedMIME !== targetMIME ||\n- convertedMediaType !== mediaType\n+ convertedMediaType !== 'photo'\n) {\nreturn null;\n}\n@@ -124,7 +163,7 @@ async function validateAndConvert(\nreturn {\nmime: targetMIME,\n- mediaType,\n+ mediaType: 'photo',\nname: convertedName,\nbuffer: convertedBuffer,\ndimensions: convertedDimensions,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Modified validateAndConvert to handle video upload
Test Plan: NA
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D677 |
129,184 | 03.02.2021 06:27:46 | 28,800 | 6432699fb238e197dc8e8bd88ac5714da1bf51a6 | Show processingStep in multimedia progress indicator
Summary: Added text in multimedia progress indicator to show processingStep.
Test Plan: Tested with the usual video message scenarios (iOS/android, aspect ratios, multi-upload)
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/chat/inline-multimedia.react.js",
"new_path": "native/chat/inline-multimedia.react.js",
"diff": "// @flow\nimport * as React from 'react';\n-import { View, StyleSheet } from 'react-native';\n+import { View, StyleSheet, Text } from 'react-native';\nimport * as Progress from 'react-native-progress';\nimport Icon from 'react-native-vector-icons/Feather';\n+import tinycolor from 'tinycolor2';\nimport type { MediaInfo } from 'lib/types/media-types';\n@@ -12,9 +13,6 @@ import type { PendingMultimediaUpload } from '../input/input-state';\nimport { KeyboardContext } from '../keyboard/keyboard-state';\nimport Multimedia from '../media/multimedia.react';\n-const formatProgressText = (progress: number) =>\n- `${Math.floor(progress * 100)}%`;\n-\ntype Props = {|\n+mediaInfo: MediaInfo,\n+onPress: () => void,\n@@ -28,8 +26,9 @@ function InlineMultimedia(props: Props) {\nlet failed = mediaInfo.id.startsWith('localUpload') && !postInProgress;\nlet progressPercent = 1;\n+ let processingStep;\nif (pendingUpload) {\n- ({ progressPercent, failed } = pendingUpload);\n+ ({ progressPercent, failed, processingStep } = pendingUpload);\n}\nlet progressIndicator;\n@@ -40,21 +39,44 @@ function InlineMultimedia(props: Props) {\n</View>\n);\n} else if (progressPercent !== 1) {\n+ const progressOverlay = (\n+ <View style={styles.progressOverlay}>\n+ <Text style={styles.progressPercentText}>\n+ {`${Math.floor(progressPercent * 100).toString()}%`}\n+ </Text>\n+ <Text style={styles.processingStepText}>\n+ {processingStep ? processingStep : 'pending'}\n+ </Text>\n+ </View>\n+ );\n+\n+ const primaryColor = tinycolor(props.spinnerColor);\n+ const secondaryColor = primaryColor.isDark()\n+ ? primaryColor.lighten(20).toString()\n+ : primaryColor.darken(20).toString();\n+\n+ const progressSpinnerProps = {\n+ size: 120,\n+ indeterminate: progressPercent === 0,\n+ progress: progressPercent,\n+ fill: secondaryColor,\n+ unfilledColor: secondaryColor,\n+ color: props.spinnerColor,\n+ thickness: 10,\n+ borderWidth: 0,\n+ };\n+\n+ let progressSpinner;\n+ if (processingStep === 'transcoding') {\n+ progressSpinner = <Progress.Circle {...progressSpinnerProps} />;\n+ } else {\n+ progressSpinner = <Progress.Pie {...progressSpinnerProps} />;\n+ }\n+\nprogressIndicator = (\n<View style={styles.centerContainer}>\n- <Progress.Circle\n- size={100}\n- indeterminate={progressPercent === 0}\n- progress={progressPercent}\n- borderWidth={5}\n- fill=\"#DDDDDD\"\n- unfilledColor=\"#DDDDDD\"\n- color=\"#88BB88\"\n- thickness={15}\n- showsText={true}\n- textStyle={styles.progressIndicatorText}\n- formatText={formatProgressText}\n- />\n+ {progressSpinner}\n+ {progressOverlay}\n</View>\n);\n}\n@@ -88,9 +110,23 @@ const styles = StyleSheet.create({\nexpand: {\nflex: 1,\n},\n- progressIndicatorText: {\n- color: 'black',\n- fontSize: 21,\n+ processingStepText: {\n+ color: 'white',\n+ fontSize: 12,\n+ textShadowColor: '#000',\n+ textShadowRadius: 1,\n+ },\n+ progressOverlay: {\n+ alignItems: 'center',\n+ justifyContent: 'center',\n+ position: 'absolute',\n+ },\n+ progressPercentText: {\n+ color: 'white',\n+ fontSize: 24,\n+ fontWeight: 'bold',\n+ textShadowColor: '#000',\n+ textShadowRadius: 1,\n},\nuploadError: {\ncolor: 'white',\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message-multimedia.react.js",
"new_path": "native/chat/multimedia-message-multimedia.react.js",
"diff": "@@ -158,7 +158,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nonLongPress={this.onLongPress}\npostInProgress={postInProgress}\npendingUpload={pendingUpload}\n- spinnerColor={this.props.colors.listSeparatorLabel}\n+ spinnerColor={this.props.item.threadInfo.color}\n/>\n</View>\n</Animated.View>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/input/input-state-container.react.js",
"new_path": "native/input/input-state-container.react.js",
"diff": "@@ -540,7 +540,7 @@ class InputStateContainer extends React.PureComponent<Props, State> {\n{ ...processedMedia.dimensions, loop: processedMedia.loop },\n{\nonProgress: (percent: number) =>\n- this.setProgress(localMessageID, localID, 'upload', percent),\n+ this.setProgress(localMessageID, localID, 'uploading', percent),\nuploadBlob: this.uploadBlob,\n},\n);\n@@ -636,7 +636,7 @@ class InputStateContainer extends React.PureComponent<Props, State> {\nmediaProcessConfig(localMessageID: string, localID: string) {\nconst { hasWiFi, viewerID } = this.props;\nconst onTranscodingProgress = (percent: number) => {\n- this.setProgress(localMessageID, localID, 'transcode', percent);\n+ this.setProgress(localMessageID, localID, 'transcoding', percent);\n};\nif (__DEV__ || (viewerID && isStaff(viewerID))) {\nreturn {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/input/input-state.js",
"new_path": "native/input/input-state.js",
"diff": "@@ -6,7 +6,7 @@ import * as React from 'react';\nimport type { NativeMediaSelection } from 'lib/types/media-types';\nimport type { RawTextMessageInfo } from 'lib/types/messages/text';\n-export type MultimediaProcessingStep = 'transcode' | 'upload';\n+export type MultimediaProcessingStep = 'transcoding' | 'uploading';\nexport type PendingMultimediaUpload = {|\n+failed: ?string,\n@@ -17,7 +17,7 @@ export type PendingMultimediaUpload = {|\nconst pendingMultimediaUploadPropType = PropTypes.shape({\nfailed: PropTypes.string,\nprogressPercent: PropTypes.number.isRequired,\n- processingStep: PropTypes.oneOf(['transcode', 'upload']),\n+ processingStep: PropTypes.oneOf(['transcoding', 'uploading']),\n});\nexport type MessagePendingUploads = {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Show processingStep in multimedia progress indicator
Summary: Added text in multimedia progress indicator to show processingStep.
Test Plan: Tested with the usual video message scenarios (iOS/android, aspect ratios, multi-upload)
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D690 |
129,191 | 04.02.2021 17:26:55 | -3,600 | a1ec80be6ceb4c366a8ee2178bf7954d2533c72b | [native] Display the senders
Test Plan: Open a parent thread and check if senders were displayed correctly
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/text-utils.js",
"new_path": "lib/utils/text-utils.js",
"diff": "@@ -31,4 +31,17 @@ function trimText(text: string, maxLength: number): string {\nreturn text.substr(0, maxLength - 3) + '...';\n}\n-export { pluralize, trimText };\n+function pluralizeAndTrim(\n+ nouns: $ReadOnlyArray<string>,\n+ maxLength: number,\n+): string {\n+ for (let maxNumberOfNouns = 3; maxNumberOfNouns >= 2; --maxNumberOfNouns) {\n+ const text = pluralize(nouns, maxNumberOfNouns);\n+ if (text.length <= maxLength) {\n+ return text;\n+ }\n+ }\n+ return pluralize(nouns, 1);\n+}\n+\n+export { pluralize, trimText, pluralizeAndTrim };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/inline-sidebar.react.js",
"new_path": "native/chat/inline-sidebar.react.js",
"diff": "@@ -5,10 +5,14 @@ import * as React from 'react';\nimport { Text, View } from 'react-native';\nimport Icon from 'react-native-vector-icons/Feather';\n+import { relativeMemberInfoSelectorForMembersOfThread } from 'lib/selectors/user-selectors';\n+import { stringForUser } from 'lib/shared/user-utils';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n+import { pluralizeAndTrim } from 'lib/utils/text-utils';\nimport Button from '../components/button.react';\nimport { MessageListRouteName } from '../navigation/route-names';\n+import { useSelector } from '../redux/redux-utils';\nimport { useStyles } from '../themes/colors';\nimport type { ChatNavigationProp } from './chat.react';\n@@ -50,11 +54,25 @@ function InlineSidebar(props: Props) {\nconst repliesText = `${repliesCount} ${\nrepliesCount > 1 ? 'replies' : 'reply'\n}`;\n+\n+ const threadMembers = useSelector(\n+ relativeMemberInfoSelectorForMembersOfThread(threadInfo.id),\n+ );\n+ const sendersText = React.useMemo(() => {\n+ const senders = threadMembers\n+ .filter((member) => member.isSender)\n+ .map(stringForUser);\n+ return senders.length > 0 ? `${pluralizeAndTrim(senders, 25)} sent ` : '';\n+ }, [threadMembers]);\n+\nreturn (\n<View style={[styles.content, alignStyle]}>\n<Button style={styles.sidebar} onPress={onPress}>\n{nonViewerIcon}\n- <Text style={[styles.name, unreadStyle]}>{repliesText}</Text>\n+ <Text style={[styles.name, unreadStyle]}>\n+ {sendersText}\n+ {repliesText}\n+ </Text>\n{viewerIcon}\n</Button>\n</View>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Display the senders
Test Plan: Open a parent thread and check if senders were displayed correctly
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D698 |
129,187 | 06.02.2021 13:00:35 | 18,000 | 5e48d9ce43115c2753523bde205234496b1127f3 | Increase heap_size in .flowconfig to max for M1
Summary: Based on [this comment](https://github.com/facebook/flow/issues/8538#issuecomment-774419666), but would be great if could test it out locally.
Test Plan: tests it :)
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/.flowconfig",
"new_path": "lib/.flowconfig",
"diff": "[libs]\n[options]\n-sharedmemory.heap_size=3221225472\n+sharedmemory.heap_size=4221225472\n+\nesproposal.optional_chaining=enable\nesproposal.nullish_coalescing=enable\n"
},
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": "../node_modules/react-native/flow/\n[options]\n-sharedmemory.heap_size=3221225472\n+sharedmemory.heap_size=4221225472\n+\nemoji=true\nesproposal.optional_chaining=enable\n"
},
{
"change_type": "MODIFY",
"old_path": "server/.flowconfig",
"new_path": "server/.flowconfig",
"diff": "../lib/flow-typed\n[options]\n-sharedmemory.heap_size=3221225472\n+sharedmemory.heap_size=4221225472\n+\nmodule.file_ext=.js\nmodule.file_ext=.cjs\nmodule.file_ext=.json\n"
},
{
"change_type": "MODIFY",
"old_path": "web/.flowconfig",
"new_path": "web/.flowconfig",
"diff": "../lib/flow-typed\n[options]\n-sharedmemory.heap_size=3221225472\n+sharedmemory.heap_size=4221225472\n+\nmodule.name_mapper.extension='css' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'\nesproposal.optional_chaining=enable\nesproposal.nullish_coalescing=enable\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Increase heap_size in .flowconfig to max for M1
Summary: Based on [this comment](https://github.com/facebook/flow/issues/8538#issuecomment-774419666), but would be great if @atul could test it out locally.
Test Plan: @atul tests it :)
Reviewers: atul, palys-swm
Reviewed By: atul
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga, atul
Differential Revision: https://phabricator.ashoat.com/D703 |
129,191 | 04.02.2021 16:26:41 | -3,600 | f5a60bccdc3b4fd060bf8efcaa062219f3847167 | [server] Add migration script which computes sender status
Test Plan: Run the script and check in db if the status was set correctly
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/determine-sender-status.js",
"diff": "+// @flow\n+\n+import { messageSpecs } from 'lib/shared/messages/message-specs';\n+import { messageTypes } from 'lib/types/message-types';\n+import { updateTypes } from 'lib/types/update-types';\n+\n+import { createUpdates } from '../creators/update-creator';\n+import { dbQuery, mergeOrConditions, SQL } from '../database/database';\n+import { main } from './utils';\n+\n+async function determineSenderStatus() {\n+ const includedMessageTypes = Object.keys(messageTypes)\n+ .map((key) => messageTypes[key])\n+ .filter((type) => messageSpecs[type].includedInRepliesCount);\n+\n+ const sendersQuery = SQL`\n+ SELECT DISTINCT m.thread AS threadID, m.user AS userID\n+ FROM messages m\n+ WHERE m.type IN (${includedMessageTypes})\n+ `;\n+ const [senders] = await dbQuery(sendersQuery);\n+\n+ const conditions = senders.map(\n+ ({ threadID, userID }) => SQL`thread = ${threadID} AND user = ${userID}`,\n+ );\n+ const setSenders = SQL`\n+ UPDATE memberships m\n+ SET m.sender = 1\n+ WHERE\n+ `;\n+ setSenders.append(mergeOrConditions(conditions));\n+\n+ const updatedThreads = new Set(senders.map(({ threadID }) => threadID));\n+ const affectedMembersQuery = SQL`\n+ SELECT thread AS threadID, user AS userID\n+ FROM memberships\n+ WHERE thread IN (${[...updatedThreads]})\n+ AND role >= 0\n+ `;\n+\n+ const [[affectedMembers]] = await Promise.all([\n+ dbQuery(affectedMembersQuery),\n+ dbQuery(setSenders),\n+ ]);\n+\n+ const time = Date.now();\n+ const updates = affectedMembers.map(({ threadID, userID }) => ({\n+ userID,\n+ time,\n+ threadID,\n+ type: updateTypes.UPDATE_THREAD,\n+ }));\n+ await createUpdates(updates);\n+}\n+\n+main([determineSenderStatus]);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Add migration script which computes sender status
Test Plan: Run the script and check in db if the status was set correctly
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D696 |
129,191 | 08.02.2021 12:04:46 | -3,600 | 29f8791294c06f1f87f7649b3c9a76d061dfc839 | [server] Create setup sidebars script
Test Plan: Run the script when the columns were present and check the result. Drop columns, run and check again.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "DELETE",
"old_path": "server/src/scripts/add-replies-count-column.js",
"new_path": null,
"diff": "-// @flow\n-\n-import { dbQuery, SQL } from '../database/database';\n-import { main } from './utils';\n-\n-async function addColumn() {\n- const update = SQL`\n- ALTER TABLE threads\n- ADD replies_count INT UNSIGNED NOT NULL DEFAULT 0\n- `;\n- await dbQuery(update);\n-}\n-\n-main([addColumn]);\n"
},
{
"change_type": "DELETE",
"old_path": "server/src/scripts/add-sender-column.js",
"new_path": null,
"diff": "-// @flow\n-\n-import { dbQuery, SQL } from '../database/database';\n-import { main } from './utils';\n-\n-async function addColumn() {\n- const update = SQL`\n- ALTER TABLE memberships\n- ADD sender TINYINT(1) UNSIGNED NOT NULL DEFAULT 0\n- `;\n- await dbQuery(update);\n-}\n-\n-main([addColumn]);\n"
},
{
"change_type": "DELETE",
"old_path": "server/src/scripts/compute-replies-count.js",
"new_path": null,
"diff": "-// @flow\n-\n-import { messageSpecs } from 'lib/shared/messages/message-specs';\n-import { messageTypes } from 'lib/types/message-types';\n-import { threadTypes } from 'lib/types/thread-types';\n-import { updateTypes } from 'lib/types/update-types';\n-\n-import { createUpdates } from '../creators/update-creator';\n-import { dbQuery, SQL } from '../database/database';\n-import { main } from './utils';\n-\n-async function computeRepliesCount() {\n- const includedMessageTypes = Object.keys(messageTypes)\n- .map((key) => messageTypes[key])\n- .filter((type) => messageSpecs[type].includedInRepliesCount);\n-\n- const sidebarMembersQuery = SQL`\n- SELECT t.id AS threadID, m.user AS userID\n- FROM threads t\n- INNER JOIN memberships m ON t.id = m.thread\n- WHERE t.type = ${threadTypes.SIDEBAR}\n- AND m.role >= 0\n- `;\n- const readCountUpdate = SQL`\n- UPDATE threads t\n- INNER JOIN (\n- SELECT thread AS threadID, COUNT(*) AS count\n- FROM messages\n- WHERE type IN (${includedMessageTypes})\n- GROUP BY thread\n- ) c ON c.threadID = t.id\n- SET t.replies_count = c.count\n- WHERE t.type = ${threadTypes.SIDEBAR}\n- `;\n- const [[sidebarMembers]] = await Promise.all([\n- dbQuery(sidebarMembersQuery),\n- dbQuery(readCountUpdate),\n- ]);\n-\n- const time = Date.now();\n- const updates = sidebarMembers.map(({ threadID, userID }) => ({\n- userID,\n- time,\n- threadID,\n- type: updateTypes.UPDATE_THREAD,\n- }));\n- await createUpdates(updates);\n-}\n-\n-main([computeRepliesCount]);\n"
},
{
"change_type": "DELETE",
"old_path": "server/src/scripts/determine-sender-status.js",
"new_path": null,
"diff": "-// @flow\n-\n-import { messageSpecs } from 'lib/shared/messages/message-specs';\n-import { messageTypes } from 'lib/types/message-types';\n-import { updateTypes } from 'lib/types/update-types';\n-\n-import { createUpdates } from '../creators/update-creator';\n-import { dbQuery, mergeOrConditions, SQL } from '../database/database';\n-import { main } from './utils';\n-\n-async function determineSenderStatus() {\n- const includedMessageTypes = Object.keys(messageTypes)\n- .map((key) => messageTypes[key])\n- .filter((type) => messageSpecs[type].includedInRepliesCount);\n-\n- const sendersQuery = SQL`\n- SELECT DISTINCT m.thread AS threadID, m.user AS userID\n- FROM messages m\n- WHERE m.type IN (${includedMessageTypes})\n- `;\n- const [senders] = await dbQuery(sendersQuery);\n-\n- const conditions = senders.map(\n- ({ threadID, userID }) => SQL`thread = ${threadID} AND user = ${userID}`,\n- );\n- const setSenders = SQL`\n- UPDATE memberships m\n- SET m.sender = 1\n- WHERE\n- `;\n- setSenders.append(mergeOrConditions(conditions));\n-\n- const updatedThreads = new Set(senders.map(({ threadID }) => threadID));\n- const affectedMembersQuery = SQL`\n- SELECT thread AS threadID, user AS userID\n- FROM memberships\n- WHERE thread IN (${[...updatedThreads]})\n- AND role >= 0\n- `;\n-\n- const [[affectedMembers]] = await Promise.all([\n- dbQuery(affectedMembersQuery),\n- dbQuery(setSenders),\n- ]);\n-\n- const time = Date.now();\n- const updates = affectedMembers.map(({ threadID, userID }) => ({\n- userID,\n- time,\n- threadID,\n- type: updateTypes.UPDATE_THREAD,\n- }));\n- await createUpdates(updates);\n-}\n-\n-main([determineSenderStatus]);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/setup-sidebars.js",
"diff": "+// @flow\n+\n+import { messageSpecs } from 'lib/shared/messages/message-specs';\n+import { messageTypes } from 'lib/types/message-types';\n+import { threadTypes } from 'lib/types/thread-types';\n+import { updateTypes } from 'lib/types/update-types';\n+\n+import { createUpdates } from '../creators/update-creator';\n+import { dbQuery, mergeOrConditions, SQL } from '../database/database';\n+import { main } from './utils';\n+\n+async function addRepliesCountColumn() {\n+ const update = SQL`\n+ ALTER TABLE threads\n+ ADD replies_count INT UNSIGNED NOT NULL DEFAULT 0\n+ `;\n+\n+ try {\n+ await dbQuery(update);\n+ } catch (e) {\n+ console.log(e, 'replies-count column already exists');\n+ }\n+}\n+\n+async function addSenderColumn() {\n+ const update = SQL`\n+ ALTER TABLE memberships\n+ ADD sender TINYINT(1) UNSIGNED NOT NULL DEFAULT 0\n+ `;\n+\n+ try {\n+ await dbQuery(update);\n+ } catch (e) {\n+ console.log(e, 'sender column already exists');\n+ }\n+}\n+\n+async function computeRepliesCount() {\n+ const includedMessageTypes = Object.keys(messageTypes)\n+ .map((key) => messageTypes[key])\n+ .filter((type) => messageSpecs[type].includedInRepliesCount);\n+\n+ const sidebarMembersQuery = SQL`\n+ SELECT t.id AS threadID, m.user AS userID\n+ FROM threads t\n+ INNER JOIN memberships m ON t.id = m.thread\n+ WHERE t.type = ${threadTypes.SIDEBAR}\n+ AND m.role >= 0\n+ `;\n+ const readCountUpdate = SQL`\n+ UPDATE threads t\n+ INNER JOIN (\n+ SELECT thread AS threadID, COUNT(*) AS count\n+ FROM messages\n+ WHERE type IN (${includedMessageTypes})\n+ GROUP BY thread\n+ ) c ON c.threadID = t.id\n+ SET t.replies_count = c.count\n+ WHERE t.type = ${threadTypes.SIDEBAR}\n+ `;\n+ const [[sidebarMembers]] = await Promise.all([\n+ dbQuery(sidebarMembersQuery),\n+ dbQuery(readCountUpdate),\n+ ]);\n+\n+ const time = Date.now();\n+ const updates = sidebarMembers.map(({ threadID, userID }) => ({\n+ userID,\n+ time,\n+ threadID,\n+ type: updateTypes.UPDATE_THREAD,\n+ }));\n+ await createUpdates(updates);\n+}\n+\n+export async function determineSenderStatus() {\n+ const includedMessageTypes = Object.keys(messageTypes)\n+ .map((key) => messageTypes[key])\n+ .filter((type) => messageSpecs[type].includedInRepliesCount);\n+\n+ const sendersQuery = SQL`\n+ SELECT DISTINCT m.thread AS threadID, m.user AS userID\n+ FROM messages m\n+ WHERE m.type IN (${includedMessageTypes})\n+ `;\n+ const [senders] = await dbQuery(sendersQuery);\n+\n+ const conditions = senders.map(\n+ ({ threadID, userID }) => SQL`thread = ${threadID} AND user = ${userID}`,\n+ );\n+ const setSenders = SQL`\n+ UPDATE memberships m\n+ SET m.sender = 1\n+ WHERE\n+ `;\n+ setSenders.append(mergeOrConditions(conditions));\n+\n+ const updatedThreads = new Set(senders.map(({ threadID }) => threadID));\n+ const affectedMembersQuery = SQL`\n+ SELECT thread AS threadID, user AS userID\n+ FROM memberships\n+ WHERE thread IN (${[...updatedThreads]})\n+ AND role >= 0\n+ `;\n+\n+ const [[affectedMembers]] = await Promise.all([\n+ dbQuery(affectedMembersQuery),\n+ dbQuery(setSenders),\n+ ]);\n+\n+ const time = Date.now();\n+ const updates = affectedMembers.map(({ threadID, userID }) => ({\n+ userID,\n+ time,\n+ threadID,\n+ type: updateTypes.UPDATE_THREAD,\n+ }));\n+ await createUpdates(updates);\n+}\n+\n+main([\n+ addRepliesCountColumn,\n+ addSenderColumn,\n+ computeRepliesCount,\n+ determineSenderStatus,\n+]);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Create setup sidebars script
Test Plan: Run the script when the columns were present and check the result. Drop columns, run and check again.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D704 |
129,184 | 08.02.2021 05:59:09 | 28,800 | 058708f3fbbf910ef32d1f9bcb01bec1bd3064d8 | Minor color change for consistency in thread settings
Summary: Changed `addIcon` color in thread settings to be consistent with text (green -> blue)
Test Plan: NA
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-list-action.react.js",
"new_path": "native/chat/settings/thread-settings-list-action.react.js",
"diff": "@@ -100,7 +100,7 @@ const unboundStyles = {\npaddingTop: Platform.OS === 'ios' ? 4 : 1,\n},\naddIcon: {\n- color: '#009900',\n+ color: 'link',\n},\naddItemRow: {\nbackgroundColor: 'panelForeground',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Minor color change for consistency in thread settings
Summary: Changed `addIcon` color in thread settings to be consistent with text (green -> blue)
Test Plan: NA
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D705 |
129,208 | 08.02.2021 12:50:31 | 18,000 | e0e6fddccdccf242892744d6b20dd6a63307a8a0 | [server] Added -1 type support to changeRole and changeRoleThreadQuery
Summary: Added -1 type support to changeRole and changeRoleThreadQuery.
Test Plan: Ran flow and made sure accounts could still be created and threads still work.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -61,6 +61,7 @@ type MembershipRowToDelete = {|\noperation: 'delete',\nuserID: string,\nthreadID: string,\n+ forceRowCreation?: boolean,\n|};\ntype MembershipRow = MembershipRowToSave | MembershipRowToDelete;\ntype Changeset = {|\n@@ -74,7 +75,7 @@ type Changeset = {|\nasync function changeRole(\nthreadID: string,\nuserIDs: $ReadOnlyArray<string>,\n- role: string | 0 | null,\n+ role: string | -1 | 0 | null,\n): Promise<?Changeset> {\nconst membershipQuery = SQL`\nSELECT m.user, m.role, m.permissions_for_children,\n@@ -139,9 +140,15 @@ async function changeRole(\nconst permissionsForChildren = makePermissionsForChildrenBlob(permissions);\nif (permissions) {\n+ if (role === -1) {\n+ console.warn(\n+ `changeRole called for -1 role,\n+ but found non-null permissions for userID ${userID} and threadID ${threadID}`,\n+ );\n+ }\nmembershipRows.push({\noperation:\n- roleThreadResult.roleColumnValue !== '0' &&\n+ Number(roleThreadResult.roleColumnValue) > 0 &&\n(!userRoleInfo || Number(userRoleInfo.oldRole) <= 0)\n? 'join'\n: 'update',\n@@ -149,13 +156,17 @@ async function changeRole(\nthreadID,\npermissions,\npermissionsForChildren,\n- role: roleThreadResult.roleColumnValue,\n+ role:\n+ Number(roleThreadResult.roleColumnValue) >= 0\n+ ? roleThreadResult.roleColumnValue\n+ : '0',\n});\n} else {\nmembershipRows.push({\noperation: 'delete',\nuserID,\nthreadID,\n+ forceRowCreation: role === -1,\n});\n}\n@@ -197,7 +208,7 @@ type RoleThreadResult = {|\n|};\nasync function changeRoleThreadQuery(\nthreadID: string,\n- role: string | 0 | null,\n+ role: string | -1 | 0 | null,\n): Promise<?RoleThreadResult> {\nif (role === 0) {\nconst query = SQL`SELECT type FROM threads WHERE id = ${threadID}`;\n@@ -211,6 +222,18 @@ async function changeRoleThreadQuery(\nthreadType: assertThreadType(row.type),\nrolePermissions: null,\n};\n+ } else if (role === -1) {\n+ const query = SQL`SELECT type FROM threads WHERE id = ${threadID}`;\n+ const [result] = await dbQuery(query);\n+ if (result.length === 0) {\n+ return null;\n+ }\n+ const row = result[0];\n+ return {\n+ roleColumnValue: '-1',\n+ threadType: assertThreadType(row.type),\n+ rolePermissions: null,\n+ };\n} else if (role !== null) {\nconst query = SQL`\nSELECT t.type, r.permissions\n@@ -541,10 +564,48 @@ async function deleteMemberships(\nif (toDelete.length === 0) {\nreturn;\n}\n- const deleteRows = toDelete.map(\n- (rowToDelete) =>\n+\n+ const time = Date.now();\n+ const insertRows = [];\n+ const deleteRows = [];\n+ for (const rowToDelete of toDelete) {\n+ if (rowToDelete.forceRowCreation) {\n+ insertRows.push([\n+ rowToDelete.userID,\n+ rowToDelete.threadID,\n+ -1,\n+ time,\n+ defaultSubscriptionString,\n+ null,\n+ null,\n+ 0,\n+ 0,\n+ ]);\n+ } else {\n+ deleteRows.push(\nSQL`(user = ${rowToDelete.userID} AND thread = ${rowToDelete.threadID})`,\n);\n+ }\n+ }\n+\n+ const queries = [];\n+ if (insertRows.length > 0) {\n+ const query = SQL`\n+ INSERT INTO memberships (user, thread, role, creation_time, subscription,\n+ permissions, permissions_for_children, last_message, last_read_message)\n+ VALUES ${insertRows}\n+ ON DUPLICATE KEY UPDATE\n+ role = -1,\n+ permissions = NULL,\n+ permissions_for_children = NULL,\n+ subscription = ${defaultSubscriptionString},\n+ last_message = 0,\n+ last_read_message = 0\n+ `;\n+ queries.push(dbQuery(query));\n+ }\n+\n+ if (deleteRows.length > 0) {\nconst conditions = mergeOrConditions(deleteRows);\nconst query = SQL`\nUPDATE memberships\n@@ -553,7 +614,10 @@ async function deleteMemberships(\nlast_read_message = 0\nWHERE `;\nquery.append(conditions);\n- await dbQuery(query);\n+ queries.push(dbQuery(query));\n+ }\n+\n+ await Promise.all(queries);\n}\n// Specify non-empty changedThreadIDs to force updates to be generated for those\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Added -1 type support to changeRole and changeRoleThreadQuery
Summary: Added -1 type support to changeRole and changeRoleThreadQuery.
Test Plan: Ran flow and made sure accounts could still be created and threads still work.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D656 |
129,208 | 08.02.2021 13:17:08 | 18,000 | 787d7c31eb98a1ba0c942bf92440642a26279748 | [server] Added ghostMemberIDs type to BaseNewThreadRequest
Summary: Added ghostMemberIDs
Test Plan: Tested with flow, also made sure createThread still works.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -338,6 +338,7 @@ export type BaseNewThreadRequest = {|\n+color?: ?string,\n+parentThreadID?: ?string,\n+initialMemberIDs?: ?$ReadOnlyArray<string>,\n+ +ghostMemberIDs?: ?$ReadOnlyArray<string>,\n|};\nexport type NewThreadRequest =\n| {|\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/thread-creator.js",
"new_path": "server/src/creators/thread-creator.js",
"diff": "@@ -71,6 +71,10 @@ async function createThread(\nrequest.initialMemberIDs && request.initialMemberIDs.length > 0\n? request.initialMemberIDs\n: null;\n+ const ghostMemberIDs =\n+ request.ghostMemberIDs && request.ghostMemberIDs.length > 0\n+ ? request.ghostMemberIDs\n+ : null;\nif (\nthreadType !== threadTypes.CHAT_SECRET &&\n@@ -102,16 +106,23 @@ async function createThread(\n: threadPermissions.CREATE_SUBTHREADS,\n);\n}\n+\n+ const memberIDs = [];\nif (initialMemberIDs) {\n- checkPromises.fetchInitialMembers = fetchKnownUserInfos(\n- viewer,\n- initialMemberIDs,\n- );\n+ memberIDs.push(...initialMemberIDs);\n+ }\n+ if (ghostMemberIDs) {\n+ memberIDs.push(...ghostMemberIDs);\n}\n+\n+ if (initialMemberIDs || ghostMemberIDs) {\n+ checkPromises.fetchMemberIDs = fetchKnownUserInfos(viewer, memberIDs);\n+ }\n+\nconst {\nparentThreadFetch,\nhasParentPermission,\n- fetchInitialMembers,\n+ fetchMemberIDs,\n} = await promiseAll(checkPromises);\nlet parentThreadMembers;\n@@ -127,22 +138,22 @@ async function createThread(\n}\nconst viewerNeedsRelationshipsWith = [];\n- if (fetchInitialMembers) {\n- invariant(initialMemberIDs, 'should be set');\n- for (const initialMemberID of initialMemberIDs) {\n- const initialMember = fetchInitialMembers[initialMemberID];\n+ if (fetchMemberIDs) {\n+ invariant(initialMemberIDs || ghostMemberIDs, 'should be set');\n+ for (const memberID of memberIDs) {\n+ const member = fetchMemberIDs[memberID];\nif (\n- !initialMember &&\n+ !member &&\nshouldCreateRelationships &&\n(threadType !== threadTypes.SIDEBAR ||\n- parentThreadMembers?.includes(initialMemberID))\n+ parentThreadMembers?.includes(memberID))\n) {\n- viewerNeedsRelationshipsWith.push(initialMemberID);\n+ viewerNeedsRelationshipsWith.push(memberID);\ncontinue;\n- } else if (!initialMember) {\n+ } else if (!member) {\nthrow new ServerError('invalid_credentials');\n}\n- const { relationshipStatus } = initialMember;\n+ const { relationshipStatus } = member;\nif (\nrelationshipStatus === userRelationshipStatus.FRIEND &&\nthreadType !== threadTypes.SIDEBAR\n@@ -155,7 +166,7 @@ async function createThread(\nthrow new ServerError('invalid_credentials');\n} else if (\nparentThreadMembers &&\n- parentThreadMembers.includes(initialMemberID)\n+ parentThreadMembers.includes(memberID)\n) {\ncontinue;\n} else if (!shouldCreateRelationships) {\n@@ -275,10 +286,12 @@ async function createThread(\nconst [\ncreatorChangeset,\ninitialMembersChangeset,\n+ ghostMembersChangeset,\nrecalculatePermissionsChangeset,\n] = await Promise.all([\nchangeRole(id, [viewer.userID], newRoles.creator.id),\ninitialMemberIDs ? changeRole(id, initialMemberIDs, null) : undefined,\n+ ghostMemberIDs ? changeRole(id, ghostMemberIDs, -1) : undefined,\nrecalculateAllPermissions(id, threadType),\n]);\n@@ -290,9 +303,6 @@ async function createThread(\nrelationshipRows: creatorRelationshipRows,\n} = creatorChangeset;\n- const initialMemberAndCreatorIDs = initialMemberIDs\n- ? [...initialMemberIDs, viewer.userID]\n- : [viewer.userID];\nconst {\nmembershipRows: recalculateMembershipRows,\nrelationshipRows: recalculateRelationshipRows,\n@@ -306,8 +316,8 @@ async function createThread(\n...creatorRelationshipRows,\n...recalculateRelationshipRows,\n];\n- if (initialMemberIDs) {\n- if (!initialMembersChangeset) {\n+ if (initialMemberIDs || ghostMemberIDs) {\n+ if (!initialMembersChangeset && !ghostMembersChangeset) {\nthrow new ServerError('unknown_error');\n}\nrelationshipRows.push(\n@@ -316,21 +326,39 @@ async function createThread(\nviewerNeedsRelationshipsWith,\n),\n);\n+ const membersMembershipRows = [];\n+ const membersRelationshipRows = [];\n+ if (initialMembersChangeset) {\nconst {\nmembershipRows: initialMembersMembershipRows,\nrelationshipRows: initialMembersRelationshipRows,\n} = initialMembersChangeset;\n+ membersMembershipRows.push(...initialMembersMembershipRows);\n+ membersRelationshipRows.push(...initialMembersRelationshipRows);\n+ }\n+\n+ if (ghostMembersChangeset) {\n+ const {\n+ membershipRows: ghostMembersMembershipRows,\n+ relationshipRows: ghostMembersRelationshipRows,\n+ } = ghostMembersChangeset;\n+ membersMembershipRows.push(...ghostMembersMembershipRows);\n+ membersRelationshipRows.push(...ghostMembersRelationshipRows);\n+ }\n+\n+ const memberAndCreatorIDs = [...memberIDs, viewer.userID];\nconst parentRelationshipRows = getParentThreadRelationshipRowsForNewUsers(\nid,\nrecalculateMembershipRows,\n- initialMemberAndCreatorIDs,\n+ memberAndCreatorIDs,\n);\n- membershipRows.push(...initialMembersMembershipRows);\n+ membershipRows.push(...membersMembershipRows);\nrelationshipRows.push(\n- ...initialMembersRelationshipRows,\n+ ...membersRelationshipRows,\n...parentRelationshipRows,\n);\n}\n+\nsetJoinsToUnread(membershipRows, viewer.userID, id);\nconst changeset = { membershipRows, relationshipRows };\n@@ -342,6 +370,9 @@ async function createThread(\nupdatesForCurrentSession,\n});\n+ const initialMemberAndCreatorIDs = initialMemberIDs\n+ ? [...initialMemberIDs, viewer.userID]\n+ : [viewer.userID];\nconst messageDatas = [];\nif (threadType !== threadTypes.SIDEBAR) {\nmessageDatas.push({\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Added ghostMemberIDs type to BaseNewThreadRequest
Summary: Added ghostMemberIDs
Test Plan: Tested with flow, also made sure createThread still works.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D671 |
129,183 | 02.02.2021 08:39:41 | -3,600 | 358ba256e0d7f7d80b3faab32ba4f2c7888950cb | [web] Display sidebars inline
Test Plan: Check if sidebars are displayed inline correctly, if pressing navigates to correct sidebar and if styling matches native
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-message-list.css",
"new_path": "web/chat/chat-message-list.css",
"diff": "@@ -368,3 +368,38 @@ div.imageGrid > span.multimedia:nth-last-child(n+5):first-child,\ndiv.imageGrid > span.multimedia:nth-last-child(n+5):first-child ~ * {\ngrid-column-end: span 2;\n}\n+\n+div.inlineSidebarContent {\n+ flex-direction: row;\n+ display: flex;\n+ margin: 0 40px 0 20px;\n+ cursor: pointer;\n+}\n+div.inlineSidebar {\n+ flex-direction: row;\n+ display: flex;\n+ align-items: center;\n+}\n+div.inlineSidebarName {\n+ padding-Top: 1px;\n+ color: #666666;\n+ font-size: 16px;\n+ padding-left: 4px;\n+ padding-right: 2px;\n+}\n+div.unread {\n+ font-weight: bold;\n+}\n+div.centerContainer {\n+ justify-content: center;\n+}\n+div.sidebarMarginBottom {\n+ margin-bottom: 8px;\n+}\n+div.sidebarMarginTop {\n+ margin-top: 5px;\n+ margin-bottom: -8px;\n+}\n+svg.inlineSidebarIcon {\n+ color: #666666;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/composed-message.react.js",
"new_path": "web/chat/composed-message.react.js",
"diff": "@@ -4,7 +4,7 @@ import classNames from 'classnames';\nimport invariant from 'invariant';\nimport * as React from 'react';\nimport {\n- Circle as CircleIcon,\n+ CornerDownRight as CircleIcon,\nCheckCircle as CheckCircleIcon,\nXCircle as XCircleIcon,\n} from 'react-feather';\n@@ -17,6 +17,7 @@ import { type ThreadInfo } from 'lib/types/thread-types';\nimport { type InputState, InputStateContext } from '../input/input-state';\nimport css from './chat-message-list.css';\nimport FailedSend from './failed-send.react';\n+import { InlineSidebar } from './inline-sidebar.react';\nimport {\ntype OnMessagePositionInfo,\ntype MessagePositionInfo,\n@@ -129,6 +130,19 @@ class ComposedMessage extends React.PureComponent<Props> {\n}\n}\n+ let inlineSidebar = null;\n+ if (item.threadCreatedFromMessage) {\n+ const positioning = isViewer ? 'right' : 'left';\n+ inlineSidebar = (\n+ <div className={css.sidebarMarginBottom}>\n+ <InlineSidebar\n+ threadInfo={item.threadCreatedFromMessage}\n+ positioning={positioning}\n+ />\n+ </div>\n+ );\n+ }\n+\nreturn (\n<React.Fragment>\n{authorName}\n@@ -147,6 +161,7 @@ class ComposedMessage extends React.PureComponent<Props> {\n{deliveryIcon}\n</div>\n{failedSendInfo}\n+ {inlineSidebar}\n</React.Fragment>\n);\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "web/chat/inline-sidebar.react.js",
"diff": "+// @flow\n+\n+import classNames from 'classnames';\n+import * as React from 'react';\n+import {\n+ CornerDownRight as CornerDownRightIcon,\n+ CornerDownLeft as CornerDownLeftIcon,\n+} from 'react-feather';\n+\n+import { relativeMemberInfoSelectorForMembersOfThread } from 'lib/selectors/user-selectors';\n+import { stringForUser } from 'lib/shared/user-utils';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { pluralizeAndTrim } from 'lib/utils/text-utils';\n+\n+import { useSelector } from '../redux/redux-utils';\n+import { useOnClickThread } from '../selectors/nav-selectors';\n+import css from './chat-message-list.css';\n+\n+type Props = {|\n+ +threadInfo: ThreadInfo,\n+ +positioning: 'left' | 'center' | 'right',\n+|};\n+function InlineSidebar(props: Props) {\n+ const { threadInfo } = props;\n+\n+ const onClick = useOnClickThread(threadInfo.id);\n+\n+ let viewerIcon, nonViewerIcon, alignStyle;\n+ if (props.positioning === 'right') {\n+ viewerIcon = (\n+ <CornerDownLeftIcon className={css.inlineSidebarIcon} size={18} />\n+ );\n+ alignStyle = css.viewerMessageBoxContainer;\n+ } else if (props.positioning === 'left') {\n+ nonViewerIcon = (\n+ <CornerDownRightIcon className={css.inlineSidebarIcon} size={18} />\n+ );\n+ alignStyle = css.nonViewerMessageBoxContainer;\n+ } else {\n+ nonViewerIcon = (\n+ <CornerDownRightIcon className={css.inlineSidebarIcon} size={18} />\n+ );\n+ alignStyle = css.centerContainer;\n+ }\n+\n+ const unreadStyle = threadInfo.currentUser.unread ? css.unread : null;\n+ const repliesCount = threadInfo.repliesCount || 1;\n+ const repliesText = `${repliesCount} ${\n+ repliesCount > 1 ? 'replies' : 'reply'\n+ }`;\n+\n+ const threadMembers = useSelector(\n+ relativeMemberInfoSelectorForMembersOfThread(threadInfo.id),\n+ );\n+ const sendersText = React.useMemo(() => {\n+ const senders = threadMembers\n+ .filter((member) => member.isSender)\n+ .map(stringForUser);\n+ return senders.length > 0 ? `${pluralizeAndTrim(senders, 25)} sent ` : '';\n+ }, [threadMembers]);\n+\n+ return (\n+ <div className={classNames([css.inlineSidebarContent, alignStyle])}>\n+ <div onClick={onClick} className={css.inlineSidebar}>\n+ {nonViewerIcon}\n+ <div className={classNames([css.inlineSidebarName, unreadStyle])}>\n+ {sendersText}\n+ {repliesText}\n+ </div>\n+ {viewerIcon}\n+ </div>\n+ </div>\n+ );\n+}\n+\n+const inlineSidebarHeight = 20;\n+\n+export { InlineSidebar, inlineSidebarHeight };\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/robotext-message.react.js",
"new_path": "web/chat/robotext-message.react.js",
"diff": "@@ -14,6 +14,7 @@ import Markdown from '../markdown/markdown.react';\nimport { linkRules } from '../markdown/rules.react';\nimport { type AppState, updateNavInfoActionType } from '../redux/redux-setup';\nimport css from './chat-message-list.css';\n+import { InlineSidebar } from './inline-sidebar.react';\nimport type { MessagePositionInfo } from './message-position-types';\ntype Props = {|\n@@ -24,11 +25,23 @@ type Props = {|\n|};\nclass RobotextMessage extends React.PureComponent<Props> {\nrender() {\n+ let inlineSidebar;\n+ if (this.props.item.threadCreatedFromMessage) {\n+ inlineSidebar = (\n+ <div className={css.sidebarMarginTop}>\n+ <InlineSidebar\n+ threadInfo={this.props.item.threadCreatedFromMessage}\n+ positioning=\"center\"\n+ />\n+ </div>\n+ );\n+ }\nreturn (\n<div className={css.robotext}>\n<span onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>\n{this.linkedRobotext()}\n</span>\n+ {inlineSidebar}\n</div>\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Display sidebars inline
Test Plan: Check if sidebars are displayed inline correctly, if pressing navigates to correct sidebar and if styling matches native
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D681 |
129,191 | 09.02.2021 14:42:16 | -3,600 | 08a4d1ec04e8f53f56415b7a243cf096a93f8758 | [web] Add option to open empty pending thread
Summary: Introduce new nav params (pendingThread and sourceMessage)
Test Plan: Create a button which calls useOnCLickPendingSidebar, click it and verify that empty page is displayed (app should not crash)
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "web/app.react.js",
"new_path": "web/app.react.js",
"diff": "@@ -349,7 +349,7 @@ export default React.memo<BaseProps>(function ConnectedApp(props: BaseProps) {\nconst activeThreadCurrentlyUnread = useSelector(\n(state) =>\n!activeChatThreadID ||\n- !!state.threadStore.threadInfos[activeChatThreadID].currentUser.unread,\n+ !!state.threadStore.threadInfos[activeChatThreadID]?.currentUser.unread,\n);\nconst viewerID = useSelector(\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-message-list.react.js",
"new_path": "web/chat/chat-message-list.react.js",
"diff": "@@ -365,7 +365,7 @@ export default React.memo<BaseProps>(function ConnectedChatMessageList(\nif (!activeID) {\nreturn null;\n}\n- return threadInfoSelector(state)[activeID];\n+ return threadInfoSelector(state)[activeID] ?? state.navInfo.pendingThread;\n});\nconst startReached = useSelector((state) => {\nconst activeID = state.navInfo.activeChatThreadID;\n@@ -373,6 +373,10 @@ export default React.memo<BaseProps>(function ConnectedChatMessageList(\nreturn null;\n}\n+ if (state.navInfo.pendingThread) {\n+ return true;\n+ }\n+\nconst threadMessageInfo = state.messageStore.threads[activeID];\nif (!threadMessageInfo) {\nreturn null;\n"
},
{
"change_type": "MODIFY",
"old_path": "web/redux/redux-setup.js",
"new_path": "web/redux/redux-setup.js",
"diff": "@@ -19,7 +19,8 @@ import type { BaseNavInfo } from 'lib/types/nav-types';\nimport type { BaseAction } from 'lib/types/redux-types';\nimport type { ClientReportCreationRequest } from 'lib/types/report-types';\nimport type { ConnectionInfo } from 'lib/types/socket-types';\n-import type { ThreadStore } from 'lib/types/thread-types';\n+import type { ThreadInfo, ThreadStore } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\nimport type { CurrentUserInfo, UserStore } from 'lib/types/user-types';\nimport type { ServerVerificationResult } from 'lib/types/verify-types';\nimport { setNewSessionActionType } from 'lib/utils/action-utils';\n@@ -33,6 +34,8 @@ export type NavInfo = {|\n+tab: 'calendar' | 'chat',\n+verify: ?string,\n+activeChatThreadID: ?string,\n+ +pendingThread?: ThreadInfo,\n+ +sourceMessageID?: string,\n|};\nexport const navInfoPropType = PropTypes.shape({\n@@ -41,6 +44,8 @@ export const navInfoPropType = PropTypes.shape({\ntab: PropTypes.oneOf(['calendar', 'chat']).isRequired,\nverify: PropTypes.string,\nactiveChatThreadID: PropTypes.string,\n+ pendingThread: threadInfoPropType,\n+ sourceMessageID: PropTypes.string,\n});\nexport type WindowDimensions = {| width: number, height: number |};\n@@ -146,6 +151,7 @@ export function reducer(oldState: AppState | void, action: Action) {\nfunction validateState(oldState: AppState, state: AppState): AppState {\nif (\nstate.navInfo.activeChatThreadID &&\n+ !state.navInfo.pendingThread &&\n!state.threadStore.threadInfos[state.navInfo.activeChatThreadID]\n) {\n// Makes sure the active thread always exists\n@@ -166,6 +172,7 @@ function validateState(oldState: AppState, state: AppState): AppState {\ndocument &&\ndocument.hasFocus &&\ndocument.hasFocus() &&\n+ !state.navInfo.pendingThread &&\nstate.threadStore.threadInfos[activeThread].currentUser.unread\n) {\n// Makes sure a currently focused thread is never unread\n"
},
{
"change_type": "MODIFY",
"old_path": "web/selectors/nav-selectors.js",
"new_path": "web/selectors/nav-selectors.js",
"diff": "@@ -7,8 +7,14 @@ import { createSelector } from 'reselect';\nimport { nonThreadCalendarFiltersSelector } from 'lib/selectors/calendar-filter-selectors';\nimport { currentCalendarQuery } from 'lib/selectors/nav-selectors';\n+import { createPendingSidebar } from 'lib/shared/thread-utils';\nimport type { CalendarQuery } from 'lib/types/entry-types';\nimport type { CalendarFilter } from 'lib/types/filter-types';\n+import type {\n+ ComposableMessageInfo,\n+ RobotextMessageInfo,\n+} from 'lib/types/message-types';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport type { AppState } from '../redux/redux-setup';\nimport { updateNavInfoActionType } from '../redux/redux-setup';\n@@ -137,6 +143,36 @@ function useThreadIsActive(threadID: string) {\nreturn useSelector((state) => threadID === state.navInfo.activeChatThreadID);\n}\n+function useOnClickPendingSidebar(\n+ messageInfo: ComposableMessageInfo | RobotextMessageInfo,\n+ threadInfo: ThreadInfo,\n+) {\n+ const dispatch = useDispatch();\n+ const viewerID = useSelector((state) => state.currentUserInfo?.id);\n+ return React.useCallback(\n+ (event: SyntheticEvent<HTMLElement>) => {\n+ event.preventDefault();\n+ if (!viewerID) {\n+ return;\n+ }\n+ const pendingSidebarInfo = createPendingSidebar(\n+ messageInfo,\n+ threadInfo,\n+ viewerID,\n+ );\n+ dispatch({\n+ type: updateNavInfoActionType,\n+ payload: {\n+ activeChatThreadID: pendingSidebarInfo.id,\n+ pendingThread: pendingSidebarInfo,\n+ sourceMessageID: messageInfo.id,\n+ },\n+ });\n+ },\n+ [viewerID, messageInfo, threadInfo, dispatch],\n+ );\n+}\n+\nexport {\nyearExtractor,\nyearAssertingSelector,\n@@ -147,4 +183,5 @@ export {\nnonThreadCalendarQuery,\nuseOnClickThread,\nuseThreadIsActive,\n+ useOnClickPendingSidebar,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Add option to open empty pending thread
Summary: Introduce new nav params (pendingThread and sourceMessage)
Test Plan: Create a button which calls useOnCLickPendingSidebar, click it and verify that empty page is displayed (app should not crash)
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D709 |
129,184 | 12.02.2021 15:20:27 | 28,800 | 359b7644fd2b33bbf8ff9a9a4ad5a0d4b11f9551 | Image paste modal cleanup
Summary: Removed extraneous styles and closing tags.
Test Plan: Tested on iOS and everything looks and works the same.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/chat/image-paste-modal.react.js",
"new_path": "native/chat/image-paste-modal.react.js",
"diff": "@@ -57,37 +57,26 @@ function ImagePasteModal(props: Props) {\nsafeAreaEdges={['top']}\n>\n<Image style={styles.image} source={{ uri: imagePasteStagingInfo.uri }} />\n- <View style={styles.linebreak}></View>\n- <View style={styles.spacer}></View>\n+ <View style={styles.linebreak} />\n+ <View style={styles.spacer} />\n<Button title=\"Send\" onPress={sendImage} />\n- <View style={styles.linebreak}></View>\n- <View style={styles.spacer}></View>\n+ <View style={styles.linebreak} />\n+ <View style={styles.spacer} />\n<Button title=\"Cancel\" onPress={cancel} />\n- <View style={styles.spacer}></View>\n+ <View style={styles.spacer} />\n</Modal>\n);\n}\nconst unboundStyles = {\nmodal: {\n- backgroundColor: 'modalBackground',\n- flex: 1,\n- justifyContent: 'center',\nmarginHorizontal: 0,\nmarginTop: 300,\nmarginBottom: 0,\n- padding: 12,\nborderTopLeftRadius: 10,\nborderTopRightRadius: 10,\nborderRadius: 0,\n},\n- modalBackground: {\n- backgroundColor: 'modalBackground',\n- padding: 12,\n- justifyContent: 'center',\n- alignItems: 'center',\n- borderRadius: 5,\n- },\nimage: {\nresizeMode: 'contain',\nflex: 1,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Image paste modal cleanup
Summary: Removed extraneous styles and closing tags.
Test Plan: Tested on iOS and everything looks and works the same.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D723 |
129,184 | 12.02.2021 15:03:10 | 28,800 | 35e8bca35b70b4eb9857868579719c14b98433d0 | Animate video playback modal in/out
Summary: Code written by Ashoat during video call explaining animations using the reanimated library.
Test Plan: Tested basic functionality on iOS. Will test media pipeline scenarios comprehensively after the remaining modal animation diffs.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/media/video-playback-modal.react.js",
"new_path": "native/media/video-playback-modal.react.js",
"diff": "@@ -5,18 +5,45 @@ import * as React from 'react';\nimport { useState } from 'react';\nimport { View, Text, TouchableWithoutFeedback } from 'react-native';\nimport * as Progress from 'react-native-progress';\n+import Animated from 'react-native-reanimated';\nimport Icon from 'react-native-vector-icons/MaterialCommunityIcons';\nimport Video from 'react-native-video';\n+import type { MediaInfo } from 'lib/types/media-types';\n+\n+import type { ChatMultimediaMessageInfoItem } from '../chat/multimedia-message.react';\nimport Button from '../components/button.react';\n-import Modal from '../components/modal.react';\n+import ConnectedStatusBar from '../connected-status-bar.react';\nimport type { AppNavigationProp } from '../navigation/app-navigator.react';\n+import { OverlayContext } from '../navigation/overlay-context';\nimport type { NavigationRoute } from '../navigation/route-names';\n+import { useSelector } from '../redux/redux-utils';\n+import { derivedDimensionsInfoSelector } from '../selectors/dimensions-selectors';\nimport { useStyles } from '../themes/colors';\n+import type { VerticalBounds, LayoutCoordinates } from '../types/layout-types';\nimport { formatDuration } from './video-utils';\n+/* eslint-disable import/no-named-as-default-member */\n+const {\n+ Value,\n+ Extrapolate,\n+ set,\n+ add,\n+ sub,\n+ multiply,\n+ divide,\n+ max,\n+ min,\n+ abs,\n+ interpolate,\n+} = Animated;\n+\nexport type VideoPlaybackModalParams = {|\n- +videoUri: string,\n+ +presentedFrom: string,\n+ +mediaInfo: MediaInfo,\n+ +initialCoordinates: LayoutCoordinates,\n+ +verticalBounds: VerticalBounds,\n+ +item: ChatMultimediaMessageInfoItem,\n|};\ntype Props = {|\n@@ -24,6 +51,167 @@ type Props = {|\n+route: NavigationRoute<'VideoPlaybackModal'>,\n|};\nfunction VideoPlaybackModal(props: Props) {\n+ const { mediaInfo } = props.route.params;\n+ const mediaDimensions = mediaInfo.dimensions;\n+ const screenDimensions = useSelector(derivedDimensionsInfoSelector);\n+\n+ const frame = React.useMemo(\n+ () => ({\n+ width: screenDimensions.width,\n+ height: screenDimensions.safeAreaHeight,\n+ }),\n+ [screenDimensions],\n+ );\n+\n+ const mediaDisplayDimensions = React.useMemo(() => {\n+ let { height: maxHeight, width: maxWidth } = frame;\n+ if (maxHeight > maxWidth) {\n+ maxHeight -= 100;\n+ } else {\n+ maxWidth -= 100;\n+ }\n+\n+ if (\n+ mediaDimensions.height < maxHeight &&\n+ mediaDimensions.width < maxWidth\n+ ) {\n+ return mediaDimensions;\n+ }\n+\n+ const heightRatio = maxHeight / mediaDimensions.height;\n+ const widthRatio = maxWidth / mediaDimensions.width;\n+\n+ if (heightRatio < widthRatio) {\n+ return {\n+ height: maxHeight,\n+ width: mediaDimensions.width * heightRatio,\n+ };\n+ } else {\n+ return {\n+ width: maxWidth,\n+ height: mediaDimensions.height * widthRatio,\n+ };\n+ }\n+ }, [frame, mediaDimensions]);\n+\n+ const centerXRef = React.useRef<Value>(new Value(frame.width / 2));\n+ const centerYRef = React.useRef<Value>(\n+ new Value(frame.height / 2 + screenDimensions.topInset),\n+ );\n+ const frameWidthRef = React.useRef<Value>(new Value(frame.width));\n+ const frameHeightRef = React.useRef<Value>(new Value(frame.height));\n+ const imageWidthRef = React.useRef<Value>(\n+ new Value(mediaDisplayDimensions.width),\n+ );\n+ const imageHeightRef = React.useRef<Value>(\n+ new Value(mediaDisplayDimensions.height),\n+ );\n+ React.useEffect(() => {\n+ const { width: frameWidth, height: frameHeight } = frame;\n+ const { topInset } = screenDimensions;\n+ frameWidthRef.current.setValue(frameWidth);\n+ frameHeightRef.current.setValue(frameHeight);\n+\n+ const centerX = frameWidth / 2;\n+ const centerY = frameHeight / 2 + topInset;\n+ centerXRef.current.setValue(centerX);\n+ centerYRef.current.setValue(centerY);\n+\n+ const { width, height } = mediaDisplayDimensions;\n+ imageWidthRef.current.setValue(width);\n+ imageHeightRef.current.setValue(height);\n+ }, [screenDimensions, frame, mediaDisplayDimensions]);\n+\n+ const centerX = centerXRef.current;\n+ const centerY = centerYRef.current;\n+ const frameWidth = frameWidthRef.current;\n+ const frameHeight = frameHeightRef.current;\n+ const imageWidth = imageWidthRef.current;\n+ const imageHeight = imageHeightRef.current;\n+\n+ const left = sub(centerX, divide(imageWidth, 2));\n+ const top = sub(centerY, divide(imageHeight, 2));\n+\n+ const { initialCoordinates } = props.route.params;\n+ const initialScale = divide(initialCoordinates.width, imageWidth);\n+ const initialTranslateX = sub(\n+ initialCoordinates.x + initialCoordinates.width / 2,\n+ add(left, divide(imageWidth, 2)),\n+ );\n+ const initialTranslateY = sub(\n+ initialCoordinates.y + initialCoordinates.height / 2,\n+ add(top, divide(imageHeight, 2)),\n+ );\n+\n+ // The all-important outputs\n+ const curScale = new Value(1);\n+ const curX = new Value(0);\n+ const curY = new Value(0);\n+ const curBackdropOpacity = new Value(1);\n+\n+ const progressiveOpacity = max(\n+ min(\n+ sub(1, abs(divide(curX, frameWidth))),\n+ sub(1, abs(divide(curY, frameHeight))),\n+ ),\n+ 0,\n+ );\n+\n+ const updates = [set(curBackdropOpacity, progressiveOpacity)];\n+ const updatedScale = [updates, curScale];\n+ const updatedCurX = [updates, curX];\n+ const updatedCurY = [updates, curY];\n+ const updatedBackdropOpacity = [updates, curBackdropOpacity];\n+\n+ const overlayContext = React.useContext(OverlayContext);\n+ invariant(overlayContext, 'VideoPlaybackModal should have OverlayContext');\n+ const navigationProgress = overlayContext.position;\n+\n+ const reverseNavigationProgress = sub(1, navigationProgress);\n+ const scale = add(\n+ multiply(reverseNavigationProgress, initialScale),\n+ multiply(navigationProgress, updatedScale),\n+ );\n+ const x = add(\n+ multiply(reverseNavigationProgress, initialTranslateX),\n+ multiply(navigationProgress, updatedCurX),\n+ );\n+ const y = add(\n+ multiply(reverseNavigationProgress, initialTranslateY),\n+ multiply(navigationProgress, updatedCurY),\n+ );\n+\n+ const backdropOpacity = multiply(navigationProgress, updatedBackdropOpacity);\n+ const imageContainerOpacity = interpolate(navigationProgress, {\n+ inputRange: [0, 0.1],\n+ outputRange: [0, 1],\n+ extrapolate: Extrapolate.CLAMP,\n+ });\n+ const { verticalBounds } = props.route.params;\n+ const videoContainerStyle = React.useMemo(() => {\n+ const { height, width } = mediaDisplayDimensions;\n+ const { height: frameH, width: frameW } = frame;\n+\n+ return {\n+ height,\n+ width,\n+ marginTop:\n+ (frameH - height) / 2 + screenDimensions.topInset - verticalBounds.y,\n+ marginLeft: (frameW - width) / 2,\n+ opacity: imageContainerOpacity,\n+ transform: [{ translateX: x }, { translateY: y }, { scale: scale }],\n+ };\n+ }, [\n+ mediaDisplayDimensions,\n+ frame,\n+ screenDimensions.topInset,\n+ verticalBounds.y,\n+ imageContainerOpacity,\n+ x,\n+ y,\n+ scale,\n+ ]);\n+\nconst styles = useStyles(unboundStyles);\nconst [paused, setPaused] = useState(false);\n@@ -36,7 +224,9 @@ function VideoPlaybackModal(props: Props) {\nconst {\nnavigation,\nroute: {\n- params: { videoUri },\n+ params: {\n+ mediaInfo: { uri: videoUri },\n+ },\n},\n} = props;\n@@ -61,9 +251,32 @@ function VideoPlaybackModal(props: Props) {\n);\n}, []);\n- let controls;\n- if (controlsVisible) {\n- controls = (\n+ const statusBar = overlayContext.isDismissing ? null : (\n+ <ConnectedStatusBar hidden />\n+ );\n+\n+ const backdropStyle = React.useMemo(() => ({ opacity: backdropOpacity }), [\n+ backdropOpacity,\n+ ]);\n+\n+ const contentContainerStyle = React.useMemo(() => {\n+ const fullScreenHeight = screenDimensions.height;\n+ const bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n+\n+ // margin will clip, but padding won't\n+ const verticalStyle = overlayContext.isDismissing\n+ ? { marginTop: verticalBounds.y, marginBottom: bottom }\n+ : { paddingTop: verticalBounds.y, paddingBottom: bottom };\n+ return [styles.contentContainer, verticalStyle];\n+ }, [\n+ screenDimensions.height,\n+ verticalBounds.y,\n+ verticalBounds.height,\n+ overlayContext.isDismissing,\n+ styles.contentContainer,\n+ ]);\n+\n+ const controls = (\n<>\n<View style={styles.header}>\n<View style={styles.closeButton}>\n@@ -72,7 +285,6 @@ function VideoPlaybackModal(props: Props) {\n</Button>\n</View>\n</View>\n-\n<View style={styles.footer}>\n<View style={styles.playPauseButton}>\n<TouchableWithoutFeedback onPress={togglePlayback}>\n@@ -99,14 +311,13 @@ function VideoPlaybackModal(props: Props) {\n</View>\n</>\n);\n- }\nreturn (\n- <Modal\n- modalStyle={styles.modal}\n- navigation={navigation}\n- safeAreaEdges={['left']}\n- >\n+ <Animated.View style={styles.modal}>\n+ {statusBar}\n+ <Animated.View style={[styles.backdrop, backdropStyle]} />\n+ <View style={contentContainerStyle}>\n+ <Animated.View style={videoContainerStyle}>\n<TouchableWithoutFeedback onPress={togglePlaybackControls}>\n<Video\nsource={{ uri: videoUri }}\n@@ -117,20 +328,16 @@ function VideoPlaybackModal(props: Props) {\nonEnd={resetVideo}\n/>\n</TouchableWithoutFeedback>\n- {controls}\n- </Modal>\n+ </Animated.View>\n+ </View>\n+ {controlsVisible ? controls : null}\n+ </Animated.View>\n);\n}\nconst unboundStyles = {\nmodal: {\n- backgroundColor: 'black',\n- justifyContent: 'center',\n- marginHorizontal: 0,\n- marginTop: 0,\n- marginBottom: 0,\n- padding: 0,\n- borderRadius: 0,\n+ flex: 1,\n},\nbackgroundVideo: {\nposition: 'absolute',\n@@ -184,6 +391,18 @@ const unboundStyles = {\ncolor: 'white',\nfontSize: 11,\n},\n+ backdrop: {\n+ backgroundColor: 'black',\n+ bottom: 0,\n+ left: 0,\n+ position: 'absolute',\n+ right: 0,\n+ top: 0,\n+ },\n+ contentContainer: {\n+ flex: 1,\n+ overflow: 'hidden',\n+ },\n};\nexport default VideoPlaybackModal;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Animate video playback modal in/out
Summary: Code written by Ashoat during video call explaining animations using the reanimated library.
Test Plan: Tested basic functionality on iOS. Will test media pipeline scenarios comprehensively after the remaining modal animation diffs.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D721 |
129,184 | 15.02.2021 01:59:11 | 28,800 | b0c91b0f91f32ff151104f85cb65939687eba0e0 | Toggle between video playback and multimedia modal
Summary: Display VideoPlaybackModal or MultimediaModal based on mediaInfo.type
Test Plan: Tested on iOS. Will test media pipeline scenarios comprehensively after the modal animation diffs.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message-multimedia.react.js",
"new_path": "native/chat/multimedia-message-multimedia.react.js",
"diff": "@@ -22,8 +22,9 @@ import {\nOverlayContext,\ntype OverlayContextType,\n} from '../navigation/overlay-context';\n-import type { NavigationRoute } from '../navigation/route-names';\nimport {\n+ type NavigationRoute,\n+ VideoPlaybackModalRouteName,\nMultimediaModalRouteName,\nMultimediaTooltipModalRouteName,\n} from '../navigation/route-names';\n@@ -198,7 +199,10 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nview.measure((x, y, width, height, pageX, pageY) => {\nconst coordinates = { x: pageX, y: pageY, width, height };\nthis.props.navigation.navigate({\n- name: MultimediaModalRouteName,\n+ name:\n+ mediaInfo.type === 'video'\n+ ? VideoPlaybackModalRouteName\n+ : MultimediaModalRouteName,\nkey: MultimediaMessageMultimedia.getStableKey(this.props),\nparams: {\npresentedFrom: this.props.route.key,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Toggle between video playback and multimedia modal
Summary: Display VideoPlaybackModal or MultimediaModal based on mediaInfo.type
Test Plan: Tested on iOS. Will test media pipeline scenarios comprehensively after the modal animation diffs.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D725 |
129,184 | 16.02.2021 00:29:47 | 28,800 | 48c364f1e4d1ea37865396bad7044817fb34b519 | [native] Use hook instead of connect functions and HOC in Modal
Summary: NA
Test Plan: Tried various modals (eg ImagePickerModal, ColorPickerModal) and they worked as before.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/thread-picker-modal.react.js",
"new_path": "native/calendar/thread-picker-modal.react.js",
"diff": "@@ -77,7 +77,7 @@ function ThreadPickerModal(props: Props) {\nonScreenEntryEditableThreadInfos(state),\n);\nreturn (\n- <Modal navigation={navigation}>\n+ <Modal>\n<ThreadList\nthreadInfos={onScreenThreadInfos}\nonSelect={threadPicked}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/image-paste-modal.react.js",
"new_path": "native/chat/image-paste-modal.react.js",
"diff": "@@ -51,11 +51,7 @@ function ImagePasteModal(props: Props) {\n}, [imagePasteStagingInfo.uri, navigation]);\nreturn (\n- <Modal\n- modalStyle={styles.modal}\n- navigation={navigation}\n- safeAreaEdges={['top']}\n- >\n+ <Modal modalStyle={styles.modal} safeAreaEdges={['top']}>\n<Image style={styles.image} source={{ uri: imagePasteStagingInfo.uri }} />\n<View style={styles.linebreak} />\n<View style={styles.spacer} />\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/add-users-modal.react.js",
"new_path": "native/chat/settings/add-users-modal.react.js",
"diff": "@@ -180,7 +180,7 @@ class AddUsersModal extends React.PureComponent<Props, State> {\nonSubmitEditing: this.onPressAdd,\n};\nreturn (\n- <Modal navigation={this.props.navigation}>\n+ <Modal>\n<TagInput\nvalue={this.state.userInfoInputArray}\nonChange={this.onChangeTagInput}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/color-picker-modal.react.js",
"new_path": "native/chat/settings/color-picker-modal.react.js",
"diff": "@@ -57,10 +57,7 @@ class ColorPickerModal extends React.PureComponent<Props> {\n// and consequently width is the lowest dimensions\nconst modalStyle = { height: this.props.windowWidth - 5 };\nreturn (\n- <Modal\n- navigation={this.props.navigation}\n- modalStyle={[this.props.styles.colorPickerContainer, modalStyle]}\n- >\n+ <Modal modalStyle={[this.props.styles.colorPickerContainer, modalStyle]}>\n<ColorPicker\ndefaultColor={color}\noldColor={threadInfo.color}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/compose-subthread-modal.react.js",
"new_path": "native/chat/settings/compose-subthread-modal.react.js",
"diff": "@@ -56,10 +56,7 @@ class ComposeSubthreadModal extends React.PureComponent<Props> {\nrender() {\nreturn (\n- <Modal\n- navigation={this.props.navigation}\n- modalStyle={this.props.styles.modal}\n- >\n+ <Modal modalStyle={this.props.styles.modal}>\n<Text style={this.props.styles.visibility}>Thread type</Text>\n<Button style={this.props.styles.option} onPress={this.onPressOpen}>\n<Icon\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/sidebar-list-modal.react.js",
"new_path": "native/chat/sidebar-list-modal.react.js",
"diff": "@@ -128,7 +128,7 @@ function SidebarListModal(props: Props) {\nconst indicatorStyle = useIndicatorStyle();\nreturn (\n- <Modal navigation={navigation}>\n+ <Modal>\n<Search\nsearchText={searchState.text}\nonChangeText={onChangeSearchText}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/modal.react.js",
"new_path": "native/components/modal.react.js",
"diff": "// @flow\n+import { useNavigation } from '@react-navigation/native';\nimport * as React from 'react';\nimport { View, TouchableWithoutFeedback, StyleSheet } from 'react-native';\nimport { SafeAreaView } from 'react-native-safe-area-context';\nimport type { Edge } from 'react-native-safe-area-context';\n-import { connect } from 'lib/utils/redux-utils';\n-\n-import type { RootNavigationProp } from '../navigation/root-navigator.react';\n-import type { AppState } from '../redux/redux-setup';\n-import { styleSelector } from '../themes/colors';\n+import { useStyles } from '../themes/colors';\nimport type { ViewStyle } from '../types/styles';\nimport KeyboardAvoidingView from './keyboard-avoiding-view.react';\ntype Props = $ReadOnly<{|\n- navigation: RootNavigationProp<>,\n- children: React.Node,\n- containerStyle?: ViewStyle,\n- modalStyle?: ViewStyle,\n- safeAreaEdges?: $ReadOnlyArray<Edge>,\n- // Redux state\n- styles: typeof styles,\n+ +children: React.Node,\n+ +containerStyle?: ViewStyle,\n+ +modalStyle?: ViewStyle,\n+ +safeAreaEdges?: $ReadOnlyArray<Edge>,\n|}>;\n-class Modal extends React.PureComponent<Props> {\n- close = () => {\n- if (this.props.navigation.isFocused()) {\n- this.props.navigation.goBackOnce();\n+function Modal(props: Props) {\n+ const navigation = useNavigation();\n+ const close = React.useCallback(() => {\n+ if (navigation.isFocused()) {\n+ navigation.goBack();\n}\n- };\n+ }, [navigation]);\n- render() {\n- const { containerStyle, modalStyle, children, safeAreaEdges } = this.props;\n+ const styles = useStyles(unboundStyles);\n+ const { containerStyle, modalStyle, children, safeAreaEdges } = props;\nreturn (\n- <SafeAreaView style={this.props.styles.container} edges={safeAreaEdges}>\n+ <SafeAreaView style={styles.container} edges={safeAreaEdges}>\n<KeyboardAvoidingView\nbehavior=\"padding\"\n- style={[this.props.styles.container, containerStyle]}\n+ style={[styles.container, containerStyle]}\n>\n- <TouchableWithoutFeedback onPress={this.close}>\n+ <TouchableWithoutFeedback onPress={close}>\n<View style={StyleSheet.absoluteFill} />\n</TouchableWithoutFeedback>\n- <View style={[this.props.styles.modal, modalStyle]}>{children}</View>\n+ <View style={[styles.modal, modalStyle]}>{children}</View>\n</KeyboardAvoidingView>\n</SafeAreaView>\n);\n}\n-}\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nflex: 1,\njustifyContent: 'center',\n@@ -64,8 +58,5 @@ const styles = {\npadding: 12,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(Modal);\n+export default Modal;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/custom-server-modal.react.js",
"new_path": "native/more/custom-server-modal.react.js",
"diff": "@@ -53,7 +53,6 @@ class CustomServerModal extends React.PureComponent<Props, State> {\nrender() {\nreturn (\n<Modal\n- navigation={this.props.navigation}\ncontainerStyle={this.props.styles.container}\nmodalStyle={this.props.styles.modal}\n>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in Modal
Summary: NA
Test Plan: Tried various modals (eg ImagePickerModal, ColorPickerModal) and they worked as before.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D729 |
129,191 | 11.02.2021 18:21:59 | -3,600 | 129f18bd64fa4d3239f1dc271d1bb6ffcc57e2a0 | [lib] Extract real thread creation hook
Test Plan: Open pending sidebar, send couple of messages and check if exactly one sidebar was created.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -10,6 +10,7 @@ import {\nfetchMostRecentMessagesActionTypes,\nfetchMostRecentMessages,\n} from '../actions/message-actions';\n+import { newThread, newThreadActionTypes } from '../actions/thread-actions';\nimport {\npermissionLookup,\ngetAllThreadPermissions,\n@@ -37,6 +38,7 @@ import {\nthreadTypes,\nthreadPermissions,\n} from '../types/thread-types';\n+import type { NewThreadRequest, NewThreadResult } from '../types/thread-types';\nimport { type UpdateInfo, updateTypes } from '../types/update-types';\nimport type {\nGlobalAccountUserInfo,\n@@ -44,6 +46,7 @@ import type {\nUserInfo,\n} from '../types/user-types';\nimport { useDispatchActionPromise, useServerCall } from '../utils/action-utils';\n+import type { DispatchActionPromise } from '../utils/action-utils';\nimport { pluralize } from '../utils/text-utils';\nimport { getMessageTitle } from './message-utils';\nimport { relationshipBlockedInEitherDirection } from './relationship-utils';\n@@ -369,6 +372,86 @@ function pendingThreadType(numberOfOtherMembers: number) {\n: threadTypes.CHAT_SECRET;\n}\n+async function createRealThreadFromPendingThread(\n+ threadInfo: ThreadInfo,\n+ dispatchActionPromise: DispatchActionPromise,\n+ createNewThread: (request: NewThreadRequest) => Promise<NewThreadResult>,\n+ sourceMessageID: ?string,\n+ handleError?: () => mixed,\n+): Promise<?string> {\n+ const otherMemberIDs = getPendingThreadOtherUsers(threadInfo);\n+ try {\n+ let resultPromise;\n+ if (threadInfo.type !== threadTypes.SIDEBAR) {\n+ invariant(\n+ otherMemberIDs.length > 0,\n+ 'otherMemberIDs should not be empty for threads',\n+ );\n+ resultPromise = createNewThread({\n+ type: pendingThreadType(otherMemberIDs.length),\n+ initialMemberIDs: otherMemberIDs,\n+ color: threadInfo.color,\n+ });\n+ } else {\n+ invariant(\n+ sourceMessageID,\n+ 'sourceMessageID should be set when creating a sidebar',\n+ );\n+\n+ resultPromise = createNewThread({\n+ type: threadTypes.SIDEBAR,\n+ initialMemberIDs: otherMemberIDs,\n+ color: threadInfo.color,\n+ sourceMessageID,\n+ parentThreadID: threadInfo.parentThreadID,\n+ name: threadInfo.name,\n+ });\n+ }\n+ dispatchActionPromise(newThreadActionTypes, resultPromise);\n+ const { newThreadID } = await resultPromise;\n+ return newThreadID;\n+ } catch (e) {\n+ if (handleError) {\n+ handleError();\n+ return undefined;\n+ } else {\n+ throw e;\n+ }\n+ }\n+}\n+\n+function useRealThreadCreator(\n+ threadInfo: ThreadInfo,\n+ sourceMessageID?: ?string,\n+ handleError?: () => mixed,\n+) {\n+ const serverThreadID = React.useRef<?string>(\n+ threadIsPending(threadInfo.id) ? null : threadInfo.id,\n+ );\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callNewThread = useServerCall(newThread);\n+ return React.useCallback(async () => {\n+ if (serverThreadID.current) {\n+ return serverThreadID.current;\n+ }\n+ const newThreadID = await createRealThreadFromPendingThread(\n+ threadInfo,\n+ dispatchActionPromise,\n+ callNewThread,\n+ sourceMessageID,\n+ handleError,\n+ );\n+ serverThreadID.current = newThreadID;\n+ return newThreadID;\n+ }, [\n+ callNewThread,\n+ dispatchActionPromise,\n+ handleError,\n+ sourceMessageID,\n+ threadInfo,\n+ ]);\n+}\n+\ntype RawThreadInfoOptions = {|\n+includeVisibilityRules?: ?boolean,\n+filterMemberList?: ?boolean,\n@@ -789,6 +872,7 @@ export {\ncreatePendingThreadItem,\ncreatePendingSidebar,\npendingThreadType,\n+ useRealThreadCreator,\ngetCurrentUser,\nthreadFrozenDueToBlock,\nthreadFrozenDueToViewerBlock,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-input-bar.react.js",
"new_path": "native/chat/chat-input-bar.react.js",
"diff": "@@ -22,12 +22,7 @@ import Icon from 'react-native-vector-icons/Ionicons';\nimport { useDispatch } from 'react-redux';\nimport { saveDraftActionType } from 'lib/actions/miscellaneous-action-types';\n-import {\n- joinThreadActionTypes,\n- joinThread,\n- newThread,\n- newThreadActionTypes,\n-} from 'lib/actions/thread-actions';\n+import { joinThreadActionTypes, joinThread } from 'lib/actions/thread-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { trimMessage } from 'lib/shared/message-utils';\nimport {\n@@ -35,9 +30,7 @@ import {\nviewerIsMember,\nthreadFrozenDueToViewerBlock,\nthreadActualMembers,\n- threadIsPending,\n- getPendingThreadOtherUsers,\n- pendingThreadType,\n+ useRealThreadCreator,\n} from 'lib/shared/thread-utils';\nimport type { CalendarQuery } from 'lib/types/entry-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\n@@ -51,9 +44,6 @@ import {\nthreadPermissions,\ntype ClientThreadJoinRequest,\ntype ThreadJoinPayload,\n- type NewThreadRequest,\n- type NewThreadResult,\n- threadTypes,\n} from 'lib/types/thread-types';\nimport { type UserInfos, userInfoPropType } from 'lib/types/user-types';\nimport {\n@@ -152,7 +142,7 @@ type Props = {|\n+dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n+joinThread: (request: ClientThreadJoinRequest) => Promise<ThreadJoinPayload>,\n- +newThread: (request: NewThreadRequest) => Promise<NewThreadResult>,\n+ +getServerThreadID: () => Promise<?string>,\n// withInputState\n+inputState: ?InputState,\n|};\n@@ -179,7 +169,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\ndispatchActionPromise: PropTypes.func.isRequired,\njoinThread: PropTypes.func.isRequired,\ninputState: inputStatePropType,\n- newThread: PropTypes.func.isRequired,\n+ getServerThreadID: PropTypes.func.isRequired,\n};\ntextInput: ?React.ElementRef<typeof TextInput>;\nclearableTextInput: ?ClearableTextInput;\n@@ -195,8 +185,6 @@ class ChatInputBar extends React.PureComponent<Props, State> {\ntargetSendButtonContainerOpen: Value;\nsendButtonContainerStyle: ViewStyle;\n- newThreadID: ?string;\n-\nconstructor(props: Props) {\nsuper(props);\nthis.state = {\n@@ -619,56 +607,6 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nthis.textInput.focus();\n};\n- getServerThreadID = async () => {\n- if (this.newThreadID) {\n- return this.newThreadID;\n- }\n- const { threadInfo } = this.props;\n- if (!threadIsPending(threadInfo.id)) {\n- return threadInfo.id;\n- }\n-\n- const otherMemberIDs = getPendingThreadOtherUsers(threadInfo);\n- try {\n- let resultPromise;\n- if (threadInfo.type !== threadTypes.SIDEBAR) {\n- invariant(\n- otherMemberIDs.length > 0,\n- 'otherMemberIDs should not be empty for threads',\n- );\n- resultPromise = this.props.newThread({\n- type: pendingThreadType(otherMemberIDs.length),\n- initialMemberIDs: otherMemberIDs,\n- color: threadInfo.color,\n- });\n- } else {\n- const sourceMessageID = this.props.route.params.sidebarSourceMessageID;\n- invariant(\n- sourceMessageID,\n- 'sourceMessageID should be set in getServerThreadID for sidebar',\n- );\n-\n- resultPromise = this.props.newThread({\n- type: threadTypes.SIDEBAR,\n- initialMemberIDs: otherMemberIDs,\n- color: threadInfo.color,\n- sourceMessageID,\n- parentThreadID: threadInfo.parentThreadID,\n- name: threadInfo.name,\n- });\n- }\n- this.props.dispatchActionPromise(newThreadActionTypes, resultPromise);\n- const { newThreadID } = await resultPromise;\n- this.newThreadID = newThreadID;\n- return newThreadID;\n- } catch (e) {\n- Alert.alert('Unknown error', 'Uhh... try again?', [{ text: 'OK' }], {\n- cancelable: false,\n- });\n- }\n- return undefined;\n- };\n-\nonSend = async () => {\nif (!trimMessage(this.state.text)) {\nreturn;\n@@ -688,7 +626,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nconst localID = `local${this.props.nextLocalID}`;\nconst creatorID = this.props.viewerID;\n- const threadID = await this.getServerThreadID();\n+ const threadID = await this.props.getServerThreadID();\ninvariant(creatorID, 'should have viewer ID in order to send a message');\ninvariant(\nthis.props.inputState,\n@@ -861,6 +799,11 @@ const joinThreadLoadingStatusSelector = createLoadingStatusSelector(\njoinThreadActionTypes,\n);\n+const showErrorAlert = () =>\n+ Alert.alert('Unknown error', 'Uhh... try again?', [{ text: 'OK' }], {\n+ cancelable: false,\n+ });\n+\nexport default React.memo<BaseProps>(function ConnectedChatInputBar(\nprops: BaseProps,\n) {\n@@ -895,7 +838,6 @@ export default React.memo<BaseProps>(function ConnectedChatInputBar(\nconst dispatch = useDispatch();\nconst dispatchActionPromise = useDispatchActionPromise();\nconst callJoinThread = useServerCall(joinThread);\n- const callNewThread = useServerCall(newThread);\nconst imagePastedCallback = React.useCallback(\n(imagePastedEvent) => {\n@@ -933,6 +875,12 @@ export default React.memo<BaseProps>(function ConnectedChatInputBar(\nreturn () => imagePasteListener.remove();\n}, [imagePastedCallback]);\n+ const getServerThreadID = useRealThreadCreator(\n+ props.threadInfo,\n+ props.route.params.sidebarSourceMessageID,\n+ showErrorAlert,\n+ );\n+\nreturn (\n<ChatInputBar\n{...props}\n@@ -950,7 +898,7 @@ export default React.memo<BaseProps>(function ConnectedChatInputBar(\ndispatchActionPromise={dispatchActionPromise}\njoinThread={callJoinThread}\ninputState={inputState}\n- newThread={callNewThread}\n+ getServerThreadID={getServerThreadID}\n/>\n);\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Extract real thread creation hook
Test Plan: Open pending sidebar, send couple of messages and check if exactly one sidebar was created.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D718 |
129,183 | 17.02.2021 14:45:46 | -3,600 | 76e8aae6829441b84c6cb548f0d9985f27d63ffa | [web] Use correct icon
Summary: When I introduced D681, I accidentally changed icon used for composed message send status. This diff just brings it back
Test Plan: Make sure correct icon is displayed
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "web/chat/composed-message.react.js",
"new_path": "web/chat/composed-message.react.js",
"diff": "@@ -4,7 +4,7 @@ import classNames from 'classnames';\nimport invariant from 'invariant';\nimport * as React from 'react';\nimport {\n- CornerDownRight as CircleIcon,\n+ Circle as CircleIcon,\nCheckCircle as CheckCircleIcon,\nXCircle as XCircleIcon,\n} from 'react-feather';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use correct icon
Summary: When I introduced D681, I accidentally changed icon used for composed message send status. This diff just brings it back
Test Plan: Make sure correct icon is displayed
Reviewers: ashoat, palys-swm
Reviewed By: palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D738 |
129,184 | 15.02.2021 01:13:42 | 28,800 | 9e347b7a4d33852d54d22b90daa6c9526fe369ff | Podfile and xcodeproj tweaks for M1 iOS Simulator
Test Plan: I don't think these settings should affect Intel Macs.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/ios/Podfile",
"new_path": "native/ios/Podfile",
"diff": "@@ -30,5 +30,11 @@ target 'SquadCal' do\nend\nend\nend\n+\n+ # M1 Simulator fix\n+ installer.pods_project.build_configurations.each do |config|\n+ config.build_settings[\"EXCLUDED_ARCHS[sdk=iphonesimulator*]\"] = \"arm64\"\n+ end\n+\nend\nend\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/Podfile.lock",
"new_path": "native/ios/Podfile.lock",
"diff": "@@ -779,6 +779,6 @@ SPEC CHECKSUMS:\nYoga: 4bd86afe9883422a7c4028c00e34790f560923d6\nYogaKit: f782866e155069a2cca2517aafea43200b01fd5a\n-PODFILE CHECKSUM: 9e67a7c3373805d3742a6685b308d920d73ed027\n+PODFILE CHECKSUM: c3f7a686f2abca70ee40588f64e5d7a561d42386\nCOCOAPODS: 1.10.1\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "DEAD_CODE_STRIPPING = NO;\nDEVELOPMENT_TEAM = 6BF4H9TU5U;\nENABLE_BITCODE = NO;\n+ \"EXCLUDED_ARCHS[sdk=iphonesimulator*]\" = arm64;\nGCC_PREPROCESSOR_DEFINITIONS = (\n\"$(inherited)\",\n\"COCOAPODS=1\",\nCURRENT_PROJECT_VERSION = 1;\nDEVELOPMENT_TEAM = 6BF4H9TU5U;\nENABLE_BITCODE = YES;\n+ \"EXCLUDED_ARCHS[sdk=iphonesimulator*]\" = arm64;\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Podfile and xcodeproj tweaks for M1 iOS Simulator
Test Plan: I don't think these settings should affect Intel Macs.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D724 |
129,191 | 17.02.2021 10:21:48 | -3,600 | b54974bb7d3fc0c06cdc5d1e3e6fcec87810c86a | [native] Create real thread when image is sent by pasting
Test Plan: Paste an image in pending sidebar and check if the thread was created
Reviewers: ashoat, atul
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-input-bar.react.js",
"new_path": "native/chat/chat-input-bar.react.js",
"diff": "@@ -866,11 +866,18 @@ export default React.memo<BaseProps>(function ConnectedChatInputBar(\nname: ImagePasteModalRouteName,\nparams: {\nimagePasteStagingInfo: pastedImage,\n- threadID: props.threadInfo.id,\n+ thread: {\n+ threadInfo: props.threadInfo,\n+ sourceMessageID: props.route.params.thread.sourceMessageID,\n+ },\n},\n});\n},\n- [props.navigation, props.threadInfo.id],\n+ [\n+ props.navigation,\n+ props.route.params.thread.sourceMessageID,\n+ props.threadInfo,\n+ ],\n);\nReact.useEffect(() => {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/image-paste-modal.react.js",
"new_path": "native/chat/image-paste-modal.react.js",
"diff": "import invariant from 'invariant';\nimport * as React from 'react';\n-import { Button, View, Image } from 'react-native';\n+import { Button, View, Image, Alert } from 'react-native';\nimport filesystem from 'react-native-fs';\n+import { useRealThreadCreator } from 'lib/shared/thread-utils';\nimport type { PhotoPaste } from 'lib/types/media-types';\n+import type { OptimisticThreadInfo } from 'lib/types/thread-types';\nimport sleep from 'lib/utils/sleep';\nimport Modal from '../components/modal.react';\n@@ -16,9 +18,14 @@ import { useStyles } from '../themes/colors';\nexport type ImagePasteModalParams = {|\n+imagePasteStagingInfo: PhotoPaste,\n- +threadID: string,\n+ +thread: OptimisticThreadInfo,\n|};\n+const showErrorAlert = () =>\n+ Alert.alert('Unknown error', 'Uhh... try again?', [{ text: 'OK' }], {\n+ cancelable: false,\n+ });\n+\ntype Props = {|\n+navigation: RootNavigationProp<'ImagePasteModal'>,\n+route: NavigationRoute<'ImagePasteModal'>,\n@@ -29,20 +36,26 @@ function ImagePasteModal(props: Props) {\nconst {\nnavigation,\nroute: {\n- params: { imagePasteStagingInfo, threadID },\n+ params: { imagePasteStagingInfo, thread },\n},\n} = props;\n+ const getServerThreadID = useRealThreadCreator(thread, showErrorAlert);\n+\nconst sendImage = React.useCallback(async () => {\nnavigation.goBackOnce();\nconst selection: $ReadOnlyArray<PhotoPaste> = [imagePasteStagingInfo];\n+ const threadID = await getServerThreadID();\n+ if (!threadID) {\n+ return;\n+ }\ninvariant(inputState, 'inputState should be set in ImagePasteModal');\nawait inputState.sendMultimediaMessage(threadID, selection);\ninvariant(\nimagePasteStagingInfo,\n'imagePasteStagingInfo should be set in ImagePasteModal',\n);\n- }, [imagePasteStagingInfo, inputState, navigation, threadID]);\n+ }, [getServerThreadID, imagePasteStagingInfo, inputState, navigation]);\nconst cancel = React.useCallback(async () => {\nnavigation.goBackOnce();\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Create real thread when image is sent by pasting
Test Plan: Paste an image in pending sidebar and check if the thread was created
Reviewers: ashoat, atul
Reviewed By: ashoat, atul
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D735 |
129,187 | 19.02.2021 07:01:24 | 25,200 | 94387487bcd36c293a3ec58d03682957c76de274 | [native] Avoid importing useSelector directly from react-redux
Summary: Additional context [here](https://phabricator.ashoat.com/D743#inline-3620)
Test Plan: Flow
Reviewers: KatPo, subnub, palys-swm
Subscribers: zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message-multimedia.react.js",
"new_path": "native/chat/multimedia-message-multimedia.react.js",
"diff": "@@ -4,7 +4,6 @@ import invariant from 'invariant';\nimport * as React from 'react';\nimport { View, StyleSheet } from 'react-native';\nimport Animated from 'react-native-reanimated';\n-import { useSelector } from 'react-redux';\nimport { messageKey } from 'lib/shared/message-utils';\nimport { relationshipBlockedInEitherDirection } from 'lib/shared/relationship-utils';\n@@ -28,6 +27,7 @@ import {\nMultimediaModalRouteName,\nMultimediaTooltipModalRouteName,\n} from '../navigation/route-names';\n+import { useSelector } from '../redux/redux-utils';\nimport { type Colors, useColors } from '../themes/colors';\nimport { type VerticalBounds } from '../types/layout-types';\nimport type { ViewStyle } from '../types/styles';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "import invariant from 'invariant';\nimport * as React from 'react';\nimport { View } from 'react-native';\n-import { useSelector } from 'react-redux';\nimport { messageKey } from 'lib/shared/message-utils';\nimport { relationshipBlockedInEitherDirection } from 'lib/shared/relationship-utils';\n@@ -16,6 +15,7 @@ import { KeyboardContext } from '../keyboard/keyboard-state';\nimport { OverlayContext } from '../navigation/overlay-context';\nimport { RobotextMessageTooltipModalRouteName } from '../navigation/route-names';\nimport type { NavigationRoute } from '../navigation/route-names';\n+import { useSelector } from '../redux/redux-utils';\nimport { useStyles } from '../themes/colors';\nimport type { VerticalBounds } from '../types/layout-types';\nimport type { ChatNavigationProp } from './chat.react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/color-picker-modal.react.js",
"new_path": "native/chat/settings/color-picker-modal.react.js",
"diff": "import * as React from 'react';\nimport { TouchableHighlight, Alert } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n-import { useSelector } from 'react-redux';\nimport {\nchangeThreadSettingsActionTypes,\n@@ -24,6 +23,7 @@ import ColorPicker from '../../components/color-picker.react';\nimport Modal from '../../components/modal.react';\nimport type { RootNavigationProp } from '../../navigation/root-navigator.react';\nimport type { NavigationRoute } from '../../navigation/route-names';\n+import { useSelector } from '../../redux/redux-utils';\nimport { type Colors, useStyles, useColors } from '../../themes/colors';\nexport type ColorPickerModalParams = {|\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "import invariant from 'invariant';\nimport * as React from 'react';\nimport { View } from 'react-native';\n-import { useSelector } from 'react-redux';\nimport { messageKey } from 'lib/shared/message-utils';\nimport { relationshipBlockedInEitherDirection } from 'lib/shared/relationship-utils';\n@@ -24,6 +23,7 @@ import {\n} from '../navigation/overlay-context';\nimport type { NavigationRoute } from '../navigation/route-names';\nimport { TextMessageTooltipModalRouteName } from '../navigation/route-names';\n+import { useSelector } from '../redux/redux-utils';\nimport type { VerticalBounds } from '../types/layout-types';\nimport type { ChatNavigationProp } from './chat.react';\nimport { ComposedMessage, clusterEndHeight } from './composed-message.react';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Avoid importing useSelector directly from react-redux
Summary: Additional context [here](https://phabricator.ashoat.com/D743#inline-3620)
Test Plan: Flow
Reviewers: KatPo, subnub, palys-swm
Reviewed By: KatPo, palys-swm
Subscribers: zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D754 |
129,191 | 22.02.2021 12:30:34 | -3,600 | ca40e4328e32ed376e110e8984a4593a5006d24a | [lib] Add explicit type to messageContent functions
Summary: It appears that flow has some issues in determining the type of parameters inside spec functions. This is the first diff which adds explicit type annotations.
Test Plan: Flow
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/add-members-message-spec.js",
"new_path": "lib/shared/messages/add-members-message-spec.js",
"diff": "@@ -22,7 +22,7 @@ export const addMembersMessageSpec: MessageSpec<\nRawAddMembersMessageInfo,\nAddMembersMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: AddMembersMessageData): string {\nreturn JSON.stringify(data.addedUserIDs);\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/change-role-message-spec.js",
"new_path": "lib/shared/messages/change-role-message-spec.js",
"diff": "@@ -22,7 +22,7 @@ export const changeRoleMessageSpec: MessageSpec<\nRawChangeRoleMessageInfo,\nChangeRoleMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: ChangeRoleMessageData): string {\nreturn JSON.stringify({\nuserIDs: data.userIDs,\nnewRole: data.newRole,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/change-settings-message-spec.js",
"new_path": "lib/shared/messages/change-settings-message-spec.js",
"diff": "@@ -23,7 +23,7 @@ export const changeSettingsMessageSpec: MessageSpec<\nRawChangeSettingsMessageInfo,\nChangeSettingsMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: ChangeSettingsMessageData): string {\nreturn JSON.stringify({\n[data.field]: data.value,\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-entry-message-spec.js",
"new_path": "lib/shared/messages/create-entry-message-spec.js",
"diff": "@@ -23,7 +23,7 @@ export const createEntryMessageSpec: MessageSpec<\nRawCreateEntryMessageInfo,\nCreateEntryMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: CreateEntryMessageData): string {\nreturn JSON.stringify({\nentryID: data.entryID,\ndate: data.date,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sidebar-message-spec.js",
"new_path": "lib/shared/messages/create-sidebar-message-spec.js",
"diff": "@@ -23,7 +23,7 @@ export const createSidebarMessageSpec: MessageSpec<\nRawCreateSidebarMessageInfo,\nCreateSidebarMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: CreateSidebarMessageData): string {\nreturn JSON.stringify({\n...data.initialThreadState,\nsourceMessageAuthorID: data.sourceMessageAuthorID,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sub-thread-message-spec.js",
"new_path": "lib/shared/messages/create-sub-thread-message-spec.js",
"diff": "@@ -23,7 +23,7 @@ export const createSubThreadMessageSpec: MessageSpec<\nRawCreateSubthreadMessageInfo,\nCreateSubthreadMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: CreateSubthreadMessageData): string {\nreturn data.childThreadID;\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-thread-message-spec.js",
"new_path": "lib/shared/messages/create-thread-message-spec.js",
"diff": "@@ -22,7 +22,7 @@ export const createThreadMessageSpec: MessageSpec<\nRawCreateThreadMessageInfo,\nCreateThreadMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: CreateThreadMessageData): string {\nreturn JSON.stringify(data.initialThreadState);\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/delete-entry-message-spec.js",
"new_path": "lib/shared/messages/delete-entry-message-spec.js",
"diff": "@@ -23,7 +23,7 @@ export const deleteEntryMessageSpec: MessageSpec<\nRawDeleteEntryMessageInfo,\nDeleteEntryMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: DeleteEntryMessageData): string {\nreturn JSON.stringify({\nentryID: data.entryID,\ndate: data.date,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/edit-entry-message-spec.js",
"new_path": "lib/shared/messages/edit-entry-message-spec.js",
"diff": "@@ -23,7 +23,7 @@ export const editEntryMessageSpec: MessageSpec<\nRawEditEntryMessageInfo,\nEditEntryMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: EditEntryMessageData): string {\nreturn JSON.stringify({\nentryID: data.entryID,\ndate: data.date,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/message-spec.js",
"new_path": "lib/shared/messages/message-spec.js",
"diff": "@@ -25,7 +25,7 @@ export type MessageTitleParam<Info> = {|\n|};\nexport type MessageSpec<Data, RawInfo, Info> = {|\n- +messageContent?: (data: Data) => string | null,\n+ +messageContent?: (data: Data) => string,\n+messageTitle: (param: MessageTitleParam<Info>) => string,\n+rawMessageInfoFromRow?: (\nrow: Object,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/multimedia-message-spec.js",
"new_path": "lib/shared/messages/multimedia-message-spec.js",
"diff": "@@ -40,7 +40,7 @@ export const multimediaMessageSpec: MessageSpec<\nRawMediaMessageInfo | RawImagesMessageInfo,\nMediaMessageInfo | ImagesMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: MediaMessageData | ImagesMessageData): string {\nconst mediaIDs = data.media.map((media) => parseInt(media.id, 10));\nreturn JSON.stringify(mediaIDs);\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/remove-members-message-spec.js",
"new_path": "lib/shared/messages/remove-members-message-spec.js",
"diff": "@@ -22,7 +22,7 @@ export const removeMembersMessageSpec: MessageSpec<\nRawRemoveMembersMessageInfo,\nRemoveMembersMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: RemoveMembersMessageData): string {\nreturn JSON.stringify(data.removedUserIDs);\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/restore-entry-message-spec.js",
"new_path": "lib/shared/messages/restore-entry-message-spec.js",
"diff": "@@ -23,7 +23,7 @@ export const restoreEntryMessageSpec: MessageSpec<\nRawRestoreEntryMessageInfo,\nRestoreEntryMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: RestoreEntryMessageData): string {\nreturn JSON.stringify({\nentryID: data.entryID,\ndate: data.date,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/sidebar-source-message-spec.js",
"new_path": "lib/shared/messages/sidebar-source-message-spec.js",
"diff": "@@ -17,7 +17,7 @@ export const sidebarSourceMessageSpec: MessageSpec<\nRawSidebarSourceMessageInfo,\nSidebarSourceMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: SidebarSourceMessageData): string {\nconst sourceMessageID = data.sourceMessage?.id;\ninvariant(sourceMessageID, 'Source message id should be set');\nreturn JSON.stringify({\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/text-message-spec.js",
"new_path": "lib/shared/messages/text-message-spec.js",
"diff": "@@ -57,7 +57,7 @@ export const textMessageSpec: MessageSpec<\nRawTextMessageInfo,\nTextMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: TextMessageData): string {\nreturn data.text;\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/update-relationship-message-spec.js",
"new_path": "lib/shared/messages/update-relationship-message-spec.js",
"diff": "@@ -23,7 +23,7 @@ export const updateRelationshipMessageSpec: MessageSpec<\nRawUpdateRelationshipMessageInfo,\nUpdateRelationshipMessageInfo,\n> = Object.freeze({\n- messageContent(data) {\n+ messageContent(data: UpdateRelationshipMessageData): string {\nreturn JSON.stringify({\noperation: data.operation,\ntargetID: data.targetID,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add explicit type to messageContent functions
Summary: It appears that flow has some issues in determining the type of parameters inside spec functions. This is the first diff which adds explicit type annotations.
Test Plan: Flow
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D758 |
129,191 | 22.02.2021 13:22:24 | -3,600 | 41ecb7298c075afa380b5dc107fd0deff6b097bf | [lib] Add explicit type to robotext functions
Test Plan: Flow
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/add-members-message-spec.js",
"new_path": "lib/shared/messages/add-members-message-spec.js",
"diff": "@@ -19,6 +19,7 @@ import type {\nCreateMessageInfoParams,\nMessageSpec,\nMessageTitleParam,\n+ RobotextParams,\n} from './message-spec';\nimport { joinResult } from './utils';\n@@ -88,7 +89,11 @@ export const addMembersMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator, params) {\n+ robotext(\n+ messageInfo: AddMembersMessageInfo,\n+ creator: string,\n+ params: RobotextParams,\n+ ): string {\nconst users = messageInfo.addedMembers;\ninvariant(users.length !== 0, 'added who??');\nconst addedUsersString = params.robotextForUsers(users);\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/change-role-message-spec.js",
"new_path": "lib/shared/messages/change-role-message-spec.js",
"diff": "@@ -19,6 +19,7 @@ import type {\nCreateMessageInfoParams,\nMessageSpec,\nMessageTitleParam,\n+ RobotextParams,\n} from './message-spec';\nimport { joinResult } from './utils';\n@@ -92,7 +93,11 @@ export const changeRoleMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator, params) {\n+ robotext(\n+ messageInfo: ChangeRoleMessageInfo,\n+ creator: string,\n+ params: RobotextParams,\n+ ): string {\nconst users = messageInfo.members;\ninvariant(users.length !== 0, 'changed whose role??');\nconst usersString = params.robotextForUsers(users);\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/change-settings-message-spec.js",
"new_path": "lib/shared/messages/change-settings-message-spec.js",
"diff": "@@ -16,7 +16,11 @@ import {\nremoveCreatorAsViewer,\n} from '../message-utils';\nimport { threadLabel } from '../thread-utils';\n-import type { MessageSpec, MessageTitleParam } from './message-spec';\n+import type {\n+ MessageSpec,\n+ MessageTitleParam,\n+ RobotextParams,\n+} from './message-spec';\nimport { joinResult } from './utils';\nexport const changeSettingsMessageSpec: MessageSpec<\n@@ -80,7 +84,11 @@ export const changeSettingsMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator, params) {\n+ robotext(\n+ messageInfo: ChangeSettingsMessageInfo,\n+ creator: string,\n+ params: RobotextParams,\n+ ): string {\nlet value;\nif (messageInfo.field === 'color') {\nvalue = `<#${messageInfo.value}|c${messageInfo.threadID}>`;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-entry-message-spec.js",
"new_path": "lib/shared/messages/create-entry-message-spec.js",
"diff": "@@ -83,7 +83,7 @@ export const createEntryMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator) {\n+ robotext(messageInfo: CreateEntryMessageInfo, creator: string): string {\nconst date = prettyDate(messageInfo.date);\nreturn (\n`${creator} created an event scheduled for ${date}: ` +\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sidebar-message-spec.js",
"new_path": "lib/shared/messages/create-sidebar-message-spec.js",
"diff": "@@ -20,6 +20,7 @@ import type {\nCreateMessageInfoParams,\nMessageSpec,\nMessageTitleParam,\n+ RobotextParams,\n} from './message-spec';\nimport { assertSingleMessageInfo } from './utils';\n@@ -123,7 +124,11 @@ export const createSidebarMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator, params) {\n+ robotext(\n+ messageInfo: CreateSidebarMessageInfo,\n+ creator: string,\n+ params: RobotextParams,\n+ ): string {\nlet text = `started ${params.encodedThreadEntity(\nmessageInfo.threadID,\n`this sidebar`,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sub-thread-message-spec.js",
"new_path": "lib/shared/messages/create-sub-thread-message-spec.js",
"diff": "@@ -88,7 +88,7 @@ export const createSubThreadMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator) {\n+ robotext(messageInfo: CreateSubthreadMessageInfo, creator: string): string {\nconst childName = messageInfo.childThreadInfo.name;\nconst childNoun =\nmessageInfo.childThreadInfo.type === threadTypes.SIDEBAR\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-thread-message-spec.js",
"new_path": "lib/shared/messages/create-thread-message-spec.js",
"diff": "@@ -19,6 +19,7 @@ import type {\nCreateMessageInfoParams,\nMessageSpec,\nMessageTitleParam,\n+ RobotextParams,\n} from './message-spec';\nimport { assertSingleMessageInfo } from './utils';\n@@ -106,7 +107,11 @@ export const createThreadMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator, params) {\n+ robotext(\n+ messageInfo: CreateThreadMessageInfo,\n+ creator: string,\n+ params: RobotextParams,\n+ ): string {\nlet text = `created ${params.encodedThreadEntity(\nmessageInfo.threadID,\n`this thread`,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/delete-entry-message-spec.js",
"new_path": "lib/shared/messages/delete-entry-message-spec.js",
"diff": "@@ -83,7 +83,7 @@ export const deleteEntryMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator) {\n+ robotext(messageInfo: DeleteEntryMessageInfo, creator: string): string {\nconst date = prettyDate(messageInfo.date);\nreturn (\n`${creator} deleted an event scheduled for ${date}: ` +\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/edit-entry-message-spec.js",
"new_path": "lib/shared/messages/edit-entry-message-spec.js",
"diff": "@@ -83,7 +83,7 @@ export const editEntryMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator) {\n+ robotext(messageInfo: EditEntryMessageInfo, creator: string): string {\nconst date = prettyDate(messageInfo.date);\nreturn (\n`${creator} updated the text of an event scheduled for ` +\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/join-thread-message-spec.js",
"new_path": "lib/shared/messages/join-thread-message-spec.js",
"diff": "@@ -17,7 +17,11 @@ import {\nremoveCreatorAsViewer,\n} from '../message-utils';\nimport { stringForUser } from '../user-utils';\n-import type { MessageSpec, MessageTitleParam } from './message-spec';\n+import type {\n+ MessageSpec,\n+ MessageTitleParam,\n+ RobotextParams,\n+} from './message-spec';\nimport { joinResult } from './utils';\nexport const joinThreadMessageSpec: MessageSpec<\n@@ -69,7 +73,11 @@ export const joinThreadMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator, params) {\n+ robotext(\n+ messageInfo: JoinThreadMessageInfo,\n+ creator: string,\n+ params: RobotextParams,\n+ ): string {\nreturn (\n`${creator} joined ` +\nparams.encodedThreadEntity(messageInfo.threadID, 'this thread')\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/leave-thread-message-spec.js",
"new_path": "lib/shared/messages/leave-thread-message-spec.js",
"diff": "@@ -17,7 +17,11 @@ import {\nremoveCreatorAsViewer,\n} from '../message-utils';\nimport { stringForUser } from '../user-utils';\n-import type { MessageSpec, MessageTitleParam } from './message-spec';\n+import type {\n+ MessageSpec,\n+ MessageTitleParam,\n+ RobotextParams,\n+} from './message-spec';\nimport { joinResult } from './utils';\nexport const leaveThreadMessageSpec: MessageSpec<\n@@ -69,7 +73,11 @@ export const leaveThreadMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator, params) {\n+ robotext(\n+ messageInfo: LeaveThreadMessageInfo,\n+ creator: string,\n+ params: RobotextParams,\n+ ): string {\nreturn (\n`${creator} left ` +\nparams.encodedThreadEntity(messageInfo.threadID, 'this thread')\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/message-spec.js",
"new_path": "lib/shared/messages/message-spec.js",
"diff": "@@ -41,6 +41,13 @@ export type CreateMessageInfoParams = {|\n) => RelativeUserInfo[],\n|};\n+export type RobotextParams = {|\n+ +encodedThreadEntity: (threadID: string, text: string) => string,\n+ +robotextForUsers: (users: RelativeUserInfo[]) => string,\n+ +robotextForUser: (user: RelativeUserInfo) => string,\n+ +threadInfo: ThreadInfo,\n+|};\n+\nexport type MessageSpec<Data, RawInfo, Info> = {|\n+messageContent?: (data: Data) => string,\n+messageTitle: (param: MessageTitleParam<Info>) => string,\n@@ -57,12 +64,7 @@ export type MessageSpec<Data, RawInfo, Info> = {|\n+robotext?: (\nmessageInfo: Info,\ncreator: string,\n- params: {|\n- +encodedThreadEntity: (threadID: string, text: string) => string,\n- +robotextForUsers: (users: RelativeUserInfo[]) => string,\n- +robotextForUser: (user: RelativeUserInfo) => string,\n- +threadInfo: ThreadInfo,\n- |},\n+ params: RobotextParams,\n) => string,\n+shimUnsupportedMessageInfo?: (\nrawMessageInfo: RawInfo,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/remove-members-message-spec.js",
"new_path": "lib/shared/messages/remove-members-message-spec.js",
"diff": "@@ -19,6 +19,7 @@ import type {\nCreateMessageInfoParams,\nMessageSpec,\nMessageTitleParam,\n+ RobotextParams,\n} from './message-spec';\nimport { joinResult } from './utils';\n@@ -88,7 +89,11 @@ export const removeMembersMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator, params) {\n+ robotext(\n+ messageInfo: RemoveMembersMessageInfo,\n+ creator: string,\n+ params: RobotextParams,\n+ ): string {\nconst users = messageInfo.removedMembers;\ninvariant(users.length !== 0, 'removed who??');\nconst removedUsersString = params.robotextForUsers(users);\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/restore-entry-message-spec.js",
"new_path": "lib/shared/messages/restore-entry-message-spec.js",
"diff": "@@ -83,7 +83,7 @@ export const restoreEntryMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator) {\n+ robotext(messageInfo: RestoreEntryMessageInfo, creator: string): string {\nconst date = prettyDate(messageInfo.date);\nreturn (\n`${creator} restored an event scheduled for ${date}: ` +\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/unsupported-message-spec.js",
"new_path": "lib/shared/messages/unsupported-message-spec.js",
"diff": "@@ -48,7 +48,7 @@ export const unsupportedMessageSpec: MessageSpec<\n);\n},\n- robotext(messageInfo, creator) {\n+ robotext(messageInfo: UnsupportedMessageInfo, creator: string): string {\nif (messageInfo.dontPrefixCreator) {\nreturn messageInfo.robotext;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/update-relationship-message-spec.js",
"new_path": "lib/shared/messages/update-relationship-message-spec.js",
"diff": "@@ -20,6 +20,7 @@ import type {\nCreateMessageInfoParams,\nMessageSpec,\nMessageTitleParam,\n+ RobotextParams,\n} from './message-spec';\nimport { assertSingleMessageInfo } from './utils';\n@@ -93,7 +94,11 @@ export const updateRelationshipMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- robotext(messageInfo, creator, params) {\n+ robotext(\n+ messageInfo: UpdateRelationshipMessageInfo,\n+ creator: string,\n+ params: RobotextParams,\n+ ): string {\nconst target = params.robotextForUser(messageInfo.target);\nif (messageInfo.operation === 'request_sent') {\nreturn `${creator} sent ${target} a friend request`;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add explicit type to robotext functions
Test Plan: Flow
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D762 |
129,191 | 22.02.2021 13:31:31 | -3,600 | 7169a31b6abb8bfb5d73c48d783bc096eb4b5f74 | [lib] Add explicit type to shimUnsupportedMessageInfo functions
Test Plan: Flow
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sidebar-message-spec.js",
"new_path": "lib/shared/messages/create-sidebar-message-spec.js",
"diff": "import invariant from 'invariant';\n+import type { PlatformDetails } from '../../types/device-types';\nimport { messageTypes } from '../../types/message-types';\nimport type {\nCreateSidebarMessageData,\nCreateSidebarMessageInfo,\nRawCreateSidebarMessageInfo,\n} from '../../types/messages/create-sidebar';\n+import type { RawUnsupportedMessageInfo } from '../../types/messages/unsupported';\nimport type { RelativeUserInfo } from '../../types/user-types';\nimport {\nrobotextToRawString,\n@@ -143,7 +145,10 @@ export const createSidebarMessageSpec: MessageSpec<\nreturn `${creator} ${text}`;\n},\n- shimUnsupportedMessageInfo(rawMessageInfo, platformDetails) {\n+ shimUnsupportedMessageInfo(\n+ rawMessageInfo: RawCreateSidebarMessageInfo,\n+ platformDetails: ?PlatformDetails,\n+ ): RawCreateSidebarMessageInfo | RawUnsupportedMessageInfo {\n// TODO determine min code version\nif (hasMinCodeVersion(platformDetails, 75)) {\nreturn rawMessageInfo;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/multimedia-message-spec.js",
"new_path": "lib/shared/messages/multimedia-message-spec.js",
"diff": "@@ -24,6 +24,7 @@ import type {\nMediaMessageInfo,\nRawMediaMessageInfo,\n} from '../../types/messages/media';\n+import type { RawUnsupportedMessageInfo } from '../../types/messages/unsupported';\nimport type { RelativeUserInfo } from '../../types/user-types';\nimport {\ncreateMediaMessageInfo,\n@@ -126,7 +127,10 @@ export const multimediaMessageSpec: MessageSpec<\n}\n},\n- shimUnsupportedMessageInfo(rawMessageInfo, platformDetails) {\n+ shimUnsupportedMessageInfo(\n+ rawMessageInfo: RawMediaMessageInfo | RawImagesMessageInfo,\n+ platformDetails: ?PlatformDetails,\n+ ): RawMediaMessageInfo | RawImagesMessageInfo | RawUnsupportedMessageInfo {\nif (rawMessageInfo.type === messageTypes.IMAGES) {\nconst shimmedRawMessageInfo = shimMediaMessageInfo(\nrawMessageInfo,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/sidebar-source-message-spec.js",
"new_path": "lib/shared/messages/sidebar-source-message-spec.js",
"diff": "import invariant from 'invariant';\n+import type { PlatformDetails } from '../../types/device-types';\nimport type {\nRawSidebarSourceMessageInfo,\nSidebarSourceMessageData,\nSidebarSourceMessageInfo,\n} from '../../types/message-types';\nimport { messageTypes } from '../../types/message-types';\n+import type { RawUnsupportedMessageInfo } from '../../types/messages/unsupported';\nimport type { RelativeUserInfo } from '../../types/user-types';\nimport { hasMinCodeVersion } from '../version-utils';\nimport type {\n@@ -92,7 +94,10 @@ export const sidebarSourceMessageSpec: MessageSpec<\nreturn { ...messageData, id };\n},\n- shimUnsupportedMessageInfo(rawMessageInfo, platformDetails) {\n+ shimUnsupportedMessageInfo(\n+ rawMessageInfo: RawSidebarSourceMessageInfo,\n+ platformDetails: ?PlatformDetails,\n+ ): RawSidebarSourceMessageInfo | RawUnsupportedMessageInfo {\n// TODO determine min code version\nif (\nhasMinCodeVersion(platformDetails, 75) &&\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/update-relationship-message-spec.js",
"new_path": "lib/shared/messages/update-relationship-message-spec.js",
"diff": "import invariant from 'invariant';\n+import type { PlatformDetails } from '../../types/device-types';\nimport { messageTypes } from '../../types/message-types';\n+import type { RawUnsupportedMessageInfo } from '../../types/messages/unsupported';\nimport type {\nRawUpdateRelationshipMessageInfo,\nUpdateRelationshipMessageData,\n@@ -115,7 +117,10 @@ export const updateRelationshipMessageSpec: MessageSpec<\n);\n},\n- shimUnsupportedMessageInfo(rawMessageInfo, platformDetails) {\n+ shimUnsupportedMessageInfo(\n+ rawMessageInfo: RawUpdateRelationshipMessageInfo,\n+ platformDetails: ?PlatformDetails,\n+ ): RawUpdateRelationshipMessageInfo | RawUnsupportedMessageInfo {\nif (hasMinCodeVersion(platformDetails, 71)) {\nreturn rawMessageInfo;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add explicit type to shimUnsupportedMessageInfo functions
Test Plan: Flow
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D763 |
129,191 | 22.02.2021 13:36:51 | -3,600 | 0952b48acffd677d338f61e24b741c3c37f4000c | [lib] Add explicit type to unshimMessageInfo functions
Test Plan: Flow
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sidebar-message-spec.js",
"new_path": "lib/shared/messages/create-sidebar-message-spec.js",
"diff": "@@ -166,7 +166,9 @@ export const createSidebarMessageSpec: MessageSpec<\n};\n},\n- unshimMessageInfo(unwrapped) {\n+ unshimMessageInfo(\n+ unwrapped: RawCreateSidebarMessageInfo,\n+ ): RawCreateSidebarMessageInfo {\nreturn unwrapped;\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/multimedia-message-spec.js",
"new_path": "lib/shared/messages/multimedia-message-spec.js",
"diff": "@@ -9,7 +9,10 @@ import {\n} from '../../media/media-utils';\nimport type { PlatformDetails } from '../../types/device-types';\nimport type { Media, Video, Image } from '../../types/media-types';\n-import type { RawMultimediaMessageInfo } from '../../types/message-types';\n+import type {\n+ RawMessageInfo,\n+ RawMultimediaMessageInfo,\n+} from '../../types/message-types';\nimport {\nmessageTypes,\ntype MultimediaMessageInfo,\n@@ -173,7 +176,10 @@ export const multimediaMessageSpec: MessageSpec<\n}\n},\n- unshimMessageInfo(unwrapped, messageInfo) {\n+ unshimMessageInfo(\n+ unwrapped: RawMediaMessageInfo | RawImagesMessageInfo,\n+ messageInfo: RawMessageInfo,\n+ ): ?RawMessageInfo {\nif (unwrapped.type === messageTypes.IMAGES) {\nreturn {\n...unwrapped,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/sidebar-source-message-spec.js",
"new_path": "lib/shared/messages/sidebar-source-message-spec.js",
"diff": "@@ -119,7 +119,9 @@ export const sidebarSourceMessageSpec: MessageSpec<\n};\n},\n- unshimMessageInfo(unwrapped) {\n+ unshimMessageInfo(\n+ unwrapped: RawSidebarSourceMessageInfo,\n+ ): RawSidebarSourceMessageInfo {\nreturn unwrapped;\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/update-relationship-message-spec.js",
"new_path": "lib/shared/messages/update-relationship-message-spec.js",
"diff": "@@ -137,7 +137,9 @@ export const updateRelationshipMessageSpec: MessageSpec<\n};\n},\n- unshimMessageInfo(unwrapped) {\n+ unshimMessageInfo(\n+ unwrapped: RawUpdateRelationshipMessageInfo,\n+ ): RawUpdateRelationshipMessageInfo {\nreturn unwrapped;\n},\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add explicit type to unshimMessageInfo functions
Test Plan: Flow
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D764 |
129,191 | 22.02.2021 13:54:24 | -3,600 | dbc5ec8d23a66d8a11cd1c6bcaf6c821576ff9c3 | [lib] Add explicit type to notificationCollapseKey functions
Test Plan: Flow
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/add-members-message-spec.js",
"new_path": "lib/shared/messages/add-members-message-spec.js",
"diff": "@@ -140,7 +140,7 @@ export const addMembersMessageSpec: MessageSpec<\n};\n},\n- notificationCollapseKey(rawMessageInfo) {\n+ notificationCollapseKey(rawMessageInfo: RawAddMembersMessageInfo): string {\nreturn joinResult(\nrawMessageInfo.type,\nrawMessageInfo.threadID,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/change-role-message-spec.js",
"new_path": "lib/shared/messages/change-role-message-spec.js",
"diff": "@@ -148,7 +148,7 @@ export const changeRoleMessageSpec: MessageSpec<\n};\n},\n- notificationCollapseKey(rawMessageInfo) {\n+ notificationCollapseKey(rawMessageInfo: RawChangeRoleMessageInfo): string {\nreturn joinResult(\nrawMessageInfo.type,\nrawMessageInfo.threadID,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/change-settings-message-spec.js",
"new_path": "lib/shared/messages/change-settings-message-spec.js",
"diff": "@@ -134,7 +134,9 @@ export const changeSettingsMessageSpec: MessageSpec<\n};\n},\n- notificationCollapseKey(rawMessageInfo) {\n+ notificationCollapseKey(\n+ rawMessageInfo: RawChangeSettingsMessageInfo,\n+ ): string {\nreturn joinResult(\nrawMessageInfo.type,\nrawMessageInfo.threadID,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-entry-message-spec.js",
"new_path": "lib/shared/messages/create-entry-message-spec.js",
"diff": "@@ -143,7 +143,7 @@ export const createEntryMessageSpec: MessageSpec<\n};\n},\n- notificationCollapseKey(rawMessageInfo) {\n+ notificationCollapseKey(rawMessageInfo: RawCreateEntryMessageInfo): string {\nreturn joinResult(rawMessageInfo.creatorID, rawMessageInfo.entryID);\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/edit-entry-message-spec.js",
"new_path": "lib/shared/messages/edit-entry-message-spec.js",
"diff": "@@ -143,7 +143,7 @@ export const editEntryMessageSpec: MessageSpec<\n};\n},\n- notificationCollapseKey(rawMessageInfo) {\n+ notificationCollapseKey(rawMessageInfo: RawEditEntryMessageInfo): string {\nreturn joinResult(rawMessageInfo.creatorID, rawMessageInfo.entryID);\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/join-thread-message-spec.js",
"new_path": "lib/shared/messages/join-thread-message-spec.js",
"diff": "@@ -113,7 +113,7 @@ export const joinThreadMessageSpec: MessageSpec<\n};\n},\n- notificationCollapseKey(rawMessageInfo) {\n+ notificationCollapseKey(rawMessageInfo: RawJoinThreadMessageInfo): string {\nreturn joinResult(rawMessageInfo.type, rawMessageInfo.threadID);\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/leave-thread-message-spec.js",
"new_path": "lib/shared/messages/leave-thread-message-spec.js",
"diff": "@@ -113,7 +113,7 @@ export const leaveThreadMessageSpec: MessageSpec<\n};\n},\n- notificationCollapseKey(rawMessageInfo) {\n+ notificationCollapseKey(rawMessageInfo: RawLeaveThreadMessageInfo): string {\nreturn joinResult(rawMessageInfo.type, rawMessageInfo.threadID);\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/message-spec.js",
"new_path": "lib/shared/messages/message-spec.js",
"diff": "@@ -98,7 +98,7 @@ export type MessageSpec<Data, RawInfo, Info> = {|\nthreadInfo: ThreadInfo,\nparams: NotificationTextsParams,\n) => NotifTexts,\n- +notificationCollapseKey?: (rawMessageInfo: RawInfo) => ?string,\n+ +notificationCollapseKey?: (rawMessageInfo: RawInfo) => string,\n+generatesNotifs: boolean,\n+userIDs?: (rawMessageInfo: RawInfo) => $ReadOnlyArray<string>,\n+startsThread?: boolean,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/multimedia-message-spec.js",
"new_path": "lib/shared/messages/multimedia-message-spec.js",
"diff": "@@ -248,7 +248,9 @@ export const multimediaMessageSpec: MessageSpec<\n};\n},\n- notificationCollapseKey(rawMessageInfo) {\n+ notificationCollapseKey(\n+ rawMessageInfo: RawMediaMessageInfo | RawImagesMessageInfo,\n+ ): string {\n// We use the legacy constant here to collapse both types into one\nreturn joinResult(\nmessageTypes.IMAGES,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/remove-members-message-spec.js",
"new_path": "lib/shared/messages/remove-members-message-spec.js",
"diff": "@@ -140,7 +140,7 @@ export const removeMembersMessageSpec: MessageSpec<\n};\n},\n- notificationCollapseKey(rawMessageInfo) {\n+ notificationCollapseKey(rawMessageInfo: RawRemoveMembersMessageInfo): string {\nreturn joinResult(\nrawMessageInfo.type,\nrawMessageInfo.threadID,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add explicit type to notificationCollapseKey functions
Test Plan: Flow
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D766 |
129,191 | 22.02.2021 13:57:50 | -3,600 | 42f9ded8798448316d8f26702e7d16100064f350 | [lib] Add explicit type to userIDs functions
Test Plan: Flow
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/add-members-message-spec.js",
"new_path": "lib/shared/messages/add-members-message-spec.js",
"diff": "@@ -150,7 +150,7 @@ export const addMembersMessageSpec: MessageSpec<\ngeneratesNotifs: false,\n- userIDs(rawMessageInfo) {\n+ userIDs(rawMessageInfo: RawAddMembersMessageInfo): $ReadOnlyArray<string> {\nreturn rawMessageInfo.addedUserIDs;\n},\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sidebar-message-spec.js",
"new_path": "lib/shared/messages/create-sidebar-message-spec.js",
"diff": "@@ -204,7 +204,7 @@ export const createSidebarMessageSpec: MessageSpec<\ngeneratesNotifs: true,\n- userIDs(rawMessageInfo) {\n+ userIDs(rawMessageInfo: RawCreateSidebarMessageInfo): $ReadOnlyArray<string> {\nreturn rawMessageInfo.initialThreadState.memberIDs;\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-thread-message-spec.js",
"new_path": "lib/shared/messages/create-thread-message-spec.js",
"diff": "@@ -175,7 +175,7 @@ export const createThreadMessageSpec: MessageSpec<\ngeneratesNotifs: true,\n- userIDs(rawMessageInfo) {\n+ userIDs(rawMessageInfo: RawCreateThreadMessageInfo): $ReadOnlyArray<string> {\nreturn rawMessageInfo.initialThreadState.memberIDs;\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/remove-members-message-spec.js",
"new_path": "lib/shared/messages/remove-members-message-spec.js",
"diff": "@@ -150,7 +150,7 @@ export const removeMembersMessageSpec: MessageSpec<\ngeneratesNotifs: false,\n- userIDs(rawMessageInfo) {\n+ userIDs(rawMessageInfo: RawRemoveMembersMessageInfo): $ReadOnlyArray<string> {\nreturn rawMessageInfo.removedUserIDs;\n},\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add explicit type to userIDs functions
Test Plan: Flow
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D767 |
129,191 | 22.02.2021 14:00:25 | -3,600 | c193c6c824b65cb4afe4dfd953acd49859de88b8 | [lib] Add explicit type to threadIDs functions
Test Plan: Flow
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sidebar-message-spec.js",
"new_path": "lib/shared/messages/create-sidebar-message-spec.js",
"diff": "@@ -208,7 +208,9 @@ export const createSidebarMessageSpec: MessageSpec<\nreturn rawMessageInfo.initialThreadState.memberIDs;\n},\n- threadIDs(rawMessageInfo) {\n+ threadIDs(\n+ rawMessageInfo: RawCreateSidebarMessageInfo,\n+ ): $ReadOnlyArray<string> {\nconst { parentThreadID } = rawMessageInfo.initialThreadState;\nreturn [parentThreadID];\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sub-thread-message-spec.js",
"new_path": "lib/shared/messages/create-sub-thread-message-spec.js",
"diff": "@@ -132,7 +132,9 @@ export const createSubThreadMessageSpec: MessageSpec<\ngeneratesNotifs: true,\n- threadIDs(rawMessageInfo) {\n+ threadIDs(\n+ rawMessageInfo: RawCreateSubthreadMessageInfo,\n+ ): $ReadOnlyArray<string> {\nreturn [rawMessageInfo.childThreadID];\n},\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-thread-message-spec.js",
"new_path": "lib/shared/messages/create-thread-message-spec.js",
"diff": "@@ -181,7 +181,9 @@ export const createThreadMessageSpec: MessageSpec<\nstartsThread: true,\n- threadIDs(rawMessageInfo) {\n+ threadIDs(\n+ rawMessageInfo: RawCreateThreadMessageInfo,\n+ ): $ReadOnlyArray<string> {\nconst { parentThreadID } = rawMessageInfo.initialThreadState;\nreturn parentThreadID ? [parentThreadID] : [];\n},\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add explicit type to threadIDs functions
Test Plan: Flow
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D768 |
129,208 | 18.02.2021 12:57:04 | 18,000 | bd81a863ad9451d04f349545ea494839a692637f | [native] Use hook instead of connect function and HOC in MessagePreview
Summary: Switched to hooks instead of the connect function the MessagePreview class.
Test Plan: Made sure that message previews still are displayed properly.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-preview.react.js",
"new_path": "native/chat/message-preview.react.js",
"diff": "@@ -14,53 +14,44 @@ import {\ntype RobotextMessageInfo,\n} from 'lib/types/message-types';\nimport { type ThreadInfo } from 'lib/types/thread-types';\n-import { connect } from 'lib/utils/redux-utils';\nimport { SingleLine } from '../components/single-line.react';\nimport { getDefaultTextMessageRules } from '../markdown/rules.react';\n-import type { AppState } from '../redux/redux-setup';\n-import { styleSelector } from '../themes/colors';\n+import { useStyles } from '../themes/colors';\ntype Props = {|\n+messageInfo: MessageInfo,\n+threadInfo: ThreadInfo,\n- // Redux state\n- +styles: typeof styles,\n|};\n-class MessagePreview extends React.PureComponent<Props> {\n- render() {\n+function MessagePreview(props: Props) {\n+ const styles = useStyles(unboundStyles);\nconst messageInfo: ComposableMessageInfo | RobotextMessageInfo =\n- this.props.messageInfo.type === messageTypes.SIDEBAR_SOURCE\n- ? this.props.messageInfo.sourceMessage\n- : this.props.messageInfo;\n- const unreadStyle = this.props.threadInfo.currentUser.unread\n- ? this.props.styles.unread\n+ props.messageInfo.type === messageTypes.SIDEBAR_SOURCE\n+ ? props.messageInfo.sourceMessage\n+ : props.messageInfo;\n+ const unreadStyle = props.threadInfo.currentUser.unread\n+ ? styles.unread\n: null;\nconst messageTitle = getMessageTitle(\nmessageInfo,\n- this.props.threadInfo,\n+ props.threadInfo,\ngetDefaultTextMessageRules().simpleMarkdownRules,\n);\nif (messageInfo.type === messageTypes.TEXT) {\nlet usernameText = null;\nif (\n- threadIsGroupChat(this.props.threadInfo) ||\n- this.props.threadInfo.name !== '' ||\n+ threadIsGroupChat(props.threadInfo) ||\n+ props.threadInfo.name !== '' ||\nmessageInfo.creator.isViewer\n) {\nconst userString = stringForUser(messageInfo.creator);\nconst username = `${userString}: `;\nusernameText = (\n- <Text style={[this.props.styles.username, unreadStyle]}>\n- {username}\n- </Text>\n+ <Text style={[styles.username, unreadStyle]}>{username}</Text>\n);\n}\nreturn (\n- <Text\n- style={[this.props.styles.lastMessage, unreadStyle]}\n- numberOfLines={1}\n- >\n+ <Text style={[styles.lastMessage, unreadStyle]} numberOfLines={1}>\n{usernameText}\n{messageTitle}\n</Text>\n@@ -71,21 +62,14 @@ class MessagePreview extends React.PureComponent<Props> {\n'Sidebar source should not be handled here',\n);\nreturn (\n- <SingleLine\n- style={[\n- this.props.styles.lastMessage,\n- this.props.styles.preview,\n- unreadStyle,\n- ]}\n- >\n+ <SingleLine style={[styles.lastMessage, styles.preview, unreadStyle]}>\n{messageTitle}\n</SingleLine>\n);\n}\n}\n-}\n-const styles = {\n+const unboundStyles = {\nlastMessage: {\ncolor: 'listForegroundTertiaryLabel',\nflex: 1,\n@@ -102,8 +86,5 @@ const styles = {\ncolor: 'listForegroundQuaternaryLabel',\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(MessagePreview);\n+export default MessagePreview;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect function and HOC in MessagePreview
Summary: Switched to hooks instead of the connect function the MessagePreview class.
Test Plan: Made sure that message previews still are displayed properly.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D742 |
129,184 | 23.02.2021 20:30:57 | 28,800 | 69bf92bb114735cf665e8f3121461af738a5482c | [native] Rename MultimediaModal to ImageModal
Summary: NA
Test Plan: Everything seems to work as it did before.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message-multimedia.react.js",
"new_path": "native/chat/multimedia-message-multimedia.react.js",
"diff": "@@ -24,7 +24,7 @@ import {\nimport {\ntype NavigationRoute,\nVideoPlaybackModalRouteName,\n- MultimediaModalRouteName,\n+ ImageModalRouteName,\nMultimediaTooltipModalRouteName,\n} from '../navigation/route-names';\nimport { useSelector } from '../redux/redux-utils';\n@@ -96,7 +96,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nconst { visibleOverlays } = overlayContext;\nfor (let overlay of visibleOverlays) {\nif (\n- overlay.routeName === MultimediaModalRouteName &&\n+ overlay.routeName === ImageModalRouteName &&\noverlay.presentedFrom === props.route.key &&\noverlay.routeKey === MultimediaMessageMultimedia.getStableKey(props)\n) {\n@@ -202,7 +202,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nname:\nmediaInfo.type === 'video'\n? VideoPlaybackModalRouteName\n- : MultimediaModalRouteName,\n+ : ImageModalRouteName,\nkey: MultimediaMessageMultimedia.getStableKey(this.props),\nparams: {\npresentedFrom: this.props.route.key,\n"
},
{
"change_type": "RENAME",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/image-view-modal.react.js",
"diff": "@@ -136,7 +136,7 @@ function runDecay(\n];\n}\n-export type MultimediaModalParams = {|\n+export type ImageModalParams = {|\npresentedFrom: string,\nmediaInfo: MediaInfo,\ninitialCoordinates: LayoutCoordinates,\n@@ -150,8 +150,8 @@ type TouchableOpacityInstance = React.AbstractComponent<\n>;\ntype BaseProps = {|\n- +navigation: AppNavigationProp<'MultimediaModal'>,\n- +route: NavigationRoute<'MultimediaModal'>,\n+ +navigation: AppNavigationProp<'ImageModal'>,\n+ +route: NavigationRoute<'ImageModal'>,\n|};\ntype Props = {|\n...BaseProps,\n@@ -164,7 +164,7 @@ type State = {|\n+closeButtonEnabled: boolean,\n+actionLinksEnabled: boolean,\n|};\n-class MultimediaModal extends React.PureComponent<Props, State> {\n+class ImageModal extends React.PureComponent<Props, State> {\nstate: State = {\ncloseButtonEnabled: true,\nactionLinksEnabled: true,\n@@ -236,7 +236,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n);\nconst { overlayContext } = props;\n- invariant(overlayContext, 'MultimediaModal should have OverlayContext');\n+ invariant(overlayContext, 'ImageModal should have OverlayContext');\nconst navigationProgress = overlayContext.position;\n// The inputs we receive from PanGestureHandler\n@@ -914,13 +914,13 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n}\ncomponentDidMount() {\n- if (MultimediaModal.isActive(this.props)) {\n+ if (ImageModal.isActive(this.props)) {\nOrientation.unlockAllOrientations();\n}\n}\ncomponentWillUnmount() {\n- if (MultimediaModal.isActive(this.props)) {\n+ if (ImageModal.isActive(this.props)) {\nOrientation.lockToPortrait();\n}\n}\n@@ -930,8 +930,8 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nthis.updateDimensions();\n}\n- const isActive = MultimediaModal.isActive(this.props);\n- const wasActive = MultimediaModal.isActive(prevProps);\n+ const isActive = ImageModal.isActive(this.props);\n+ const wasActive = ImageModal.isActive(prevProps);\nif (isActive && !wasActive) {\nOrientation.unlockAllOrientations();\n} else if (!isActive && wasActive) {\n@@ -995,7 +995,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nstatic isActive(props) {\nconst { overlayContext } = props;\n- invariant(overlayContext, 'MultimediaModal should have OverlayContext');\n+ invariant(overlayContext, 'ImageModal should have OverlayContext');\nreturn !overlayContext.isDismissing;\n}\n@@ -1006,7 +1006,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nconst bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n// margin will clip, but padding won't\n- const verticalStyle = MultimediaModal.isActive(this.props)\n+ const verticalStyle = ImageModal.isActive(this.props)\n? { paddingTop: top, paddingBottom: bottom }\n: { marginTop: top, marginBottom: bottom };\nreturn [styles.contentContainer, verticalStyle];\n@@ -1014,7 +1014,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nrender() {\nconst { mediaInfo } = this.props.route.params;\n- const statusBar = MultimediaModal.isActive(this.props) ? (\n+ const statusBar = ImageModal.isActive(this.props) ? (\n<ConnectedStatusBar hidden />\n) : null;\nconst backdropStyle = { opacity: this.backdropOpacity };\n@@ -1223,13 +1223,13 @@ const styles = StyleSheet.create({\n},\n});\n-export default React.memo<BaseProps>(function ConnectedMultimediaModal(\n+export default React.memo<BaseProps>(function ConnectedImageModal(\nprops: BaseProps,\n) {\nconst dimensions = useSelector(derivedDimensionsInfoSelector);\nconst overlayContext = React.useContext(OverlayContext);\nreturn (\n- <MultimediaModal\n+ <ImageModal\n{...props}\ndimensions={dimensions}\noverlayContext={overlayContext}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/app-navigator.react.js",
"new_path": "native/navigation/app-navigator.react.js",
"diff": "@@ -17,7 +17,7 @@ import ThreadSettingsMemberTooltipModal from '../chat/settings/thread-settings-m\nimport { TextMessageTooltipModal } from '../chat/text-message-tooltip-modal.react';\nimport KeyboardStateContainer from '../keyboard/keyboard-state-container.react';\nimport CameraModal from '../media/camera-modal.react';\n-import MultimediaModal from '../media/multimedia-modal.react';\n+import ImageModal from '../media/image-view-modal.react';\nimport VideoPlaybackModal from '../media/video-playback-modal.react';\nimport More from '../more/more.react';\nimport RelationshipListItemTooltipModal from '../more/relationship-list-item-tooltip-modal.react';\n@@ -35,7 +35,7 @@ import {\nChatRouteName,\nMoreRouteName,\nTabNavigatorRouteName,\n- MultimediaModalRouteName,\n+ ImageModalRouteName,\nMultimediaTooltipModalRouteName,\nActionResultModalRouteName,\nTextMessageTooltipModalRouteName,\n@@ -168,10 +168,7 @@ function AppNavigator(props: AppNavigatorProps) {\n<KeyboardStateContainer>\n<App.Navigator>\n<App.Screen name={TabNavigatorRouteName} component={TabNavigator} />\n- <App.Screen\n- name={MultimediaModalRouteName}\n- component={MultimediaModal}\n- />\n+ <App.Screen name={ImageModalRouteName} component={ImageModal} />\n<App.Screen\nname={MultimediaTooltipModalRouteName}\ncomponent={MultimediaTooltipModal}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/route-names.js",
"new_path": "native/navigation/route-names.js",
"diff": "@@ -18,7 +18,7 @@ import type { ThreadSettingsParams } from '../chat/settings/thread-settings.reac\nimport type { SidebarListModalParams } from '../chat/sidebar-list-modal.react';\nimport type { TextMessageTooltipModalParams } from '../chat/text-message-tooltip-modal.react';\nimport type { CameraModalParams } from '../media/camera-modal.react';\n-import type { MultimediaModalParams } from '../media/multimedia-modal.react';\n+import type { ImageModalParams } from '../media/image-view-modal.react';\nimport type { VideoPlaybackModalParams } from '../media/video-playback-modal.react';\nimport type { CustomServerModalParams } from '../more/custom-server-modal.react';\nimport type { RelationshipListItemTooltipModalParams } from '../more/relationship-list-item-tooltip-modal.react';\n@@ -52,7 +52,7 @@ export const AddUsersModalRouteName = 'AddUsersModal';\nexport const CustomServerModalRouteName = 'CustomServerModal';\nexport const ColorPickerModalRouteName = 'ColorPickerModal';\nexport const ComposeSubthreadModalRouteName = 'ComposeSubthreadModal';\n-export const MultimediaModalRouteName = 'MultimediaModal';\n+export const ImageModalRouteName = 'ImageModal';\nexport const MultimediaTooltipModalRouteName = 'MultimediaTooltipModal';\nexport const ActionResultModalRouteName = 'ActionResultModal';\nexport const TextMessageTooltipModalRouteName = 'TextMessageTooltipModal';\n@@ -90,7 +90,7 @@ export type TooltipModalParamList = {|\nexport type OverlayParamList = {|\n+TabNavigator: void,\n- +MultimediaModal: MultimediaModalParams,\n+ +ImageModal: ImageModalParams,\n+ActionResultModal: ActionResultModalParams,\n+CameraModal: CameraModalParams,\n+VideoPlaybackModal: VideoPlaybackModalParams,\n@@ -148,7 +148,7 @@ export const accountModals = [\n];\nexport const scrollBlockingModals = [\n- MultimediaModalRouteName,\n+ ImageModalRouteName,\nMultimediaTooltipModalRouteName,\nTextMessageTooltipModalRouteName,\nThreadSettingsMemberTooltipModalRouteName,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Rename MultimediaModal to ImageModal
Summary: NA
Test Plan: Everything seems to work as it did before.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D791 |
129,191 | 18.02.2021 12:55:44 | -3,600 | debfb95d6f4614b65cd1cd8ccda83e75f939cbbb | [web] Create failed send modal
Test Plan: Call `setModal(<FailedSendModal setModal={props.setModal} />)` and check if it was displayed correctly and if clicking close button closes the modal.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "web/modals/chat/failed-send.react.js",
"diff": "+// @flow\n+\n+import * as React from 'react';\n+\n+import css from '../../style.css';\n+import Modal from '../modal.react';\n+\n+type Props = {|\n+ +setModal: (modal: ?React.Node) => void,\n+|};\n+\n+function FailedSendModal({ setModal }: Props) {\n+ const clearModal = React.useCallback(() => setModal(null), [setModal]);\n+\n+ return (\n+ <Modal onClose={clearModal} name=\"Failed send\">\n+ <div className={css['modal-body']}>\n+ <p>Something went wrong while sending the message. Please try again.</p>\n+ </div>\n+ </Modal>\n+ );\n+}\n+\n+export default FailedSendModal;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Create failed send modal
Test Plan: Call `setModal(<FailedSendModal setModal={props.setModal} />)` and check if it was displayed correctly and if clicking close button closes the modal.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D739 |
129,184 | 24.02.2021 03:26:53 | 28,800 | dc57c99fe43ad56c24b0a9e8fe2fa96ae2d27677 | [native] Rename image-view-modal to image-modal
Summary: NA
Test Plan: Ran flow
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "RENAME",
"old_path": "native/media/image-view-modal.react.js",
"new_path": "native/media/image-modal.react.js",
"diff": ""
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/app-navigator.react.js",
"new_path": "native/navigation/app-navigator.react.js",
"diff": "@@ -17,7 +17,7 @@ import ThreadSettingsMemberTooltipModal from '../chat/settings/thread-settings-m\nimport { TextMessageTooltipModal } from '../chat/text-message-tooltip-modal.react';\nimport KeyboardStateContainer from '../keyboard/keyboard-state-container.react';\nimport CameraModal from '../media/camera-modal.react';\n-import ImageModal from '../media/image-view-modal.react';\n+import ImageModal from '../media/image-modal.react';\nimport VideoPlaybackModal from '../media/video-playback-modal.react';\nimport More from '../more/more.react';\nimport RelationshipListItemTooltipModal from '../more/relationship-list-item-tooltip-modal.react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/route-names.js",
"new_path": "native/navigation/route-names.js",
"diff": "@@ -18,7 +18,7 @@ import type { ThreadSettingsParams } from '../chat/settings/thread-settings.reac\nimport type { SidebarListModalParams } from '../chat/sidebar-list-modal.react';\nimport type { TextMessageTooltipModalParams } from '../chat/text-message-tooltip-modal.react';\nimport type { CameraModalParams } from '../media/camera-modal.react';\n-import type { ImageModalParams } from '../media/image-view-modal.react';\n+import type { ImageModalParams } from '../media/image-modal.react';\nimport type { VideoPlaybackModalParams } from '../media/video-playback-modal.react';\nimport type { CustomServerModalParams } from '../more/custom-server-modal.react';\nimport type { RelationshipListItemTooltipModalParams } from '../more/relationship-list-item-tooltip-modal.react';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Rename image-view-modal to image-modal
Summary: NA
Test Plan: Ran flow
Reviewers: ashoat, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D796 |
129,208 | 24.02.2021 14:14:20 | 18,000 | a9fadb8a6a2b7025f775d3ccb6898e649e292107 | [web] Use hooks instead of connect function and HOC in Calendar
Summary: Switched to hooks instead of the connect function in the Calendar class.
Test Plan: Checked if the calendar still showed up on web and worked correctly.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "web/calendar/calendar.react.js",
"new_path": "web/calendar/calendar.react.js",
"diff": "@@ -4,7 +4,6 @@ import { faFilter } from '@fortawesome/free-solid-svg-icons';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport dateFormat from 'dateformat';\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\n@@ -13,26 +12,25 @@ import {\n} from 'lib/actions/entry-actions';\nimport { currentDaysToEntries } from 'lib/selectors/thread-selectors';\nimport {\n- entryInfoPropType,\ntype EntryInfo,\ntype CalendarQuery,\ntype CalendarQueryUpdateResult,\ntype CalendarQueryUpdateStartingPayload,\n} from 'lib/types/entry-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import {\n+ type DispatchActionPromise,\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\nimport {\ngetDate,\ndateString,\nstartDateForYearAndMonth,\nendDateForYearAndMonth,\n} from 'lib/utils/date-utils';\n-import { connect } from 'lib/utils/redux-utils';\n-import {\n- type AppState,\n- type NavInfo,\n- navInfoPropType,\n-} from '../redux/redux-setup';\n+import { type NavInfo } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\nimport {\nyearAssertingSelector,\nmonthAssertingSelector,\n@@ -43,39 +41,27 @@ import css from './calendar.css';\nimport Day from './day.react';\nimport FilterPanel from './filter-panel.react';\n-type Props = {\n- setModal: (modal: ?React.Node) => void,\n- url: string,\n- // Redux state\n- year: number,\n- month: number, // 1-indexed\n- daysToEntries: { [dayString: string]: EntryInfo[] },\n- navInfo: NavInfo,\n- currentCalendarQuery: () => CalendarQuery,\n- // Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- updateCalendarQuery: (\n+type BaseProps = {|\n+ +setModal: (modal: ?React.Node) => void,\n+ +url: string,\n+|};\n+type Props = {|\n+ ...BaseProps,\n+ +year: number,\n+ +month: number,\n+ +daysToEntries: { [dayString: string]: EntryInfo[] },\n+ +navInfo: NavInfo,\n+ +currentCalendarQuery: () => CalendarQuery,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +updateCalendarQuery: (\ncalendarQuery: CalendarQuery,\nreduxAlreadyUpdated?: boolean,\n) => Promise<CalendarQueryUpdateResult>,\n-};\n+|};\ntype State = {|\nfilterPanelOpen: boolean,\n|};\nclass Calendar extends React.PureComponent<Props, State> {\n- static propTypes = {\n- setModal: PropTypes.func.isRequired,\n- url: PropTypes.string.isRequired,\n- year: PropTypes.number.isRequired,\n- month: PropTypes.number.isRequired,\n- daysToEntries: PropTypes.objectOf(PropTypes.arrayOf(entryInfoPropType))\n- .isRequired,\n- navInfo: navInfoPropType.isRequired,\n- currentCalendarQuery: PropTypes.func.isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- updateCalendarQuery: PropTypes.func.isRequired,\n- };\nstate: State = {\nfilterPanelOpen: false,\n};\n@@ -269,13 +255,27 @@ class Calendar extends React.PureComponent<Props, State> {\n};\n}\n-export default connect(\n- (state: AppState) => ({\n- year: yearAssertingSelector(state),\n- month: monthAssertingSelector(state),\n- daysToEntries: currentDaysToEntries(state),\n- navInfo: state.navInfo,\n- currentCalendarQuery: webCalendarQuery(state),\n- }),\n- { updateCalendarQuery },\n-)(Calendar);\n+export default React.memo<BaseProps>(function ConnectedCalendar(\n+ props: BaseProps,\n+) {\n+ const year = useSelector(yearAssertingSelector);\n+ const month = useSelector(monthAssertingSelector);\n+ const daysToEntries = useSelector(currentDaysToEntries);\n+ const navInfo = useSelector((state) => state.navInfo);\n+ const currentCalendarQuery = useSelector(webCalendarQuery);\n+ const callUpdateCalendarQuery = useServerCall(updateCalendarQuery);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <Calendar\n+ {...props}\n+ year={year}\n+ month={month}\n+ daysToEntries={daysToEntries}\n+ navInfo={navInfo}\n+ currentCalendarQuery={currentCalendarQuery}\n+ dispatchActionPromise={dispatchActionPromise}\n+ updateCalendarQuery={callUpdateCalendarQuery}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hooks instead of connect function and HOC in Calendar
Summary: Switched to hooks instead of the connect function in the Calendar class.
Test Plan: Checked if the calendar still showed up on web and worked correctly.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D752 |
129,187 | 23.02.2021 15:39:53 | 18,000 | 824b3aa2ffb548e857b53ad19fd45004ff83c5ca | [server] Factor out updateRoleAndPermissions
Summary: This code was copied from `create-personal-threads.js` into `create-private-threads.js` in D722. This diff factors out the shared code.
Test Plan: Flow
Reviewers: subnub, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/create-personal-threads.js",
"new_path": "server/src/scripts/create-personal-threads.js",
"diff": "@@ -8,10 +8,7 @@ import { getRolePermissionBlobsForChat } from '../creators/role-creator';\nimport { createThread } from '../creators/thread-creator';\nimport { dbQuery, SQL } from '../database/database';\nimport { createScriptViewer } from '../session/scripts';\n-import {\n- commitMembershipChangeset,\n- recalculateAllPermissions,\n-} from '../updaters/thread-permission-updaters';\n+import { DEPRECATED_updateRoleAndPermissions } from '../updaters/role-updaters';\nimport { endScript } from './utils';\nasync function main() {\n@@ -81,22 +78,16 @@ async function markThreadsAsPersonal() {\nconst defaultRolePermissions = getRolePermissionBlobsForChat(\nthreadTypes.PERSONAL,\n).Members;\n- const defaultRolePermissionString = JSON.stringify(defaultRolePermissions);\nconst viewer = createScriptViewer(bots.squadbot.userID);\nconst permissionPromises = result.map(async ({ id, role }) => {\nconsole.log(`Updating thread ${id} and role ${role}`);\n- const updatePermissions = SQL`\n- UPDATE roles\n- SET permissions = ${defaultRolePermissionString}\n- WHERE id = ${role}\n- `;\n- await dbQuery(updatePermissions);\n-\n- const changeset = await recalculateAllPermissions(\n+ return await DEPRECATED_updateRoleAndPermissions(\n+ viewer,\nid.toString(),\nthreadTypes.PERSONAL,\n+ role.toString(),\n+ defaultRolePermissions,\n);\n- return await commitMembershipChangeset(viewer, changeset);\n});\nawait Promise.all([dbQuery(updateThreads), ...permissionPromises]);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/create-private-threads.js",
"new_path": "server/src/scripts/create-private-threads.js",
"diff": "@@ -7,10 +7,7 @@ import { getRolePermissionBlobsForChat } from '../creators/role-creator';\nimport { privateThreadDescription } from '../creators/thread-creator';\nimport { dbQuery, SQL } from '../database/database';\nimport { createScriptViewer } from '../session/scripts';\n-import {\n- commitMembershipChangeset,\n- recalculateAllPermissions,\n-} from '../updaters/thread-permission-updaters';\n+import { DEPRECATED_updateRoleAndPermissions } from '../updaters/role-updaters';\nimport { main } from './utils';\nasync function markThreadsAsPrivate() {\n@@ -44,22 +41,16 @@ async function markThreadsAsPrivate() {\nconst defaultRolePermissions = getRolePermissionBlobsForChat(\nthreadTypes.PRIVATE,\n).Members;\n- const defaultRolePermissionString = JSON.stringify(defaultRolePermissions);\nconst viewer = createScriptViewer(bots.squadbot.userID);\nconst permissionPromises = result.map(async ({ id, role }) => {\nconsole.log(`Updating thread ${id} and role ${role}`);\n- const updatePermissions = SQL`\n- UPDATE roles\n- SET permissions = ${defaultRolePermissionString}\n- WHERE id = ${role}\n- `;\n- await dbQuery(updatePermissions);\n-\n- const changeset = await recalculateAllPermissions(\n+ return await DEPRECATED_updateRoleAndPermissions(\n+ viewer,\nid.toString(),\nthreadTypes.PRIVATE,\n+ role.toString(),\n+ defaultRolePermissions,\n);\n- return await commitMembershipChangeset(viewer, changeset);\n});\nawait Promise.all([dbQuery(updateThreads), ...permissionPromises]);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/role-updaters.js",
"new_path": "server/src/updaters/role-updaters.js",
"diff": "import invariant from 'invariant';\nimport _isEqual from 'lodash/fp/isEqual';\n-import type { ThreadType } from 'lib/types/thread-types';\n+import type {\n+ ThreadType,\n+ ThreadRolePermissionsBlob,\n+} from 'lib/types/thread-types';\nimport createIDs from '../creators/id-creator';\nimport { getRolePermissionBlobsForChat } from '../creators/role-creator';\nimport { dbQuery, SQL } from '../database/database';\nimport { fetchRoles } from '../fetchers/role-fetchers';\nimport type { Viewer } from '../session/viewer';\n+import {\n+ commitMembershipChangeset,\n+ recalculateAllPermissions,\n+} from './thread-permission-updaters';\nasync function updateRoles(\nviewer: Viewer,\n@@ -100,4 +107,27 @@ async function updateRoles(\nawait Promise.all(promises);\n}\n-export { updateRoles };\n+// Best to avoid this function going forward...\n+// It was used in a couple scripts that were meant to convert between thread\n+// types, but those scripts didn't properly handle converting between threads\n+// with different numbers of roles.\n+async function DEPRECATED_updateRoleAndPermissions(\n+ viewer: Viewer,\n+ threadID: string,\n+ threadType: ThreadType,\n+ roleID: string,\n+ rolePermissionsBlob: ThreadRolePermissionsBlob,\n+): Promise<void> {\n+ const rolePermissionsString = JSON.stringify(rolePermissionsBlob);\n+ const updatePermissions = SQL`\n+ UPDATE roles\n+ SET permissions = ${rolePermissionsString}\n+ WHERE id = ${roleID}\n+ `;\n+ await dbQuery(updatePermissions);\n+\n+ const changeset = await recalculateAllPermissions(threadID, threadType);\n+ return await commitMembershipChangeset(viewer, changeset);\n+}\n+\n+export { updateRoles, DEPRECATED_updateRoleAndPermissions };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Factor out updateRoleAndPermissions
Summary: This code was copied from `create-personal-threads.js` into `create-private-threads.js` in D722. This diff factors out the shared code.
Test Plan: Flow
Reviewers: subnub, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D780 |
129,187 | 23.02.2021 19:15:26 | 18,000 | 134796caca083f9d5230344ac3f9e66b6a45ba10 | [lib] Add comments about thread types
Test Plan: N/A
Reviewers: palys-swm, subnub
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -22,10 +22,18 @@ export const threadTypes = Object.freeze({\n//OPEN: 0, (DEPRECATED)\n//CLOSED: 1, (DEPRECATED)\n//SECRET: 2, (DEPRECATED)\n+ // an open subthread. has parent, top-level (not sidebar), and visible to all\n+ // members of parent\nCHAT_NESTED_OPEN: 3,\n+ // basic thread type. optional parent, top-level (not sidebar), visible only\n+ // to its members\nCHAT_SECRET: 4,\n+ // has parent, not top-level (appears under parent in inbox), and visible to\n+ // all members of parent\nSIDEBAR: 5,\n+ // canonical thread for each pair of users. represents the friendship\nPERSONAL: 6,\n+ // canonical thread for each single user\nPRIVATE: 7,\n});\nexport type ThreadType = $Values<typeof threadTypes>;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add comments about thread types
Test Plan: N/A
Reviewers: palys-swm, subnub
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D783 |
129,187 | 23.02.2021 19:35:19 | 18,000 | 710de34b672c19a591d02e7b9dc2d7bdc091d127 | [server] Fix up logic in updateThread to handle thread parent requirements
Summary: Noticed this was broken
Test Plan: didn't have time to test :( careful reading and Flow
Reviewers: subnub, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -961,6 +961,25 @@ function useLatestThreadInfo(\n]);\n}\n+type ThreadTypeParentRequirement = 'optional' | 'required' | 'disabled';\n+function getThreadTypeParentRequirement(\n+ threadType: ThreadType,\n+): ThreadTypeParentRequirement {\n+ if (\n+ threadType === threadTypes.CHAT_NESTED_OPEN ||\n+ threadType === threadTypes.SIDEBAR\n+ ) {\n+ return 'required';\n+ } else if (\n+ threadType === threadTypes.PERSONAL ||\n+ threadType === threadTypes.PRIVATE\n+ ) {\n+ return 'disabled';\n+ } else {\n+ return 'optional';\n+ }\n+}\n+\nexport {\ncolorIsDark,\ngenerateRandomColor,\n@@ -1008,4 +1027,5 @@ export {\nuseWatchThread,\nuseSidebarCandidate,\nuseLatestThreadInfo,\n+ getThreadTypeParentRequirement,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-updaters.js",
"new_path": "server/src/updaters/thread-updaters.js",
"diff": "@@ -7,6 +7,7 @@ import {\nthreadHasAdminRole,\nroleIsAdminRole,\nviewerIsMember,\n+ getThreadTypeParentRequirement,\n} from 'lib/shared/thread-utils';\nimport { hasMinCodeVersion } from 'lib/shared/version-utils';\nimport type { Shape } from 'lib/types/core';\n@@ -414,15 +415,25 @@ async function updateThread(\nthreadType !== null && threadType !== undefined\n? threadType\n: oldThreadType;\n- const nextParentThreadID =\n+ let nextParentThreadID =\nparentThreadID !== undefined ? parentThreadID : oldParentThreadID;\n- // If the thread is being switched to nested, a parent must be specified\n+ // Does the new thread type preclude a parent?\nif (\n- oldThreadType === threadTypes.CHAT_SECRET &&\nthreadType !== undefined &&\nthreadType !== null &&\n- threadType !== threadTypes.CHAT_SECRET &&\n+ getThreadTypeParentRequirement(threadType) === 'disabled' &&\n+ nextParentThreadID !== null\n+ ) {\n+ nextParentThreadID = null;\n+ sqlUpdate.parent_thread_id = null;\n+ }\n+\n+ // Does the new thread type require a parent?\n+ if (\n+ threadType !== undefined &&\n+ threadType !== null &&\n+ getThreadTypeParentRequirement(threadType) === 'required' &&\nnextParentThreadID === null\n) {\nthrow new ServerError('no_parent_thread_specified');\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Fix up logic in updateThread to handle thread parent requirements
Summary: Noticed this was broken
Test Plan: didn't have time to test :( careful reading and Flow
Reviewers: subnub, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D784 |
129,187 | 23.02.2021 19:49:56 | 18,000 | 99031615b791a063d580eb04fdae8bfafbba62bc | [server] Factor out threadRootChanged in updateThread
Test Plan: Flow
Reviewers: subnub, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-updaters.js",
"new_path": "server/src/updaters/thread-updaters.js",
"diff": "@@ -439,16 +439,17 @@ async function updateThread(\nthrow new ServerError('no_parent_thread_specified');\n}\n+ const threadRootChanged =\n+ nextParentThreadID !== oldParentThreadID ||\n+ nextThreadType !== oldThreadType;\n+\nlet parentThreadMembers;\nif (nextParentThreadID) {\nconst promises = [\nfetchThreadInfos(viewer, SQL`t.id = ${nextParentThreadID}`),\n];\n- const threadChanged =\n- nextParentThreadID !== oldParentThreadID ||\n- nextThreadType !== oldThreadType;\n- if (threadChanged) {\n+ if (threadRootChanged) {\npromises.push(\ncheckThreadPermission(\nviewer,\n@@ -468,7 +469,7 @@ async function updateThread(\nif (!parentThreadInfo) {\nthrow new ServerError('invalid_parameters');\n}\n- if (threadChanged && !hasParentPermission) {\n+ if (threadRootChanged && !hasParentPermission) {\nthrow new ServerError('invalid_parameters');\n}\nparentThreadMembers = parentThreadInfo.members.map(\n@@ -522,10 +523,7 @@ async function updateThread(\nnull,\n);\n}\n- if (\n- nextThreadType !== oldThreadType ||\n- nextParentThreadID !== oldParentThreadID\n- ) {\n+ if (threadRootChanged) {\nintermediatePromises.recalculatePermissionsChangeset = (async () => {\nif (nextThreadType !== oldThreadType) {\nawait updateRoles(viewer, request.threadID, nextThreadType);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Factor out threadRootChanged in updateThread
Test Plan: Flow
Reviewers: subnub, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D785 |
129,187 | 23.02.2021 19:51:38 | 18,000 | 370621ef18e27b09bc0d7d2ec270169a7df879e1 | [server] Add forceUpdateRoot to UpdateThreadOptions
Test Plan: Will be tested in concert with upcoming diffs
Reviewers: subnub, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-updaters.js",
"new_path": "server/src/updaters/thread-updaters.js",
"diff": "@@ -292,6 +292,7 @@ async function leaveThread(\ntype UpdateThreadOptions = Shape<{|\n+forceAddMembers: boolean,\n+ +forceUpdateRoot: boolean,\n|}>;\nasync function updateThread(\n@@ -303,6 +304,7 @@ async function updateThread(\nthrow new ServerError('not_logged_in');\n}\nconst forceAddMembers = options?.forceAddMembers ?? false;\n+ const forceUpdateRoot = options?.forceUpdateRoot ?? false;\nconst validationPromises = {};\nconst changedFields = {};\n@@ -440,6 +442,7 @@ async function updateThread(\n}\nconst threadRootChanged =\n+ forceUpdateRoot ||\nnextParentThreadID !== oldParentThreadID ||\nnextThreadType !== oldThreadType;\n@@ -525,7 +528,7 @@ async function updateThread(\n}\nif (threadRootChanged) {\nintermediatePromises.recalculatePermissionsChangeset = (async () => {\n- if (nextThreadType !== oldThreadType) {\n+ if (forceUpdateRoot || nextThreadType !== oldThreadType) {\nawait updateRoles(viewer, request.threadID, nextThreadType);\n}\nreturn await recalculateAllPermissions(request.threadID, nextThreadType);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Add forceUpdateRoot to UpdateThreadOptions
Test Plan: Will be tested in concert with upcoming diffs
Reviewers: subnub, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D786 |
129,187 | 23.02.2021 19:52:58 | 18,000 | d2515b1f3076dd5a0a68300ca14ade9cacd01843 | [server] Prevent updateThread from converting to PERSONAL/PRIVATE outside scripts
Summary: Updating this condition to handle `PRIVATE` thread and excluding scripts (since we're about to call it from a script)
Test Plan: Flow
Reviewers: subnub, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-updaters.js",
"new_path": "server/src/updaters/thread-updaters.js",
"diff": "@@ -336,7 +336,10 @@ async function updateThread(\nsqlUpdate.type = threadType;\n}\n- if (threadType === threadTypes.PERSONAL) {\n+ if (\n+ !viewer.isScriptViewer &&\n+ (threadType === threadTypes.PERSONAL || threadType === threadTypes.PRIVATE)\n+ ) {\nthrow new ServerError('invalid_parameters');\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Prevent updateThread from converting to PERSONAL/PRIVATE outside scripts
Summary: Updating this condition to handle `PRIVATE` thread and excluding scripts (since we're about to call it from a script)
Test Plan: Flow
Reviewers: subnub, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D787 |
129,187 | 23.02.2021 23:14:56 | 18,000 | 90372ac708c2ce09e7e16e4e0275e0c5a9e68887 | [server] Have script viewers automatically pass checkThreads
Summary: This is so we can use `updateThread` in scripts without having to pass permission checks
Test Plan: Tested in concert with upcoming script
Reviewers: subnub, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/thread-permission-fetchers.js",
"new_path": "server/src/fetchers/thread-permission-fetchers.js",
"diff": "@@ -79,6 +79,11 @@ async function checkThreads(\nthreadIDs: $ReadOnlyArray<string>,\nchecks: $ReadOnlyArray<Check>,\n): Promise<Set<string>> {\n+ if (viewer.isScriptViewer) {\n+ // script viewers are all-powerful\n+ return new Set(threadIDs);\n+ }\n+\nconst query = SQL`\nSELECT thread, permissions, role\nFROM memberships\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Have script viewers automatically pass checkThreads
Summary: This is so we can use `updateThread` in scripts without having to pass permission checks
Test Plan: Tested in concert with upcoming script
Reviewers: subnub, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D788 |
129,184 | 24.02.2021 12:01:39 | 28,800 | fe0829c2a7b67de20992fea4e8be46e1ace49f61 | [native] Move VideoPlaybackModal close button to top right
Summary: Moved close button to top right to be more "reachable" on large devices and to be consistent with ImageModal
Test Plan: NA, here's what it looks like:
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/media/video-playback-modal.react.js",
"new_path": "native/media/video-playback-modal.react.js",
"diff": "@@ -366,8 +366,8 @@ const unboundStyles = {\n},\ncloseButton: {\npaddingTop: 10,\n- paddingLeft: 20,\n- justifyContent: 'flex-start',\n+ paddingRight: 20,\n+ justifyContent: 'flex-end',\nalignItems: 'center',\nflexDirection: 'row',\nheight: 100,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Move VideoPlaybackModal close button to top right
Summary: Moved close button to top right to be more "reachable" on large devices and to be consistent with ImageModal
Test Plan: NA, here's what it looks like: https://blob.sh/atul/33d5.png
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D800 |
129,187 | 24.02.2021 18:05:41 | 18,000 | 3165a3b8141482115cfbdc8b619b718086e9ca5a | [server] Rescind notifs from fix-new-thread-types script
Summary: Ugh... having to fix the fix script. Very frustrating. Ended up spamming lots of notifs with it, hopefully this will undo those notifs.
Test Plan: test on prod!
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "server/src/push/send.js",
"new_path": "server/src/push/send.js",
"diff": "@@ -732,8 +732,10 @@ async function updateBadgeCount(\nFROM cookies\nWHERE user = ${userID}\nAND device_token IS NOT NULL\n- AND id != ${viewer.cookieID}\n`;\n+ if (viewer.data.cookieID) {\n+ deviceTokenQuery.append(SQL`AND id != ${viewer.cookieID} `);\n+ }\nif (excludeDeviceTokens.length > 0) {\ndeviceTokenQuery.append(\nSQL`AND device_token NOT IN (${excludeDeviceTokens}) `,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/rescind-notifs.js",
"diff": "+// @flow\n+\n+import { threadTypes } from 'lib/types/thread-types';\n+\n+import { dbQuery, SQL } from '../database/database';\n+import { createScriptViewer } from '../session/scripts';\n+import { activityUpdater } from '../updaters/activity-updaters';\n+import { main } from './utils';\n+\n+async function rescindNotifs() {\n+ const fetchRescindThreadInfo = SQL`\n+ SELECT m.user, m.thread, m.last_message\n+ FROM users u\n+ INNER JOIN memberships m\n+ ON m.user = u.id\n+ INNER JOIN threads t\n+ ON t.id = m.thread\n+ WHERE t.type IN (${[threadTypes.PERSONAL, threadTypes.PRIVATE]})\n+ `;\n+ const [result] = await dbQuery(fetchRescindThreadInfo);\n+\n+ const usersToActivityUpdates = new Map();\n+ for (const row of result) {\n+ const user = row.user.toString();\n+ let activityUpdates = usersToActivityUpdates.get(user);\n+ if (!activityUpdates) {\n+ activityUpdates = [];\n+ usersToActivityUpdates.set(user, activityUpdates);\n+ }\n+ activityUpdates.push({\n+ focus: false,\n+ threadID: row.thread.toString(),\n+ latestMessage: row.last_message.toString(),\n+ });\n+ }\n+\n+ for (const [user, activityUpdates] of usersToActivityUpdates) {\n+ await activityUpdater(createScriptViewer(user), {\n+ updates: activityUpdates,\n+ });\n+ }\n+}\n+\n+main([rescindNotifs]);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/activity-updaters.js",
"new_path": "server/src/updaters/activity-updaters.js",
"diff": "@@ -263,8 +263,10 @@ async function updateFocusedRows(\n`);\n}\n+ if (viewer.hasSessionInfo) {\nawait deleteActivityForViewerSession(viewer, time);\n}\n+}\n// To protect against a possible race condition, we reset the thread to unread\n// if the latest message ID on the client at the time that focus was dropped\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Rescind notifs from fix-new-thread-types script
Summary: Ugh... having to fix the fix script. Very frustrating. Ended up spamming lots of notifs with it, hopefully this will undo those notifs.
Test Plan: test on prod!
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D804 |
129,187 | 24.02.2021 19:26:12 | 18,000 | e80163e768afb4bfdafc6107ed1dd2ec0b49e827 | [lib] Break more ties in message timestamps with message IDs
Summary: Follow-up to D805
Test Plan: test on prod...
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/message-reducer.js",
"new_path": "lib/reducers/message-reducer.js",
"diff": "@@ -79,9 +79,16 @@ import { setNewSessionActionType } from '../utils/action-utils';\nconst _mapValuesWithKeys = _mapValues.convert({ cap: false });\n+const sortMessageList = _orderBy(['time', 'id'])(['desc', 'desc']);\n+const sortMessageIDs = (messages: { [id: string]: RawMessageInfo }) =>\n+ _orderBy([(id: string) => messages[id].time, (id: string) => id])([\n+ 'desc',\n+ 'desc',\n+ ]);\n+\n// Input must already be ordered!\nfunction threadsToMessageIDsFromMessageInfos(\n- orderedMessageInfos: RawMessageInfo[],\n+ orderedMessageInfos: $ReadOnlyArray<RawMessageInfo>,\n): { [threadID: string]: string[] } {\nconst threads: { [threadID: string]: string[] } = {};\nfor (let messageInfo of orderedMessageInfos) {\n@@ -113,7 +120,7 @@ function freshMessageStore(\nthreadInfos: { [threadID: string]: RawThreadInfo },\n): MessageStore {\nconst unshimmed = unshimMessageInfos(messageInfos);\n- const orderedMessageInfos = _orderBy('time')('desc')(unshimmed);\n+ const orderedMessageInfos = sortMessageList(unshimmed);\nconst messages = _keyBy(messageID)(orderedMessageInfos);\nconst threadsToMessageIDs = threadsToMessageIDsFromMessageInfos(\norderedMessageInfos,\n@@ -234,7 +241,7 @@ function mergeNewMessages(\n? currentMessageInfo\n: messageInfo;\n}),\n- _orderBy('time')('desc'),\n+ sortMessageList,\n)(unshimmed);\nconst threadsToMessageIDs = threadsToMessageIDsFromMessageInfos(\n@@ -370,15 +377,14 @@ function mergeNewMessages(\n}\nconst messages = _flow(\n- _orderBy(['time', 'id'])(['desc', 'desc']),\n+ sortMessageList,\n_keyBy(messageID),\n)([...orderedNewMessageInfos, ...oldMessageInfosToCombine]);\nfor (let threadID of mustResortThreadMessageIDs) {\n- threads[threadID].messageIDs = _orderBy([\n- (id: string) => messages[id].time,\n- (id: string) => id,\n- ])(['desc', 'desc'])(threads[threadID].messageIDs);\n+ threads[threadID].messageIDs = sortMessageIDs(messages)(\n+ threads[threadID].messageIDs,\n+ );\n}\nconst currentAsOf = Math.max(\n@@ -615,7 +621,7 @@ function reduceMessageStore(\n...messageStore.threads,\n[threadID]: {\n...messageStore.threads[threadID],\n- messageIDs: _orderBy([(id: string) => messages[id].time])('desc')(\n+ messageIDs: sortMessageIDs(messages)(\nmessageStore.threads[threadID].messageIDs,\n),\n},\n@@ -694,7 +700,7 @@ function reduceMessageStore(\nconst threadID = payload.threadID;\nconst newMessageIDs = _flow(\n_uniq,\n- _orderBy([(id: string) => newMessages[id].time])('desc'),\n+ sortMessageIDs(newMessages),\n)(messageStore.threads[threadID].messageIDs.map(replaceMessageKey));\nconst currentAsOf =\npayload.interface === 'socket'\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Break more ties in message timestamps with message IDs
Summary: Follow-up to D805
Test Plan: test on prod...
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D806 |
129,184 | 23.02.2021 22:46:41 | 28,800 | 7971554e8155d7e9d4937da4067924ba83cabf42 | [native] Add spinner to VideoPlaybackModal
Summary: Spinner displayed until `onReadyForDisplay` callback
Test Plan: Works as expected on iOS. Will test android and media pipeline scenarios comprehensively after the native video playback diffs.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/media/video-playback-modal.react.js",
"new_path": "native/media/video-playback-modal.react.js",
"diff": "@@ -213,6 +213,7 @@ function VideoPlaybackModal(props: Props) {\nconst [paused, setPaused] = useState(false);\nconst [percentElapsed, setPercentElapsed] = useState(0);\nconst [controlsVisible, setControlsVisible] = useState(true);\n+ const [spinnerVisible, setSpinnerVisible] = useState(true);\nconst [timeElapsed, setTimeElapsed] = useState('0:00');\nconst [totalDuration, setTotalDuration] = useState('0:00');\nconst videoRef = React.useRef();\n@@ -247,6 +248,10 @@ function VideoPlaybackModal(props: Props) {\n);\n}, []);\n+ const readyForDisplayCallback = React.useCallback(() => {\n+ setSpinnerVisible(false);\n+ }, []);\n+\nconst statusBar = overlayContext.isDismissing ? null : (\n<ConnectedStatusBar hidden />\n);\n@@ -308,11 +313,24 @@ function VideoPlaybackModal(props: Props) {\n</>\n);\n+ let spinner;\n+ if (spinnerVisible) {\n+ spinner = (\n+ <Progress.Circle\n+ size={80}\n+ indeterminate={true}\n+ color={'white'}\n+ style={styles.progressCircle}\n+ />\n+ );\n+ }\n+\nreturn (\n<Animated.View style={styles.modal}>\n{statusBar}\n<Animated.View style={[styles.backdrop, backdropStyle]} />\n<View style={contentContainerStyle}>\n+ {spinner}\n<Animated.View style={videoContainerStyle}>\n<TouchableWithoutFeedback onPress={togglePlaybackControls}>\n<Video\n@@ -322,6 +340,7 @@ function VideoPlaybackModal(props: Props) {\npaused={paused}\nonProgress={progressCallback}\nonEnd={resetVideo}\n+ onReadyForDisplay={readyForDisplayCallback}\n/>\n</TouchableWithoutFeedback>\n</Animated.View>\n@@ -379,6 +398,15 @@ const unboundStyles = {\ncolor: 'white',\npaddingRight: 10,\n},\n+ progressCircle: {\n+ position: 'absolute',\n+ alignItems: 'center',\n+ justifyContent: 'center',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ },\niconButton: {\npaddingRight: 10,\ncolor: 'white',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Add spinner to VideoPlaybackModal
Summary: Spinner displayed until `onReadyForDisplay` callback
Test Plan: Works as expected on iOS. Will test android and media pipeline scenarios comprehensively after the native video playback diffs.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D799 |
129,187 | 24.02.2021 23:27:38 | 18,000 | 8822262610a85128f7d0c53142c4330d2c5cea07 | [native] Set ITSAppUsesNonExemptEncryption to NO for iOS builds
Summary: See [here](https://developer.apple.com/forums/thread/674299?answerId=663520022#663520022)... unblocks Testflight builds by circumventing some App Store Connect bug.
Test Plan: Upload a new Testflight build
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/Info.debug.plist",
"new_path": "native/ios/SquadCal/Info.debug.plist",
"diff": "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n+ <key>ITSAppUsesNonExemptEncryption</key>\n+ <false/>\n<key>CFBundleDevelopmentRegion</key>\n<string>en</string>\n<key>CFBundleDisplayName</key>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/Info.release.plist",
"new_path": "native/ios/SquadCal/Info.release.plist",
"diff": "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n+ <key>ITSAppUsesNonExemptEncryption</key>\n+ <false/>\n<key>CFBundleDevelopmentRegion</key>\n<string>en</string>\n<key>CFBundleDisplayName</key>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Set ITSAppUsesNonExemptEncryption to NO for iOS builds
Summary: See [here](https://developer.apple.com/forums/thread/674299?answerId=663520022#663520022)... unblocks Testflight builds by circumventing some App Store Connect bug.
Test Plan: Upload a new Testflight build
Reviewers: atul, palys-swm
Reviewed By: atul
Subscribers: KatPo, zrebcu411, Adrian, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D807 |
129,208 | 25.02.2021 11:16:26 | 18,000 | 129754434e68c0209a8e5af88f91b782d670141b | [native] Use hook instead of the connect function and HOC in LogInPanelContainer
Summary: Switched to hooks instead of the connect function in the LogInPanelContainer class.
Test Plan: Made sure the login panel still showed up and worked correctly
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel-container.react.js",
"new_path": "native/account/log-in-panel-container.react.js",
"diff": "// @flow\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n-import { connect } from 'lib/utils/redux-utils';\nimport sleep from 'lib/utils/sleep';\n-import type { AppState } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\nimport { runTiming } from '../utils/animation-utils';\n-import {\n- type StateContainer,\n- stateContainerPropType,\n-} from '../utils/state-container';\n+import { type StateContainer } from '../utils/state-container';\nimport ForgotPasswordPanel from './forgot-password-panel.react';\nimport LogInPanel from './log-in-panel.react';\nimport type { InnerLogInPanel, LogInState } from './log-in-panel.react';\n@@ -44,28 +39,21 @@ const {\n} = Animated;\n/* eslint-enable import/no-named-as-default-member */\n+type BaseProps = {|\n+ +setActiveAlert: (activeAlert: boolean) => void,\n+ +opacityValue: Value,\n+ +hideForgotPasswordLink: Value,\n+ +logInState: StateContainer<LogInState>,\n+|};\ntype Props = {|\n- setActiveAlert: (activeAlert: boolean) => void,\n- opacityValue: Value,\n- hideForgotPasswordLink: Value,\n- logInState: StateContainer<LogInState>,\n- innerRef: (container: ?LogInPanelContainer) => void,\n- // Redux state\n- windowWidth: number,\n+ ...BaseProps,\n+ +windowWidth: number,\n|};\ntype State = {|\nlogInMode: LogInMode,\nnextLogInMode: LogInMode,\n|};\nclass LogInPanelContainer extends React.PureComponent<Props, State> {\n- static propTypes = {\n- setActiveAlert: PropTypes.func.isRequired,\n- opacityValue: PropTypes.object.isRequired,\n- hideForgotPasswordLink: PropTypes.instanceOf(Value).isRequired,\n- logInState: stateContainerPropType.isRequired,\n- innerRef: PropTypes.func.isRequired,\n- windowWidth: PropTypes.number.isRequired,\n- };\nlogInPanel: ?InnerLogInPanel = null;\npanelTransitionTarget: Value;\n@@ -110,14 +98,6 @@ class LogInPanelContainer extends React.PureComponent<Props, State> {\n]);\n}\n- componentDidMount() {\n- this.props.innerRef(this);\n- }\n-\n- componentWillUnmount() {\n- this.props.innerRef(null);\n- }\n-\nrender() {\nconst { windowWidth } = this.props;\nconst logInPanelDynamicStyle = {\n@@ -271,6 +251,14 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect((state: AppState) => ({\n- windowWidth: state.dimensions.width,\n-}))(LogInPanelContainer);\n+export default React.forwardRef<BaseProps, LogInPanelContainer>(\n+ function ForwardedConnectedLogInPanelContainer(\n+ props: BaseProps,\n+ ref: React.Ref<typeof LogInPanelContainer>,\n+ ) {\n+ const windowWidth = useSelector((state) => state.dimensions.width);\n+ return (\n+ <LogInPanelContainer {...props} windowWidth={windowWidth} ref={ref} />\n+ );\n+ },\n+);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -127,7 +127,7 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nmounted = false;\nnextMode: LoggedOutMode = 'loading';\nactiveAlert = false;\n- logInPanelContainer: ?LogInPanelContainer = null;\n+ logInPanelContainer: ?React.ElementRef<typeof LogInPanelContainer> = null;\ncontentHeight: Value;\nkeyboardHeightValue = new Value(0);\n@@ -577,7 +577,7 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nopacityValue={this.panelOpacityValue}\nhideForgotPasswordLink={this.hideForgotPasswordLink}\nlogInState={this.state.logInState}\n- innerRef={this.logInPanelContainerRef}\n+ ref={this.logInPanelContainerRef}\n/>\n);\n} else if (this.state.mode === 'register') {\n@@ -678,7 +678,9 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\n);\n}\n- logInPanelContainerRef = (logInPanelContainer: ?LogInPanelContainer) => {\n+ logInPanelContainerRef = (\n+ logInPanelContainer: ?React.ElementRef<typeof LogInPanelContainer>,\n+ ) => {\nthis.logInPanelContainer = logInPanelContainer;\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of the connect function and HOC in LogInPanelContainer
Summary: Switched to hooks instead of the connect function in the LogInPanelContainer class.
Test Plan: Made sure the login panel still showed up and worked correctly
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D770 |
129,208 | 25.02.2021 11:21:16 | 18,000 | 1905d3cb8d7a12cf1251ba629d801bf658bc398b | [native] Use hook instead of connect functions and HOC in ConnectedStatusBar
Summary: Switched to hooks instead of the connect function for the ConnectedStatusBar class
Test Plan: Made sure the statusbar still showed up and functioned normally.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/connected-status-bar.react.js",
"new_path": "native/connected-status-bar.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport React from 'react';\nimport { StatusBar, Platform } from 'react-native';\nimport { globalLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import type { LoadingStatus } from 'lib/types/loading-types';\n-import { connect } from 'lib/utils/redux-utils';\n-import type { AppState } from './redux/redux-setup';\n-import { type GlobalTheme, globalThemePropType } from './types/themes';\n+import { useSelector } from './redux/redux-utils';\ntype Props = {|\n- barStyle?: 'default' | 'light-content' | 'dark-content',\n- animated?: boolean,\n- // Redux state\n- globalLoadingStatus: LoadingStatus,\n- activeTheme: ?GlobalTheme,\n+ +barStyle?: 'default' | 'light-content' | 'dark-content',\n+ +animated?: boolean,\n+ +hidden?: boolean,\n|};\n-class ConnectedStatusBar extends React.PureComponent<Props> {\n- static propTypes = {\n- barStyle: PropTypes.oneOf(['default', 'light-content', 'dark-content']),\n- animated: PropTypes.bool,\n- globalLoadingStatus: PropTypes.string.isRequired,\n- activeTheme: globalThemePropType,\n- };\n-\n- render() {\n- const {\n- barStyle: inBarStyle,\n- activeTheme,\n- globalLoadingStatus,\n- ...statusBarProps\n- } = this.props;\n+export default function ConnectedStatusBar(props: Props) {\n+ const globalLoadingStatus = useSelector(globalLoadingStatusSelector);\n+ const activeTheme = useSelector((state) => state.globalThemeInfo.activeTheme);\n+ const { barStyle: inBarStyle, ...statusBarProps } = props;\nlet barStyle = inBarStyle;\nif (!barStyle) {\n- if (Platform.OS !== 'android' && this.props.activeTheme === 'light') {\n+ if (Platform.OS !== 'android' && activeTheme === 'light') {\nbarStyle = 'dark-content';\n} else {\nbarStyle = 'light-content';\n}\n}\n- const fetchingSomething = this.props.globalLoadingStatus === 'loading';\n+ const fetchingSomething = globalLoadingStatus === 'loading';\nreturn (\n<StatusBar\n{...statusBarProps}\n@@ -52,9 +35,3 @@ class ConnectedStatusBar extends React.PureComponent<Props> {\n/>\n);\n}\n-}\n-\n-export default connect((state: AppState) => ({\n- globalLoadingStatus: globalLoadingStatusSelector(state),\n- activeTheme: state.globalThemeInfo.activeTheme,\n-}))(ConnectedStatusBar);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in ConnectedStatusBar
Summary: Switched to hooks instead of the connect function for the ConnectedStatusBar class
Test Plan: Made sure the statusbar still showed up and functioned normally.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D771 |
129,208 | 25.02.2021 11:28:31 | 18,000 | aaa11d011c2a9ee7c54e9e2c63afffe8b9fd69f3 | [web] Use hook instead of connect and HOC in LogInModal
Test Plan: Tested if the login modal still popped up and fuctioned normally
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "web/modals/account/log-in-modal.react.js",
"new_path": "web/modals/account/log-in-modal.react.js",
"diff": "@@ -16,23 +16,26 @@ import type {\nLogInResult,\nLogInStartingPayload,\n} from 'lib/types/account-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ type DispatchActionPromise,\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\n-import type { AppState } from '../../redux/redux-setup';\n+import { useSelector } from '../../redux/redux-utils';\nimport { webLogInExtraInfoSelector } from '../../selectors/account-selectors';\nimport css from '../../style.css';\nimport Modal from '../modal.react';\nimport ForgotPasswordModal from './forgot-password-modal.react';\n-type Props = {|\n+type BaseProps = {|\n+setModal: (modal: ?React.Node) => void,\n- // Redux state\n+|};\n+type Props = {|\n+ ...BaseProps,\n+inputDisabled: boolean,\n+logInExtraInfo: () => LogInExtraInfo,\n- // Redux dispatch functions\n+dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n+logIn: (logInInfo: LogInInfo) => Promise<LogInResult>,\n|};\ntype State = {|\n@@ -238,10 +241,21 @@ LogInModal.propTypes = {\nconst loadingStatusSelector = createLoadingStatusSelector(logInActionTypes);\n-export default connect(\n- (state: AppState) => ({\n- inputDisabled: loadingStatusSelector(state) === 'loading',\n- logInExtraInfo: webLogInExtraInfoSelector(state),\n- }),\n- { logIn },\n-)(LogInModal);\n+export default React.memo<BaseProps>(function ConnectedLoginModal(\n+ props: BaseProps,\n+) {\n+ const inputDisabled = useSelector(loadingStatusSelector) === 'loading';\n+ const loginExtraInfo = useSelector(webLogInExtraInfoSelector);\n+ const callLogIn = useServerCall(logIn);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <LogInModal\n+ {...props}\n+ inputDisabled={inputDisabled}\n+ logInExtraInfo={loginExtraInfo}\n+ logIn={callLogIn}\n+ dispatchActionPromise={dispatchActionPromise}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook instead of connect and HOC in LogInModal
Test Plan: Tested if the login modal still popped up and fuctioned normally
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D773 |
129,208 | 25.02.2021 11:36:17 | 18,000 | edc2934bc323361f0cab9a7708676c21414a68c2 | [web] Use hook instead of connect and HOC in RegisterModal
Test Plan: Flow
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "web/modals/account/register-modal.react.js",
"new_path": "web/modals/account/register-modal.react.js",
"diff": "@@ -13,23 +13,26 @@ import type {\nRegisterResult,\nLogInStartingPayload,\n} from 'lib/types/account-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ type DispatchActionPromise,\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\n-import type { AppState } from '../../redux/redux-setup';\n+import { useSelector } from '../../redux/redux-utils';\nimport { webLogInExtraInfoSelector } from '../../selectors/account-selectors';\nimport css from '../../style.css';\nimport Modal from '../modal.react';\nimport VerifyEmailModal from './verify-email-modal.react';\n-type Props = {|\n+type BaseProps = {|\n+setModal: (modal: ?React.Node) => void,\n- // Redux state\n+|};\n+type Props = {|\n+ ...BaseProps,\n+inputDisabled: boolean,\n+logInExtraInfo: () => LogInExtraInfo,\n- // Redux dispatch functions\n+dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n+register: (registerInfo: RegisterInfo) => Promise<RegisterResult>,\n|};\ntype State = {|\n@@ -306,10 +309,21 @@ RegisterModal.propTypes = {\nconst loadingStatusSelector = createLoadingStatusSelector(registerActionTypes);\n-export default connect(\n- (state: AppState) => ({\n- inputDisabled: loadingStatusSelector(state) === 'loading',\n- logInExtraInfo: webLogInExtraInfoSelector(state),\n- }),\n- { register },\n-)(RegisterModal);\n+export default React.memo<BaseProps>(function ConnectedRegisterModal(\n+ props: BaseProps,\n+) {\n+ const inputDisabled = useSelector(loadingStatusSelector) === 'loading';\n+ const loginExtraInfo = useSelector(webLogInExtraInfoSelector);\n+ const callRegister = useServerCall(register);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <RegisterModal\n+ {...props}\n+ inputDisabled={inputDisabled}\n+ logInExtraInfo={loginExtraInfo}\n+ register={callRegister}\n+ dispatchActionPromise={dispatchActionPromise}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook instead of connect and HOC in RegisterModal
Test Plan: Flow
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D774 |
129,208 | 25.02.2021 11:38:19 | 18,000 | 53d7de9b2cc993a193dca2cf47f7fea89c414b00 | [web] Use hook instead of connect function and HOC in UserSettingsModal
Test Plan: Tested settings modal pop
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "web/modals/account/user-settings-modal.react.js",
"new_path": "web/modals/account/user-settings-modal.react.js",
"diff": "@@ -29,10 +29,13 @@ import {\ntype CurrentUserInfo,\ncurrentUserPropType,\n} from 'lib/types/user-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ type DispatchActionPromise,\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\n-import type { AppState } from '../../redux/redux-setup';\n+import { useSelector } from '../../redux/redux-utils';\nimport css from '../../style.css';\nimport Modal from '../modal.react';\nimport VerifyEmailModal from './verify-email-modal.react';\n@@ -63,24 +66,24 @@ class Tab extends React.PureComponent<TabProps> {\n};\n}\n-type Props = {\n- setModal: (modal: ?React.Node) => void,\n- // Redux state\n- currentUserInfo: ?CurrentUserInfo,\n- preRequestUserState: PreRequestUserState,\n- inputDisabled: boolean,\n- // Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- deleteAccount: (\n+type BaseProps = {|\n+ +setModal: (modal: ?React.Node) => void,\n+|};\n+type Props = {|\n+ ...BaseProps,\n+ +currentUserInfo: ?CurrentUserInfo,\n+ +preRequestUserState: PreRequestUserState,\n+ +inputDisabled: boolean,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +deleteAccount: (\npassword: string,\npreRequestUserState: PreRequestUserState,\n) => Promise<LogOutResult>,\n- changeUserSettings: (\n+ +changeUserSettings: (\naccountUpdate: AccountUpdate,\n) => Promise<ChangeUserSettingsResult>,\n- resendVerificationEmail: () => Promise<void>,\n-};\n+ +resendVerificationEmail: () => Promise<void>,\n+|};\ntype State = {\nemail: ?string,\nemailVerified: ?boolean,\n@@ -506,18 +509,32 @@ const resendVerificationEmailLoadingStatusSelector = createLoadingStatusSelector\nresendVerificationEmailActionTypes,\n);\n-export default connect(\n- (state: AppState) => ({\n- currentUserInfo: state.currentUserInfo,\n- preRequestUserState: preRequestUserStateSelector(state),\n- inputDisabled:\n+export default React.memo<BaseProps>(function ConnectedUserSettingsModal(\n+ props: BaseProps,\n+) {\n+ const currentUserInfo = useSelector((state) => state.currentUserInfo);\n+ const preRequestUserState = useSelector(preRequestUserStateSelector);\n+ const inputDisabled = useSelector(\n+ (state) =>\ndeleteAccountLoadingStatusSelector(state) === 'loading' ||\nchangeUserSettingsLoadingStatusSelector(state) === 'loading' ||\nresendVerificationEmailLoadingStatusSelector(state) === 'loading',\n- }),\n- {\n- deleteAccount,\n- changeUserSettings,\n- resendVerificationEmail,\n- },\n-)(UserSettingsModal);\n+ );\n+ const callDeleteAccount = useServerCall(deleteAccount);\n+ const callChangeUserSettings = useServerCall(changeUserSettings);\n+ const callResendVerificationEmail = useServerCall(resendVerificationEmail);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <UserSettingsModal\n+ {...props}\n+ currentUserInfo={currentUserInfo}\n+ preRequestUserState={preRequestUserState}\n+ inputDisabled={inputDisabled}\n+ deleteAccount={callDeleteAccount}\n+ changeUserSettings={callChangeUserSettings}\n+ resendVerificationEmail={callResendVerificationEmail}\n+ dispatchActionPromise={dispatchActionPromise}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook instead of connect function and HOC in UserSettingsModal
Test Plan: Tested settings modal pop
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D775 |
129,208 | 25.02.2021 11:42:13 | 18,000 | 641026c507d901d80a85b0917e6470e2c991b6b5 | [web] Use hook instead of connect function and HOC in VerificationModal
Test Plan: Flow
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "web/modals/account/verification-modal.react.js",
"new_path": "web/modals/account/verification-modal.react.js",
"diff": "@@ -7,17 +7,18 @@ import {\ntype ServerVerificationResult,\nverifyField,\n} from 'lib/types/verify-types';\n-import { connect } from 'lib/utils/redux-utils';\n-import type { AppState } from '../../redux/redux-setup';\n+import { useSelector } from '../../redux/redux-utils';\nimport css from '../../style.css';\nimport Modal from '../modal.react';\n-type Props = {\n- onClose: () => void,\n- // Redux state\n- serverVerificationResult: ?ServerVerificationResult,\n-};\n+type BaseProps = {|\n+ +onClose: () => void,\n+|};\n+type Props = {|\n+ ...BaseProps,\n+ +serverVerificationResult: ?ServerVerificationResult,\n+|};\nfunction VerificationModal(props: Props) {\nconst { onClose, serverVerificationResult } = props;\ninvariant(\n@@ -49,6 +50,17 @@ function VerificationModal(props: Props) {\n);\n}\n-export default connect((state: AppState) => ({\n- serverVerificationResult: state.serverVerificationResult,\n-}))(VerificationModal);\n+export default React.memo<BaseProps>(function ConnectedVerificationModal(\n+ props: BaseProps,\n+) {\n+ const serverVerificationResult = useSelector(\n+ (state) => state.serverVerificationResult,\n+ );\n+\n+ return (\n+ <VerificationModal\n+ {...props}\n+ serverVerificationResult={serverVerificationResult}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook instead of connect function and HOC in VerificationModal
Test Plan: Flow
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D776 |
129,208 | 25.02.2021 11:44:52 | 18,000 | f220ac7b45c4db44e95a9a12b1c24d8f82acae6d | [native] Use hook instead of connect function and HOC in AppearancePreferences
Test Plan: Tested to see if the theme could still be changed.
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/more/appearance-preferences.react.js",
"new_path": "native/more/appearance-preferences.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { View, Text, ScrollView, Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/Ionicons';\n+import { useDispatch } from 'react-redux';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport Button from '../components/button.react';\nimport { updateThemeInfoActionType } from '../redux/action-types';\n-import type { AppState } from '../redux/redux-setup';\n-import {\n- type Colors,\n- colorsPropType,\n- colorsSelector,\n- styleSelector,\n-} from '../themes/colors';\n+import { useSelector } from '../redux/redux-utils';\n+import { type Colors, useColors, useStyles } from '../themes/colors';\nimport {\ntype GlobalThemePreference,\ntype GlobalThemeInfo,\n- globalThemeInfoPropType,\nosCanTheme,\n} from '../types/themes';\nconst CheckIcon = () => (\n- <Icon name=\"md-checkmark\" size={20} color=\"#008800\" style={styles.icon} />\n+ <Icon\n+ name=\"md-checkmark\"\n+ size={20}\n+ color=\"#008800\"\n+ style={unboundStyles.icon}\n+ />\n);\ntype OptionText = {|\n@@ -43,22 +41,14 @@ if (osCanTheme) {\n});\n}\n-type Props = {|\n- // Redux state\n- globalThemeInfo: GlobalThemeInfo,\n- styles: typeof styles,\n- colors: Colors,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n-|};\n-class AppearancePreferences extends React.PureComponent<Props> {\n- static propTypes = {\n- globalThemeInfo: globalThemeInfoPropType.isRequired,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- colors: colorsPropType.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n+type Props = {\n+ +globalThemeInfo: GlobalThemeInfo,\n+ +styles: typeof unboundStyles,\n+ +colors: Colors,\n+ +dispatch: Dispatch,\n+ ...\n};\n-\n+class AppearancePreferences extends React.PureComponent<Props> {\nrender() {\nconst { panelIosHighlightUnderlay: underlay } = this.props.colors;\n@@ -107,14 +97,17 @@ class AppearancePreferences extends React.PureComponent<Props> {\nthemePreference === 'system'\n? this.props.globalThemeInfo.systemTheme\n: themePreference;\n- this.props.dispatchActionPayload(updateThemeInfoActionType, {\n+ this.props.dispatch({\n+ type: updateThemeInfoActionType,\n+ payload: {\npreference: themePreference,\nactiveTheme: theme,\n+ },\n});\n};\n}\n-const styles = {\n+const unboundStyles = {\nheader: {\ncolor: 'panelBackgroundLabel',\nfontSize: 12,\n@@ -155,14 +148,22 @@ const styles = {\npaddingVertical: 2,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect(\n- (state: AppState) => ({\n- globalThemeInfo: state.globalThemeInfo,\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- }),\n- null,\n- true,\n-)(AppearancePreferences);\n+export default React.memo<{ ... }>(\n+ function ConnectedAppearancePreferences(props: { ... }) {\n+ const globalThemeInfo = useSelector((state) => state.globalThemeInfo);\n+ const styles = useStyles(unboundStyles);\n+ const colors = useColors();\n+ const dispatch = useDispatch();\n+\n+ return (\n+ <AppearancePreferences\n+ {...props}\n+ globalThemeInfo={globalThemeInfo}\n+ styles={styles}\n+ colors={colors}\n+ dispatch={dispatch}\n+ />\n+ );\n+ },\n+);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect function and HOC in AppearancePreferences
Test Plan: Tested to see if the theme could still be changed.
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D798 |
129,208 | 25.02.2021 11:51:31 | 18,000 | 70b06ebaf621d886ff1da7b771a3c28bf6dc9d35 | [native] Use hook instead of connect function and HOC in CustomServerModal
Test Plan: Tested to see if modal still popped up and pressing go still worked
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/more/custom-server-modal.react.js",
"new_path": "native/more/custom-server-modal.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { Text, TextInput } from 'react-native';\n+import { useDispatch } from 'react-redux';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport { setURLPrefix } from 'lib/utils/url-utils';\nimport Button from '../components/button.react';\nimport Modal from '../components/modal.react';\nimport type { RootNavigationProp } from '../navigation/root-navigator.react';\n-import type { AppState } from '../redux/redux-setup';\n-import { styleSelector } from '../themes/colors';\n+import type { NavigationRoute } from '../navigation/route-names';\n+import { useSelector } from '../redux/redux-utils';\n+import { useStyles } from '../themes/colors';\nimport { setCustomServer } from '../utils/url-utils';\nexport type CustomServerModalParams = {|\npresentedFrom: string,\n|};\n+type BaseProps = {|\n+ +navigation: RootNavigationProp<'CustomServerModal'>,\n+ +route: NavigationRoute<'CustomServerModal'>,\n+|};\ntype Props = {|\n- navigation: RootNavigationProp<'CustomServerModal'>,\n- // Redux state\n- urlPrefix: string,\n- customServer: ?string,\n- styles: typeof styles,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n+ ...BaseProps,\n+ +urlPrefix: string,\n+ +customServer: ?string,\n+ +styles: typeof unboundStyles,\n+ +dispatch: Dispatch,\n|};\ntype State = {|\ncustomServer: string,\n|};\nclass CustomServerModal extends React.PureComponent<Props, State> {\n- static propTypes = {\n- navigation: PropTypes.shape({\n- goBackOnce: PropTypes.func.isRequired,\n- }).isRequired,\n- urlPrefix: PropTypes.string.isRequired,\n- customServer: PropTypes.string,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\n-\nconstructor(props: Props) {\nsuper(props);\nconst { customServer } = props;\n@@ -76,16 +68,22 @@ class CustomServerModal extends React.PureComponent<Props, State> {\nonPressGo = () => {\nconst { customServer } = this.state;\nif (customServer !== this.props.urlPrefix) {\n- this.props.dispatchActionPayload(setURLPrefix, customServer);\n+ this.props.dispatch({\n+ type: setURLPrefix,\n+ payload: customServer,\n+ });\n}\nif (customServer && customServer !== this.props.customServer) {\n- this.props.dispatchActionPayload(setCustomServer, customServer);\n+ this.props.dispatch({\n+ type: setCustomServer,\n+ payload: customServer,\n+ });\n}\nthis.props.navigation.goBackOnce();\n};\n}\n-const styles = {\n+const unboundStyles = {\nbutton: {\nbackgroundColor: 'greenButton',\nborderRadius: 5,\n@@ -115,14 +113,22 @@ const styles = {\nborderBottomColor: 'transparent',\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect(\n- (state: AppState) => ({\n- urlPrefix: state.urlPrefix,\n- customServer: state.customServer,\n- styles: stylesSelector(state),\n- }),\n- null,\n- true,\n-)(CustomServerModal);\n+export default React.memo<BaseProps>(function ConnectedCustomServerModal(\n+ props: BaseProps,\n+) {\n+ const urlPrefix = useSelector((state) => state.urlPrefix);\n+ const customServer = useSelector((state) => state.customServer);\n+ const styles = useStyles(unboundStyles);\n+ const dispatch = useDispatch();\n+\n+ return (\n+ <CustomServerModal\n+ {...props}\n+ urlPrefix={urlPrefix}\n+ customServer={customServer}\n+ styles={styles}\n+ dispatch={dispatch}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect function and HOC in CustomServerModal
Test Plan: Tested to see if modal still popped up and pressing go still worked
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D801 |
129,187 | 25.02.2021 10:50:38 | 18,000 | 9e15dd3594153b2c09e9729171511f128e298ef2 | [lib] Only pass threadID to getMostRecentNonLocalMessageID
Summary: Some potential callers have `RawThreadInfo` instead of `ThreadInfo`, so this will make it easier to use this function from more places.
Test Plan: Flow
Reviewers: atul, subnub, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/chat-selectors.js",
"new_path": "lib/selectors/chat-selectors.js",
"diff": "@@ -111,7 +111,7 @@ function createChatThreadItem(\nmessages,\n);\nconst mostRecentNonLocalMessage = getMostRecentNonLocalMessageID(\n- threadInfo,\n+ threadInfo.id,\nmessageStore,\n);\nconst lastUpdatedTime = getLastUpdatedTime(threadInfo, mostRecentMessageInfo);\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/selectors/thread-selectors.js",
"new_path": "lib/selectors/thread-selectors.js",
"diff": "@@ -205,7 +205,7 @@ const sidebarInfoSelector: (\nconst lastUpdatedTime =\nmostRecentRawMessageInfo?.time ?? childThreadInfo.creationTime;\nconst mostRecentNonLocalMessage = getMostRecentNonLocalMessageID(\n- childThreadInfo,\n+ childThreadInfo.id,\nmessageStore,\n);\nsidebarInfos.push({\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -344,10 +344,10 @@ function createMessageReply(message: string) {\n}\nfunction getMostRecentNonLocalMessageID(\n- threadInfo: ThreadInfo,\n+ threadID: string,\nmessageStore: MessageStore,\n): ?string {\n- const thread = messageStore.threads[threadInfo.id];\n+ const thread = messageStore.threads[threadID];\nreturn thread?.messageIDs.find((id) => !id.startsWith('local'));\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Only pass threadID to getMostRecentNonLocalMessageID
Summary: Some potential callers have `RawThreadInfo` instead of `ThreadInfo`, so this will make it easier to use this function from more places.
Test Plan: Flow
Reviewers: atul, subnub, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D808 |
129,187 | 25.02.2021 10:52:52 | 18,000 | 27dad91483deef04ce62c2e1fe8dfda39db2c469 | [lib] Use getMostRecentNonLocalMessageID in ActivityHandler
Test Plan: Flow
Reviewers: atul, subnub, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/socket/activity-handler.react.js",
"new_path": "lib/socket/activity-handler.react.js",
"diff": "@@ -7,13 +7,14 @@ import {\nupdateActivityActionTypes,\nupdateActivity,\n} from '../actions/activity-actions';\n+import { getMostRecentNonLocalMessageID } from '../shared/message-utils';\nimport { queueActivityUpdatesActionType } from '../types/activity-types';\nimport { useServerCall, useDispatchActionPromise } from '../utils/action-utils';\nimport { useSelector } from '../utils/redux-utils';\ntype Props = {|\n- activeThread: ?string,\n- frozen: boolean,\n+ +activeThread: ?string,\n+ +frozen: boolean,\n|};\nfunction ActivityHandler(props: Props) {\nconst { activeThread, frozen } = props;\n@@ -36,9 +37,7 @@ function ActivityHandler(props: Props) {\nif (!activeThread) {\nreturn undefined;\n}\n- return state.messageStore.threads[activeThread]?.messageIDs.find(\n- (id) => !id.startsWith('local'),\n- );\n+ return getMostRecentNonLocalMessageID(activeThread, state.messageStore);\n});\nconst prevActiveThreadLatestMessageRef = React.useRef();\nReact.useEffect(() => {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use getMostRecentNonLocalMessageID in ActivityHandler
Test Plan: Flow
Reviewers: atul, subnub, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D809 |
129,187 | 25.02.2021 10:47:51 | 18,000 | 9657668b2a61a83c48b8eda70b8129479eedc65c | [lib] Avoid setting inaccessible MessageInfo as mostRecentMessageInfo
Summary: This fixes a bug where the `MessagePreview` displays "No messages" even though the `MessageList` shows messages.
Test Plan: Flow
Reviewers: atul, subnub, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/chat-selectors.js",
"new_path": "lib/selectors/chat-selectors.js",
"diff": "@@ -84,8 +84,11 @@ function getMostRecentMessageInfo(\nif (!thread) {\nreturn null;\n}\n- for (let messageID of thread.messageIDs) {\n- return messages[messageID];\n+ for (const messageID of thread.messageIDs) {\n+ const messageInfo = messages[messageID];\n+ if (messageInfo) {\n+ return messageInfo;\n+ }\n}\nreturn null;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Avoid setting inaccessible MessageInfo as mostRecentMessageInfo
Summary: This fixes a bug where the `MessagePreview` displays "No messages" even though the `MessageList` shows messages.
Test Plan: Flow
Reviewers: atul, subnub, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D810 |
129,208 | 25.02.2021 11:58:52 | 18,000 | 62649c39a4c146e9e55b7cfcd63e2b59b6392d7e | [native] Use hook insteaf of connect function and HOC in DevTools
Test Plan: Checked if you could still navigate to dev tools, and functions such as 'Trigger a crash' still worked
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/more/dev-tools.react.js",
"new_path": "native/more/dev-tools.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { View, Text, ScrollView, Platform } from 'react-native';\nimport ExitApp from 'react-native-exit-app';\nimport Icon from 'react-native-vector-icons/Ionicons';\n+import { useDispatch } from 'react-redux';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport { setURLPrefix } from 'lib/utils/url-utils';\nimport Button from '../components/button.react';\nimport type { NavigationRoute } from '../navigation/route-names';\nimport { CustomServerModalRouteName } from '../navigation/route-names';\n-import type { AppState } from '../redux/redux-setup';\n-import {\n- type Colors,\n- colorsPropType,\n- colorsSelector,\n- styleSelector,\n-} from '../themes/colors';\n+import { useSelector } from '../redux/redux-utils';\n+import { useColors, useStyles, type Colors } from '../themes/colors';\nimport { wipeAndExit } from '../utils/crash-utils';\nimport { serverOptions } from '../utils/url-utils';\nimport type { MoreNavigationProp } from './more.react';\nconst ServerIcon = () => (\n- <Icon name=\"md-checkmark\" size={20} color=\"#008800\" style={styles.icon} />\n+ <Icon\n+ name=\"md-checkmark\"\n+ size={20}\n+ color=\"#008800\"\n+ style={unboundStyles.icon}\n+ />\n);\n+type BaseProps = {|\n+ +navigation: MoreNavigationProp<'DevTools'>,\n+ +route: NavigationRoute<'DevTools'>,\n+|};\ntype Props = {|\n- navigation: MoreNavigationProp<'DevTools'>,\n- route: NavigationRoute<'DevTools'>,\n- // Redux state\n- urlPrefix: string,\n- customServer: ?string,\n- colors: Colors,\n- styles: typeof styles,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n+ ...BaseProps,\n+ +urlPrefix: string,\n+ +customServer: ?string,\n+ +colors: Colors,\n+ +styles: typeof unboundStyles,\n+ +dispatch: Dispatch,\n|};\nclass DevTools extends React.PureComponent<Props> {\n- static propTypes = {\n- navigation: PropTypes.shape({\n- navigate: PropTypes.func.isRequired,\n- }).isRequired,\n- route: PropTypes.shape({\n- key: PropTypes.string.isRequired,\n- }).isRequired,\n- urlPrefix: PropTypes.string.isRequired,\n- customServer: PropTypes.string,\n- colors: colorsPropType.isRequired,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\n-\nrender() {\nconst { panelIosHighlightUnderlay: underlay } = this.props.colors;\n@@ -167,7 +153,10 @@ class DevTools extends React.PureComponent<Props> {\nonSelectServer = (server: string) => {\nif (server !== this.props.urlPrefix) {\n- this.props.dispatchActionPayload(setURLPrefix, server);\n+ this.props.dispatch({\n+ type: setURLPrefix,\n+ payload: server,\n+ });\n}\n};\n@@ -178,7 +167,7 @@ class DevTools extends React.PureComponent<Props> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nflex: 1,\n},\n@@ -234,14 +223,24 @@ const styles = {\npaddingVertical: 2,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect(\n- (state: AppState) => ({\n- urlPrefix: state.urlPrefix,\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- }),\n- null,\n- true,\n-)(DevTools);\n+export default React.memo<BaseProps>(function ConnectedDevTools(\n+ props: BaseProps,\n+) {\n+ const urlPrefix = useSelector((state) => state.urlPrefix);\n+ const customServer = useSelector((state) => state.customServer);\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ const dispatch = useDispatch();\n+\n+ return (\n+ <DevTools\n+ {...props}\n+ urlPrefix={urlPrefix}\n+ customServer={customServer}\n+ colors={colors}\n+ styles={styles}\n+ dispatch={dispatch}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook insteaf of connect function and HOC in DevTools
Test Plan: Checked if you could still navigate to dev tools, and functions such as 'Trigger a crash' still worked
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D802 |
129,208 | 25.02.2021 12:02:03 | 18,000 | 7782432a5ecb00d7b000f5ed39a31c1b21c79e0d | [native] Use hook instead of connect function and HOC in EditEmail
Test Plan: Checked if you could still navigate to the email section, and that changing email still worked
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "native/more/edit-email.react.js",
"new_path": "native/more/edit-email.react.js",
"diff": "import { CommonActions } from '@react-navigation/native';\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\nText,\n@@ -20,55 +19,42 @@ import {\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { validEmailRegex } from 'lib/shared/account-utils';\nimport type { ChangeUserSettingsResult } from 'lib/types/account-types';\n-import { loadingStatusPropType } from 'lib/types/loading-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { AccountUpdate } from 'lib/types/user-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ type DispatchActionPromise,\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\nimport Button from '../components/button.react';\n-import type { AppState } from '../redux/redux-setup';\n-import {\n- type Colors,\n- colorsPropType,\n- colorsSelector,\n- styleSelector,\n-} from '../themes/colors';\n-import { type GlobalTheme, globalThemePropType } from '../types/themes';\n+import type { NavigationRoute } from '../navigation/route-names';\n+import { useSelector } from '../redux/redux-utils';\n+import { type Colors, useColors, useStyles } from '../themes/colors';\n+import { type GlobalTheme } from '../types/themes';\nimport type { MoreNavigationProp } from './more.react';\n+type BaseProps = {|\n+ +navigation: MoreNavigationProp<'EditEmail'>,\n+ +route: NavigationRoute<'EditEmail'>,\n+|};\ntype Props = {|\n- navigation: MoreNavigationProp<'EditEmail'>,\n- // Redux state\n- email: ?string,\n- loadingStatus: LoadingStatus,\n- activeTheme: ?GlobalTheme,\n- colors: Colors,\n- styles: typeof styles,\n- // Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- changeUserSettings: (\n+ ...BaseProps,\n+ +email: ?string,\n+ +loadingStatus: LoadingStatus,\n+ +activeTheme: ?GlobalTheme,\n+ +colors: Colors,\n+ +styles: typeof unboundStyles,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +changeUserSettings: (\naccountUpdate: AccountUpdate,\n) => Promise<ChangeUserSettingsResult>,\n|};\ntype State = {|\n- email: string,\n- password: string,\n+ +email: string,\n+ +password: string,\n|};\nclass EditEmail extends React.PureComponent<Props, State> {\n- static propTypes = {\n- navigation: PropTypes.shape({\n- dispatch: PropTypes.func.isRequired,\n- }).isRequired,\n- email: PropTypes.string,\n- loadingStatus: loadingStatusPropType.isRequired,\n- activeTheme: globalThemePropType,\n- colors: colorsPropType.isRequired,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- changeUserSettings: PropTypes.func.isRequired,\n- };\nmounted = false;\npasswordInput: ?React.ElementRef<typeof TextInput>;\nemailInput: ?React.ElementRef<typeof TextInput>;\n@@ -253,7 +239,7 @@ class EditEmail extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\nheader: {\ncolor: 'panelBackgroundLabel',\nfontSize: 12,\n@@ -300,22 +286,36 @@ const styles = {\npaddingVertical: 12,\n},\n};\n-const stylesSelector = styleSelector(styles);\nconst loadingStatusSelector = createLoadingStatusSelector(\nchangeUserSettingsActionTypes,\n);\n-export default connect(\n- (state: AppState) => ({\n- email:\n+export default React.memo<BaseProps>(function ConnectedEditEmail(\n+ props: BaseProps,\n+) {\n+ const email = useSelector((state) =>\nstate.currentUserInfo && !state.currentUserInfo.anonymous\n? state.currentUserInfo.email\n: undefined,\n- loadingStatus: loadingStatusSelector(state),\n- activeTheme: state.globalThemeInfo.activeTheme,\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- }),\n- { changeUserSettings },\n-)(EditEmail);\n+ );\n+ const loadingStatus = useSelector(loadingStatusSelector);\n+ const activeTheme = useSelector((state) => state.globalThemeInfo.activeTheme);\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ const callChangeUserSettings = useServerCall(changeUserSettings);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <EditEmail\n+ {...props}\n+ email={email}\n+ loadingStatus={loadingStatus}\n+ activeTheme={activeTheme}\n+ colors={colors}\n+ styles={styles}\n+ changeUserSettings={callChangeUserSettings}\n+ dispatchActionPromise={dispatchActionPromise}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect function and HOC in EditEmail
Test Plan: Checked if you could still navigate to the email section, and that changing email still worked
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D803 |
129,208 | 25.02.2021 20:42:18 | 18,000 | 2c626a520275c58189545086509854cb8d9855d9 | [web] Use hook instead of connect function in HistoryEntry
Test Plan: Tested to see if history entry still showed up, and functions such as restore entry still worked
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "web/modals/history/history-entry.react.js",
"new_path": "web/modals/history/history-entry.react.js",
"diff": "import classNames from 'classnames';\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\n@@ -14,36 +13,37 @@ import { threadInfoSelector } from 'lib/selectors/thread-selectors';\nimport { colorIsDark } from 'lib/shared/thread-utils';\nimport {\ntype EntryInfo,\n- entryInfoPropType,\ntype RestoreEntryInfo,\ntype RestoreEntryResponse,\ntype CalendarQuery,\n} from 'lib/types/entry-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n-import { threadInfoPropType } from 'lib/types/thread-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ type DispatchActionPromise,\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\nimport LoadingIndicator from '../../loading-indicator.react';\n-import type { AppState } from '../../redux/redux-setup';\n+import { useSelector } from '../../redux/redux-utils';\nimport { nonThreadCalendarQuery } from '../../selectors/nav-selectors';\nimport css from './history.css';\n-type Props = {\n- entryInfo: EntryInfo,\n- onClick: (entryID: string) => void,\n- animateAndLoadEntry: (entryID: string) => void,\n- // Redux state\n- threadInfo: ThreadInfo,\n- loggedIn: boolean,\n- restoreLoadingStatus: LoadingStatus,\n- calendarQuery: () => CalendarQuery,\n- // Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- restoreEntry: (info: RestoreEntryInfo) => Promise<RestoreEntryResponse>,\n-};\n+type BaseProps = {|\n+ +entryInfo: EntryInfo,\n+ +onClick: (entryID: string) => void,\n+ +animateAndLoadEntry: (entryID: string) => void,\n+|};\n+type Props = {|\n+ ...BaseProps,\n+ +threadInfo: ThreadInfo,\n+ +loggedIn: boolean,\n+ +restoreLoadingStatus: LoadingStatus,\n+ +calendarQuery: () => CalendarQuery,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +restoreEntry: (info: RestoreEntryInfo) => Promise<RestoreEntryResponse>,\n+|};\nclass HistoryEntry extends React.PureComponent<Props> {\nrender() {\n@@ -145,35 +145,37 @@ class HistoryEntry extends React.PureComponent<Props> {\n}\n}\n-HistoryEntry.propTypes = {\n- entryInfo: entryInfoPropType,\n- onClick: PropTypes.func.isRequired,\n- animateAndLoadEntry: PropTypes.func.isRequired,\n- threadInfo: threadInfoPropType,\n- loggedIn: PropTypes.bool.isRequired,\n- restoreLoadingStatus: PropTypes.string.isRequired,\n- calendarQuery: PropTypes.func.isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- restoreEntry: PropTypes.func.isRequired,\n-};\n-\n-export default connect(\n- (state: AppState, ownProps: { entryInfo: EntryInfo }) => {\n- const entryID = ownProps.entryInfo.id;\n+export default React.memo<BaseProps>(function ConnectedHistoryEntry(\n+ props: BaseProps,\n+) {\n+ const entryID = props.entryInfo.id;\ninvariant(entryID, 'entryInfo.id (serverID) should be set');\n- return {\n- threadInfo: threadInfoSelector(state)[ownProps.entryInfo.threadID],\n- loggedIn: !!(\n- state.currentUserInfo &&\n- !state.currentUserInfo.anonymous &&\n- true\n- ),\n- restoreLoadingStatus: createLoadingStatusSelector(\n+ const threadInfo = useSelector(\n+ (state) => threadInfoSelector(state)[props.entryInfo.threadID],\n+ );\n+ const loggedIn = useSelector(\n+ (state) =>\n+ !!(state.currentUserInfo && !state.currentUserInfo.anonymous && true),\n+ );\n+ const restoreLoadingStatus = useSelector(\n+ createLoadingStatusSelector(\nrestoreEntryActionTypes,\n`${restoreEntryActionTypes.started}:${entryID}`,\n- )(state),\n- calendarQuery: nonThreadCalendarQuery(state),\n- };\n- },\n- { restoreEntry },\n-)(HistoryEntry);\n+ ),\n+ );\n+ const calanderQuery = useSelector(nonThreadCalendarQuery);\n+ const callRestoreEntry = useServerCall(restoreEntry);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <HistoryEntry\n+ {...props}\n+ threadInfo={threadInfo}\n+ loggedIn={loggedIn}\n+ restoreLoadingStatus={restoreLoadingStatus}\n+ calendarQuery={calanderQuery}\n+ restoreEntry={callRestoreEntry}\n+ dispatchActionPromise={dispatchActionPromise}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook instead of connect function in HistoryEntry
Test Plan: Tested to see if history entry still showed up, and functions such as restore entry still worked
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D813 |
129,208 | 25.02.2021 20:44:54 | 18,000 | c7a0db0c54a273272f1ac83b48c370f97d3f9402 | [web] Use hook instead of connect function in HistoryModal
Test Plan: Checked if the history modal still popped up and worked correctly.
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "web/modals/history/history-modal.react.js",
"new_path": "web/modals/history/history-modal.react.js",
"diff": "@@ -7,7 +7,6 @@ import _filter from 'lodash/fp/filter';\nimport _flow from 'lodash/fp/flow';\nimport _map from 'lodash/fp/map';\nimport _unionBy from 'lodash/fp/unionBy';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\n@@ -23,49 +22,48 @@ import type {\nCalendarQuery,\nFetchEntryInfosResult,\n} from 'lib/types/entry-types';\n-import { entryInfoPropType } from 'lib/types/entry-types';\n-import {\n- type CalendarFilter,\n- calendarFilterPropType,\n-} from 'lib/types/filter-types';\n+import { type CalendarFilter } from 'lib/types/filter-types';\nimport type { HistoryMode, HistoryRevisionInfo } from 'lib/types/history-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import {\n+ type DispatchActionPromise,\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport { dateFromString } from 'lib/utils/date-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport LoadingIndicator from '../../loading-indicator.react';\n-import type { AppState } from '../../redux/redux-setup';\n+import { useSelector } from '../../redux/redux-utils';\nimport { allDaysToEntries } from '../../selectors/entry-selectors';\nimport Modal from '../modal.react';\nimport HistoryEntry from './history-entry.react';\nimport HistoryRevision from './history-revision.react';\nimport css from './history.css';\n-type Props = {\n- mode: HistoryMode,\n- dayString: string,\n- onClose: () => void,\n- currentEntryID?: ?string,\n- // Redux state\n- entryInfos: ?(EntryInfo[]),\n- dayLoadingStatus: LoadingStatus,\n- entryLoadingStatus: LoadingStatus,\n- calendarFilters: $ReadOnlyArray<CalendarFilter>,\n- // Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- fetchEntries: (\n+type BaseProps = {|\n+ +mode: HistoryMode,\n+ +dayString: string,\n+ +onClose: () => void,\n+ +currentEntryID?: ?string,\n+|};\n+type Props = {|\n+ ...BaseProps,\n+ +entryInfos: ?(EntryInfo[]),\n+ +dayLoadingStatus: LoadingStatus,\n+ +entryLoadingStatus: LoadingStatus,\n+ +calendarFilters: $ReadOnlyArray<CalendarFilter>,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +fetchEntries: (\ncalendarQuery: CalendarQuery,\n) => Promise<FetchEntryInfosResult>,\n- fetchRevisionsForEntry: (entryID: string) => Promise<HistoryRevisionInfo[]>,\n-};\n-type State = {\n- mode: HistoryMode,\n- animateModeChange: boolean,\n- currentEntryID: ?string,\n- revisions: HistoryRevisionInfo[],\n-};\n+ +fetchRevisionsForEntry: (entryID: string) => Promise<HistoryRevisionInfo[]>,\n+|};\n+type State = {|\n+ +mode: HistoryMode,\n+ +animateModeChange: boolean,\n+ +currentEntryID: ?string,\n+ +revisions: $ReadOnlyArray<HistoryRevisionInfo>,\n+|};\nclass HistoryModal extends React.PureComponent<Props, State> {\nstatic defaultProps = { currentEntryID: null };\n@@ -243,20 +241,6 @@ class HistoryModal extends React.PureComponent<Props, State> {\n};\n}\n-HistoryModal.propTypes = {\n- mode: PropTypes.string.isRequired,\n- dayString: PropTypes.string.isRequired,\n- onClose: PropTypes.func.isRequired,\n- currentEntryID: PropTypes.string,\n- entryInfos: PropTypes.arrayOf(entryInfoPropType),\n- dayLoadingStatus: PropTypes.string.isRequired,\n- entryLoadingStatus: PropTypes.string.isRequired,\n- calendarFilters: PropTypes.arrayOf(calendarFilterPropType).isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- fetchEntries: PropTypes.func.isRequired,\n- fetchRevisionsForEntry: PropTypes.func.isRequired,\n-};\n-\nconst dayLoadingStatusSelector = createLoadingStatusSelector(\nfetchEntriesActionTypes,\n);\n@@ -264,13 +248,29 @@ const entryLoadingStatusSelector = createLoadingStatusSelector(\nfetchRevisionsForEntryActionTypes,\n);\n-type OwnProps = { dayString: string };\n-export default connect(\n- (state: AppState, ownProps: OwnProps) => ({\n- entryInfos: allDaysToEntries(state)[ownProps.dayString],\n- dayLoadingStatus: dayLoadingStatusSelector(state),\n- entryLoadingStatus: entryLoadingStatusSelector(state),\n- calendarFilters: nonExcludeDeletedCalendarFiltersSelector(state),\n- }),\n- { fetchEntries, fetchRevisionsForEntry },\n-)(HistoryModal);\n+export default React.memo<BaseProps>(function ConnectedHistoryModal(\n+ props: BaseProps,\n+) {\n+ const entryInfos = useSelector(\n+ (state) => allDaysToEntries(state)[props.dayString],\n+ );\n+ const dayLoadingStatus = useSelector(dayLoadingStatusSelector);\n+ const entryLoadingStatus = useSelector(entryLoadingStatusSelector);\n+ const calendarFilters = useSelector(nonExcludeDeletedCalendarFiltersSelector);\n+ const callFetchEntries = useServerCall(fetchEntries);\n+ const callFetchRevisionsForEntry = useServerCall(fetchRevisionsForEntry);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <HistoryModal\n+ {...props}\n+ entryInfos={entryInfos}\n+ dayLoadingStatus={dayLoadingStatus}\n+ entryLoadingStatus={entryLoadingStatus}\n+ calendarFilters={calendarFilters}\n+ fetchEntries={callFetchEntries}\n+ fetchRevisionsForEntry={callFetchRevisionsForEntry}\n+ dispatchActionPromise={dispatchActionPromise}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook instead of connect function in HistoryModal
Test Plan: Checked if the history modal still popped up and worked correctly.
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D814 |
129,208 | 25.02.2021 20:53:04 | 18,000 | 9b675d87a440cfc7a7e3c0945246b5ca2648aed1 | [web] Use hook instead of connect function and HOC in NewThreadModal
Test Plan: Flow
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "web/modals/threads/new-thread-modal.react.js",
"new_path": "web/modals/threads/new-thread-modal.react.js",
"diff": "// @flow\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { newThreadActionTypes, newThread } from 'lib/actions/thread-actions';\n@@ -13,49 +12,43 @@ import {\n} from 'lib/shared/thread-utils';\nimport {\ntype ThreadInfo,\n- threadInfoPropType,\nthreadTypes,\nassertThreadType,\ntype ThreadType,\ntype NewThreadRequest,\ntype NewThreadResult,\n} from 'lib/types/thread-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ type DispatchActionPromise,\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\n-import type { AppState } from '../../redux/redux-setup';\n+import { useSelector } from '../../redux/redux-utils';\nimport css from '../../style.css';\nimport Modal from '../modal.react';\nimport ColorPicker from './color-picker.react';\n-type Props = {\n- onClose: () => void,\n- parentThreadID?: ?string,\n- // Redux state\n- inputDisabled: boolean,\n- parentThreadInfo: ?ThreadInfo,\n- // Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- newThread: (request: NewThreadRequest) => Promise<NewThreadResult>,\n-};\n-type State = {\n- threadType: ?ThreadType,\n- name: string,\n- description: string,\n- color: string,\n- errorMessage: string,\n-};\n+type BaseProps = {|\n+ +onClose: () => void,\n+ +parentThreadID?: ?string,\n+|};\n+type Props = {|\n+ ...BaseProps,\n+ +inputDisabled: boolean,\n+ +parentThreadInfo: ?ThreadInfo,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +newThread: (request: NewThreadRequest) => Promise<NewThreadResult>,\n+|};\n+type State = {|\n+ +threadType: ?ThreadType,\n+ +name: string,\n+ +description: string,\n+ +color: string,\n+ +errorMessage: string,\n+|};\nclass NewThreadModal extends React.PureComponent<Props, State> {\n- static propTypes = {\n- onClose: PropTypes.func.isRequired,\n- parentThreadID: PropTypes.string,\n- inputDisabled: PropTypes.bool.isRequired,\n- parentThreadInfo: threadInfoPropType,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- newThread: PropTypes.func.isRequired,\n- };\nnameInput: ?HTMLInputElement;\nopenPrivacyInput: ?HTMLInputElement;\nthreadPasswordInput: ?HTMLInputElement;\n@@ -286,18 +279,25 @@ class NewThreadModal extends React.PureComponent<Props, State> {\nconst loadingStatusSelector = createLoadingStatusSelector(newThreadActionTypes);\n-export default connect(\n- (state: AppState, ownProps: { parentThreadID?: ?string }) => {\n- let parentThreadInfo = null;\n- const parentThreadID = ownProps.parentThreadID;\n- if (parentThreadID) {\n- parentThreadInfo = threadInfoSelector(state)[parentThreadID];\n- invariant(parentThreadInfo, 'parent thread should exist');\n- }\n- return {\n- parentThreadInfo,\n- inputDisabled: loadingStatusSelector(state) === 'loading',\n- };\n- },\n- { newThread },\n-)(NewThreadModal);\n+export default React.memo<BaseProps>(function ConnectedNewThreadModal(\n+ props: BaseProps,\n+) {\n+ const { parentThreadID } = props;\n+ const parentThreadInfo: ?ThreadInfo = useSelector((state) =>\n+ parentThreadID ? threadInfoSelector(state)[parentThreadID] : null,\n+ );\n+ invariant(!parentThreadID || parentThreadInfo, 'parent thread should exist');\n+ const inputDisabled = useSelector(loadingStatusSelector) === 'loading';\n+ const callNewThread = useServerCall(newThread);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <NewThreadModal\n+ {...props}\n+ parentThreadInfo={parentThreadInfo}\n+ inputDisabled={inputDisabled}\n+ newThread={callNewThread}\n+ dispatchActionPromise={dispatchActionPromise}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook instead of connect function and HOC in NewThreadModal
Test Plan: Flow
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D817 |
129,208 | 25.02.2021 20:54:32 | 18,000 | 5ca9c8dd132666a9930e5d598c342fd6f81745cb | [web] Use hook instead of connect function in FilterPanel
Test Plan: Checked if the filter panel still showed up, and functions such as filtering, clear filter, and include deleted items still worked
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "web/calendar/filter-panel.react.js",
"new_path": "web/calendar/filter-panel.react.js",
"diff": "@@ -8,8 +8,8 @@ import {\n} from '@fortawesome/free-solid-svg-icons';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport classNames from 'classnames';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\n+import { useDispatch } from 'react-redux';\nimport Switch from 'react-switch';\nimport {\n@@ -20,17 +20,15 @@ import SearchIndex from 'lib/shared/search-index';\nimport {\ncalendarThreadFilterTypes,\ntype FilterThreadInfo,\n- filterThreadInfoPropType,\nupdateCalendarThreadFilter,\nclearCalendarThreadFilter,\nsetCalendarDeletedFilter,\n} from 'lib/types/filter-types';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport ThreadSettingsModal from '../modals/threads/thread-settings-modal.react';\n-import type { AppState } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\nimport {\nwebFilterThreadInfos,\nwebFilterThreadSearchIndex,\n@@ -38,30 +36,23 @@ import {\nimport { MagnifyingGlass } from '../vectors.react';\nimport css from './filter-panel.css';\n+type BaseProps = {|\n+ +setModal: (modal: ?React.Node) => void,\n+|};\ntype Props = {|\n- setModal: (modal: ?React.Node) => void,\n- // Redux state\n- filterThreadInfos: () => $ReadOnlyArray<FilterThreadInfo>,\n- filterThreadSearchIndex: () => SearchIndex,\n- filteredThreadIDs: ?Set<string>,\n- includeDeleted: boolean,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n+ ...BaseProps,\n+ +filterThreadInfos: () => $ReadOnlyArray<FilterThreadInfo>,\n+ +filterThreadSearchIndex: () => SearchIndex,\n+ +filteredThreadIDs: ?Set<string>,\n+ +includeDeleted: boolean,\n+ +dispatch: Dispatch,\n|};\ntype State = {|\n- query: string,\n- searchResults: $ReadOnlyArray<FilterThreadInfo>,\n- collapsed: boolean,\n+ +query: string,\n+ +searchResults: $ReadOnlyArray<FilterThreadInfo>,\n+ +collapsed: boolean,\n|};\nclass FilterPanel extends React.PureComponent<Props, State> {\n- static propTypes = {\n- setModal: PropTypes.func.isRequired,\n- filterThreadInfos: PropTypes.func.isRequired,\n- filterThreadSearchIndex: PropTypes.func.isRequired,\n- filteredThreadIDs: PropTypes.instanceOf(Set),\n- includeDeleted: PropTypes.bool.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\nstate: State = {\nquery: '',\nsearchResults: [],\n@@ -199,11 +190,16 @@ class FilterPanel extends React.PureComponent<Props, State> {\nsetFilterThreads(threadIDs: ?$ReadOnlyArray<string>) {\nif (!threadIDs) {\n- this.props.dispatchActionPayload(clearCalendarThreadFilter);\n+ this.props.dispatch({\n+ type: clearCalendarThreadFilter,\n+ });\n} else {\n- this.props.dispatchActionPayload(updateCalendarThreadFilter, {\n+ this.props.dispatch({\n+ type: updateCalendarThreadFilter,\n+ payload: {\ntype: calendarThreadFilterTypes.THREAD_LIST,\nthreadIDs,\n+ },\n});\n}\n}\n@@ -236,8 +232,11 @@ class FilterPanel extends React.PureComponent<Props, State> {\n};\nonChangeIncludeDeleted = (includeDeleted: boolean) => {\n- this.props.dispatchActionPayload(setCalendarDeletedFilter, {\n+ this.props.dispatch({\n+ type: setCalendarDeletedFilter,\n+ payload: {\nincludeDeleted,\n+ },\n});\n};\n@@ -247,21 +246,13 @@ class FilterPanel extends React.PureComponent<Props, State> {\n}\ntype ItemProps = {|\n- filterThreadInfo: FilterThreadInfo,\n- onToggle: (threadID: string, value: boolean) => void,\n- onClickOnly: (threadID: string) => void,\n- onClickSettings: (threadInfo: ThreadInfo) => void,\n- selected: boolean,\n+ +filterThreadInfo: FilterThreadInfo,\n+ +onToggle: (threadID: string, value: boolean) => void,\n+ +onClickOnly: (threadID: string) => void,\n+ +onClickSettings: (threadInfo: ThreadInfo) => void,\n+ +selected: boolean,\n|};\nclass Item extends React.PureComponent<ItemProps> {\n- static propTypes = {\n- filterThreadInfo: filterThreadInfoPropType.isRequired,\n- onToggle: PropTypes.func.isRequired,\n- onClickOnly: PropTypes.func.isRequired,\n- onClickSettings: PropTypes.func.isRequired,\n- selected: PropTypes.bool.isRequired,\n- };\n-\nrender() {\nconst threadInfo = this.props.filterThreadInfo.threadInfo;\nconst beforeCheckStyles = { borderColor: `#${threadInfo.color}` };\n@@ -323,21 +314,13 @@ class Item extends React.PureComponent<ItemProps> {\n}\ntype CategoryProps = {|\n- numThreads: number,\n- onToggle: (value: boolean) => void,\n- collapsed: boolean,\n- onCollapse: (value: boolean) => void,\n- selected: boolean,\n+ +numThreads: number,\n+ +onToggle: (value: boolean) => void,\n+ +collapsed: boolean,\n+ +onCollapse: (value: boolean) => void,\n+ +selected: boolean,\n|};\nclass Category extends React.PureComponent<CategoryProps> {\n- static propTypes = {\n- numThreads: PropTypes.number.isRequired,\n- onToggle: PropTypes.func.isRequired,\n- collapsed: PropTypes.bool.isRequired,\n- onCollapse: PropTypes.func.isRequired,\n- selected: PropTypes.bool.isRequired,\n- };\n-\nrender() {\nconst beforeCheckStyles = { borderColor: 'white' };\nlet afterCheck = null;\n@@ -387,13 +370,23 @@ class Category extends React.PureComponent<CategoryProps> {\n};\n}\n-export default connect(\n- (state: AppState) => ({\n- filteredThreadIDs: filteredThreadIDsSelector(state),\n- filterThreadInfos: webFilterThreadInfos(state),\n- filterThreadSearchIndex: webFilterThreadSearchIndex(state),\n- includeDeleted: includeDeletedSelector(state),\n- }),\n- null,\n- true,\n-)(FilterPanel);\n+export default React.memo<BaseProps>(function ConnectedFilterPanel(\n+ props: BaseProps,\n+) {\n+ const filteredThreadIDs = useSelector(filteredThreadIDsSelector);\n+ const filterThreadInfos = useSelector(webFilterThreadInfos);\n+ const filterThreadSearchIndex = useSelector(webFilterThreadSearchIndex);\n+ const includeDeleted = useSelector(includeDeletedSelector);\n+ const dispatch = useDispatch();\n+\n+ return (\n+ <FilterPanel\n+ {...props}\n+ filteredThreadIDs={filteredThreadIDs}\n+ filterThreadInfos={filterThreadInfos}\n+ filterThreadSearchIndex={filterThreadSearchIndex}\n+ includeDeleted={includeDeleted}\n+ dispatch={dispatch}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook instead of connect function in FilterPanel
Test Plan: Checked if the filter panel still showed up, and functions such as filtering, clear filter, and include deleted items still worked
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D818 |
129,191 | 25.02.2021 17:01:45 | -3,600 | 8bba96f97de80527fb27c4c36869384e314ea796 | [lib] Include source message id in pending thread id
Test Plan:
Create a thread from pending thread and check if correct members were added.
Create sideber (on web and native) and check if it was correct.
Reviewers: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -238,8 +238,14 @@ function getSingleOtherUser(\nreturn otherMemberIDs[0];\n}\n-function getPendingThreadKey(memberIDs: $ReadOnlyArray<string>) {\n- return [...memberIDs].sort().join('+');\n+function getPendingThreadKey(\n+ memberIDs: $ReadOnlyArray<string>,\n+ sourceMessageID: ?string,\n+) {\n+ const membersBasedID = [...memberIDs].sort().join('+');\n+ return sourceMessageID\n+ ? `${membersBasedID}/${sourceMessageID}`\n+ : membersBasedID;\n}\ntype CreatePendingThreadArgs = {|\n@@ -249,6 +255,7 @@ type CreatePendingThreadArgs = {|\n+parentThreadID?: ?string,\n+threadColor?: ?string,\n+name?: ?string,\n+ +sourceMessageID?: string,\n|};\nfunction createPendingThread({\n@@ -258,11 +265,12 @@ function createPendingThread({\nparentThreadID,\nthreadColor,\nname,\n+ sourceMessageID,\n}: CreatePendingThreadArgs) {\nconst now = Date.now();\nmembers = members ?? [];\nconst memberIDs = members.map((member) => member.id);\n- const threadID = `pending/${getPendingThreadKey(memberIDs)}`;\n+ const threadID = `pending/${getPendingThreadKey(memberIDs, sourceMessageID)}`;\nconst permissions = {\n[threadPermissions.KNOW_OF]: true,\n@@ -316,6 +324,7 @@ function createPendingThread({\nunread: false,\n},\nrepliesCount: 0,\n+ sourceMessageID,\n};\nconst userInfos = {};\n@@ -376,6 +385,7 @@ function createPendingSidebar(\nparentThreadID,\nthreadColor: color,\nname: threadName,\n+ sourceMessageID: messageInfo.id,\n});\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Include source message id in pending thread id
Test Plan:
Create a thread from pending thread and check if correct members were added.
Create sideber (on web and native) and check if it was correct.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D811 |
129,183 | 23.02.2021 09:11:45 | -3,600 | f239b577415f14e38f0b40258f8d67eac08c0622 | Extract hook to get message list data
Summary: Second part of extracting shared logic from message-list-container into hooks to get this working on web
Test Plan: Check if message list is displayed correctly like before
Reviewers: palys-swm, ashoat
Subscribers: ashoat, zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/chat-selectors.js",
"new_path": "lib/selectors/chat-selectors.js",
"diff": "@@ -17,7 +17,11 @@ import {\ncreateMessageInfo,\ngetMostRecentNonLocalMessageID,\n} from '../shared/message-utils';\n-import { threadIsTopLevel, threadInChatList } from '../shared/thread-utils';\n+import {\n+ threadIsTopLevel,\n+ threadInChatList,\n+ useSidebarCandidate,\n+} from '../shared/thread-utils';\nimport {\ntype MessageInfo,\ntype MessageStore,\n@@ -35,7 +39,7 @@ import {\nmaxReadSidebars,\nmaxUnreadSidebars,\n} from '../types/thread-types';\n-import type { UserInfo } from '../types/user-types';\n+import type { UserInfo, AccountUserInfo } from '../types/user-types';\nimport { threeDays } from '../utils/date-utils';\nimport {\nthreadInfoSelector,\n@@ -425,6 +429,53 @@ function getSourceMessageChatItemForPendingSidebar(\n}\n}\n+type UseMessageListDataArgs = {|\n+ +boundMessageListData: $ReadOnlyArray<ChatMessageItem>,\n+ +sourceMessageID: ?string,\n+ +searching: boolean,\n+ +userInfoInputArray: $ReadOnlyArray<AccountUserInfo>,\n+|};\n+\n+function useMessageListData({\n+ boundMessageListData,\n+ sourceMessageID,\n+ searching,\n+ userInfoInputArray,\n+}: UseMessageListDataArgs) {\n+ const threadInfos = useSelector(threadInfoSelector);\n+ const sidebarCandidate = useSidebarCandidate(sourceMessageID);\n+ const sidebarSourceMessageInfo = useSelector((state) =>\n+ sourceMessageID && !sidebarCandidate\n+ ? messageInfoSelector(state)[sourceMessageID]\n+ : null,\n+ );\n+ invariant(\n+ !sidebarSourceMessageInfo ||\n+ sidebarSourceMessageInfo.type !== messageTypes.SIDEBAR_SOURCE,\n+ 'sidebars can not be created from sidebar_source message',\n+ );\n+\n+ return React.useMemo(() => {\n+ if (searching && userInfoInputArray.length === 0) {\n+ return [];\n+ } else if (sidebarSourceMessageInfo) {\n+ return [\n+ getSourceMessageChatItemForPendingSidebar(\n+ sidebarSourceMessageInfo,\n+ threadInfos,\n+ ),\n+ ];\n+ }\n+ return boundMessageListData;\n+ }, [\n+ searching,\n+ userInfoInputArray.length,\n+ sidebarSourceMessageInfo,\n+ boundMessageListData,\n+ threadInfos,\n+ ]);\n+}\n+\nexport {\nmessageInfoSelector,\ncreateChatThreadItem,\n@@ -433,4 +484,5 @@ export {\nmessageListData,\nuseFlattenedChatListData,\ngetSourceMessageChatItemForPendingSidebar,\n+ useMessageListData,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -7,20 +7,15 @@ import { View } from 'react-native';\nimport {\ntype ChatMessageItem,\nmessageListData as messageListDataSelector,\n- messageInfoSelector,\n- getSourceMessageChatItemForPendingSidebar,\n+ useMessageListData,\n} from 'lib/selectors/chat-selectors';\n-import { threadInfoSelector } from 'lib/selectors/thread-selectors';\nimport {\nuserInfoSelectorForPotentialMembers,\nuserSearchIndexForPotentialMembers,\n} from 'lib/selectors/user-selectors';\nimport { messageID } from 'lib/shared/message-utils';\nimport { getPotentialMemberItems } from 'lib/shared/search-utils';\n-import {\n- useLatestThreadInfo,\n- useSidebarCandidate,\n-} from 'lib/shared/thread-utils';\n+import { useLatestThreadInfo } from 'lib/shared/thread-utils';\nimport { messageTypes } from 'lib/types/message-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport type { AccountUserInfo, UserListItem } from 'lib/types/user-types';\n@@ -339,7 +334,6 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\n[usernameInputText, otherUserInfos, userSearchIndex, userInfoInputArray],\n);\n- const threadInfos = useSelector(threadInfoSelector);\nconst threadInfoRef = React.useRef(props.route.params.threadInfo);\nconst [originalThreadInfo, setOriginalThreadInfo] = React.useState(\nprops.route.params.threadInfo,\n@@ -380,37 +374,13 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\n}, [setParams, threadInfo]);\nconst threadID = threadInfoRef.current.id;\n- const sidebarCandidate = useSidebarCandidate(sourceMessageID);\nconst boundMessageListData = useSelector(messageListDataSelector(threadID));\n- const sidebarSourceMessageInfo = useSelector((state) =>\n- sourceMessageID && !sidebarCandidate\n- ? messageInfoSelector(state)[sourceMessageID]\n- : null,\n- );\n- invariant(\n- !sidebarSourceMessageInfo ||\n- sidebarSourceMessageInfo.type !== messageTypes.SIDEBAR_SOURCE,\n- 'sidebars can not be created from sidebar_source message',\n- );\n- const messageListData = React.useMemo(() => {\n- if (searching && userInfoInputArray.length === 0) {\n- return [];\n- } else if (sidebarSourceMessageInfo) {\n- return [\n- getSourceMessageChatItemForPendingSidebar(\n- sidebarSourceMessageInfo,\n- threadInfos,\n- ),\n- ];\n- }\n- return boundMessageListData;\n- }, [\n- searching,\n- userInfoInputArray.length,\n- sidebarSourceMessageInfo,\n+ const messageListData = useMessageListData({\nboundMessageListData,\n- threadInfos,\n- ]);\n+ sourceMessageID,\n+ searching: !!searching,\n+ userInfoInputArray,\n+ });\nconst composedMessageMaxWidth = useSelector(composedMessageMaxWidthSelector);\nconst colors = useColors();\nconst styles = useStyles(unboundStyles);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Extract hook to get message list data
Summary: Second part of extracting shared logic from message-list-container into hooks to get this working on web
Test Plan: Check if message list is displayed correctly like before
Reviewers: palys-swm, ashoat
Reviewed By: palys-swm, ashoat
Subscribers: ashoat, zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D777 |
129,184 | 01.03.2021 10:13:00 | 28,800 | 7b2823df87b04525cd35938a3f7b029d13b18832 | [native] Play button for video messages
Summary: Added play button for video messages
Test Plan: Looked fine on iOS Simulator:
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub | [
{
"change_type": "MODIFY",
"old_path": "native/chat/inline-multimedia.react.js",
"new_path": "native/chat/inline-multimedia.react.js",
"diff": "@@ -4,6 +4,7 @@ import * as React from 'react';\nimport { View, StyleSheet, Text } from 'react-native';\nimport * as Progress from 'react-native-progress';\nimport Icon from 'react-native-vector-icons/Feather';\n+import IonIcon from 'react-native-vector-icons/Ionicons';\nimport tinycolor from 'tinycolor2';\nimport type { MediaInfo } from 'lib/types/media-types';\n@@ -81,6 +82,15 @@ function InlineMultimedia(props: Props) {\n);\n}\n+ let playButton;\n+ if (mediaInfo.type === 'video') {\n+ playButton = (\n+ <View style={styles.centerContainer}>\n+ <IonIcon name=\"ios-play-circle\" style={styles.playButton} size={80} />\n+ </View>\n+ );\n+ }\n+\nconst keyboardState = React.useContext(KeyboardContext);\nconst keyboardShowing = keyboardState?.keyboardShowing;\n@@ -92,7 +102,7 @@ function InlineMultimedia(props: Props) {\nstyle={styles.expand}\n>\n<Multimedia mediaInfo={mediaInfo} spinnerColor={props.spinnerColor} />\n- {progressIndicator}\n+ {progressIndicator ? progressIndicator : playButton}\n</GestureTouchableOpacity>\n);\n}\n@@ -110,6 +120,13 @@ const styles = StyleSheet.create({\nexpand: {\nflex: 1,\n},\n+ playButton: {\n+ color: 'white',\n+ opacity: 0.9,\n+ textShadowColor: '#000',\n+ textShadowOffset: { width: 0, height: 1 },\n+ textShadowRadius: 1,\n+ },\nprocessingStepText: {\ncolor: 'white',\nfontSize: 12,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Play button for video messages
Summary: Added play button for video messages
Test Plan: Looked fine on iOS Simulator: https://blob.sh/atul/comm-play-button.png
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub
Differential Revision: https://phabricator.ashoat.com/D834 |
129,208 | 02.03.2021 16:44:02 | 18,000 | 83670e83ddfb74c82c93ef7ee7d3cce897d03799 | [native] Use hook instead of connect function in MoreScreen
Test Plan: Checked if the user could still navigate to the more screen, and functions such as logging out, resending email verification, and deleting account still worked
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/more/more-screen.react.js",
"new_path": "native/more/more-screen.react.js",
"diff": "// @flow\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\nView,\n@@ -22,16 +21,13 @@ import {\nimport { preRequestUserStateSelector } from 'lib/selectors/account-selectors';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport type { LogOutResult } from 'lib/types/account-types';\n+import { type PreRequestUserState } from 'lib/types/session-types';\n+import { type CurrentUserInfo } from 'lib/types/user-types';\nimport {\n- type PreRequestUserState,\n- preRequestUserStatePropType,\n-} from 'lib/types/session-types';\n-import {\n- type CurrentUserInfo,\n- currentUserPropType,\n-} from 'lib/types/user-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+ type DispatchActionPromise,\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\nimport { firstLine } from 'lib/utils/string-utils';\nimport {\n@@ -41,6 +37,7 @@ import {\nimport Button from '../components/button.react';\nimport EditSettingButton from '../components/edit-setting-button.react';\nimport { SingleLine } from '../components/single-line.react';\n+import type { NavigationRoute } from '../navigation/route-names';\nimport {\nEditEmailRouteName,\nEditPasswordRouteName,\n@@ -51,46 +48,27 @@ import {\nFriendListRouteName,\nBlockListRouteName,\n} from '../navigation/route-names';\n-import type { AppState } from '../redux/redux-setup';\n-import {\n- type Colors,\n- colorsPropType,\n- colorsSelector,\n- styleSelector,\n-} from '../themes/colors';\n+import { useSelector } from '../redux/redux-utils';\n+import { type Colors, useColors, useStyles } from '../themes/colors';\nimport type { MoreNavigationProp } from './more.react';\n-type Props = {\n- navigation: MoreNavigationProp<'MoreScreen'>,\n- // Redux state\n- currentUserInfo: ?CurrentUserInfo,\n- preRequestUserState: PreRequestUserState,\n- resendVerificationLoading: boolean,\n- logOutLoading: boolean,\n- colors: Colors,\n- styles: typeof styles,\n- // Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- logOut: (preRequestUserState: PreRequestUserState) => Promise<LogOutResult>,\n- resendVerificationEmail: () => Promise<void>,\n-};\n+type BaseProps = {|\n+ +navigation: MoreNavigationProp<'MoreScreen'>,\n+ +route: NavigationRoute<'MoreScreen'>,\n+|};\n+type Props = {|\n+ ...BaseProps,\n+ +currentUserInfo: ?CurrentUserInfo,\n+ +preRequestUserState: PreRequestUserState,\n+ +resendVerificationLoading: boolean,\n+ +logOutLoading: boolean,\n+ +colors: Colors,\n+ +styles: typeof unboundStyles,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +logOut: (preRequestUserState: PreRequestUserState) => Promise<LogOutResult>,\n+ +resendVerificationEmail: () => Promise<void>,\n+|};\nclass MoreScreen extends React.PureComponent<Props> {\n- static propTypes = {\n- navigation: PropTypes.shape({\n- navigate: PropTypes.func.isRequired,\n- }).isRequired,\n- currentUserInfo: currentUserPropType,\n- preRequestUserState: preRequestUserStatePropType.isRequired,\n- resendVerificationLoading: PropTypes.bool.isRequired,\n- logOutLoading: PropTypes.bool.isRequired,\n- colors: colorsPropType.isRequired,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- logOut: PropTypes.func.isRequired,\n- resendVerificationEmail: PropTypes.func.isRequired,\n- };\n-\nget username() {\nreturn this.props.currentUserInfo && !this.props.currentUserInfo.anonymous\n? this.props.currentUserInfo.username\n@@ -409,7 +387,7 @@ class MoreScreen extends React.PureComponent<Props> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nflex: 1,\n},\n@@ -535,7 +513,6 @@ const styles = {\nfontStyle: 'italic',\n},\n};\n-const stylesSelector = styleSelector(styles);\nconst logOutLoadingStatusSelector = createLoadingStatusSelector(\nlogOutActionTypes,\n@@ -544,15 +521,32 @@ const resendVerificationLoadingStatusSelector = createLoadingStatusSelector(\nresendVerificationEmailActionTypes,\n);\n-export default connect(\n- (state: AppState) => ({\n- currentUserInfo: state.currentUserInfo,\n- preRequestUserState: preRequestUserStateSelector(state),\n- resendVerificationLoading:\n- resendVerificationLoadingStatusSelector(state) === 'loading',\n- logOutLoading: logOutLoadingStatusSelector(state) === 'loading',\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- }),\n- { logOut, resendVerificationEmail },\n-)(MoreScreen);\n+export default React.memo<BaseProps>(function ConnectedMoreScreen(\n+ props: BaseProps,\n+) {\n+ const currentUserInfo = useSelector((state) => state.currentUserInfo);\n+ const preRequestUserState = useSelector(preRequestUserStateSelector);\n+ const resendVerificationLoading =\n+ useSelector(resendVerificationLoadingStatusSelector) === 'loading';\n+ const logOutLoading = useSelector(logOutLoadingStatusSelector) === 'loading';\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ const callLogOut = useServerCall(logOut);\n+ const callResendVerificationEmail = useServerCall(resendVerificationEmail);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <MoreScreen\n+ {...props}\n+ currentUserInfo={currentUserInfo}\n+ preRequestUserState={preRequestUserState}\n+ resendVerificationLoading={resendVerificationLoading}\n+ logOutLoading={logOutLoading}\n+ colors={colors}\n+ styles={styles}\n+ logOut={callLogOut}\n+ resendVerificationEmail={callResendVerificationEmail}\n+ dispatchActionPromise={dispatchActionPromise}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect function in MoreScreen
Test Plan: Checked if the user could still navigate to the more screen, and functions such as logging out, resending email verification, and deleting account still worked
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D824 |
129,208 | 02.03.2021 16:49:45 | 18,000 | 282904377237c6137eabe1c6fa500fe01330ea8a | [lib] Use hook instead of connect function in APIRequestHandler
Test Plan: Checked if mobile and web could still connect to the server
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/socket/api-request-handler.react.js",
"new_path": "lib/socket/api-request-handler.react.js",
"diff": "// @flow\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport type { APIRequest } from '../types/endpoints';\n-import type { BaseAppState } from '../types/redux-types';\nimport {\nclientSocketMessageTypes,\nserverSocketMessageTypes,\ntype ClientSocketMessageWithoutID,\ntype ConnectionInfo,\n- connectionInfoPropType,\n} from '../types/socket-types';\nimport { registerActiveSocket } from '../utils/action-utils';\n-import { connect } from '../utils/redux-utils';\n+import { useSelector } from '../utils/redux-utils';\nimport { InflightRequests, SocketOffline } from './inflight-requests';\n+type BaseProps = {|\n+ +inflightRequests: ?InflightRequests,\n+ +sendMessage: (message: ClientSocketMessageWithoutID) => number,\n+|};\ntype Props = {|\n- inflightRequests: ?InflightRequests,\n- sendMessage: (message: ClientSocketMessageWithoutID) => number,\n- // Redux state\n- connection: ConnectionInfo,\n+ ...BaseProps,\n+ +connection: ConnectionInfo,\n|};\nclass APIRequestHandler extends React.PureComponent<Props> {\n- static propTypes = {\n- inflightRequests: PropTypes.object,\n- sendMessage: PropTypes.func.isRequired,\n- connection: connectionInfoPropType.isRequired,\n- };\n-\nstatic isConnected(props: Props, request?: APIRequest) {\nconst { inflightRequests, connection } = props;\nif (!inflightRequests) {\n@@ -96,6 +89,9 @@ class APIRequestHandler extends React.PureComponent<Props> {\n};\n}\n-export default connect((state: BaseAppState<*>) => ({\n- connection: state.connection,\n-}))(APIRequestHandler);\n+export default React.memo<BaseProps>(function ConnectedAPIRequestHandler(\n+ props: BaseProps,\n+) {\n+ const connection = useSelector((state) => state.connection);\n+ return <APIRequestHandler {...props} connection={connection} />;\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use hook instead of connect function in APIRequestHandler
Test Plan: Checked if mobile and web could still connect to the server
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D826 |
129,208 | 02.03.2021 16:51:51 | 18,000 | ac6161d59b0a08f337b5fb42ae2bfa03f0f639a9 | [lib] Use hook instead of connect function in CalendarQueryHandler
Test Plan: Checked if when creating calendar queries it would be updated in real time from web to native and vise versa
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/socket/calendar-query-handler.react.js",
"new_path": "lib/socket/calendar-query-handler.react.js",
"diff": "// @flow\nimport _isEqual from 'lodash/fp/isEqual';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\n@@ -14,39 +13,30 @@ import type {\nCalendarQueryUpdateResult,\nCalendarQueryUpdateStartingPayload,\n} from '../types/entry-types';\n-import type { BaseAppState } from '../types/redux-types';\n+import { type ConnectionInfo } from '../types/socket-types';\nimport {\n- type ConnectionInfo,\n- connectionInfoPropType,\n-} from '../types/socket-types';\n-import type { DispatchActionPromise } from '../utils/action-utils';\n-import { connect } from '../utils/redux-utils';\n+ type DispatchActionPromise,\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from '../utils/action-utils';\n+import { useSelector } from '../utils/redux-utils';\n+type BaseProps = {|\n+ +currentCalendarQuery: () => CalendarQuery,\n+ +frozen: boolean,\n+|};\ntype Props = {|\n- currentCalendarQuery: () => CalendarQuery,\n- frozen: boolean,\n- // Redux state\n- connection: ConnectionInfo,\n- lastUserInteractionCalendar: number,\n- foreground: boolean,\n- // Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- updateCalendarQuery: (\n+ ...BaseProps,\n+ +connection: ConnectionInfo,\n+ +lastUserInteractionCalendar: number,\n+ +foreground: boolean,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +updateCalendarQuery: (\ncalendarQuery: CalendarQuery,\nreduxAlreadyUpdated?: boolean,\n) => Promise<CalendarQueryUpdateResult>,\n|};\nclass CalendarQueryHandler extends React.PureComponent<Props> {\n- static propTypes = {\n- currentCalendarQuery: PropTypes.func.isRequired,\n- frozen: PropTypes.bool.isRequired,\n- connection: connectionInfoPropType.isRequired,\n- lastUserInteractionCalendar: PropTypes.number.isRequired,\n- foreground: PropTypes.bool.isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- updateCalendarQuery: PropTypes.func.isRequired,\n- };\nserverCalendarQuery: CalendarQuery;\nexpirationTimeoutID: ?TimeoutID;\n@@ -129,12 +119,26 @@ class CalendarQueryHandler extends React.PureComponent<Props> {\n};\n}\n-export default connect(\n- (state: BaseAppState<*>) => ({\n- connection: state.connection,\n- lastUserInteractionCalendar: state.entryStore.lastUserInteractionCalendar,\n+export default React.memo<BaseProps>(function ConnectedCalendarQueryHandler(\n+ props: BaseProps,\n+) {\n+ const connection = useSelector((state) => state.connection);\n+ const lastUserInteractionCalendar = useSelector(\n+ (state) => state.entryStore.lastUserInteractionCalendar,\n+ );\n// We include this so that componentDidUpdate will be called on foreground\n- foreground: state.foreground,\n- }),\n- { updateCalendarQuery },\n-)(CalendarQueryHandler);\n+ const foreground = useSelector((state) => state.foreground);\n+ const callUpdateCalendarQuery = useServerCall(updateCalendarQuery);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <CalendarQueryHandler\n+ {...props}\n+ connection={connection}\n+ lastUserInteractionCalendar={lastUserInteractionCalendar}\n+ foreground={foreground}\n+ updateCalendarQuery={callUpdateCalendarQuery}\n+ dispatchActionPromise={dispatchActionPromise}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use hook instead of connect function in CalendarQueryHandler
Test Plan: Checked if when creating calendar queries it would be updated in real time from web to native and vise versa
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D827 |
129,208 | 02.03.2021 16:54:06 | 18,000 | 51d944f8ea8bb5813579740b5e74e50eb66a1fd2 | [lib] Use hook instead of connect function in MessageHandler
Test Plan: Checked if onMessage still fired and worked correcly on web and native
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/socket/message-handler.react.js",
"new_path": "lib/socket/message-handler.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\n+import { useDispatch } from 'react-redux';\nimport { processMessagesActionType } from '../actions/message-actions';\nimport {\n@@ -9,43 +9,33 @@ import {\nserverSocketMessageTypes,\ntype SocketListener,\n} from '../types/socket-types';\n-import type { DispatchActionPayload } from '../utils/action-utils';\n-import { connect } from '../utils/redux-utils';\ntype Props = {|\n- addListener: (listener: SocketListener) => void,\n- removeListener: (listener: SocketListener) => void,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n+ +addListener: (listener: SocketListener) => void,\n+ +removeListener: (listener: SocketListener) => void,\n|};\n-class MessageHandler extends React.PureComponent<Props> {\n- static propTypes = {\n- addListener: PropTypes.func.isRequired,\n- removeListener: PropTypes.func.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\n-\n- componentDidMount() {\n- this.props.addListener(this.onMessage);\n- }\n+export default function MessageHandler(props: Props) {\n+ const { addListener, removeListener } = props;\n- componentWillUnmount() {\n- this.props.removeListener(this.onMessage);\n- }\n-\n- render() {\n- return null;\n- }\n-\n- onMessage = (message: ServerSocketMessage) => {\n+ const dispatch = useDispatch();\n+ const onMessage = React.useCallback(\n+ (message: ServerSocketMessage) => {\nif (message.type !== serverSocketMessageTypes.MESSAGES) {\nreturn;\n}\n- this.props.dispatchActionPayload(\n- processMessagesActionType,\n- message.payload,\n+ dispatch({\n+ type: processMessagesActionType,\n+ payload: message.payload,\n+ });\n+ },\n+ [dispatch],\n);\n+ React.useEffect(() => {\n+ addListener(onMessage);\n+ return () => {\n+ removeListener(onMessage);\n};\n-}\n+ }, [addListener, removeListener, onMessage]);\n-export default connect(null, null, true)(MessageHandler);\n+ return null;\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use hook instead of connect function in MessageHandler
Test Plan: Checked if onMessage still fired and worked correcly on web and native
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D828 |
129,208 | 02.03.2021 16:55:50 | 18,000 | b7d3e3b5c0de6bc7ea61596ae7a5590bbd5ba067 | [lib] Use hook instead of connect function in ReportHandler
Test Plan: Flow and also check if it still mounted correctly in web and native
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/socket/report-handler.react.js",
"new_path": "lib/socket/report-handler.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { sendReportsActionTypes, sendReports } from '../actions/report-actions';\n-import { queuedReports } from '../selectors/socket-selectors';\n-import type { AppState } from '../types/redux-types';\n+import { queuedReports as queuedReportsSelector } from '../selectors/socket-selectors';\nimport {\ntype ClientReportCreationRequest,\ntype ClearDeliveredReportsPayload,\n- queuedClientReportCreationRequestPropType,\n} from '../types/report-types';\n-import type { DispatchActionPromise } from '../utils/action-utils';\n-import { connect } from '../utils/redux-utils';\n+import {\n+ type DispatchActionPromise,\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from '../utils/action-utils';\n+import { useSelector } from '../utils/redux-utils';\n+type BaseProps = {|\n+ +canSendReports: boolean,\n+|};\ntype Props = {|\n- canSendReports: boolean,\n- // Redux state\n- queuedReports: $ReadOnlyArray<ClientReportCreationRequest>,\n- // Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- sendReports: (\n+ ...BaseProps,\n+ +queuedReports: $ReadOnlyArray<ClientReportCreationRequest>,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +sendReports: (\nreports: $ReadOnlyArray<ClientReportCreationRequest>,\n) => Promise<void>,\n|};\nclass ReportHandler extends React.PureComponent<Props> {\n- static propTypes = {\n- canSendReports: PropTypes.bool.isRequired,\n- queuedReports: PropTypes.arrayOf(queuedClientReportCreationRequestPropType)\n- .isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- sendReports: PropTypes.func.isRequired,\n- };\n-\ncomponentDidMount() {\nif (this.props.canSendReports) {\nthis.dispatchSendReports(this.props.queuedReports);\n@@ -82,9 +75,19 @@ class ReportHandler extends React.PureComponent<Props> {\n}\n}\n-export default connect(\n- (state: AppState) => ({\n- queuedReports: queuedReports(state),\n- }),\n- { sendReports },\n-)(ReportHandler);\n+export default React.memo<BaseProps>(function ConnectedReportHandler(\n+ props: BaseProps,\n+) {\n+ const queuedReports = useSelector(queuedReportsSelector);\n+ const callSendReports = useServerCall(sendReports);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+\n+ return (\n+ <ReportHandler\n+ {...props}\n+ queuedReports={queuedReports}\n+ sendReports={callSendReports}\n+ dispatchActionPromise={dispatchActionPromise}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use hook instead of connect function in ReportHandler
Test Plan: Flow and also check if it still mounted correctly in web and native
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D829 |
129,208 | 02.03.2021 16:58:29 | 18,000 | 6cd6f814748d5273d25c689ea7d7c6d95602d26a | [lib] Use hook instead of connect function in RequestResponseHandler
Test Plan: Checked if onMessage still fires
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/socket/request-response-handler.react.js",
"new_path": "lib/socket/request-response-handler.react.js",
"diff": "// @flow\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\n+import { useDispatch } from 'react-redux';\nimport type { CalendarQuery } from '../types/entry-types';\n-import type { AppState } from '../types/redux-types';\n+import type { Dispatch } from '../types/redux-types';\nimport {\nprocessServerRequestsActionType,\ntype ClientClientResponse,\n@@ -19,39 +19,27 @@ import {\ntype ClientSocketMessageWithoutID,\ntype SocketListener,\ntype ConnectionInfo,\n- connectionInfoPropType,\n} from '../types/socket-types';\n-import type { DispatchActionPayload } from '../utils/action-utils';\nimport { ServerError } from '../utils/errors';\n-import { connect } from '../utils/redux-utils';\n+import { useSelector } from '../utils/redux-utils';\nimport { InflightRequests, SocketTimeout } from './inflight-requests';\n-type Props = {|\n- inflightRequests: ?InflightRequests,\n- sendMessage: (message: ClientSocketMessageWithoutID) => number,\n- addListener: (listener: SocketListener) => void,\n- removeListener: (listener: SocketListener) => void,\n- getClientResponses: (\n+type BaseProps = {|\n+ +inflightRequests: ?InflightRequests,\n+ +sendMessage: (message: ClientSocketMessageWithoutID) => number,\n+ +addListener: (listener: SocketListener) => void,\n+ +removeListener: (listener: SocketListener) => void,\n+ +getClientResponses: (\nactiveServerRequests: $ReadOnlyArray<ServerRequest>,\n) => $ReadOnlyArray<ClientClientResponse>,\n- currentCalendarQuery: () => CalendarQuery,\n- // Redux state\n- connection: ConnectionInfo,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n+ +currentCalendarQuery: () => CalendarQuery,\n+|};\n+type Props = {|\n+ ...BaseProps,\n+ +connection: ConnectionInfo,\n+ +dispatch: Dispatch,\n|};\nclass RequestResponseHandler extends React.PureComponent<Props> {\n- static propTypes = {\n- inflightRequests: PropTypes.object,\n- sendMessage: PropTypes.func.isRequired,\n- addListener: PropTypes.func.isRequired,\n- removeListener: PropTypes.func.isRequired,\n- getClientResponses: PropTypes.func.isRequired,\n- currentCalendarQuery: PropTypes.func.isRequired,\n- connection: connectionInfoPropType.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\n-\ncomponentDidMount() {\nthis.props.addListener(this.onMessage);\n}\n@@ -73,9 +61,12 @@ class RequestResponseHandler extends React.PureComponent<Props> {\nreturn;\n}\nconst calendarQuery = this.props.currentCalendarQuery();\n- this.props.dispatchActionPayload(processServerRequestsActionType, {\n+ this.props.dispatch({\n+ type: processServerRequestsActionType,\n+ payload: {\nserverRequests,\ncalendarQuery,\n+ },\n});\nif (this.props.inflightRequests) {\nconst clientResponses = this.props.getClientResponses(serverRequests);\n@@ -141,10 +132,17 @@ class RequestResponseHandler extends React.PureComponent<Props> {\n}\n}\n-export default connect(\n- (state: AppState) => ({\n- connection: state.connection,\n- }),\n- null,\n- true,\n-)(RequestResponseHandler);\n+export default React.memo<BaseProps>(function ConnectedRequestResponseHandler(\n+ props: BaseProps,\n+) {\n+ const connection = useSelector((state) => state.connection);\n+ const dispatch = useDispatch();\n+\n+ return (\n+ <RequestResponseHandler\n+ {...props}\n+ connection={connection}\n+ dispatch={dispatch}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use hook instead of connect function in RequestResponseHandler
Test Plan: Checked if onMessage still fires
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D830 |
129,208 | 02.03.2021 17:00:01 | 18,000 | a12f5926334b1e50abd8a2383b9ba1a01d78c417 | [lib] Use hook instead of connect function in UpdateHandler
Test Plan: Checked if onMessage was still being called on native and web
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/socket/update-handler.react.js",
"new_path": "lib/socket/update-handler.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\n+import { useEffect } from 'react';\n+import { useDispatch } from 'react-redux';\n-import type { AppState } from '../types/redux-types';\nimport {\ntype ClientSocketMessageWithoutID,\ntype SocketListener,\n- type ConnectionInfo,\n- connectionInfoPropType,\ntype ServerSocketMessage,\nserverSocketMessageTypes,\nclientSocketMessageTypes,\n} from '../types/socket-types';\nimport { processUpdatesActionType } from '../types/update-types';\n-import type { DispatchActionPayload } from '../utils/action-utils';\n-import { connect } from '../utils/redux-utils';\n+import { useSelector } from '../utils/redux-utils';\ntype Props = {|\n- sendMessage: (message: ClientSocketMessageWithoutID) => number,\n- addListener: (listener: SocketListener) => void,\n- removeListener: (listener: SocketListener) => void,\n- // Redux state\n- connection: ConnectionInfo,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n+ +sendMessage: (message: ClientSocketMessageWithoutID) => number,\n+ +addListener: (listener: SocketListener) => void,\n+ +removeListener: (listener: SocketListener) => void,\n|};\n-class UpdateHandler extends React.PureComponent<Props> {\n- static propTypes = {\n- sendMessage: PropTypes.func.isRequired,\n- addListener: PropTypes.func.isRequired,\n- removeListener: PropTypes.func.isRequired,\n- connection: connectionInfoPropType.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\n-\n- componentDidMount() {\n- this.props.addListener(this.onMessage);\n- }\n+export default function UpdateHandler(props: Props) {\n+ const { addListener, removeListener, sendMessage } = props;\n- componentWillUnmount() {\n- this.props.removeListener(this.onMessage);\n- }\n-\n- render() {\n- return null;\n- }\n-\n- onMessage = (message: ServerSocketMessage) => {\n+ const dispatch = useDispatch();\n+ const connectionStatus = useSelector((state) => state.connection.status);\n+ const onMessage = React.useCallback(\n+ (message: ServerSocketMessage) => {\nif (message.type !== serverSocketMessageTypes.UPDATES) {\nreturn;\n}\n- this.props.dispatchActionPayload(processUpdatesActionType, message.payload);\n- if (this.props.connection.status !== 'connected') {\n+ dispatch({\n+ type: processUpdatesActionType,\n+ payload: message.payload,\n+ });\n+ if (connectionStatus !== 'connected') {\nreturn;\n}\n- this.props.sendMessage({\n+ sendMessage({\ntype: clientSocketMessageTypes.ACK_UPDATES,\npayload: {\ncurrentAsOf: message.payload.updatesResult.currentAsOf,\n},\n});\n+ },\n+ [connectionStatus, dispatch, sendMessage],\n+ );\n+ useEffect(() => {\n+ addListener(onMessage);\n+ return () => {\n+ removeListener(onMessage);\n};\n-}\n+ }, [addListener, removeListener, onMessage]);\n-export default connect(\n- (state: AppState) => ({\n- connection: state.connection,\n- }),\n- null,\n- true,\n-)(UpdateHandler);\n+ return null;\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use hook instead of connect function in UpdateHandler
Test Plan: Checked if onMessage was still being called on native and web
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D831 |
129,208 | 02.03.2021 17:02:07 | 18,000 | fe64d89c9724e919fcced4194eb19814a2f1c9f8 | [native] Use hook instead of connect function in OrientationHandler
Test Plan: Clicked on a photo and checked if rotating the device still worked correctly (ios simulator)
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/navigation/orientation-handler.react.js",
"new_path": "native/navigation/orientation-handler.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport type { Orientations } from 'react-native-orientation-locker';\nimport Orientation from 'react-native-orientation-locker';\n+import { useDispatch } from 'react-redux';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport { updateDeviceOrientationActionType } from '../redux/action-types';\n-import type { AppState } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\n-type Props = {\n- // Redux state\n- deviceOrientation: Orientations,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n-};\n+type Props = {|\n+ +deviceOrientation: Orientations,\n+ +dispatch: Dispatch,\n+|};\nclass OrientationHandler extends React.PureComponent<Props> {\n- static propTypes = {\n- deviceOrientation: PropTypes.string.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\n-\ncomponentDidMount() {\nOrientation.addOrientationListener(this.updateOrientation);\n}\n@@ -43,10 +35,10 @@ class OrientationHandler extends React.PureComponent<Props> {\nupdateOrientation = (orientation) => {\nif (orientation !== this.props.deviceOrientation) {\n- this.props.dispatchActionPayload(\n- updateDeviceOrientationActionType,\n- orientation,\n- );\n+ this.props.dispatch({\n+ type: updateDeviceOrientationActionType,\n+ payload: orientation,\n+ });\n}\n};\n@@ -55,10 +47,14 @@ class OrientationHandler extends React.PureComponent<Props> {\n}\n}\n-export default connect(\n- (state: AppState) => ({\n- deviceOrientation: state.deviceOrientation,\n- }),\n- null,\n- true,\n-)(OrientationHandler);\n+export default React.memo<{||}>(function ConnectedOrientationHandler() {\n+ const deviceOrientation = useSelector((state) => state.deviceOrientation);\n+ const dispatch = useDispatch();\n+\n+ return (\n+ <OrientationHandler\n+ deviceOrientation={deviceOrientation}\n+ dispatch={dispatch}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect function in OrientationHandler
Test Plan: Clicked on a photo and checked if rotating the device still worked correctly (ios simulator)
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D832 |
129,208 | 02.03.2021 17:04:12 | 18,000 | 8ec0e9e6c9ae7304e0fbd20183f90afc787e304a | [native] Use hook instead of connect function in ColorPicker
Test Plan: Checked if the color picker still popped up and that threads colors could still be changed
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/components/color-picker.react.js",
"new_path": "native/components/color-picker.react.js",
"diff": "// @flow\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\nView,\n@@ -9,16 +8,12 @@ import {\nStyleSheet,\nI18nManager,\nPanResponder,\n- ViewPropTypes,\nText,\nKeyboard,\n} from 'react-native';\nimport tinycolor from 'tinycolor2';\n-import { connect } from 'lib/utils/redux-utils';\n-\n-import type { AppState } from '../redux/redux-setup';\n-import { type Colors, colorsPropType, colorsSelector } from '../themes/colors';\n+import { type Colors, useColors } from '../themes/colors';\nimport type { LayoutEvent } from '../types/react-native';\nimport type { ViewStyle } from '../types/styles';\nimport Button from './button.react';\n@@ -31,43 +26,26 @@ type PanEvent = $ReadOnly<{\n}>;\ntype HSVColor = {| h: number, s: number, v: number |};\ntype PickerContainer = React.ElementRef<typeof View>;\n+type BaseProps = {|\n+ +color?: string | HSVColor,\n+ +defaultColor?: string,\n+ +oldColor?: ?string,\n+ +onColorChange?: (color: HSVColor) => void,\n+ +onColorSelected?: (color: string) => void,\n+ +onOldColorSelected?: (color: string) => void,\n+ +style?: ViewStyle,\n+ +buttonText?: string,\n+ +oldButtonText?: string,\n+|};\ntype Props = {|\n- color?: string | HSVColor,\n- defaultColor?: string,\n- oldColor?: ?string,\n- onColorChange?: (color: HSVColor) => void,\n- onColorSelected?: (color: string) => void,\n- onOldColorSelected?: (color: string) => void,\n- style?: ViewStyle,\n- buttonText: string,\n- oldButtonText: string,\n- // Redux state\n- colors: Colors,\n+ ...BaseProps,\n+ +colors: Colors,\n|};\ntype State = {|\n- color: HSVColor,\n- pickerSize: ?number,\n+ +color: HSVColor,\n+ +pickerSize: ?number,\n|};\nclass ColorPicker extends React.PureComponent<Props, State> {\n- static propTypes = {\n- color: PropTypes.oneOfType([\n- PropTypes.string,\n- PropTypes.shape({\n- h: PropTypes.number,\n- s: PropTypes.number,\n- v: PropTypes.number,\n- }),\n- ]),\n- defaultColor: PropTypes.string,\n- oldColor: PropTypes.string,\n- onColorChange: PropTypes.func,\n- onColorSelected: PropTypes.func,\n- onOldColorSelected: PropTypes.func,\n- style: ViewPropTypes.style,\n- buttonText: PropTypes.string,\n- oldButtonText: PropTypes.string,\n- colors: colorsPropType.isRequired,\n- };\nstatic defaultProps = {\nbuttonText: 'Select',\noldButtonText: 'Reset',\n@@ -656,6 +634,9 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect((state: AppState) => ({\n- colors: colorsSelector(state),\n-}))(ColorPicker);\n+export default React.memo<BaseProps>(function ConnectedColorPicker(\n+ props: BaseProps,\n+) {\n+ const colors = useColors();\n+ return <ColorPicker {...props} colors={colors} />;\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect function in ColorPicker
Test Plan: Checked if the color picker still popped up and that threads colors could still be changed
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D833 |
129,183 | 18.02.2021 14:45:38 | -3,600 | 8eb83fc63995bf588f6ee211ccb345ec58d597b9 | [web] Add sidebar tooltip to robotext message
Summary: This diff requires D708 that introduces sidebar tooltip
Test Plan: Check if correct sidebar is opened, check if three dots button and sidebar menu are displayed correctly
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub, karol-bisztyga | [
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-message-list.css",
"new_path": "web/chat/chat-message-list.css",
"diff": "@@ -107,13 +107,17 @@ div.conversationHeader:last-child {\npadding-top: 6px;\n}\n-div.robotext {\n+div.robotextContainer {\ntext-align: center;\ncolor: #333333;\npadding: 6px 0;\n- margin: 0 24px 5px 24px;\n+ margin: 0 40px 5px 40px;\nfont-size: 15px;\n}\n+div.innerRobotextContainer {\n+ display: inline-flex;\n+ position: relative;\n+}\ndiv.messageTimestampTooltip {\nposition: absolute;\n@@ -170,14 +174,27 @@ div.messageTooltip {\ncolor: gray;\nfont-size: 14px;\n}\n+div.messageSidebarTooltip {\n+ position: absolute;\n+ left: 100%;\n+ top: 0;\n+ bottom: 0;\n+ color: gray;\n+ font-size: 16px;\n+}\n+div.viewerMessageSidebarTooltip {\n+ left: unset;\n+ right: 100%;\n+}\ndiv.tooltipLeftPadding {\npadding-left: 8px;\n}\ndiv.tooltipRightPadding {\npadding-right: 8px;\n}\n-div.messageSidebarTooltip {\n- font-size: 16px;\n+div.tooltipLeftRightPadding {\n+ padding-left: 8px;\n+ padding-right: 8px;\n}\ndiv.messageTooltipIcon {\n@@ -406,7 +423,7 @@ div.sidebarMarginBottom {\nmargin-bottom: 8px;\n}\ndiv.sidebarMarginTop {\n- margin-top: 5px;\n+ margin-top: 4px;\nmargin-bottom: -8px;\n}\nsvg.inlineSidebarIcon {\n@@ -460,6 +477,9 @@ svg.inlineSidebarIcon {\nleft: 0;\nmargin-left: -3px;\n}\n+.menuSidebarCenterContent {\n+ margin-right: 5px;\n+}\n.menuSidebarContent:before {\nheight: 15px;\nwidth: 55px;\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/composed-message.react.js",
"new_path": "web/chat/composed-message.react.js",
"diff": "@@ -131,6 +131,7 @@ class ComposedMessage extends React.PureComponent<Props> {\n}\n}\n+ const positioning = isViewer ? 'right' : 'left';\nlet viewerSidebarTooltip, nonViewerSidebarTooltip;\nif (\nthis.props.mouseOverMessagePosition &&\n@@ -139,9 +140,9 @@ class ComposedMessage extends React.PureComponent<Props> {\n) {\nconst sidebarTooltip = (\n<SidebarTooltip\n- messagePositionInfo={this.props.mouseOverMessagePosition}\nthreadCreatedFromMessage={this.props.item.threadCreatedFromMessage}\nonClick={this.onMouseLeave}\n+ messagePosition={positioning}\n/>\n);\nif (isViewer) {\n@@ -153,7 +154,6 @@ class ComposedMessage extends React.PureComponent<Props> {\nlet inlineSidebar = null;\nif (item.threadCreatedFromMessage) {\n- const positioning = isViewer ? 'right' : 'left';\ninlineSidebar = (\n<div className={css.sidebarMarginBottom}>\n<InlineSidebar\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/message.react.js",
"new_path": "web/chat/message.react.js",
"diff": "@@ -68,6 +68,7 @@ class Message extends React.PureComponent<Props> {\n<RobotextMessage\nitem={item}\nsetMouseOverMessagePosition={this.props.setMouseOverMessagePosition}\n+ mouseOverMessagePosition={this.props.mouseOverMessagePosition}\n/>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/robotext-message.react.js",
"new_path": "web/chat/robotext-message.react.js",
"diff": "@@ -15,13 +15,18 @@ import { linkRules } from '../markdown/rules.react';\nimport { type AppState, updateNavInfoActionType } from '../redux/redux-setup';\nimport css from './chat-message-list.css';\nimport { InlineSidebar } from './inline-sidebar.react';\n-import type { MessagePositionInfo } from './message-position-types';\n+import type {\n+ MessagePositionInfo,\n+ OnMessagePositionInfo,\n+} from './message-position-types';\n+import SidebarTooltip from './sidebar-tooltip.react';\ntype Props = {|\n- item: RobotextChatMessageInfoItem,\n- setMouseOverMessagePosition: (\n+ +item: RobotextChatMessageInfoItem,\n+ +setMouseOverMessagePosition: (\nmessagePositionInfo: MessagePositionInfo,\n) => void,\n+ +mouseOverMessagePosition: ?OnMessagePositionInfo,\n|};\nclass RobotextMessage extends React.PureComponent<Props> {\nrender() {\n@@ -36,11 +41,33 @@ class RobotextMessage extends React.PureComponent<Props> {\n</div>\n);\n}\n+\n+ const { id } = this.props.item.messageInfo;\n+ let sidebarTooltip;\n+ if (\n+ this.props.mouseOverMessagePosition &&\n+ this.props.mouseOverMessagePosition.item.messageInfo.id === id &&\n+ this.props.item.threadCreatedFromMessage\n+ ) {\n+ sidebarTooltip = (\n+ <SidebarTooltip\n+ threadCreatedFromMessage={this.props.item.threadCreatedFromMessage}\n+ onClick={this.onMouseLeave}\n+ messagePosition=\"center\"\n+ />\n+ );\n+ }\n+\nreturn (\n- <div className={css.robotext}>\n- <span onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>\n- {this.linkedRobotext()}\n- </span>\n+ <div className={css.robotextContainer}>\n+ <div\n+ className={css.innerRobotextContainer}\n+ onMouseEnter={this.onMouseEnter}\n+ onMouseLeave={this.onMouseLeave}\n+ >\n+ <span>{this.linkedRobotext()}</span>\n+ {sidebarTooltip}\n+ </div>\n{inlineSidebar}\n</div>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/sidebar-tooltip.react.js",
"new_path": "web/chat/sidebar-tooltip.react.js",
"diff": "@@ -9,15 +9,14 @@ import type { ThreadInfo } from 'lib/types/thread-types';\nimport { useOnClickThread } from '../selectors/nav-selectors';\nimport css from './chat-message-list.css';\n-import type { OnMessagePositionInfo } from './message-position-types';\ntype Props = {|\n- +messagePositionInfo: OnMessagePositionInfo,\n+threadCreatedFromMessage: ThreadInfo,\n+onClick: () => void,\n+ +messagePosition: 'left' | 'center' | 'right',\n|};\nfunction SidebarTooltip(props: Props) {\n- const { onClick, messagePositionInfo, threadCreatedFromMessage } = props;\n+ const { onClick, threadCreatedFromMessage, messagePosition } = props;\nconst [tooltipVisible, setTooltipVisible] = React.useState(false);\nconst onButtonClick = useOnClickThread(threadCreatedFromMessage.id);\n@@ -37,26 +36,27 @@ function SidebarTooltip(props: Props) {\nsetTooltipVisible(false);\n}, []);\n- const { isViewer } = messagePositionInfo.item.messageInfo.creator;\nconst sidebarMenuClassName = classNames({\n[css.menuSidebarContent]: true,\n[css.menuSidebarContentVisible]: tooltipVisible,\n- [css.menuSidebarNonViewerContent]: !isViewer,\n- [css.messageTimestampBottomRightTooltip]: isViewer,\n- [css.messageTimestampBottomLeftTooltip]: !isViewer,\n+ [css.menuSidebarNonViewerContent]: messagePosition === 'left',\n+ [css.menuSidebarCenterContent]: messagePosition === 'center',\n+ [css.messageTimestampBottomRightTooltip]: messagePosition !== 'left',\n+ [css.messageTimestampBottomLeftTooltip]: messagePosition === 'left',\n});\nconst sidebarTooltipClassName = classNames({\n- [css.messageTooltip]: true,\n[css.messageSidebarTooltip]: true,\n- [css.tooltipRightPadding]: isViewer,\n- [css.tooltipLeftPadding]: !isViewer,\n+ [css.viewerMessageSidebarTooltip]: messagePosition === 'right',\n+ [css.tooltipRightPadding]: messagePosition === 'right',\n+ [css.tooltipLeftPadding]: messagePosition !== 'right',\n});\nconst sidebarIconClassName = classNames({\n[css.messageTooltipIcon]: true,\n- [css.tooltipRightPadding]: !isViewer,\n- [css.tooltipLeftPadding]: isViewer,\n+ [css.tooltipRightPadding]: messagePosition === 'left',\n+ [css.tooltipLeftPadding]: messagePosition === 'right',\n+ [css.tooltipLeftRightPadding]: messagePosition === 'center',\n});\nreturn (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Add sidebar tooltip to robotext message
Summary: This diff requires D708 that introduces sidebar tooltip
Test Plan: Check if correct sidebar is opened, check if three dots button and sidebar menu are displayed correctly
Reviewers: ashoat, palys-swm
Reviewed By: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub, karol-bisztyga
Differential Revision: https://phabricator.ashoat.com/D740 |
129,208 | 04.03.2021 15:18:58 | 18,000 | c93907c9c353286fbf4cbcc425d3fb70761c247c | [native] Use hook instead of connect in InputStateContainer
Test Plan: Checked if text messages and such could still be sent to 2 user chats, group chats, and private chats.
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/input/input-state-container.react.js",
"new_path": "native/input/input-state-container.react.js",
"diff": "// @flow\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { Platform } from 'react-native';\nimport * as Upload from 'react-native-background-upload';\n+import { useDispatch } from 'react-redux';\nimport { createSelector } from 'reselect';\nimport {\n@@ -46,13 +46,15 @@ import {\nimport type { RawImagesMessageInfo } from 'lib/types/messages/images';\nimport type { RawMediaMessageInfo } from 'lib/types/messages/media';\nimport type { RawTextMessageInfo } from 'lib/types/messages/text';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport {\ntype MediaMissionReportCreationRequest,\nreportTypes,\n} from 'lib/types/report-types';\n-import type {\n- DispatchActionPayload,\n- DispatchActionPromise,\n+import {\n+ type DispatchActionPromise,\n+ useServerCall,\n+ useDispatchActionPromise,\n} from 'lib/utils/action-utils';\nimport { getConfig } from 'lib/utils/config';\nimport { getMessageForException, cloneError } from 'lib/utils/errors';\n@@ -60,12 +62,11 @@ import type {\nFetchJSONOptions,\nFetchJSONServerResponse,\n} from 'lib/utils/fetch-json';\n-import { connect } from 'lib/utils/redux-utils';\nimport { disposeTempFile } from '../media/file-utils';\nimport { processMedia } from '../media/media-utils';\nimport { displayActionResultModal } from '../navigation/action-result-modal';\n-import type { AppState } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\nimport {\nInputStateContext,\ntype PendingMultimediaUploads,\n@@ -78,56 +79,43 @@ function getNewLocalID() {\n}\ntype SelectionWithID = {|\n- selection: NativeMediaSelection,\n- localID: string,\n+ +selection: NativeMediaSelection,\n+ +localID: string,\n|};\n-type CompletedUploads = { [localMessageID: string]: ?Set<string> };\n+type CompletedUploads = { +[localMessageID: string]: ?Set<string> };\n+type BaseProps = {|\n+ +children: React.Node,\n+|};\ntype Props = {|\n- children: React.Node,\n- // Redux state\n- viewerID: ?string,\n- nextLocalID: number,\n- messageStoreMessages: { [id: string]: RawMessageInfo },\n- ongoingMessageCreation: boolean,\n- hasWiFi: boolean,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- uploadMultimedia: (\n+ ...BaseProps,\n+ +viewerID: ?string,\n+ +nextLocalID: number,\n+ +messageStoreMessages: { [id: string]: RawMessageInfo },\n+ +ongoingMessageCreation: boolean,\n+ +hasWiFi: boolean,\n+ +dispatch: Dispatch,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +uploadMultimedia: (\nmultimedia: Object,\nextras: MultimediaUploadExtras,\ncallbacks: MultimediaUploadCallbacks,\n) => Promise<UploadMultimediaResult>,\n- sendMultimediaMessage: (\n+ +sendMultimediaMessage: (\nthreadID: string,\nlocalID: string,\nmediaIDs: $ReadOnlyArray<string>,\n) => Promise<SendMessageResult>,\n- sendTextMessage: (\n+ +sendTextMessage: (\nthreadID: string,\nlocalID: string,\ntext: string,\n) => Promise<SendMessageResult>,\n|};\ntype State = {|\n- pendingUploads: PendingMultimediaUploads,\n+ +pendingUploads: PendingMultimediaUploads,\n|};\nclass InputStateContainer extends React.PureComponent<Props, State> {\n- static propTypes = {\n- children: PropTypes.node.isRequired,\n- viewerID: PropTypes.string,\n- nextLocalID: PropTypes.number.isRequired,\n- messageStoreMessages: PropTypes.object.isRequired,\n- ongoingMessageCreation: PropTypes.bool.isRequired,\n- hasWiFi: PropTypes.bool.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- uploadMultimedia: PropTypes.func.isRequired,\n- sendMultimediaMessage: PropTypes.func.isRequired,\n- sendTextMessage: PropTypes.func.isRequired,\n- };\nstate: State = {\npendingUploads: {},\n};\n@@ -444,10 +432,10 @@ class InputStateContainer extends React.PureComponent<Props, State> {\ncreatorID,\nmedia,\n});\n- this.props.dispatchActionPayload(\n- createLocalMessageActionType,\n- messageInfo,\n- );\n+ this.props.dispatch({\n+ type: createLocalMessageActionType,\n+ payload: messageInfo,\n+ });\n},\n);\n@@ -558,7 +546,9 @@ class InputStateContainer extends React.PureComponent<Props, State> {\nif (uploadResult) {\nconst { id, mediaType, uri, dimensions, loop } = uploadResult;\nserverID = id;\n- this.props.dispatchActionPayload(updateMultimediaMessageMediaActionType, {\n+ this.props.dispatch({\n+ type: updateMultimediaMessageMediaActionType,\n+ payload: {\nmessageID: localMessageID,\ncurrentMediaID: localID,\nmediaUpdate: {\n@@ -569,6 +559,7 @@ class InputStateContainer extends React.PureComponent<Props, State> {\nlocalMediaSelection: undefined,\nloop,\n},\n+ },\n});\nuserTime = Date.now() - start;\n}\n@@ -816,8 +807,11 @@ class InputStateContainer extends React.PureComponent<Props, State> {\nuploadLocalID: ids.localID,\nmessageLocalID: ids.localMessageID,\n};\n- this.props.dispatchActionPayload(queueReportsActionType, {\n+ this.props.dispatch({\n+ type: queueReportsActionType,\n+ payload: {\nreports: [report],\n+ },\n});\n}\n@@ -961,10 +955,10 @@ class InputStateContainer extends React.PureComponent<Props, State> {\n// We're not actually starting the send here,\n// we just use this action to update the message in Redux\n- this.props.dispatchActionPayload(\n- sendMultimediaMessageActionTypes.started,\n- newRawMessageInfo,\n- );\n+ this.props.dispatch({\n+ type: sendMultimediaMessageActionTypes.started,\n+ payload: newRawMessageInfo,\n+ });\n// We clear out the failed status on individual media here,\n// which makes the UI show pending status instead of error messages\n@@ -1083,17 +1077,43 @@ const textCreationLoadingStatusSelector = createLoadingStatusSelector(\nsendTextMessageActionTypes,\n);\n-export default connect(\n- (state: AppState) => ({\n- viewerID: state.currentUserInfo && state.currentUserInfo.id,\n- nextLocalID: state.nextLocalID,\n- messageStoreMessages: state.messageStore.messages,\n- ongoingMessageCreation:\n+export default React.memo<BaseProps>(function ConnectedInputStateContainer(\n+ props: BaseProps,\n+) {\n+ const viewerID = useSelector(\n+ (state) => state.currentUserInfo && state.currentUserInfo.id,\n+ );\n+ const nextLocalID = useSelector((state) => state.nextLocalID);\n+ const messageStoreMessages = useSelector(\n+ (state) => state.messageStore.messages,\n+ );\n+ const ongoingMessageCreation = useSelector(\n+ (state) =>\ncombineLoadingStatuses(\nmediaCreationLoadingStatusSelector(state),\ntextCreationLoadingStatusSelector(state),\n) === 'loading',\n- hasWiFi: state.connectivity.hasWiFi,\n- }),\n- { uploadMultimedia, sendMultimediaMessage, sendTextMessage },\n-)(InputStateContainer);\n+ );\n+ const hasWiFi = useSelector((state) => state.connectivity.hasWiFi);\n+ const callUploadMultimedia = useServerCall(uploadMultimedia);\n+ const callSendMultimediaMessage = useServerCall(sendMultimediaMessage);\n+ const callSendTextMessage = useServerCall(sendTextMessage);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const dispatch = useDispatch();\n+\n+ return (\n+ <InputStateContainer\n+ {...props}\n+ viewerID={viewerID}\n+ nextLocalID={nextLocalID}\n+ messageStoreMessages={messageStoreMessages}\n+ ongoingMessageCreation={ongoingMessageCreation}\n+ hasWiFi={hasWiFi}\n+ uploadMultimedia={callUploadMultimedia}\n+ sendMultimediaMessage={callSendMultimediaMessage}\n+ sendTextMessage={callSendTextMessage}\n+ dispatchActionPromise={dispatchActionPromise}\n+ dispatch={dispatch}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect in InputStateContainer
Test Plan: Checked if text messages and such could still be sent to 2 user chats, group chats, and private chats.
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D836 |
129,208 | 04.03.2021 15:21:30 | 18,000 | 5583343b80e067e5b9b97c60b7ad415de5a905a6 | [native] Use hook instead of connect in ConnectivityUpdater
Test Plan: Checked if onConnectionChange was still being called properly
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/redux/connectivity-updater.react.js",
"new_path": "native/redux/connectivity-updater.react.js",
"diff": "// @flow\nimport NetInfo from '@react-native-community/netinfo';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\n+import { useDispatch } from 'react-redux';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n-\n-import {\n- type ConnectivityInfo,\n- connectivityInfoPropType,\n-} from '../types/connectivity';\nimport { updateConnectivityActiveType } from './action-types';\n-import type { AppState } from './redux-setup';\n-\n-type Props = {|\n- // Redux state\n- connectivity: ConnectivityInfo,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n-|};\n-class ConnectivityUpdater extends React.PureComponent<Props> {\n- static propTypes = {\n- connectivity: connectivityInfoPropType.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\n- netInfoUnsubscribe: ?() => void;\n-\n- componentDidMount() {\n- this.netInfoUnsubscribe = NetInfo.addEventListener(this.onConnectionChange);\n- NetInfo.fetch().then(this.onConnectionChange);\n- }\n+import { useSelector } from './redux-utils';\n- componentWillUnmount() {\n- this.netInfoUnsubscribe && this.netInfoUnsubscribe();\n- }\n+export default function ConnectivityUpdater() {\n+ const connectivity = useSelector((state) => state.connectivity);\n+ const dispatch = useDispatch();\n- onConnectionChange = ({ type }) => {\n+ const onConnectionChange = React.useCallback(\n+ ({ type }) => {\nconst connected = type !== 'none' && type !== 'unknown';\nconst hasWiFi = type === 'wifi';\nif (\n- connected === this.props.connectivity.connected &&\n- hasWiFi === this.props.connectivity.hasWiFi\n+ connected === connectivity.connected &&\n+ hasWiFi === connectivity.hasWiFi\n) {\nreturn;\n}\n- this.props.dispatchActionPayload(updateConnectivityActiveType, {\n+ dispatch({\n+ type: updateConnectivityActiveType,\n+ payload: {\nconnected,\nhasWiFi,\n+ },\n});\n- };\n-\n- render() {\n+ },\n+ [connectivity, dispatch],\n+ );\n+ React.useEffect(() => {\n+ NetInfo.fetch().then(onConnectionChange);\n+ // eslint-disable-next-line react-hooks/exhaustive-deps\n+ }, []);\n+ React.useEffect(() => NetInfo.addEventListener(onConnectionChange), [\n+ onConnectionChange,\n+ ]);\nreturn null;\n}\n-}\n-\n-export default connect(\n- (state: AppState) => ({\n- connectivity: state.connectivity,\n- }),\n- null,\n- true,\n-)(ConnectivityUpdater);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect in ConnectivityUpdater
Test Plan: Checked if onConnectionChange was still being called properly
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D837 |
129,208 | 04.03.2021 15:55:03 | 18,000 | 2879517d113cbc7aa5db7433787c6d1428b8a185 | [web] Use hook instead of connect function in InnerThreadEntity
Test Plan: Checked if the robotext would still show up, and other message types still worked normally
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "web/chat/robotext-message.react.js",
"new_path": "web/chat/robotext-message.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\n+import { useDispatch } from 'react-redux';\nimport { type RobotextChatMessageInfoItem } from 'lib/selectors/chat-selectors';\nimport { threadInfoSelector } from 'lib/selectors/thread-selectors';\nimport { splitRobotext, parseRobotextEntity } from 'lib/shared/message-utils';\nimport { useSidebarExistsOrCanBeCreated } from 'lib/shared/thread-utils';\n-import { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import type { Dispatch } from 'lib/types/redux-types';\n+import { type ThreadInfo } from 'lib/types/thread-types';\nimport Markdown from '../markdown/markdown.react';\nimport { linkRules } from '../markdown/rules.react';\n-import { type AppState, updateNavInfoActionType } from '../redux/redux-setup';\n+import { updateNavInfoActionType } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\nimport css from './chat-message-list.css';\nimport { InlineSidebar } from './inline-sidebar.react';\nimport type {\n@@ -134,22 +134,16 @@ class RobotextMessage extends React.PureComponent<Props> {\n};\n}\n-type InnerThreadEntityProps = {\n- id: string,\n- name: string,\n- // Redux state\n- threadInfo: ThreadInfo,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n-};\n+type BaseInnerThreadEntityProps = {|\n+ +id: string,\n+ +name: string,\n+|};\n+type InnerThreadEntityProps = {|\n+ ...BaseInnerThreadEntityProps,\n+ +threadInfo: ThreadInfo,\n+ +dispatch: Dispatch,\n+|};\nclass InnerThreadEntity extends React.PureComponent<InnerThreadEntityProps> {\n- static propTypes = {\n- id: PropTypes.string.isRequired,\n- name: PropTypes.string.isRequired,\n- threadInfo: threadInfoPropType.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\n-\nrender() {\nreturn <a onClick={this.onClickThread}>{this.props.name}</a>;\n}\n@@ -157,18 +151,29 @@ class InnerThreadEntity extends React.PureComponent<InnerThreadEntityProps> {\nonClickThread = (event: SyntheticEvent<HTMLAnchorElement>) => {\nevent.preventDefault();\nconst id = this.props.id;\n- this.props.dispatchActionPayload(updateNavInfoActionType, {\n+ this.props.dispatch({\n+ type: updateNavInfoActionType,\n+ payload: {\nactiveChatThreadID: id,\n+ },\n});\n};\n}\n-const ThreadEntity = connect(\n- (state: AppState, ownProps: { id: string }) => ({\n- threadInfo: threadInfoSelector(state)[ownProps.id],\n- }),\n- null,\n- true,\n-)(InnerThreadEntity);\n+const ThreadEntity = React.memo<BaseInnerThreadEntityProps>(\n+ function ConnectedInnerThreadEntity(props: BaseInnerThreadEntityProps) {\n+ const { id } = props;\n+ const threadInfo = useSelector((state) => threadInfoSelector(state)[id]);\n+ const dispatch = useDispatch();\n+\n+ return (\n+ <InnerThreadEntity\n+ {...props}\n+ threadInfo={threadInfo}\n+ dispatch={dispatch}\n+ />\n+ );\n+ },\n+);\nfunction ColorEntity(props: {| color: string |}) {\nconst colorStyle = { color: props.color };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook instead of connect function in InnerThreadEntity
Test Plan: Checked if the robotext would still show up, and other message types still worked normally
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D838 |
129,208 | 04.03.2021 16:11:46 | 18,000 | 25f4e66f130d0f4ef4987c4d8da8dbce8a5d6beb | [native] Use hook instead of connect in RemoteImage
Test Plan: Checked if images still rendered properly, and that componentDidUpdate is being called when there are images present
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/media/remote-image.react.js",
"new_path": "native/media/remote-image.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { View, StyleSheet, ActivityIndicator } from 'react-native';\nimport FastImage from 'react-native-fast-image';\n-import {\n- type ConnectionStatus,\n- connectionStatusPropType,\n-} from 'lib/types/socket-types';\n-import { connect } from 'lib/utils/redux-utils';\n+import { type ConnectionStatus } from 'lib/types/socket-types';\n-import type { AppState } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\nimport type { ImageStyle } from '../types/styles';\n+type BaseProps = {|\n+ +uri: string,\n+ +onLoad: (uri: string) => void,\n+ +spinnerColor: string,\n+ +style: ImageStyle,\n+ +invisibleLoad: boolean,\n+|};\ntype Props = {|\n- uri: string,\n- onLoad: (uri: string) => void,\n- spinnerColor: string,\n- style: ImageStyle,\n- invisibleLoad: boolean,\n- // Redux state\n- connectionStatus: ConnectionStatus,\n+ ...BaseProps,\n+ +connectionStatus: ConnectionStatus,\n|};\ntype State = {|\n- attempt: number,\n- loaded: boolean,\n+ +attempt: number,\n+ +loaded: boolean,\n|};\nclass RemoteImage extends React.PureComponent<Props, State> {\n- static propTypes = {\n- uri: PropTypes.string.isRequired,\n- onLoad: PropTypes.func.isRequired,\n- spinnerColor: PropTypes.string.isRequired,\n- invisibleLoad: PropTypes.bool.isRequired,\n- connectionStatus: connectionStatusPropType.isRequired,\n- };\nstate: State = {\nattempt: 0,\nloaded: false,\n@@ -117,6 +107,10 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect((state: AppState) => ({\n- connectionStatus: state.connection.status,\n-}))(RemoteImage);\n+export default React.memo<BaseProps>(function ConnectedRemoteImage(\n+ props: BaseProps,\n+) {\n+ const connectionStatus = useSelector((state) => state.connection.status);\n+\n+ return <RemoteImage {...props} connectionStatus={connectionStatus} />;\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect in RemoteImage
Test Plan: Checked if images still rendered properly, and that componentDidUpdate is being called when there are images present
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D839 |
129,208 | 04.03.2021 16:28:41 | 18,000 | eaff95f81fe4a04f59f15f7364401f3fbe83725d | [web] Use hook instead of connect in Entry
Test Plan: Checked in entry still showed up correctly, and features such as deletion still worked
Reviewers: palys-swm, ashoat, atul
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "web/calendar/entry.react.js",
"new_path": "web/calendar/entry.react.js",
"diff": "import classNames from 'classnames';\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\n+import { useDispatch } from 'react-redux';\nimport {\ncreateEntryActionTypes,\n@@ -20,7 +20,6 @@ import { colorIsDark, threadHasPermission } from 'lib/shared/thread-utils';\nimport type { Shape } from 'lib/types/core';\nimport {\ntype EntryInfo,\n- entryInfoPropType,\ntype CreateEntryInfo,\ntype SaveEntryInfo,\ntype SaveEntryResponse,\n@@ -30,66 +29,51 @@ import {\ntype CalendarQuery,\n} from 'lib/types/entry-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n-import { threadInfoPropType, threadPermissions } from 'lib/types/thread-types';\n+import type { Dispatch } from 'lib/types/redux-types';\n+import { threadPermissions } from 'lib/types/thread-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n-import type {\n- DispatchActionPayload,\n- DispatchActionPromise,\n+import {\n+ type DispatchActionPromise,\n+ useServerCall,\n+ useDispatchActionPromise,\n} from 'lib/utils/action-utils';\nimport { dateString } from 'lib/utils/date-utils';\nimport { ServerError } from 'lib/utils/errors';\n-import { connect } from 'lib/utils/redux-utils';\nimport LoadingIndicator from '../loading-indicator.react';\nimport LogInFirstModal from '../modals/account/log-in-first-modal.react';\nimport ConcurrentModificationModal from '../modals/concurrent-modification-modal.react';\nimport HistoryModal from '../modals/history/history-modal.react';\n-import type { AppState } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\nimport { nonThreadCalendarQuery } from '../selectors/nav-selectors';\nimport { HistoryVector, DeleteVector } from '../vectors.react';\nimport css from './calendar.css';\n+type BaseProps = {|\n+ +innerRef: (key: string, me: Entry) => void,\n+ +entryInfo: EntryInfo,\n+ +focusOnFirstEntryNewerThan: (time: number) => void,\n+ +setModal: (modal: ?React.Node) => void,\n+ +tabIndex: number,\n+|};\ntype Props = {|\n- innerRef: (key: string, me: Entry) => void,\n- entryInfo: EntryInfo,\n- focusOnFirstEntryNewerThan: (time: number) => void,\n- setModal: (modal: ?React.Node) => void,\n- tabIndex: number,\n- // Redux state\n- threadInfo: ThreadInfo,\n- loggedIn: boolean,\n- calendarQuery: () => CalendarQuery,\n- online: boolean,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- createEntry: (info: CreateEntryInfo) => Promise<CreateEntryPayload>,\n- saveEntry: (info: SaveEntryInfo) => Promise<SaveEntryResponse>,\n- deleteEntry: (info: DeleteEntryInfo) => Promise<DeleteEntryResponse>,\n+ ...BaseProps,\n+ +threadInfo: ThreadInfo,\n+ +loggedIn: boolean,\n+ +calendarQuery: () => CalendarQuery,\n+ +online: boolean,\n+ +dispatch: Dispatch,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +createEntry: (info: CreateEntryInfo) => Promise<CreateEntryPayload>,\n+ +saveEntry: (info: SaveEntryInfo) => Promise<SaveEntryResponse>,\n+ +deleteEntry: (info: DeleteEntryInfo) => Promise<DeleteEntryResponse>,\n|};\ntype State = {|\n- focused: boolean,\n- loadingStatus: LoadingStatus,\n- text: string,\n+ +focused: boolean,\n+ +loadingStatus: LoadingStatus,\n+ +text: string,\n|};\nclass Entry extends React.PureComponent<Props, State> {\n- static propTypes = {\n- innerRef: PropTypes.func.isRequired,\n- entryInfo: entryInfoPropType.isRequired,\n- focusOnFirstEntryNewerThan: PropTypes.func.isRequired,\n- setModal: PropTypes.func.isRequired,\n- tabIndex: PropTypes.number.isRequired,\n- threadInfo: threadInfoPropType.isRequired,\n- loggedIn: PropTypes.bool.isRequired,\n- calendarQuery: PropTypes.func.isRequired,\n- online: PropTypes.bool.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- createEntry: PropTypes.func.isRequired,\n- saveEntry: PropTypes.func.isRequired,\n- deleteEntry: PropTypes.func.isRequired,\n- };\ntextarea: ?HTMLTextAreaElement;\ncreating: boolean;\nneedsUpdateAfterCreation: boolean;\n@@ -398,10 +382,10 @@ class Entry extends React.PureComponent<Props, State> {\n{ loadingStatus: 'inactive' },\nthis.updateHeight.bind(this),\n);\n- this.props.dispatchActionPayload(\n- concurrentModificationResetActionType,\n- { id: entryID, dbText: e.payload.db },\n- );\n+ this.props.dispatch({\n+ type: concurrentModificationResetActionType,\n+ payload: { id: entryID, dbText: e.payload.db },\n+ });\nthis.clearModal();\n};\nthis.props.setModal(\n@@ -482,16 +466,37 @@ class Entry extends React.PureComponent<Props, State> {\nexport type InnerEntry = Entry;\n-export default connect(\n- (state: AppState, ownProps: { entryInfo: EntryInfo }) => ({\n- threadInfo: threadInfoSelector(state)[ownProps.entryInfo.threadID],\n- loggedIn: !!(\n- state.currentUserInfo &&\n- !state.currentUserInfo.anonymous &&\n- true\n- ),\n- calendarQuery: nonThreadCalendarQuery(state),\n- online: state.connection.status === 'connected',\n- }),\n- { createEntry, saveEntry, deleteEntry },\n-)(Entry);\n+export default React.memo<BaseProps>(function ConnectedEntry(props: BaseProps) {\n+ const { threadID } = props.entryInfo;\n+ const threadInfo = useSelector(\n+ (state) => threadInfoSelector(state)[threadID],\n+ );\n+ const loggedIn = useSelector(\n+ (state) =>\n+ !!(state.currentUserInfo && !state.currentUserInfo.anonymous && true),\n+ );\n+ const calanderQuery = useSelector(nonThreadCalendarQuery);\n+ const online = useSelector(\n+ (state) => state.connection.status === 'connected',\n+ );\n+ const callCreateEntry = useServerCall(createEntry);\n+ const callSaveEntry = useServerCall(saveEntry);\n+ const callDeleteEntry = useServerCall(deleteEntry);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const dispatch = useDispatch();\n+\n+ return (\n+ <Entry\n+ {...props}\n+ threadInfo={threadInfo}\n+ loggedIn={loggedIn}\n+ calendarQuery={calanderQuery}\n+ online={online}\n+ createEntry={callCreateEntry}\n+ saveEntry={callSaveEntry}\n+ deleteEntry={callDeleteEntry}\n+ dispatchActionPromise={dispatchActionPromise}\n+ dispatch={dispatch}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook instead of connect in Entry
Test Plan: Checked in entry still showed up correctly, and features such as deletion still worked
Reviewers: palys-swm, ashoat, atul
Reviewed By: ashoat
Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D840 |
129,187 | 24.02.2021 19:49:27 | 18,000 | 4ab4773450f6f20ee0912ed8905ce7389549a3a3 | [native] codeVersion -> 79 | [
{
"change_type": "MODIFY",
"old_path": "native/android/app/build.gradle",
"new_path": "native/android/app/build.gradle",
"diff": "@@ -133,8 +133,8 @@ android {\napplicationId \"org.squadcal\"\nminSdkVersion rootProject.ext.minSdkVersion\ntargetSdkVersion rootProject.ext.targetSdkVersion\n- versionCode 74\n- versionName \"0.0.74\"\n+ versionCode 79\n+ versionName \"0.0.79\"\nmissingDimensionStrategy 'react-native-camera', 'general'\nmultiDexEnabled true\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/Info.debug.plist",
"new_path": "native/ios/SquadCal/Info.debug.plist",
"diff": "<key>CFBundlePackageType</key>\n<string>APPL</string>\n<key>CFBundleShortVersionString</key>\n- <string>0.0.74</string>\n+ <string>0.0.79</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>74</string>\n+ <string>79</string>\n<key>LSApplicationQueriesSchemes</key>\n<array>\n<string>org-appextension-feature-password-management</string>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/Info.release.plist",
"new_path": "native/ios/SquadCal/Info.release.plist",
"diff": "<key>CFBundlePackageType</key>\n<string>APPL</string>\n<key>CFBundleShortVersionString</key>\n- <string>0.0.74</string>\n+ <string>0.0.79</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>74</string>\n+ <string>79</string>\n<key>LSApplicationQueriesSchemes</key>\n<array>\n<string>org-appextension-feature-password-management</string>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux/persist.js",
"new_path": "native/redux/persist.js",
"diff": "@@ -217,7 +217,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 74;\n+const codeVersion = 79;\n// This local exists to avoid a circular dependency where redux-setup needs to\n// import all the navigation and screen stuff, but some of those screens want to\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] codeVersion -> 79 |
129,191 | 26.02.2021 13:26:25 | -3,600 | 6b1b5dfc0fce82f17a3306c894fc94bdaf4db23c | [native] Use thread watcher hook
Test Plan: Switched threads couple of times and checked using console log in thread watcher if watchedID map had correct values
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -14,8 +14,7 @@ import {\n} from 'lib/actions/message-actions';\nimport { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport { messageKey } from 'lib/shared/message-utils';\n-import { threadInChatList } from 'lib/shared/thread-utils';\n-import threadWatcher from 'lib/shared/thread-watcher';\n+import { useWatchThread } from 'lib/shared/thread-utils';\nimport type { FetchMessageInfosPayload } from 'lib/types/message-types';\nimport { type ThreadInfo, threadTypes } from 'lib/types/thread-types';\nimport {\n@@ -120,24 +119,6 @@ class MessageList extends React.PureComponent<Props, State> {\nreturn this.flatListExtraDataSelector({ ...this.props, ...this.state });\n}\n- componentDidMount() {\n- const { threadInfo } = this.props;\n- if (!threadInChatList(threadInfo)) {\n- threadWatcher.watchID(threadInfo.id);\n- this.props.dispatchActionPromise(\n- fetchMostRecentMessagesActionTypes,\n- this.props.fetchMostRecentMessages(threadInfo.id),\n- );\n- }\n- }\n-\n- componentWillUnmount() {\n- const { threadInfo } = this.props;\n- if (!threadInChatList(threadInfo)) {\n- threadWatcher.removeID(threadInfo.id);\n- }\n- }\n-\nstatic getOverlayContext(props: Props) {\nconst { overlayContext } = props;\ninvariant(overlayContext, 'MessageList should have OverlayContext');\n@@ -155,17 +136,6 @@ class MessageList extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props) {\n- const oldThreadInfo = prevProps.threadInfo;\n- const newThreadInfo = this.props.threadInfo;\n- if (oldThreadInfo.id !== newThreadInfo.id) {\n- if (!threadInChatList(oldThreadInfo)) {\n- threadWatcher.removeID(oldThreadInfo.id);\n- }\n- if (!threadInChatList(newThreadInfo)) {\n- threadWatcher.watchID(newThreadInfo.id);\n- }\n- }\n-\nconst newListData = this.props.messageListData;\nconst oldListData = prevProps.messageListData;\nif (\n@@ -391,6 +361,8 @@ export default React.memo<BaseProps>(function ConnectedMessageList(\n);\nconst callFetchMostRecentMessages = useServerCall(fetchMostRecentMessages);\n+ useWatchThread(props.threadInfo);\n+\nreturn (\n<MessageList\n{...props}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use thread watcher hook
Test Plan: Switched threads couple of times and checked using console log in thread watcher if watchedID map had correct values
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D820 |
129,191 | 26.02.2021 14:29:20 | -3,600 | 8819465863ee57cff6a5d4247747f6290c896082 | [native] Make sure that failed-send accepts only composable messages
Test Plan: Modify message creator to fail every second time. Send a message, check if retry button was displayed, retry and check if the message was sent.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/types/message-types.js",
"new_path": "lib/types/message-types.js",
"diff": "@@ -165,6 +165,17 @@ export function assertComposableMessageType(\n);\nreturn ourMessageType;\n}\n+export function assertComposableRawMessage(\n+ message: RawMessageInfo,\n+): RawComposableMessageInfo {\n+ invariant(\n+ message.type === messageTypes.TEXT ||\n+ message.type === messageTypes.IMAGES ||\n+ message.type === messageTypes.MULTIMEDIA,\n+ 'Message is not composable',\n+ );\n+ return message;\n+}\nexport function messageDataLocalID(messageData: MessageData) {\nif (\nmessageData.type !== messageTypes.TEXT &&\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/failed-send.react.js",
"new_path": "native/chat/failed-send.react.js",
"diff": "@@ -5,7 +5,11 @@ import * as React from 'react';\nimport { Text, View } from 'react-native';\nimport { messageID } from 'lib/shared/message-utils';\n-import { messageTypes, type RawMessageInfo } from 'lib/types/message-types';\n+import {\n+ assertComposableRawMessage,\n+ messageTypes,\n+} from 'lib/types/message-types';\n+import type { RawComposableMessageInfo } from 'lib/types/message-types';\nimport Button from '../components/button.react';\nimport { type InputState, InputStateContext } from '../input/input-state';\n@@ -23,7 +27,7 @@ type BaseProps = {|\ntype Props = {|\n...BaseProps,\n// Redux state\n- +rawMessageInfo: ?RawMessageInfo,\n+ +rawMessageInfo: ?RawComposableMessageInfo,\n+styles: typeof unboundStyles,\n// withInputState\n+inputState: ?InputState,\n@@ -140,9 +144,10 @@ const ConnectedFailedSend = React.memo<BaseProps>(function ConnectedFailedSend(\nprops: BaseProps,\n) {\nconst id = messageID(props.item.messageInfo);\n- const rawMessageInfo = useSelector(\n- (state) => state.messageStore.messages[id],\n- );\n+ const rawMessageInfo = useSelector((state) => {\n+ const message = state.messageStore.messages[id];\n+ return message ? assertComposableRawMessage(message) : null;\n+ });\nconst styles = useStyles(unboundStyles);\nconst inputState = React.useContext(InputStateContext);\nreturn (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Make sure that failed-send accepts only composable messages
Test Plan: Modify message creator to fail every second time. Send a message, check if retry button was displayed, retry and check if the message was sent.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D822 |
129,187 | 05.03.2021 12:39:38 | 18,000 | 6bc4f2e95876ef8b7965c6f3f29c755545e1f207 | [native] Fix ThreadSettingsPromoteSidebar name
Summary: I accidentally named this incorrectly in D274. The class name should match the filename should match the import name.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-promote-sidebar.react.js",
"new_path": "native/chat/settings/thread-settings-promote-sidebar.react.js",
"diff": "@@ -43,7 +43,7 @@ type Props = {|\nrequest: UpdateThreadRequest,\n) => Promise<ChangeThreadSettingsPayload>,\n|};\n-class ThreadSettingsPromoteSubthread extends React.PureComponent<Props> {\n+class ThreadSettingsPromoteSidebar extends React.PureComponent<Props> {\nrender() {\nconst {\npanelIosHighlightUnderlay,\n@@ -113,14 +113,14 @@ const loadingStatusSelector = createLoadingStatusSelector(\n);\nexport default React.memo<BaseProps>(\n- function ConnectedThreadSettingsPromoteSubthread(props: BaseProps) {\n+ function ConnectedThreadSettingsPromoteSidebar(props: BaseProps) {\nconst loadingStatus = useSelector(loadingStatusSelector);\nconst colors = useColors();\nconst styles = useStyles(unboundStyles);\nconst dispatchActionPromise = useDispatchActionPromise();\nconst callChangeThreadSettings = useServerCall(changeThreadSettings);\nreturn (\n- <ThreadSettingsPromoteSubthread\n+ <ThreadSettingsPromoteSidebar\n{...props}\nloadingStatus={loadingStatus}\ncolors={colors}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix ThreadSettingsPromoteSidebar name
Summary: I accidentally named this incorrectly in D274. The class name should match the filename should match the import name.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: atul
Subscribers: KatPo, zrebcu411, Adrian, subnub
Differential Revision: https://phabricator.ashoat.com/D854 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.