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,187
15.09.2020 16:13:51
14,400
eadf6984766f558d35ba2756b41e2f32f16e5174
[native] Get rid of hoistNonReactStatics Summary: We used to need this because React Navigation relied on statics on React components to specify navigation options. React Nav 5 did away with this, but at the time I forgot to remove this. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list-container.react.js", "new_path": "native/chat/message-list-container.react.js", "diff": "@@ -15,7 +15,6 @@ import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { View } from 'react-native';\nimport invariant from 'invariant';\n-import hoistNonReactStatics from 'hoist-non-react-statics';\nimport { connect } from 'lib/utils/redux-utils';\nimport { threadInfoSelector } from 'lib/selectors/thread-selectors';\n@@ -266,7 +265,7 @@ const styles = {\n};\nconst stylesSelector = styleSelector(styles);\n-const ConnectedMessageListContainer = connect(\n+export default connect(\n(state: AppState, ownProps: { route: NavigationRoute<'MessageList'> }) => {\nconst threadID = ownProps.route.params.threadInfo.id;\nreturn {\n@@ -278,7 +277,3 @@ const ConnectedMessageListContainer = connect(\n};\n},\n)(withInputState(MessageListContainer));\n-\n-hoistNonReactStatics(ConnectedMessageListContainer, MessageListContainer);\n-\n-export default ConnectedMessageListContainer;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "@@ -18,7 +18,6 @@ import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { View, FlatList } from 'react-native';\nimport invariant from 'invariant';\n-import hoistNonReactStatics from 'hoist-non-react-statics';\nimport { createSelector } from 'reselect';\nimport { relativeMemberInfoSelectorForMembersOfThread } from 'lib/selectors/user-selectors';\n@@ -897,7 +896,7 @@ const somethingIsSaving = (\nreturn false;\n};\n-const WrappedThreadSettings = connect(\n+export default connect(\n(\nstate: AppState,\nownProps: {\n@@ -918,7 +917,3 @@ const WrappedThreadSettings = connect(\n};\n},\n)(withOverlayContext(ThreadSettings));\n-\n-hoistNonReactStatics(WrappedThreadSettings, ThreadSettings);\n-\n-export default WrappedThreadSettings;\n" }, { "change_type": "DELETE", "old_path": "native/flow-typed/npm/hoist-non-react-statics_vx.x.x.js", "new_path": null, "diff": "-// flow-typed signature: 1ca10beb62bd036324c1a7b0324adcab\n-// flow-typed version: <<STUB>>/hoist-non-react-statics_v^3.1.0/flow_v0.98.0\n-\n-/**\n- * This is an autogenerated libdef stub for:\n- *\n- * 'hoist-non-react-statics'\n- *\n- * Fill this stub out by replacing all the `any` types.\n- *\n- * Once filled out, we encourage you to share your work with the\n- * community by sending a pull request to:\n- * https://github.com/flowtype/flow-typed\n- */\n-\n-declare module 'hoist-non-react-statics' {\n- declare module.exports: any;\n-}\n-\n-/**\n- * We include stubs for each file inside this npm package in case you need to\n- * require those files directly. Feel free to delete any files that aren't\n- * needed.\n- */\n-declare module 'hoist-non-react-statics/dist/hoist-non-react-statics.cjs' {\n- declare module.exports: any;\n-}\n-\n-declare module 'hoist-non-react-statics/dist/hoist-non-react-statics' {\n- declare module.exports: any;\n-}\n-\n-declare module 'hoist-non-react-statics/dist/hoist-non-react-statics.min' {\n- declare module.exports: any;\n-}\n-\n-declare module 'hoist-non-react-statics/src/index' {\n- declare module.exports: any;\n-}\n-\n-// Filename aliases\n-declare module 'hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js' {\n- declare module.exports: $Exports<'hoist-non-react-statics/dist/hoist-non-react-statics.cjs'>;\n-}\n-declare module 'hoist-non-react-statics/dist/hoist-non-react-statics.js' {\n- declare module.exports: $Exports<'hoist-non-react-statics/dist/hoist-non-react-statics'>;\n-}\n-declare module 'hoist-non-react-statics/dist/hoist-non-react-statics.min.js' {\n- declare module.exports: $Exports<'hoist-non-react-statics/dist/hoist-non-react-statics.min'>;\n-}\n-declare module 'hoist-non-react-statics/src/index.js' {\n- declare module.exports: $Exports<'hoist-non-react-statics/src/index'>;\n-}\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/navigation-context.js", "new_path": "native/navigation/navigation-context.js", "diff": "@@ -9,7 +9,6 @@ import type { ChatRouterNavigationAction } from '../chat/chat-router';\nimport type { OverlayRouterNavigationAction } from './overlay-router';\nimport * as React from 'react';\n-import hoistNonReactStatics from 'hoist-non-react-statics';\nimport PropTypes from 'prop-types';\nexport type NavAction =\n@@ -50,10 +49,8 @@ function withNavContext<\n</NavContext.Consumer>\n);\n}\n- const MemoizedNavContextHOC = React.memo(NavContextHOC);\n- hoistNonReactStatics(MemoizedNavContextHOC, Component);\n// $FlowFixMe React.memo typing fixed in later version of Flow\n- return MemoizedNavContextHOC;\n+ return React.memo(NavContextHOC);\n}\nfunction connectNav<\n@@ -82,7 +79,6 @@ function connectNav<\n? `NavConnected(${Component.displayName})`\n: `NavConnectedComponent`;\nconst MemoizedNavConnectedComponent = React.memo(NavConnectedComponent);\n- hoistNonReactStatics(MemoizedNavConnectedComponent, Component);\n// $FlowFixMe React.memo typing fixed in later version of Flow\nreturn withNavContext(MemoizedNavConnectedComponent);\n};\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"expo-media-library\": \"^8.3.0\",\n\"expo-splash-screen\": \"^0.3.1\",\n\"find-root\": \"^1.1.0\",\n- \"hoist-non-react-statics\": \"^3.1.0\",\n\"invariant\": \"^2.2.4\",\n\"lib\": \"0.0.1\",\n\"lodash\": \"^4.17.19\",\n" }, { "change_type": "MODIFY", "old_path": "native/root-context.js", "new_path": "native/root-context.js", "diff": "// @flow\nimport * as React from 'react';\n-import hoistNonReactStatics from 'hoist-non-react-statics';\nimport PropTypes from 'prop-types';\nexport type RootContextType = {|\n@@ -32,10 +31,8 @@ function withRootContext<\n</RootContext.Consumer>\n);\n}\n- const MemoizedRootContextHOC = React.memo(RootContextHOC);\n- hoistNonReactStatics(MemoizedRootContextHOC, Component);\n// $FlowFixMe React.memo typing fixed in later version of Flow\n- return MemoizedRootContextHOC;\n+ return React.memo(RootContextHOC);\n}\nconst rootContextPropType = PropTypes.shape({\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Get rid of hoistNonReactStatics Summary: We used to need this because React Navigation relied on statics on React components to specify navigation options. React Nav 5 did away with this, but at the time I forgot to remove this. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D121
129,187
15.09.2020 16:20:50
14,400
fb7f68872f12119b5d492768eadbd7cdaea353d0
[native] Use hook instead of connect functions and HOC in MessageListContainer Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list-container.react.js", "new_path": "native/chat/message-list-container.react.js", "diff": "// @flow\n-import type { AppState } from '../redux/redux-setup';\nimport { messageTypes } from 'lib/types/message-types';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\nimport type { ChatMessageInfoItemWithHeight } from './message.react';\n@@ -15,8 +14,8 @@ import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { View } from 'react-native';\nimport invariant from 'invariant';\n+import { useSelector } from 'react-redux';\n-import { connect } from 'lib/utils/redux-utils';\nimport { threadInfoSelector } from 'lib/selectors/thread-selectors';\nimport {\ntype ChatMessageItem,\n@@ -33,13 +32,13 @@ import { composedMessageMaxWidthSelector } from './composed-message-width';\nimport {\ntype InputState,\ninputStatePropType,\n- withInputState,\n+ InputStateContext,\n} from '../input/input-state';\nimport {\ntype Colors,\ncolorsPropType,\n- colorsSelector,\n- styleSelector,\n+ useColors,\n+ useStyles,\n} from '../themes/colors';\nimport ContentLoading from '../components/content-loading.react';\nimport { dummyNodeForTextMessageHeightMeasurement } from './inner-text-message.react';\n@@ -50,20 +49,23 @@ export type ChatMessageItemWithHeight =\n| {| itemType: 'loader' |}\n| ChatMessageInfoItemWithHeight;\n+type BaseProps = {|\n+ +navigation: ChatNavigationProp<'MessageList'>,\n+ +route: NavigationRoute<'MessageList'>,\n+|};\ntype Props = {|\n- navigation: ChatNavigationProp<'MessageList'>,\n- route: NavigationRoute<'MessageList'>,\n+ ...BaseProps,\n// Redux state\n- threadInfo: ?ThreadInfo,\n- messageListData: $ReadOnlyArray<ChatMessageItem>,\n- composedMessageMaxWidth: number,\n- colors: Colors,\n- styles: typeof styles,\n+ +threadInfo: ?ThreadInfo,\n+ +messageListData: $ReadOnlyArray<ChatMessageItem>,\n+ +composedMessageMaxWidth: number,\n+ +colors: Colors,\n+ +styles: typeof unboundStyles,\n// withInputState\n- inputState: ?InputState,\n+ +inputState: ?InputState,\n|};\ntype State = {|\n- listDataWithHeights: ?$ReadOnlyArray<ChatMessageItemWithHeight>,\n+ +listDataWithHeights: ?$ReadOnlyArray<ChatMessageItemWithHeight>,\n|};\nclass MessageListContainer extends React.PureComponent<Props, State> {\nstatic propTypes = {\n@@ -257,23 +259,34 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nbackgroundColor: 'listBackground',\nflex: 1,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect(\n- (state: AppState, ownProps: { route: NavigationRoute<'MessageList'> }) => {\n- const threadID = ownProps.route.params.threadInfo.id;\n- return {\n- threadInfo: threadInfoSelector(state)[threadID],\n- messageListData: messageListData(threadID)(state),\n- composedMessageMaxWidth: composedMessageMaxWidthSelector(state),\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- };\n- },\n-)(withInputState(MessageListContainer));\n+export default React.memo<BaseProps>(function ConnectedMessageListContainer(\n+ props: BaseProps,\n+) {\n+ const threadID = props.route.params.threadInfo.id;\n+ const threadInfo = useSelector(state => threadInfoSelector(state)[threadID]);\n+ const boundMessageListData = useSelector(state =>\n+ messageListData(threadID)(state),\n+ );\n+ const composedMessageMaxWidth = useSelector(composedMessageMaxWidthSelector);\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ const inputState = React.useContext(InputStateContext);\n+ return (\n+ <MessageListContainer\n+ {...props}\n+ threadInfo={threadInfo}\n+ messageListData={boundMessageListData}\n+ composedMessageMaxWidth={composedMessageMaxWidth}\n+ colors={colors}\n+ styles={styles}\n+ inputState={inputState}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in MessageListContainer Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D122
129,187
15.09.2020 16:34:04
14,400
78476fbbe120c49f7b37bb1f13053dd741926e01
[native] Use hook instead of connect functions and HOC in MultimediaTooltipButton Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "@@ -5,7 +5,6 @@ import {\nverticalBoundsPropType,\nlayoutCoordinatesPropType,\n} from '../types/layout-types';\n-import type { AppState } from '../redux/redux-setup';\nimport type { AppNavigationProp } from '../navigation/app-navigator.react';\nimport type { TooltipRoute } from '../navigation/tooltip.react';\n@@ -13,15 +12,15 @@ import * as React from 'react';\nimport Animated from 'react-native-reanimated';\nimport PropTypes from 'prop-types';\nimport { View, StyleSheet } from 'react-native';\n+import { useSelector } from 'react-redux';\n-import { connect } from 'lib/utils/redux-utils';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { messageID } from 'lib/shared/message-utils';\nimport {\ntype InputState,\ninputStatePropType,\n- withInputState,\n+ InputStateContext,\n} from '../input/input-state';\nimport InlineMultimedia from './inline-multimedia.react';\nimport { multimediaMessageBorderRadius } from './multimedia-message.react';\n@@ -32,14 +31,19 @@ import { MessageHeader } from './message-header.react';\nconst { Value } = Animated;\n/* eslint-enable import/no-named-as-default-member */\n+type BaseProps = {\n+ +navigation: AppNavigationProp<'MultimediaTooltipModal'>,\n+ +route: TooltipRoute<'MultimediaTooltipModal'>,\n+ +progress: Value,\n+ ...\n+};\ntype Props = {\n- navigation: AppNavigationProp<'MultimediaTooltipModal'>,\n- route: TooltipRoute<'MultimediaTooltipModal'>,\n- progress: Value,\n+ ...BaseProps,\n// Redux state\n- windowWidth: number,\n+ +windowWidth: number,\n// withInputState\n- inputState: ?InputState,\n+ +inputState: ?InputState,\n+ ...\n};\nclass MultimediaTooltipButton extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -123,6 +127,16 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect((state: AppState) => ({\n- windowWidth: state.dimensions.width,\n-}))(withInputState(MultimediaTooltipButton));\n+export default React.memo<BaseProps>(function ConnectedMultimediaTooltipButton(\n+ props: BaseProps,\n+) {\n+ const windowWidth = useSelector(state => state.dimensions.width);\n+ const inputState = React.useContext(InputStateContext);\n+ return (\n+ <MultimediaTooltipButton\n+ {...props}\n+ windowWidth={windowWidth}\n+ inputState={inputState}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in MultimediaTooltipButton Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D123
129,187
15.09.2020 23:38:42
14,400
c175e0ee532d916d1a9463805c628a7e11fc2ef7
[native] Use hook instead of connect functions and HOC in Tooltip Summary: `connect` and friends were hiding a whole lot of type errors here. I had to refactor things to make it work. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/utils/action-utils.js", "new_path": "lib/utils/action-utils.js", "diff": "@@ -142,12 +142,19 @@ function createDispatchActionPromise(dispatch: Dispatch) {\nreturn dispatchActionPromise;\n}\n-export type DispatchFunctions = {\n+export type DispatchFunctions = {|\n+ +dispatch: Dispatch,\n+ +dispatchActionPromise: DispatchActionPromise,\n+|};\n+\n+type LegacyDispatchFunctions = {\ndispatch: Dispatch,\ndispatchActionPayload: DispatchActionPayload,\ndispatchActionPromise: DispatchActionPromise,\n};\n-function includeDispatchActionProps(dispatch: Dispatch): DispatchFunctions {\n+function includeDispatchActionProps(\n+ dispatch: Dispatch,\n+): LegacyDispatchFunctions {\nconst dispatchActionPromise = createDispatchActionPromise(dispatch);\nconst dispatchActionPayload = function<T: string, P: ActionPayload>(\nactionType: T,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "@@ -31,20 +31,18 @@ import { MessageHeader } from './message-header.react';\nconst { Value } = Animated;\n/* eslint-enable import/no-named-as-default-member */\n-type BaseProps = {\n+type BaseProps = {|\n+navigation: AppNavigationProp<'MultimediaTooltipModal'>,\n+route: TooltipRoute<'MultimediaTooltipModal'>,\n+progress: Value,\n- ...\n-};\n-type Props = {\n+|};\n+type Props = {|\n...BaseProps,\n// Redux state\n+windowWidth: number,\n// withInputState\n+inputState: ?InputState,\n- ...\n-};\n+|};\nclass MultimediaTooltipButton extends React.PureComponent<Props> {\nstatic propTypes = {\nnavigation: PropTypes.shape({\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-modal.react.js", "new_path": "native/chat/multimedia-tooltip-modal.react.js", "diff": "@@ -7,19 +7,18 @@ import {\ncreateTooltip,\ntooltipHeight,\ntype TooltipParams,\n+ type TooltipEntry,\n} from '../navigation/tooltip.react';\nimport MultimediaTooltipButton from './multimedia-tooltip-button.react';\nimport { intentionalSaveMedia } from '../media/save-media';\n-type CustomProps = {\n- item: ChatMultimediaMessageInfoItem,\n- mediaInfo: MediaInfo,\n- verticalOffset: number,\n-};\n-\n-export type MultimediaTooltipModalParams = TooltipParams<CustomProps>;\n+export type MultimediaTooltipModalParams = TooltipParams<{|\n+ +item: ChatMultimediaMessageInfoItem,\n+ +mediaInfo: MediaInfo,\n+ +verticalOffset: number,\n+|}>;\n-function onPressSave(props: CustomProps) {\n+function onPressSave(props: MultimediaTooltipModalParams) {\nconst { mediaInfo, item } = props;\nconst { id: uploadID, uri } = mediaInfo;\nconst { id: messageServerID, localID: messageLocalID } = item.messageInfo;\n@@ -31,7 +30,10 @@ const spec = {\nentries: [{ id: 'save', text: 'Save', onPress: onPressSave }],\n};\n-const MultimediaTooltipModal = createTooltip(MultimediaTooltipButton, spec);\n+const MultimediaTooltipModal = createTooltip<\n+ 'MultimediaTooltipModal',\n+ TooltipEntry<'MultimediaTooltipModal'>,\n+>(MultimediaTooltipButton, spec);\nconst multimediaTooltipHeight = tooltipHeight(spec.entries.length);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-member-tooltip-button.react.js", "new_path": "native/chat/settings/thread-settings-member-tooltip-button.react.js", "diff": "@@ -9,7 +9,8 @@ import PropTypes from 'prop-types';\nimport PencilIcon from '../../components/pencil-icon.react';\ntype Props = {\n- navigation: AppNavigationProp<'ThreadSettingsMemberTooltipModal'>,\n+ +navigation: AppNavigationProp<'ThreadSettingsMemberTooltipModal'>,\n+ ...\n};\nclass ThreadSettingsMemberTooltipButton extends React.PureComponent<Props> {\nstatic propTypes = {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-member-tooltip-modal.react.js", "new_path": "native/chat/settings/thread-settings-member-tooltip-modal.react.js", "diff": "@@ -22,18 +22,17 @@ import { memberIsAdmin } from 'lib/shared/thread-utils';\nimport {\ncreateTooltip,\ntype TooltipParams,\n+ type TooltipEntry,\n} from '../../navigation/tooltip.react';\nimport ThreadSettingsMemberTooltipButton from './thread-settings-member-tooltip-button.react';\n-type CustomProps = {\n- memberInfo: RelativeMemberInfo,\n- threadInfo: ThreadInfo,\n-};\n-\n-export type ThreadSettingsMemberTooltipModalParams = TooltipParams<CustomProps>;\n+export type ThreadSettingsMemberTooltipModalParams = TooltipParams<{|\n+ +memberInfo: RelativeMemberInfo,\n+ +threadInfo: ThreadInfo,\n+|}>;\nfunction onRemoveUser(\n- props: CustomProps,\n+ props: ThreadSettingsMemberTooltipModalParams,\ndispatchFunctions: DispatchFunctions,\nbindServerCall: (serverCall: ActionFunc) => BoundServerCall,\n) {\n@@ -61,7 +60,7 @@ function onRemoveUser(\n}\nfunction onToggleAdmin(\n- props: CustomProps,\n+ props: ThreadSettingsMemberTooltipModalParams,\ndispatchFunctions: DispatchFunctions,\nbindServerCall: (serverCall: ActionFunc) => BoundServerCall,\n) {\n@@ -117,9 +116,9 @@ const spec = {\n],\n};\n-const ThreadSettingsMemberTooltipModal = createTooltip(\n- ThreadSettingsMemberTooltipButton,\n- spec,\n-);\n+const ThreadSettingsMemberTooltipModal = createTooltip<\n+ 'ThreadSettingsMemberTooltipModal',\n+ TooltipEntry<'ThreadSettingsMemberTooltipModal'>,\n+>(ThreadSettingsMemberTooltipButton, spec);\nexport default ThreadSettingsMemberTooltipModal;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/text-message-tooltip-button.react.js", "new_path": "native/chat/text-message-tooltip-button.react.js", "diff": "@@ -22,13 +22,13 @@ import { MessageHeader } from './message-header.react';\nconst { Value } = Animated;\n/* eslint-enable import/no-named-as-default-member */\n-type Props = {\n- navigation: AppNavigationProp<'TextMessageTooltipModal'>,\n- route: TooltipRoute<'TextMessageTooltipModal'>,\n- progress: Value,\n+type Props = {|\n+ +navigation: AppNavigationProp<'TextMessageTooltipModal'>,\n+ +route: TooltipRoute<'TextMessageTooltipModal'>,\n+ +progress: Value,\n// Redux state\n- windowWidth: number,\n-};\n+ +windowWidth: number,\n+|};\nclass TextMessageTooltipButton extends React.PureComponent<Props> {\nstatic propTypes = {\nnavigation: PropTypes.shape({\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": "@@ -6,7 +6,7 @@ import type {\nActionFunc,\nBoundServerCall,\n} from 'lib/utils/action-utils';\n-import { type InputState } from '../input/input-state';\n+import type { InputState } from '../input/input-state';\nimport Clipboard from '@react-native-community/clipboard';\nimport invariant from 'invariant';\n@@ -17,25 +17,24 @@ import {\ncreateTooltip,\ntooltipHeight,\ntype TooltipParams,\n+ type TooltipEntry,\n} from '../navigation/tooltip.react';\nimport TextMessageTooltipButton from './text-message-tooltip-button.react';\nimport { displayActionResultModal } from '../navigation/action-result-modal';\n-type CustomProps = {\n- item: ChatTextMessageInfoItemWithHeight,\n-};\n-\n-export type TextMessageTooltipModalParams = TooltipParams<CustomProps>;\n+export type TextMessageTooltipModalParams = TooltipParams<{|\n+ +item: ChatTextMessageInfoItemWithHeight,\n+|}>;\nconst confirmCopy = () => displayActionResultModal('copied!');\n-function onPressCopy(props: CustomProps) {\n+function onPressCopy(props: TextMessageTooltipModalParams) {\nClipboard.setString(props.item.messageInfo.text);\nsetTimeout(confirmCopy);\n}\nfunction onPressReply(\n- props: CustomProps,\n+ props: TextMessageTooltipModalParams,\ndispatchFunctions: DispatchFunctions,\nbindServerCall: (serverCall: ActionFunc) => BoundServerCall,\ninputState: ?InputState,\n@@ -54,7 +53,10 @@ const spec = {\n],\n};\n-const TextMessageTooltipModal = createTooltip(TextMessageTooltipButton, spec);\n+const TextMessageTooltipModal = createTooltip<\n+ 'TextMessageTooltipModal',\n+ TooltipEntry<'TextMessageTooltipModal'>,\n+>(TextMessageTooltipButton, spec);\nconst textMessageTooltipHeight = tooltipHeight(spec.entries.length);\n" }, { "change_type": "MODIFY", "old_path": "native/more/relationship-list-item-tooltip-modal.react.js", "new_path": "native/more/relationship-list-item-tooltip-modal.react.js", "diff": "@@ -17,22 +17,25 @@ import {\nupdateRelationships,\n} from 'lib/actions/relationship-actions';\n-import { createTooltip, type TooltipParams } from '../navigation/tooltip.react';\n+import {\n+ createTooltip,\n+ type TooltipParams,\n+ type TooltipEntry,\n+} from '../navigation/tooltip.react';\nimport PencilIcon from '../components/pencil-icon.react';\ntype Action = 'unfriend' | 'unblock';\n-type CustomProps = {\n- relativeUserInfo: RelativeUserInfo,\n- action: Action,\n-};\n-\n-export type RelationshipListItemTooltipModalParams = TooltipParams<\n- $Diff<CustomProps, { action: Action }>,\n->;\n+export type RelationshipListItemTooltipModalParams = TooltipParams<{|\n+ +relativeUserInfo: RelativeUserInfo,\n+|}>;\n+type OnRemoveUserProps = {|\n+ ...RelationshipListItemTooltipModalParams,\n+ +action: Action,\n+|};\nfunction onRemoveUser(\n- props: CustomProps,\n+ props: OnRemoveUserProps,\ndispatchFunctions: DispatchFunctions,\nbindServerCall: (serverCall: ActionFunc) => BoundServerCall,\n) {\n@@ -95,7 +98,8 @@ const spec = {\n};\ntype Props = {\n- navigation: AppNavigationProp<'RelationshipListItemTooltipModal'>,\n+ +navigation: AppNavigationProp<'RelationshipListItemTooltipModal'>,\n+ ...\n};\nclass RelationshipListItemTooltipButton extends React.PureComponent<Props> {\nrender() {\n@@ -111,9 +115,9 @@ class RelationshipListItemTooltipButton extends React.PureComponent<Props> {\n};\n}\n-const RelationshipListItemTooltipModal = createTooltip(\n- RelationshipListItemTooltipButton,\n- spec,\n-);\n+const RelationshipListItemTooltipModal = createTooltip<\n+ 'RelationshipListItemTooltipModal',\n+ TooltipEntry<'RelationshipListItemTooltipModal'>,\n+>(RelationshipListItemTooltipButton, spec);\nexport default RelationshipListItemTooltipModal;\n" }, { "change_type": "DELETE", "old_path": "native/navigation/tooltip-item.react.js", "new_path": null, "diff": "-// @flow\n-\n-import type { ViewStyle, TextStyle } from '../types/styles';\n-import type {\n- DispatchFunctions,\n- ActionFunc,\n- BoundServerCall,\n-} from 'lib/utils/action-utils';\n-import type { InputState } from '../input/input-state';\n-\n-import * as React from 'react';\n-import {\n- TouchableOpacity,\n- StyleSheet,\n- Text,\n- ViewPropTypes,\n-} from 'react-native';\n-import PropTypes from 'prop-types';\n-\n-import { SingleLine } from '../components/single-line.react';\n-\n-export type TooltipEntry<Params> = {|\n- id: string,\n- text: string,\n- onPress: (\n- props: Params,\n- dispatchFunctions: DispatchFunctions,\n- bindServerCall: (serverCall: ActionFunc) => BoundServerCall,\n- inputState: ?InputState,\n- ) => mixed,\n-|};\n-\n-type Props<Params, Entry: TooltipEntry<Params>> = {\n- spec: Entry,\n- onPress: (entry: Entry) => void,\n- containerStyle?: ViewStyle,\n- labelStyle?: TextStyle,\n-};\n-class TooltipItem<\n- Params,\n- Entry: TooltipEntry<Params>,\n-> extends React.PureComponent<Props<Params, Entry>> {\n- static propTypes = {\n- spec: PropTypes.shape({\n- text: PropTypes.string.isRequired,\n- onPress: PropTypes.func.isRequired,\n- }).isRequired,\n- onPress: PropTypes.func.isRequired,\n- containerStyle: ViewPropTypes.style,\n- labelStyle: Text.propTypes.style,\n- };\n-\n- render() {\n- return (\n- <TouchableOpacity\n- onPress={this.onPress}\n- style={[styles.itemContainer, this.props.containerStyle]}\n- >\n- <SingleLine style={[styles.label, this.props.labelStyle]}>\n- {this.props.spec.text}\n- </SingleLine>\n- </TouchableOpacity>\n- );\n- }\n-\n- onPress = () => {\n- this.props.onPress(this.props.spec);\n- };\n-}\n-\n-const styles = StyleSheet.create({\n- itemContainer: {\n- padding: 10,\n- },\n- label: {\n- color: '#444',\n- fontSize: 14,\n- lineHeight: 17,\n- textAlign: 'center',\n- },\n-});\n-\n-export default TooltipItem;\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/tooltip.react.js", "new_path": "native/navigation/tooltip.react.js", "diff": "@@ -6,19 +6,12 @@ import {\ntype LayoutCoordinates,\nlayoutCoordinatesPropType,\n} from '../types/layout-types';\n-import type { AppState } from '../redux/redux-setup';\nimport {\ntype DimensionsInfo,\ndimensionsInfoPropType,\n} from '../redux/dimensions-updater.react';\n-import type { ViewStyle } from '../types/styles';\n-import type { TooltipEntry } from './tooltip-item.react';\n+import type { ViewStyle, TextStyle } from '../types/styles';\nimport type { Dispatch } from 'lib/types/redux-types';\n-import type {\n- DispatchActionPayload,\n- DispatchActionPromise,\n- ActionFunc,\n-} from 'lib/utils/action-utils';\nimport type { LayoutEvent } from '../types/react-native';\nimport type { AppNavigationProp } from './app-navigator.react';\nimport type { TooltipModalParamList } from './route-names';\n@@ -26,7 +19,7 @@ import type { LeafRoute } from '@react-navigation/native';\nimport {\ntype InputState,\ninputStatePropType,\n- withInputState,\n+ InputStateContext,\n} from '../input/input-state';\nimport * as React from 'react';\n@@ -36,87 +29,134 @@ import {\nStyleSheet,\nTouchableWithoutFeedback,\nPlatform,\n+ TouchableOpacity,\n+ Text,\n+ ViewPropTypes,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n+import { useSelector, useDispatch } from 'react-redux';\nimport {\ntype ServerCallState,\nserverCallStatePropType,\nserverCallStateSelector,\n} from 'lib/selectors/server-calls';\n-import { connect } from 'lib/utils/redux-utils';\n-import { createBoundServerCallsSelector } from 'lib/utils/action-utils';\n+import {\n+ createBoundServerCallsSelector,\n+ useDispatchActionPromise,\n+ type DispatchActionPromise,\n+ type ActionFunc,\n+ type DispatchFunctions,\n+ type BoundServerCall,\n+} from 'lib/utils/action-utils';\n-import TooltipItem from './tooltip-item.react';\nimport {\n- withOverlayContext,\n+ OverlayContext,\ntype OverlayContextType,\noverlayContextPropType,\n} from './overlay-context';\n+import { SingleLine } from '../components/single-line.react';\n/* eslint-disable import/no-named-as-default-member */\nconst { Value, Extrapolate, add, multiply, interpolate } = Animated;\n/* eslint-enable import/no-named-as-default-member */\n+type InternalTooltipEntry<RouteParams> = {|\n+ +id: string,\n+ +text: string,\n+ +onPress: (\n+ props: RouteParams,\n+ dispatchFunctions: DispatchFunctions,\n+ bindServerCall: (serverCall: ActionFunc) => BoundServerCall,\n+ inputState: ?InputState,\n+ ) => mixed,\n+|};\n+type TooltipItemProps<Entry> = {|\n+ +spec: Entry,\n+ +onPress: (entry: Entry) => void,\n+ +containerStyle?: ViewStyle,\n+ +labelStyle?: TextStyle,\n+|};\ntype TooltipSpec<Entry> = {|\n- entries: $ReadOnlyArray<Entry>,\n- labelStyle?: ViewStyle,\n+ +entries: $ReadOnlyArray<Entry>,\n+ +labelStyle?: ViewStyle,\n|};\n-type TooltipCommonProps = {\n- presentedFrom: string,\n- initialCoordinates: LayoutCoordinates,\n- verticalBounds: VerticalBounds,\n- location?: 'above' | 'below',\n- margin?: number,\n- visibleEntryIDs?: $ReadOnlyArray<string>,\n-};\n-\nexport type TooltipParams<CustomProps> = {|\n- ...$Exact<CustomProps>,\n- ...$Exact<TooltipCommonProps>,\n+ ...CustomProps,\n+ +presentedFrom: string,\n+ +initialCoordinates: LayoutCoordinates,\n+ +verticalBounds: VerticalBounds,\n+ +location?: 'above' | 'below',\n+ +margin?: number,\n+ +visibleEntryIDs?: $ReadOnlyArray<string>,\n|};\n-\n-export type TooltipRoute<\n+export type TooltipEntry<\nRouteName: $Keys<TooltipModalParamList>,\n- Params = $ElementType<TooltipModalParamList, RouteName>,\n-> = {|\n+> = InternalTooltipEntry<$ElementType<TooltipModalParamList, RouteName>>;\n+export type TooltipRoute<RouteName: $Keys<TooltipModalParamList>> = {|\n...LeafRoute<RouteName>,\n- +params: Params,\n+ +params: $ElementType<TooltipModalParamList, RouteName>,\n|};\n-type ButtonProps<Navigation, Route> = {\n- navigation: Navigation,\n- route: Route,\n- progress: Value,\n-};\n-\n-type TooltipProps<Navigation, Route> = {\n- navigation: Navigation,\n- route: Route,\n+type BaseTooltipProps<RouteName> = {|\n+ +navigation: AppNavigationProp<RouteName>,\n+ +route: TooltipRoute<RouteName>,\n+|};\n+type ButtonProps<RouteName> = {|\n+ ...BaseTooltipProps<RouteName>,\n+ +progress: Value,\n+|};\n+type TooltipProps<RouteName> = {|\n+ ...BaseTooltipProps<RouteName>,\n// Redux state\n- dimensions: DimensionsInfo,\n- serverCallState: ServerCallState,\n+ +dimensions: DimensionsInfo,\n+ +serverCallState: ServerCallState,\n// Redux dispatch functions\n- dispatch: Dispatch,\n- dispatchActionPayload: DispatchActionPayload,\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatch: Dispatch,\n+ +dispatchActionPromise: DispatchActionPromise,\n// withOverlayContext\n- overlayContext: ?OverlayContextType,\n+ +overlayContext: ?OverlayContextType,\n// withInputState\n- inputState: ?InputState,\n-};\n+ +inputState: ?InputState,\n+|};\nfunction createTooltip<\nRouteName: $Keys<TooltipModalParamList>,\n- Navigation: AppNavigationProp<RouteName>,\n- Params: TooltipCommonProps,\n- Route: TooltipRoute<RouteName, Params>,\n- Entry: TooltipEntry<Params>,\n- TooltipPropsType: TooltipProps<Navigation, Route>,\n- ButtonComponentType: React.ComponentType<ButtonProps<Navigation, Route>>,\n->(ButtonComponent: ButtonComponentType, tooltipSpec: TooltipSpec<Entry>) {\n- class Tooltip extends React.PureComponent<TooltipPropsType> {\n+ Entry: InternalTooltipEntry<$ElementType<TooltipModalParamList, RouteName>>,\n+>(\n+ ButtonComponent: React.ComponentType<ButtonProps<RouteName>>,\n+ tooltipSpec: TooltipSpec<Entry>,\n+): React.ComponentType<BaseTooltipProps<RouteName>> {\n+ class TooltipItem extends React.PureComponent<TooltipItemProps<Entry>> {\n+ static propTypes = {\n+ spec: PropTypes.shape({\n+ text: PropTypes.string.isRequired,\n+ onPress: PropTypes.func.isRequired,\n+ }).isRequired,\n+ onPress: PropTypes.func.isRequired,\n+ containerStyle: ViewPropTypes.style,\n+ labelStyle: Text.propTypes.style,\n+ };\n+\n+ render() {\n+ return (\n+ <TouchableOpacity\n+ onPress={this.onPress}\n+ style={[styles.itemContainer, this.props.containerStyle]}\n+ >\n+ <SingleLine style={[styles.label, this.props.labelStyle]}>\n+ {this.props.spec.text}\n+ </SingleLine>\n+ </TouchableOpacity>\n+ );\n+ }\n+\n+ onPress = () => {\n+ this.props.onPress(this.props.spec);\n+ };\n+ }\n+ class Tooltip extends React.PureComponent<TooltipProps<RouteName>> {\nstatic propTypes = {\nnavigation: PropTypes.shape({\ngoBackOnce: PropTypes.func.isRequired,\n@@ -133,7 +173,6 @@ function createTooltip<\ndimensions: dimensionsInfoPropType.isRequired,\nserverCallState: serverCallStatePropType.isRequired,\ndispatch: PropTypes.func.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\noverlayContext: overlayContextPropType,\ninputState: inputStatePropType,\n@@ -145,7 +184,7 @@ function createTooltip<\ntooltipHorizontalOffset = new Value(0);\ntooltipHorizontal: Value;\n- constructor(props: TooltipPropsType) {\n+ constructor(props: TooltipProps<RouteName>) {\nsuper(props);\nconst { overlayContext } = props;\n@@ -181,7 +220,7 @@ function createTooltip<\n);\n}\n- get entries() {\n+ get entries(): $ReadOnlyArray<Entry> {\nconst { entries } = tooltipSpec;\nconst { visibleEntryIDs } = this.props.route.params;\nif (!visibleEntryIDs) {\n@@ -383,11 +422,10 @@ function createTooltip<\nthis.props.navigation.goBackOnce();\nconst dispatchFunctions = {\ndispatch: this.props.dispatch,\n- dispatchActionPayload: this.props.dispatchActionPayload,\ndispatchActionPromise: this.props.dispatchActionPromise,\n};\nentry.onPress(\n- this.props.route.params,\n+ (this.props.route.params: any),\ndispatchFunctions,\nthis.bindServerCall,\nthis.props.inputState,\n@@ -429,14 +467,27 @@ function createTooltip<\n}\n};\n}\n- return connect(\n- (state: AppState) => ({\n- dimensions: state.dimensions,\n- serverCallState: serverCallStateSelector(state),\n- }),\n- null,\n- true,\n- )(withOverlayContext(withInputState(Tooltip)));\n+ return React.memo<BaseTooltipProps<RouteName>>(function ConnectedTooltip(\n+ props: BaseTooltipProps<RouteName>,\n+ ) {\n+ const dimensions = useSelector(state => state.dimensions);\n+ const serverCallState = useSelector(serverCallStateSelector);\n+ const dispatch = useDispatch();\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const overlayContext = React.useContext(OverlayContext);\n+ const inputState = React.useContext(InputStateContext);\n+ return (\n+ <Tooltip\n+ {...props}\n+ dimensions={dimensions}\n+ serverCallState={serverCallState}\n+ dispatch={dispatch}\n+ dispatchActionPromise={dispatchActionPromise}\n+ overlayContext={overlayContext}\n+ inputState={inputState}\n+ />\n+ );\n+ });\n}\nconst styles = StyleSheet.create({\n@@ -455,6 +506,9 @@ const styles = StyleSheet.create({\nflex: 1,\noverflow: 'hidden',\n},\n+ itemContainer: {\n+ padding: 10,\n+ },\nitemMargin: {\nborderBottomColor: '#E1E1E1',\nborderBottomWidth: 1,\n@@ -464,6 +518,12 @@ const styles = StyleSheet.create({\nborderRadius: 5,\noverflow: 'hidden',\n},\n+ label: {\n+ color: '#444',\n+ fontSize: 14,\n+ lineHeight: 17,\n+ textAlign: 'center',\n+ },\ntriangleDown: {\nborderBottomColor: 'transparent',\nborderBottomWidth: 0,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in Tooltip Summary: `connect` and friends were hiding a whole lot of type errors here. I had to refactor things to make it work. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D124
129,187
16.09.2020 00:33:54
14,400
9022f75f6b5ecaf9037007b736b37f5e5d2ad8d9
[native] Use hook instead of connect functions and HOC in KeyboardInputHost Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/keyboard/keyboard-input-host.react.js", "new_path": "native/keyboard/keyboard-input-host.react.js", "diff": "// @flow\n-import type { AppState } from '../redux/redux-setup';\nimport {\ntype InputState,\ninputStatePropType,\n- withInputState,\n+ InputStateContext,\n} from '../input/input-state';\nimport {\ntype KeyboardState,\nkeyboardStatePropType,\n- withKeyboardState,\n+ KeyboardContext,\n} from '../keyboard/keyboard-state';\nimport type { MediaLibrarySelection } from 'lib/types/media-types';\n+import { NavContext } from '../navigation/navigation-context';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -19,25 +19,22 @@ import { TextInput } from 'react-native';\nimport { KeyboardAccessoryView } from 'react-native-keyboard-input';\nimport invariant from 'invariant';\n-import { connect } from 'lib/utils/redux-utils';\n-\n-import { styleSelector } from '../themes/colors';\n+import { useStyles } from '../themes/colors';\nimport { mediaGalleryKeyboardName } from '../media/media-gallery-keyboard.react';\nimport { activeMessageListSelector } from '../navigation/nav-selectors';\n-import {\n- connectNav,\n- type NavContextType,\n-} from '../navigation/navigation-context';\n+type BaseProps = {|\n+ +textInputRef?: React.ElementRef<typeof TextInput>,\n+|};\ntype Props = {|\n- textInputRef: ?React.ElementRef<typeof TextInput>,\n+ ...BaseProps,\n// Redux state\n- styles: typeof styles,\n- activeMessageList: ?string,\n+ +styles: typeof unboundStyles,\n+ +activeMessageList: ?string,\n// withKeyboardState\n- keyboardState: ?KeyboardState,\n+ +keyboardState: ?KeyboardState,\n// withInputState\n- inputState: ?InputState,\n+ +inputState: ?InputState,\n|};\nclass KeyboardInputHost extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -108,17 +105,27 @@ class KeyboardInputHost extends React.PureComponent<Props> {\n};\n}\n-const styles = {\n+const unboundStyles = {\nkbInitialProps: {\nbackgroundColor: 'listBackground',\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(\n- connectNav((context: ?NavContextType) => ({\n- activeMessageList: activeMessageListSelector(context),\n- }))(withKeyboardState(withInputState(KeyboardInputHost))),\n+export default React.memo<BaseProps>(function ConnectedKeyboardInputHost(\n+ props: BaseProps,\n+) {\n+ const inputState = React.useContext(InputStateContext);\n+ const keyboardState = React.useContext(KeyboardContext);\n+ const navContext = React.useContext(NavContext);\n+ const styles = useStyles(unboundStyles);\n+ const activeMessageList = activeMessageListSelector(navContext);\n+ return (\n+ <KeyboardInputHost\n+ {...props}\n+ styles={styles}\n+ activeMessageList={activeMessageList}\n+ keyboardState={keyboardState}\n+ inputState={inputState}\n+ />\n);\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in KeyboardInputHost Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D125
129,187
16.09.2020 03:27:38
14,400
c95eb9796339a9b3881c7e2b1f664c4c68e597dc
[native] Use hook instead of connect functions and HOC in CameraModal Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "// @flow\n-import type { AppState } from '../redux/redux-setup';\nimport type { PhotoCapture } from 'lib/types/media-types';\nimport {\ntype DimensionsInfo,\ndimensionsInfoPropType,\n} from '../redux/dimensions-updater.react';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\nimport { updateDeviceCameraInfoActionType } from '../redux/action-types';\nimport {\ntype DeviceCameraInfo,\n@@ -16,12 +14,13 @@ import type { Orientations } from 'react-native-orientation-locker';\nimport {\ntype InputState,\ninputStatePropType,\n- withInputState,\n+ InputStateContext,\n} from '../input/input-state';\nimport type { ViewStyle } from '../types/styles';\nimport type { NativeMethodsMixinType } from '../types/react-native';\nimport type { AppNavigationProp } from '../navigation/app-navigator.react';\nimport type { NavigationRoute } from '../navigation/route-names';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport * as React from 'react';\nimport {\n@@ -48,8 +47,8 @@ import Icon from 'react-native-vector-icons/Ionicons';\nimport Orientation from 'react-native-orientation-locker';\nimport invariant from 'invariant';\nimport filesystem from 'react-native-fs';\n+import { useSelector, useDispatch } from 'react-redux';\n-import { connect } from 'lib/utils/redux-utils';\nimport { pathFromURI, filenameFromPathOrURI } from 'lib/media/file-utils';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n@@ -58,7 +57,7 @@ import ContentLoading from '../components/content-loading.react';\nimport { colors } from '../themes/colors';\nimport SendMediaButton from './send-media-button.react';\nimport {\n- withOverlayContext,\n+ OverlayContext,\ntype OverlayContextType,\noverlayContextPropType,\n} from '../navigation/overlay-context';\n@@ -236,29 +235,36 @@ type TouchableOpacityInstance = React.AbstractComponent<\nNativeMethodsMixinType,\n>;\n-type Props = {\n- navigation: AppNavigationProp<'CameraModal'>,\n- route: NavigationRoute<'CameraModal'>,\n+type BaseProps = {|\n+ +navigation: AppNavigationProp<'CameraModal'>,\n+ +route: NavigationRoute<'CameraModal'>,\n+|};\n+type Props = {|\n+ ...BaseProps,\n// Redux state\n- dimensions: DimensionsInfo,\n- deviceCameraInfo: DeviceCameraInfo,\n- deviceOrientation: Orientations,\n- foreground: boolean,\n+ +dimensions: DimensionsInfo,\n+ +deviceCameraInfo: DeviceCameraInfo,\n+ +deviceOrientation: Orientations,\n+ +foreground: boolean,\n// Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n+ +dispatch: Dispatch,\n// withInputState\n- inputState: ?InputState,\n+ +inputState: ?InputState,\n// withOverlayContext\n- overlayContext: ?OverlayContextType,\n-};\n+ +overlayContext: ?OverlayContextType,\n+|};\ntype State = {|\n- zoom: number,\n- useFrontCamera: boolean,\n- hasCamerasOnBothSides: boolean,\n- flashMode: number,\n- autoFocusPointOfInterest: ?{| x: number, y: number, autoExposure?: boolean |},\n- stagingMode: boolean,\n- pendingPhotoCapture: ?PhotoCapture,\n+ +zoom: number,\n+ +useFrontCamera: boolean,\n+ +hasCamerasOnBothSides: boolean,\n+ +flashMode: number,\n+ +autoFocusPointOfInterest: ?{|\n+ x: number,\n+ y: number,\n+ autoExposure?: boolean,\n+ |},\n+ +stagingMode: boolean,\n+ +pendingPhotoCapture: ?PhotoCapture,\n|};\nclass CameraModal extends React.PureComponent<Props, State> {\nstatic propTypes = {\n@@ -274,7 +280,7 @@ class CameraModal extends React.PureComponent<Props, State> {\ndeviceCameraInfo: deviceCameraInfoPropType.isRequired,\ndeviceOrientation: PropTypes.string.isRequired,\nforeground: PropTypes.bool.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n+ dispatch: PropTypes.func.isRequired,\ninputState: inputStatePropType,\noverlayContext: overlayContextPropType,\n};\n@@ -1057,9 +1063,9 @@ class CameraModal extends React.PureComponent<Props, State> {\nhasCamerasOnBothSides !== oldHasCamerasOnBothSides ||\ndefaultUseFrontCamera !== oldDefaultUseFrontCamera\n) {\n- this.props.dispatchActionPayload(updateDeviceCameraInfoActionType, {\n- hasCamerasOnBothSides,\n- defaultUseFrontCamera,\n+ this.props.dispatch({\n+ type: updateDeviceCameraInfoActionType,\n+ payload: { hasCamerasOnBothSides, defaultUseFrontCamera },\n});\n}\n};\n@@ -1201,13 +1207,26 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect(\n- (state: AppState) => ({\n- dimensions: state.dimensions,\n- deviceCameraInfo: state.deviceCameraInfo,\n- deviceOrientation: state.deviceOrientation,\n- foreground: state.foreground,\n- }),\n- null,\n- true,\n-)(withOverlayContext(withInputState(CameraModal)));\n+export default React.memo<BaseProps>(function ConnectedCameraModal(\n+ props: BaseProps,\n+) {\n+ const dimensions = useSelector(state => state.dimensions);\n+ const deviceCameraInfo = useSelector(state => state.deviceCameraInfo);\n+ const deviceOrientation = useSelector(state => state.deviceOrientation);\n+ const foreground = useSelector(state => state.foreground);\n+ const overlayContext = React.useContext(OverlayContext);\n+ const inputState = React.useContext(InputStateContext);\n+ const dispatch = useDispatch();\n+ return (\n+ <CameraModal\n+ {...props}\n+ dimensions={dimensions}\n+ deviceCameraInfo={deviceCameraInfo}\n+ deviceOrientation={deviceOrientation}\n+ foreground={foreground}\n+ dispatch={dispatch}\n+ overlayContext={overlayContext}\n+ inputState={inputState}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in CameraModal Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D126
129,187
16.09.2020 03:31:00
14,400
a26cfb5d4aa3b5129bde9a39037fb8cd85a8f2aa
[native] Use hook instead of connect functions and HOC in Multimedia Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/media/multimedia.react.js", "new_path": "native/media/multimedia.react.js", "diff": "@@ -11,18 +11,21 @@ import RemoteImage from './remote-image.react';\nimport {\ntype InputState,\ninputStatePropType,\n- withInputState,\n+ InputStateContext,\n} from '../input/input-state';\n+type BaseProps = {|\n+ +mediaInfo: MediaInfo,\n+ +spinnerColor: string,\n+|};\ntype Props = {|\n- mediaInfo: MediaInfo,\n- spinnerColor: string,\n+ ...BaseProps,\n// withInputState\n- inputState: ?InputState,\n+ +inputState: ?InputState,\n|};\ntype State = {|\n- currentURI: string,\n- departingURI: ?string,\n+ +currentURI: string,\n+ +departingURI: ?string,\n|};\nclass Multimedia extends React.PureComponent<Props, State> {\nstatic propTypes = {\n@@ -143,4 +146,9 @@ const styles = StyleSheet.create({\n},\n});\n-export default withInputState(Multimedia);\n+export default React.memo<BaseProps>(function ConnectedMultimedia(\n+ props: BaseProps,\n+) {\n+ const inputState = React.useContext(InputStateContext);\n+ return <Multimedia {...props} inputState={inputState} />;\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in Multimedia Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D127
129,187
16.09.2020 03:32:02
14,400
9f294c7b2448a7a77b4dcf2bd6140a54aef43784
[native] Get rid of withInputState Summary: It's no longer used. Going forward, let's use hooks for data binding Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/input/input-state.js", "new_path": "native/input/input-state.js", "diff": "@@ -65,32 +65,9 @@ const inputStatePropType = PropTypes.shape({\nconst InputStateContext = React.createContext<?InputState>(null);\n-function withInputState<\n- AllProps: {},\n- ComponentType: React.ComponentType<AllProps>,\n->(\n- Component: ComponentType,\n-): React.ComponentType<\n- $Diff<React.ElementConfig<ComponentType>, { inputState: ?InputState }>,\n-> {\n- class InputStateHOC extends React.PureComponent<\n- $Diff<React.ElementConfig<ComponentType>, { inputState: ?InputState }>,\n- > {\n- render() {\n- return (\n- <InputStateContext.Consumer>\n- {value => <Component {...this.props} inputState={value} />}\n- </InputStateContext.Consumer>\n- );\n- }\n- }\n- return InputStateHOC;\n-}\n-\nexport {\nmessagePendingUploadsPropType,\npendingMultimediaUploadPropType,\ninputStatePropType,\nInputStateContext,\n- withInputState,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Get rid of withInputState Summary: It's no longer used. Going forward, let's use hooks for data binding Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D128
129,187
16.09.2020 23:55:29
14,400
fdd9bd64f8ac7495298abbdd56841a5f875b0739
[native] codeVersion -> 66
[ { "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 65\n- versionName \"0.0.65\"\n+ versionCode 66\n+ versionName \"0.0.66\"\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.65</string>\n+ <string>0.0.66</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>65</string>\n+ <string>66</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.65</string>\n+ <string>0.0.66</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>65</string>\n+ <string>66</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": "@@ -190,7 +190,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 65;\n+const codeVersion = 66;\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 -> 66
129,187
17.09.2020 16:34:20
14,400
d33931b6e305031b022c6cbe086f263dc439ac8f
[native] Fix local Image rendering for iOS 14 Summary: See [here](https://github.com/facebook/react-native/issues/29279) for more info about the issue. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "patches/react-native+0.62.2.patch", "new_path": "patches/react-native+0.62.2.patch", "diff": "@@ -16,3 +16,16 @@ index 624c622..bc67109 100644\n}\n/**\n+diff --git a/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m b/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m\n+index 21f1a06..0ff66f3 100644\n+--- a/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m\n++++ b/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m\n+@@ -275,6 +275,8 @@ - (void)displayLayer:(CALayer *)layer\n+ if (_currentFrame) {\n+ layer.contentsScale = self.animatedImageScale;\n+ layer.contents = (__bridge id)_currentFrame.CGImage;\n++ } else {\n++ [super displayLayer:layer];\n+ }\n+ }\n+\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix local Image rendering for iOS 14 Summary: See [here](https://github.com/facebook/react-native/issues/29279) for more info about the issue. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D136
129,187
17.09.2020 17:44:30
14,400
c00381a609ef93c1feac7274d816bf345a8e20db
[native] Fix crash if keyboard shows after locally-created event is deleted Summary: Oops... made a mistake here around three years ago. `_findIndex` returns -1 if it doesn't find the element in question Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -796,11 +796,11 @@ class Calendar extends React.PureComponent<Props, State> {\nscrollToKey(lastEntryKeyActive: string, keyboardHeight: number) {\nconst data = this.state.listDataWithHeights;\ninvariant(data, 'should be set');\n- const index = _findIndex(\n+ const index = data.findIndex(\n(item: CalendarItemWithHeight) =>\nCalendar.keyExtractor(item) === lastEntryKeyActive,\n- )(data);\n- if (index === null || index === undefined) {\n+ );\n+ if (index === -1) {\nreturn;\n}\nconst itemStart = Calendar.heightOfItems(data.filter((_, i) => i < index));\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix crash if keyboard shows after locally-created event is deleted Summary: Oops... made a mistake here around three years ago. `_findIndex` returns -1 if it doesn't find the element in question Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D137
129,187
18.09.2020 02:09:23
14,400
e8aa7847407fab0178db157bc5b8728947552672
[native] Fix release build for Xcode 12 Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "diff": ");\nINFOPLIST_FILE = SquadCal/Info.release.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n+ ONLY_ACTIVE_ARCH = YES;\nOTHER_LDFLAGS = (\n\"$(inherited)\",\n\"-ObjC\",\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix release build for Xcode 12 Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D138
129,191
17.09.2020 14:41:10
-7,200
777d5a5ab328030415efc25ac5c1b7fbef2c96fa
Add babel presets for optional chaining and nullish coalescing Summary: Add babel presets for optional chaining and nullish coalescing Reviewers: ashoat, KatPo Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/babel.config.cjs", "new_path": "lib/babel.config.cjs", "diff": "@@ -3,5 +3,7 @@ module.exports = {\nplugins: [\n'@babel/plugin-proposal-class-properties',\n'@babel/plugin-proposal-object-rest-spread',\n+ '@babel/plugin-proposal-optional-chaining',\n+ '@babel/plugin-proposal-nullish-coalescing-operator',\n],\n};\n" }, { "change_type": "MODIFY", "old_path": "lib/package.json", "new_path": "lib/package.json", "diff": "\"clean\": \"rm -rf node_modules/\"\n},\n\"devDependencies\": {\n+ \"@babel/core\": \"^7.9.0\",\n+ \"@babel/plugin-proposal-class-properties\": \"^7.10.4\",\n+ \"@babel/plugin-proposal-nullish-coalescing-operator\": \"^7.10.4\",\n+ \"@babel/plugin-proposal-object-rest-spread\": \"^7.11.0\",\n+ \"@babel/plugin-proposal-optional-chaining\": \"^7.11.0\",\n+ \"@babel/preset-flow\": \"^7.9.0\",\n+ \"@babel/preset-react\": \"^7.9.1\",\n\"flow-bin\": \"^0.113.0\",\n\"flow-typed\": \"^3.2.1\"\n},\n" }, { "change_type": "MODIFY", "old_path": "native/babel.config.cjs", "new_path": "native/babel.config.cjs", "diff": "module.exports = {\npresets: ['module:metro-react-native-babel-preset'],\n- plugins: ['transform-remove-strict-mode'],\n+ plugins: [\n+ 'transform-remove-strict-mode',\n+ '@babel/plugin-proposal-optional-chaining',\n+ '@babel/plugin-proposal-nullish-coalescing-operator',\n+ ],\nenv: {\nproduction: {\nplugins: ['transform-remove-console'],\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "},\n\"devDependencies\": {\n\"@babel/core\": \"^7.9.0\",\n+ \"@babel/plugin-proposal-nullish-coalescing-operator\": \"^7.10.4\",\n+ \"@babel/plugin-proposal-optional-chaining\": \"^7.11.0\",\n\"@babel/runtime\": \"^7.9.2\",\n\"babel-jest\": \"^24.9.0\",\n\"babel-plugin-transform-remove-console\": \"^6.8.5\",\n" }, { "change_type": "MODIFY", "old_path": "server/babel.config.cjs", "new_path": "server/babel.config.cjs", "diff": "@@ -4,5 +4,7 @@ module.exports = {\n'@babel/plugin-proposal-class-properties',\n'@babel/plugin-proposal-object-rest-spread',\n'@babel/plugin-syntax-dynamic-import',\n+ '@babel/plugin-proposal-optional-chaining',\n+ '@babel/plugin-proposal-nullish-coalescing-operator',\n],\n};\n" }, { "change_type": "MODIFY", "old_path": "server/package.json", "new_path": "server/package.json", "diff": "\"@babel/core\": \"^7.9.0\",\n\"@babel/node\": \"^7.8.7\",\n\"@babel/plugin-proposal-class-properties\": \"^7.5.5\",\n+ \"@babel/plugin-proposal-nullish-coalescing-operator\": \"^7.10.4\",\n\"@babel/plugin-proposal-object-rest-spread\": \"^7.6.2\",\n+ \"@babel/plugin-proposal-optional-chaining\": \"^7.11.0\",\n\"@babel/plugin-syntax-dynamic-import\": \"^7.2.0\",\n- \"@babel/preset-flow\": \"^7.0.0\",\n- \"@babel/preset-react\": \"^7.0.0\",\n+ \"@babel/preset-flow\": \"^7.9.0\",\n+ \"@babel/preset-react\": \"^7.9.1\",\n\"chokidar-cli\": \"^2.1.0\",\n\"concurrently\": \"^5.3.0\",\n\"flow-bin\": \"^0.113.0\",\n" }, { "change_type": "MODIFY", "old_path": "web/babel.config.cjs", "new_path": "web/babel.config.cjs", "diff": "@@ -3,5 +3,7 @@ module.exports = {\nplugins: [\n'@babel/plugin-proposal-class-properties',\n'@babel/plugin-proposal-object-rest-spread',\n+ '@babel/plugin-proposal-optional-chaining',\n+ '@babel/plugin-proposal-nullish-coalescing-operator',\n],\n};\n" }, { "change_type": "MODIFY", "old_path": "web/package.json", "new_path": "web/package.json", "diff": "\"devDependencies\": {\n\"@babel/core\": \"^7.9.0\",\n\"@babel/plugin-proposal-class-properties\": \"^7.2.3\",\n+ \"@babel/plugin-proposal-nullish-coalescing-operator\": \"^7.10.4\",\n\"@babel/plugin-proposal-object-rest-spread\": \"^7.2.0\",\n+ \"@babel/plugin-proposal-optional-chaining\": \"^7.11.0\",\n\"@babel/plugin-transform-react-constant-elements\": \"^7.2.0\",\n\"@babel/preset-env\": \"^7.9.0\",\n\"@babel/preset-flow\": \"^7.9.0\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "\"@babel/template\" \"^7.8.3\"\n\"@babel/types\" \"^7.8.3\"\n+\"@babel/helper-skip-transparent-expression-wrappers@^7.11.0\":\n+ version \"7.11.0\"\n+ resolved \"https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.11.0.tgz#eec162f112c2f58d3af0af125e3bb57665146729\"\n+ integrity sha512-0XIdiQln4Elglgjbwo9wuJpL/K7AGCY26kmEt0+pRP0TAj4jjyNq1MjoRvikrTVqKcx4Gysxt4cXvVFXP/JO2Q==\n+ dependencies:\n+ \"@babel/types\" \"^7.11.0\"\n+\n\"@babel/helper-split-export-declaration@^7.10.4\":\nversion \"7.10.4\"\nresolved \"https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.4.tgz#2c70576eaa3b5609b24cb99db2888cc3fc4251d1\"\n\"@babel/helper-create-class-features-plugin\" \"^7.5.5\"\n\"@babel/helper-plugin-utils\" \"^7.0.0\"\n+\"@babel/plugin-proposal-class-properties@^7.10.4\":\n+ version \"7.10.4\"\n+ resolved \"https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.10.4.tgz#a33bf632da390a59c7a8c570045d1115cd778807\"\n+ integrity sha512-vhwkEROxzcHGNu2mzUC0OFFNXdZ4M23ib8aRRcJSsW8BZK9pQMD7QB7csl97NBbgGZO7ZyHUyKDnxzOaP4IrCg==\n+ dependencies:\n+ \"@babel/helper-create-class-features-plugin\" \"^7.10.4\"\n+ \"@babel/helper-plugin-utils\" \"^7.10.4\"\n+\n\"@babel/plugin-proposal-dynamic-import@^7.8.3\":\nversion \"7.8.3\"\nresolved \"https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.8.3.tgz#38c4fe555744826e97e2ae930b0fb4cc07e66054\"\n\"@babel/helper-plugin-utils\" \"^7.0.0\"\n\"@babel/plugin-syntax-nullish-coalescing-operator\" \"^7.2.0\"\n+\"@babel/plugin-proposal-nullish-coalescing-operator@^7.10.4\":\n+ version \"7.10.4\"\n+ resolved \"https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.10.4.tgz#02a7e961fc32e6d5b2db0649e01bf80ddee7e04a\"\n+ integrity sha512-wq5n1M3ZUlHl9sqT2ok1T2/MTt6AXE0e1Lz4WzWBr95LsAZ5qDXe4KnFuauYyEyLiohvXFMdbsOTMyLZs91Zlw==\n+ dependencies:\n+ \"@babel/helper-plugin-utils\" \"^7.10.4\"\n+ \"@babel/plugin-syntax-nullish-coalescing-operator\" \"^7.8.0\"\n+\n\"@babel/plugin-proposal-nullish-coalescing-operator@^7.8.3\":\nversion \"7.8.3\"\nresolved \"https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.8.3.tgz#e4572253fdeed65cddeecfdab3f928afeb2fd5d2\"\n\"@babel/helper-plugin-utils\" \"^7.0.0\"\n\"@babel/plugin-syntax-object-rest-spread\" \"^7.2.0\"\n+\"@babel/plugin-proposal-object-rest-spread@^7.11.0\":\n+ version \"7.11.0\"\n+ resolved \"https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.11.0.tgz#bd81f95a1f746760ea43b6c2d3d62b11790ad0af\"\n+ integrity sha512-wzch41N4yztwoRw0ak+37wxwJM2oiIiy6huGCoqkvSTA9acYWcPfn9Y4aJqmFFJ70KTJUu29f3DQ43uJ9HXzEA==\n+ dependencies:\n+ \"@babel/helper-plugin-utils\" \"^7.10.4\"\n+ \"@babel/plugin-syntax-object-rest-spread\" \"^7.8.0\"\n+ \"@babel/plugin-transform-parameters\" \"^7.10.4\"\n+\n\"@babel/plugin-proposal-object-rest-spread@^7.9.0\":\nversion \"7.9.0\"\nresolved \"https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.9.0.tgz#a28993699fc13df165995362693962ba6b061d6f\"\n\"@babel/helper-plugin-utils\" \"^7.0.0\"\n\"@babel/plugin-syntax-optional-chaining\" \"^7.2.0\"\n+\"@babel/plugin-proposal-optional-chaining@^7.11.0\":\n+ version \"7.11.0\"\n+ resolved \"https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.11.0.tgz#de5866d0646f6afdaab8a566382fe3a221755076\"\n+ integrity sha512-v9fZIu3Y8562RRwhm1BbMRxtqZNFmFA2EG+pT2diuU8PT3H6T/KXoZ54KgYisfOFZHV6PfvAiBIZ9Rcz+/JCxA==\n+ dependencies:\n+ \"@babel/helper-plugin-utils\" \"^7.10.4\"\n+ \"@babel/helper-skip-transparent-expression-wrappers\" \"^7.11.0\"\n+ \"@babel/plugin-syntax-optional-chaining\" \"^7.8.0\"\n+\n\"@babel/plugin-proposal-optional-chaining@^7.9.0\":\nversion \"7.9.0\"\nresolved \"https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.9.0.tgz#31db16b154c39d6b8a645292472b98394c292a58\"\n\"@babel/helper-get-function-arity\" \"^7.0.0\"\n\"@babel/helper-plugin-utils\" \"^7.0.0\"\n+\"@babel/plugin-transform-parameters@^7.10.4\":\n+ version \"7.10.5\"\n+ resolved \"https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.10.5.tgz#59d339d58d0b1950435f4043e74e2510005e2c4a\"\n+ integrity sha512-xPHwUj5RdFV8l1wuYiu5S9fqWGM2DrYc24TMvUiRrPVm+SM3XeqU9BcokQX/kEUe+p2RBwy+yoiR1w/Blq6ubw==\n+ dependencies:\n+ \"@babel/helper-get-function-arity\" \"^7.10.4\"\n+ \"@babel/helper-plugin-utils\" \"^7.10.4\"\n+\n\"@babel/plugin-transform-parameters@^7.8.7\":\nversion \"7.9.3\"\nresolved \"https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.9.3.tgz#3028d0cc20ddc733166c6e9c8534559cee09f54a\"\n\"@babel/helper-plugin-utils\" \"^7.8.3\"\n\"@babel/plugin-syntax-jsx\" \"^7.8.3\"\n-\"@babel/plugin-transform-react-jsx-self@^7.0.0\":\n- version \"7.2.0\"\n- resolved \"https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.2.0.tgz#461e21ad9478f1031dd5e276108d027f1b5240ba\"\n- integrity sha512-v6S5L/myicZEy+jr6ielB0OR8h+EH/1QFx/YJ7c7Ua+7lqsjj/vW6fD5FR9hB/6y7mGbfT4vAURn3xqBxsUcdg==\n- dependencies:\n- \"@babel/helper-plugin-utils\" \"^7.0.0\"\n- \"@babel/plugin-syntax-jsx\" \"^7.2.0\"\n-\n\"@babel/plugin-transform-react-jsx-self@^7.9.0\":\nversion \"7.9.0\"\nresolved \"https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.9.0.tgz#f4f26a325820205239bb915bad8e06fcadabb49b\"\nlevenary \"^1.1.1\"\nsemver \"^5.5.0\"\n-\"@babel/preset-flow@^7.0.0\":\n- version \"7.0.0\"\n- resolved \"https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.0.0.tgz#afd764835d9535ec63d8c7d4caf1c06457263da2\"\n- integrity sha512-bJOHrYOPqJZCkPVbG1Lot2r5OSsB+iUOaxiHdlOeB1yPWS6evswVHwvkDLZ54WTaTRIk89ds0iHmGZSnxlPejQ==\n- dependencies:\n- \"@babel/helper-plugin-utils\" \"^7.0.0\"\n- \"@babel/plugin-transform-flow-strip-types\" \"^7.0.0\"\n-\n\"@babel/preset-flow@^7.9.0\":\nversion \"7.9.0\"\nresolved \"https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.9.0.tgz#fee847c3e090b0b2d9227c1949e4da1d1379280d\"\n\"@babel/types\" \"^7.4.4\"\nesutils \"^2.0.2\"\n-\"@babel/preset-react@^7.0.0\":\n- version \"7.0.0\"\n- resolved \"https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.0.0.tgz#e86b4b3d99433c7b3e9e91747e2653958bc6b3c0\"\n- integrity sha512-oayxyPS4Zj+hF6Et11BwuBkmpgT/zMxyuZgFrMeZID6Hdh3dGlk4sHCAhdBCpuCKW2ppBfl2uCCetlrUIJRY3w==\n- dependencies:\n- \"@babel/helper-plugin-utils\" \"^7.0.0\"\n- \"@babel/plugin-transform-react-display-name\" \"^7.0.0\"\n- \"@babel/plugin-transform-react-jsx\" \"^7.0.0\"\n- \"@babel/plugin-transform-react-jsx-self\" \"^7.0.0\"\n- \"@babel/plugin-transform-react-jsx-source\" \"^7.0.0\"\n-\n\"@babel/preset-react@^7.9.1\":\nversion \"7.9.1\"\nresolved \"https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.9.1.tgz#b346403c36d58c3bb544148272a0cefd9c28677a\"\nlodash \"^4.17.13\"\nto-fast-properties \"^2.0.0\"\n+\"@babel/types@^7.11.0\":\n+ version \"7.11.5\"\n+ resolved \"https://registry.yarnpkg.com/@babel/types/-/types-7.11.5.tgz#d9de577d01252d77c6800cee039ee64faf75662d\"\n+ integrity sha512-bvM7Qz6eKnJVFIn+1LPtjlBFPVN5jNDc1XmN15vWe7Q3DPBufWWsLiIvUu7xW87uTG6QoggpIDnUgLQvPheU+Q==\n+ dependencies:\n+ \"@babel/helper-validator-identifier\" \"^7.10.4\"\n+ lodash \"^4.17.19\"\n+ to-fast-properties \"^2.0.0\"\n+\n\"@babel/types@^7.7.0\", \"@babel/types@^7.8.3\", \"@babel/types@^7.8.6\", \"@babel/types@^7.9.0\":\nversion \"7.9.0\"\nresolved \"https://registry.yarnpkg.com/@babel/types/-/types-7.9.0.tgz#00b064c3df83ad32b2dbf5ff07312b15c7f1efb5\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Add babel presets for optional chaining and nullish coalescing Summary: Add babel presets for optional chaining and nullish coalescing Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D133
129,191
17.09.2020 15:24:02
-7,200
55e795bf95e7ca371ff9d6037c92f78bf5932d68
[server] Move thread permission fetchers to a new file Summary: Move thread permission fetchers to a new file Reviewers: ashoat, KatPo Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/creators/entry-creator.js", "new_path": "server/src/creators/entry-creator.js", "diff": "@@ -18,7 +18,7 @@ import { dbQuery, SQL } from '../database';\nimport fetchOrCreateDayID from '../creators/day-creator';\nimport createIDs from '../creators/id-creator';\nimport createMessages from '../creators/message-creator';\n-import { checkThreadPermission } from '../fetchers/thread-fetchers';\n+import { checkThreadPermission } from '../fetchers/thread-permission-fetchers';\nimport { createUpdateDatasForChangedEntryInfo } from '../updaters/entry-updaters';\nimport { fetchEntryInfoForLocalID } from '../fetchers/entry-fetchers';\nimport { fetchMessageInfoForEntryAction } from '../fetchers/message-fetchers';\n" }, { "change_type": "MODIFY", "old_path": "server/src/creators/thread-creator.js", "new_path": "server/src/creators/thread-creator.js", "diff": "@@ -17,7 +17,7 @@ import { promiseAll } from 'lib/utils/promises';\nimport { hasMinCodeVersion } from 'lib/shared/version-utils';\nimport { dbQuery, SQL } from '../database';\n-import { checkThreadPermission } from '../fetchers/thread-fetchers';\n+import { checkThreadPermission } from '../fetchers/thread-permission-fetchers';\nimport createIDs from './id-creator';\nimport { createInitialRolesForNewThread } from './role-creator';\nimport { fetchKnownUserInfos } from '../fetchers/user-fetchers';\n" }, { "change_type": "MODIFY", "old_path": "server/src/deleters/thread-deleters.js", "new_path": "server/src/deleters/thread-deleters.js", "diff": "@@ -16,10 +16,10 @@ import { hasMinCodeVersion } from 'lib/shared/version-utils';\nimport { dbQuery, SQL } from '../database';\nimport {\n- fetchThreadPermissionsBlob,\nfetchThreadInfos,\nfetchServerThreadInfos,\n} from '../fetchers/thread-fetchers';\n+import { fetchThreadPermissionsBlob } from '../fetchers/thread-permission-fetchers';\nimport { rescindPushNotifs } from '../push/rescind';\nimport { createUpdates } from '../creators/update-creator';\nimport { fetchUpdateInfoForThreadDeletion } from '../fetchers/update-fetchers';\n" }, { "change_type": "MODIFY", "old_path": "server/src/fetchers/thread-fetchers.js", "new_path": "server/src/fetchers/thread-fetchers.js", "diff": "// @flow\n-import type {\n- RawThreadInfo,\n- ServerThreadInfo,\n- ThreadPermission,\n- ThreadPermissionsBlob,\n-} from 'lib/types/thread-types';\n+import type { RawThreadInfo, ServerThreadInfo } from 'lib/types/thread-types';\nimport type { Viewer } from '../session/viewer';\n-import {\n- getAllThreadPermissions,\n- permissionLookup,\n-} from 'lib/permissions/thread-permissions';\n+import { getAllThreadPermissions } from 'lib/permissions/thread-permissions';\nimport { rawThreadInfoFromServerThreadInfo } from 'lib/shared/thread-utils';\nimport { dbQuery, SQL, SQLStatement } from '../database';\n@@ -140,90 +132,10 @@ async function verifyThreadID(threadID: string): Promise<boolean> {\nreturn result.length !== 0;\n}\n-async function fetchThreadPermissionsBlob(\n- viewer: Viewer,\n- threadID: string,\n-): Promise<?ThreadPermissionsBlob> {\n- const viewerID = viewer.id;\n- const query = SQL`\n- SELECT permissions\n- FROM memberships\n- WHERE thread = ${threadID} AND user = ${viewerID}\n- `;\n- const [result] = await dbQuery(query);\n-\n- if (result.length === 0) {\n- return null;\n- }\n- const row = result[0];\n- return row.permissions;\n-}\n-\n-async function checkThreadPermission(\n- viewer: Viewer,\n- threadID: string,\n- permission: ThreadPermission,\n-): Promise<boolean> {\n- const permissionsBlob = await fetchThreadPermissionsBlob(viewer, threadID);\n- return permissionLookup(permissionsBlob, permission);\n-}\n-\n-async function checkThreadPermissions(\n- viewer: Viewer,\n- threadIDs: $ReadOnlyArray<string>,\n- permission: ThreadPermission,\n-): Promise<{ [threadID: string]: boolean }> {\n- const viewerID = viewer.id;\n- const query = SQL`\n- SELECT thread, permissions\n- FROM memberships\n- WHERE thread IN (${threadIDs}) AND user = ${viewerID}\n- `;\n- const [result] = await dbQuery(query);\n-\n- const permissionsBlobs = new Map();\n- for (let row of result) {\n- const threadID = row.thread.toString();\n- permissionsBlobs.set(threadID, row.permissions);\n- }\n-\n- const permissionByThread = {};\n- for (let threadID of threadIDs) {\n- const permissionsBlob = permissionsBlobs.get(threadID);\n- permissionByThread[threadID] = permissionLookup(\n- permissionsBlob,\n- permission,\n- );\n- }\n- return permissionByThread;\n-}\n-\n-async function viewerIsMember(\n- viewer: Viewer,\n- threadID: string,\n-): Promise<boolean> {\n- const viewerID = viewer.id;\n- const query = SQL`\n- SELECT role\n- FROM memberships\n- WHERE user = ${viewerID} AND thread = ${threadID}\n- `;\n- const [result] = await dbQuery(query);\n- if (result.length === 0) {\n- return false;\n- }\n- const row = result[0];\n- return row.role > 0;\n-}\n-\nexport {\nfetchServerThreadInfos,\nfetchThreadInfos,\nrawThreadInfosFromServerThreadInfos,\nverifyThreadIDs,\nverifyThreadID,\n- fetchThreadPermissionsBlob,\n- checkThreadPermission,\n- checkThreadPermissions,\n- viewerIsMember,\n};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "server/src/fetchers/thread-permission-fetchers.js", "diff": "+// @flow\n+\n+import type {\n+ ThreadPermission,\n+ ThreadPermissionsBlob,\n+} from 'lib/types/thread-types';\n+import { permissionLookup } from 'lib/permissions/thread-permissions';\n+\n+import type { Viewer } from '../session/viewer';\n+\n+import { dbQuery, SQL } from '../database';\n+\n+async function fetchThreadPermissionsBlob(\n+ viewer: Viewer,\n+ threadID: string,\n+): Promise<?ThreadPermissionsBlob> {\n+ const viewerID = viewer.id;\n+ const query = SQL`\n+ SELECT permissions\n+ FROM memberships\n+ WHERE thread = ${threadID} AND user = ${viewerID}\n+ `;\n+ const [result] = await dbQuery(query);\n+\n+ if (result.length === 0) {\n+ return null;\n+ }\n+ const row = result[0];\n+ return row.permissions;\n+}\n+\n+async function checkThreadPermission(\n+ viewer: Viewer,\n+ threadID: string,\n+ permission: ThreadPermission,\n+): Promise<boolean> {\n+ const permissionsBlob = await fetchThreadPermissionsBlob(viewer, threadID);\n+ return permissionLookup(permissionsBlob, permission);\n+}\n+\n+async function checkThreadPermissions(\n+ viewer: Viewer,\n+ threadIDs: $ReadOnlyArray<string>,\n+ permission: ThreadPermission,\n+): Promise<{ [threadID: string]: boolean }> {\n+ const viewerID = viewer.id;\n+ const query = SQL`\n+ SELECT thread, permissions\n+ FROM memberships\n+ WHERE thread IN (${threadIDs}) AND user = ${viewerID}\n+ `;\n+ const [result] = await dbQuery(query);\n+\n+ const permissionsBlobs = new Map();\n+ for (let row of result) {\n+ const threadID = row.thread.toString();\n+ permissionsBlobs.set(threadID, row.permissions);\n+ }\n+\n+ const permissionByThread = {};\n+ for (let threadID of threadIDs) {\n+ const permissionsBlob = permissionsBlobs.get(threadID);\n+ permissionByThread[threadID] = permissionLookup(\n+ permissionsBlob,\n+ permission,\n+ );\n+ }\n+ return permissionByThread;\n+}\n+\n+async function viewerIsMember(\n+ viewer: Viewer,\n+ threadID: string,\n+): Promise<boolean> {\n+ const viewerID = viewer.id;\n+ const query = SQL`\n+ SELECT role\n+ FROM memberships\n+ WHERE user = ${viewerID} AND thread = ${threadID}\n+ `;\n+ const [result] = await dbQuery(query);\n+ if (result.length === 0) {\n+ return false;\n+ }\n+ const row = result[0];\n+ return row.role > 0;\n+}\n+\n+export {\n+ fetchThreadPermissionsBlob,\n+ checkThreadPermission,\n+ checkThreadPermissions,\n+ viewerIsMember,\n+};\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/message-responders.js", "new_path": "server/src/responders/message-responders.js", "diff": "@@ -21,7 +21,7 @@ import { createMediaMessageData, trimMessage } from 'lib/shared/message-utils';\nimport createMessages from '../creators/message-creator';\nimport { validateInput, tShape } from '../utils/validation-utils';\n-import { checkThreadPermission } from '../fetchers/thread-fetchers';\n+import { checkThreadPermission } from '../fetchers/thread-permission-fetchers';\nimport { fetchMessageInfos } from '../fetchers/message-fetchers';\nimport { fetchMedia } from '../fetchers/upload-fetchers';\nimport { assignMedia } from '../updaters/upload-updaters';\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -19,7 +19,7 @@ import { rescindPushNotifs } from '../push/rescind';\nimport { createUpdates } from '../creators/update-creator';\nimport { deleteActivityForViewerSession } from '../deleters/activity-deleters';\nimport { earliestFocusedTimeConsideredCurrent } from '../shared/focused-times';\n-import { checkThreadPermissions } from '../fetchers/thread-fetchers';\n+import { checkThreadPermissions } from '../fetchers/thread-permission-fetchers';\nasync function activityUpdater(\nviewer: Viewer,\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -32,12 +32,12 @@ import {\nverifyUserOrCookieIDs,\nfetchKnownUserInfos,\n} from '../fetchers/user-fetchers';\n+import { fetchServerThreadInfos } from '../fetchers/thread-fetchers';\nimport {\ncheckThreadPermission,\n- fetchServerThreadInfos,\nviewerIsMember,\nfetchThreadPermissionsBlob,\n-} from '../fetchers/thread-fetchers';\n+} from '../fetchers/thread-permission-fetchers';\nimport {\nchangeRole,\nrecalculateAllPermissions,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Move thread permission fetchers to a new file Summary: Move thread permission fetchers to a new file Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D134
129,187
18.09.2020 14:06:54
14,400
e1142691ee049afae4e7825037b4678e6df98dc6
[web] css-loader@^4.3.0, mini-css-extract-plugin@^0.11.2, style-loader@^1.2.1 Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "web/package.json", "new_path": "web/package.json", "diff": "\"babel-plugin-transform-remove-console\": \"^6.8.4\",\n\"clean-webpack-plugin\": \"^3.0.0\",\n\"concurrently\": \"^5.3.0\",\n- \"css-loader\": \"^3.2.0\",\n+ \"css-loader\": \"^4.3.0\",\n\"flow-bin\": \"^0.113.0\",\n\"flow-typed\": \"^3.2.1\",\n- \"mini-css-extract-plugin\": \"^0.8.0\",\n+ \"mini-css-extract-plugin\": \"^0.11.2\",\n\"optimize-css-assets-webpack-plugin\": \"^5.0.3\",\n- \"style-loader\": \"^1.0.0\",\n+ \"style-loader\": \"^1.2.1\",\n\"terser-webpack-plugin\": \"^2.1.2\",\n\"url-loader\": \"^2.2.0\",\n\"webpack\": \"^4.41.0\",\n" }, { "change_type": "MODIFY", "old_path": "web/webpack.config.cjs", "new_path": "web/webpack.config.cjs", "diff": "@@ -241,7 +241,10 @@ module.exports = function(env) {\n...cssLoader,\noptions: {\n...cssLoader.options,\n- onlyLocals: true,\n+ modules: {\n+ ...cssLoader.options.modules,\n+ exportOnlyLocals: true,\n+ }\n},\n},\n},\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "resolved \"https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636\"\nintegrity sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==\n+\"@types/json-schema@^7.0.5\":\n+ version \"7.0.6\"\n+ resolved \"https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0\"\n+ integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==\n+\n\"@types/keyv@*\", \"@types/keyv@^3.1.1\":\nversion \"3.1.1\"\nresolved \"https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.1.tgz#e45a45324fca9dab716ab1230ee249c9fb52cfa7\"\n@@ -3200,6 +3205,11 @@ ajv-keywords@^3.1.0, ajv-keywords@^3.4.1:\nresolved \"https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.4.1.tgz#ef916e271c64ac12171fd8384eaae6b2345854da\"\nintegrity sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==\n+ajv-keywords@^3.5.2:\n+ version \"3.5.2\"\n+ resolved \"https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d\"\n+ integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==\n+\najv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.5.5:\nversion \"6.10.2\"\nresolved \"https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52\"\n@@ -3220,6 +3230,16 @@ ajv@^6.12.0:\njson-schema-traverse \"^0.4.1\"\nuri-js \"^4.2.2\"\n+ajv@^6.12.4:\n+ version \"6.12.5\"\n+ resolved \"https://registry.yarnpkg.com/ajv/-/ajv-6.12.5.tgz#19b0e8bae8f476e5ba666300387775fb1a00a4da\"\n+ integrity sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag==\n+ dependencies:\n+ fast-deep-equal \"^3.1.1\"\n+ fast-json-stable-stringify \"^2.0.0\"\n+ json-schema-traverse \"^0.4.1\"\n+ uri-js \"^4.2.2\"\n+\nalphanum-sort@^1.0.0:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3\"\n@@ -4312,6 +4332,11 @@ camelcase@^5.0.0, camelcase@^5.3.1:\nresolved \"https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320\"\nintegrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==\n+camelcase@^6.0.0:\n+ version \"6.0.0\"\n+ resolved \"https://registry.yarnpkg.com/camelcase/-/camelcase-6.0.0.tgz#5259f7c30e35e278f1bdc2a4d91230b37cad981e\"\n+ integrity sha512-8KMDF1Vz2gzOq54ONPJS65IvTUaB1cHJ2DMM7MbPmLZljDH1qpzzLsWdiN9pHh6qvkRVDTi/07+eNGch/oLU4w==\n+\ncaniuse-api@^3.0.0:\nversion \"3.0.0\"\nresolved \"https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-3.0.0.tgz#5e4d90e2274961d46291997df599e3ed008ee4c0\"\n@@ -5075,23 +5100,23 @@ css-declaration-sorter@^4.0.1:\npostcss \"^7.0.1\"\ntimsort \"^0.3.0\"\n-css-loader@^3.2.0:\n- version \"3.2.0\"\n- resolved \"https://registry.yarnpkg.com/css-loader/-/css-loader-3.2.0.tgz#bb570d89c194f763627fcf1f80059c6832d009b2\"\n- integrity sha512-QTF3Ud5H7DaZotgdcJjGMvyDj5F3Pn1j/sC6VBEOVp94cbwqyIBdcs/quzj4MC1BKQSrTpQznegH/5giYbhnCQ==\n+css-loader@^4.3.0:\n+ version \"4.3.0\"\n+ resolved \"https://registry.yarnpkg.com/css-loader/-/css-loader-4.3.0.tgz#c888af64b2a5b2e85462c72c0f4a85c7e2e0821e\"\n+ integrity sha512-rdezjCjScIrsL8BSYszgT4s476IcNKt6yX69t0pHjJVnPUTDpn4WfIpDQTN3wCJvUvfsz/mFjuGOekf3PY3NUg==\ndependencies:\n- camelcase \"^5.3.1\"\n+ camelcase \"^6.0.0\"\ncssesc \"^3.0.0\"\nicss-utils \"^4.1.1\"\n- loader-utils \"^1.2.3\"\n- normalize-path \"^3.0.0\"\n- postcss \"^7.0.17\"\n+ loader-utils \"^2.0.0\"\n+ postcss \"^7.0.32\"\npostcss-modules-extract-imports \"^2.0.0\"\n- postcss-modules-local-by-default \"^3.0.2\"\n- postcss-modules-scope \"^2.1.0\"\n+ postcss-modules-local-by-default \"^3.0.3\"\n+ postcss-modules-scope \"^2.2.0\"\npostcss-modules-values \"^3.0.0\"\n- postcss-value-parser \"^4.0.0\"\n- schema-utils \"^2.0.0\"\n+ postcss-value-parser \"^4.1.0\"\n+ schema-utils \"^2.7.1\"\n+ semver \"^7.3.2\"\ncss-select-base-adapter@^0.1.1:\nversion \"0.1.1\"\n@@ -9366,6 +9391,15 @@ loader-utils@^1.4.0:\nemojis-list \"^3.0.0\"\njson5 \"^1.0.1\"\n+loader-utils@^2.0.0:\n+ version \"2.0.0\"\n+ resolved \"https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0\"\n+ integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==\n+ dependencies:\n+ big.js \"^5.2.2\"\n+ emojis-list \"^3.0.0\"\n+ json5 \"^2.1.2\"\n+\nlocate-path@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e\"\n@@ -10068,10 +10102,10 @@ mini-create-react-context@^0.3.0:\ngud \"^1.0.0\"\ntiny-warning \"^1.0.2\"\n-mini-css-extract-plugin@^0.8.0:\n- version \"0.8.0\"\n- resolved \"https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.8.0.tgz#81d41ec4fe58c713a96ad7c723cdb2d0bd4d70e1\"\n- integrity sha512-MNpRGbNA52q6U92i0qbVpQNsgk7LExy41MdAlG84FeytfDOtRIf/mCHdEgG8rpTKOaNKiqUnZdlptF469hxqOw==\n+mini-css-extract-plugin@^0.11.2:\n+ version \"0.11.2\"\n+ resolved \"https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.11.2.tgz#e3af4d5e04fbcaaf11838ab230510073060b37bf\"\n+ integrity sha512-h2LknfX4U1kScXxH8xE9LCOqT5B+068EAj36qicMb8l4dqdJoyHcmWmpd+ueyZfgu/POvIn+teoUnTtei2ikug==\ndependencies:\nloader-utils \"^1.1.0\"\nnormalize-url \"1.9.1\"\n@@ -11536,20 +11570,20 @@ postcss-modules-extract-imports@^2.0.0:\ndependencies:\npostcss \"^7.0.5\"\n-postcss-modules-local-by-default@^3.0.2:\n- version \"3.0.2\"\n- resolved \"https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-3.0.2.tgz#e8a6561be914aaf3c052876377524ca90dbb7915\"\n- integrity sha512-jM/V8eqM4oJ/22j0gx4jrp63GSvDH6v86OqyTHHUvk4/k1vceipZsaymiZ5PvocqZOl5SFHiFJqjs3la0wnfIQ==\n+postcss-modules-local-by-default@^3.0.3:\n+ version \"3.0.3\"\n+ resolved \"https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-3.0.3.tgz#bb14e0cc78279d504dbdcbfd7e0ca28993ffbbb0\"\n+ integrity sha512-e3xDq+LotiGesympRlKNgaJ0PCzoUIdpH0dj47iWAui/kyTgh3CiAr1qP54uodmJhl6p9rN6BoNcdEDVJx9RDw==\ndependencies:\nicss-utils \"^4.1.1\"\n- postcss \"^7.0.16\"\n+ postcss \"^7.0.32\"\npostcss-selector-parser \"^6.0.2\"\n- postcss-value-parser \"^4.0.0\"\n+ postcss-value-parser \"^4.1.0\"\n-postcss-modules-scope@^2.1.0:\n- version \"2.1.0\"\n- resolved \"https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-2.1.0.tgz#ad3f5bf7856114f6fcab901b0502e2a2bc39d4eb\"\n- integrity sha512-91Rjps0JnmtUB0cujlc8KIKCsJXWjzuxGeT/+Q2i2HXKZ7nBUeF9YQTZZTNvHVoNYj1AthsjnGLtqDUE0Op79A==\n+postcss-modules-scope@^2.2.0:\n+ version \"2.2.0\"\n+ resolved \"https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-2.2.0.tgz#385cae013cc7743f5a7d7602d1073a89eaae62ee\"\n+ integrity sha512-YyEgsTMRpNd+HmyC7H/mh3y+MeFWevy7V1evVhJWewmMbjDHIbZbOXICC2y+m1xI1UVfIT1HMW/O04Hxyu9oXQ==\ndependencies:\npostcss \"^7.0.6\"\npostcss-selector-parser \"^6.0.0\"\n@@ -11723,12 +11757,12 @@ postcss-value-parser@^3.0.0, postcss-value-parser@^3.3.1:\nresolved \"https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz#9ff822547e2893213cf1c30efa51ac5fd1ba8281\"\nintegrity sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==\n-postcss-value-parser@^4.0.0:\n- version \"4.0.2\"\n- resolved \"https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.0.2.tgz#482282c09a42706d1fc9a069b73f44ec08391dc9\"\n- integrity sha512-LmeoohTpp/K4UiyQCwuGWlONxXamGzCMtFxLq4W1nZVGIQLYvMCJx3yAF9qyyuFpflABI9yVdtJAqbihOsCsJQ==\n+postcss-value-parser@^4.1.0:\n+ version \"4.1.0\"\n+ resolved \"https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.1.0.tgz#443f6a20ced6481a2bda4fa8532a6e55d789a2cb\"\n+ integrity sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ==\n-postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.17, postcss@^7.0.5, postcss@^7.0.6:\n+postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.5, postcss@^7.0.6:\nversion \"7.0.18\"\nresolved \"https://registry.yarnpkg.com/postcss/-/postcss-7.0.18.tgz#4b9cda95ae6c069c67a4d933029eddd4838ac233\"\nintegrity sha512-/7g1QXXgegpF+9GJj4iN7ChGF40sYuGYJ8WZu8DZWnmhQ/G36hfdk3q9LBJmoK+lZ+yzZ5KYpOoxq7LF1BxE8g==\n@@ -11737,6 +11771,15 @@ postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.1\nsource-map \"^0.6.1\"\nsupports-color \"^6.1.0\"\n+postcss@^7.0.32:\n+ version \"7.0.34\"\n+ resolved \"https://registry.yarnpkg.com/postcss/-/postcss-7.0.34.tgz#f2baf57c36010df7de4009940f21532c16d65c20\"\n+ integrity sha512-H/7V2VeNScX9KE83GDrDZNiGT1m2H+UTnlinIzhjlLX9hfMUn1mHNnGeX81a1c8JSBdBvqk7c2ZOG6ZPn5itGw==\n+ dependencies:\n+ chalk \"^2.4.2\"\n+ source-map \"^0.6.1\"\n+ supports-color \"^6.1.0\"\n+\npostinstall-postinstall@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.0.0.tgz#7ba6711b4420575c4f561638836a81faad47f43f\"\n@@ -13197,7 +13240,7 @@ schema-utils@^1.0.0:\najv-errors \"^1.0.0\"\najv-keywords \"^3.1.0\"\n-schema-utils@^2.0.0, schema-utils@^2.0.1, schema-utils@^2.4.1:\n+schema-utils@^2.4.1:\nversion \"2.4.1\"\nresolved \"https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.4.1.tgz#e89ade5d056dc8bcaca377574bb4a9c4e1b8be56\"\nintegrity sha512-RqYLpkPZX5Oc3fw/kHHHyP56fg5Y+XBpIpV8nCg0znIALfq3OH+Ea9Hfeac9BAMwG5IICltiZ0vxFvJQONfA5w==\n@@ -13213,6 +13256,15 @@ schema-utils@^2.6.5:\najv \"^6.12.0\"\najv-keywords \"^3.4.1\"\n+schema-utils@^2.6.6, schema-utils@^2.7.1:\n+ version \"2.7.1\"\n+ resolved \"https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7\"\n+ integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==\n+ dependencies:\n+ \"@types/json-schema\" \"^7.0.5\"\n+ ajv \"^6.12.4\"\n+ ajv-keywords \"^3.5.2\"\n+\nselect-hose@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca\"\n@@ -14080,13 +14132,13 @@ stubs@^3.0.0:\nresolved \"https://registry.yarnpkg.com/stubs/-/stubs-3.0.0.tgz#e8d2ba1fa9c90570303c030b6900f7d5f89abe5b\"\nintegrity sha1-6NK6H6nJBXAwPAMLaQD31fiavls=\n-style-loader@^1.0.0:\n- version \"1.0.0\"\n- resolved \"https://registry.yarnpkg.com/style-loader/-/style-loader-1.0.0.tgz#1d5296f9165e8e2c85d24eee0b7caf9ec8ca1f82\"\n- integrity sha512-B0dOCFwv7/eY31a5PCieNwMgMhVGFe9w+rh7s/Bx8kfFkrth9zfTZquoYvdw8URgiqxObQKcpW51Ugz1HjfdZw==\n+style-loader@^1.2.1:\n+ version \"1.2.1\"\n+ resolved \"https://registry.yarnpkg.com/style-loader/-/style-loader-1.2.1.tgz#c5cbbfbf1170d076cfdd86e0109c5bba114baa1a\"\n+ integrity sha512-ByHSTQvHLkWE9Ir5+lGbVOXhxX10fbprhLvdg96wedFZb4NDekDPxVKv5Fwmio+QcMlkkNfuK+5W1peQ5CUhZg==\ndependencies:\n- loader-utils \"^1.2.3\"\n- schema-utils \"^2.0.1\"\n+ loader-utils \"^2.0.0\"\n+ schema-utils \"^2.6.6\"\nstylehacks@^4.0.0:\nversion \"4.0.3\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] css-loader@^4.3.0, mini-css-extract-plugin@^0.11.2, style-loader@^1.2.1 Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D143
129,187
18.09.2020 14:10:34
14,400
d74f36121e8708ed90bac694389cfd0205186524
[web] Move from to core-js@^3.6.5 Summary: Context [here](https://babeljs.io/blog/2019/03/19/7.4.0#core-js-3-7646httpsgithubcombabelbabelpull7646) and [here](https://github.com/zloirock/core-js#babel). I had to add `core-js` to the root `package.json` so that it would get resolved correctly during Webpack builds. Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "},\n\"devDependencies\": {\n\"babel-eslint\": \"^10.1.0\",\n+ \"core-js\": \"^3.6.5\",\n\"eslint\": \"^6.8.0\",\n\"eslint-config-prettier\": \"^6.10.0\",\n\"eslint-plugin-flowtype\": \"^4.6.0\",\n" }, { "change_type": "DELETE", "old_path": "web/flow-typed/npm/@babel/polyfill_v7.x.x.js", "new_path": null, "diff": "-// flow-typed signature: 9a114f58efb774c670fad41741d95885\n-// flow-typed version: c6154227d1/@babel/polyfill_v7.x.x/flow_>=v0.30.x <=v0.103.x\n-\n-declare module '@babel/polyfill' {}\n" }, { "change_type": "MODIFY", "old_path": "web/package.json", "new_path": "web/package.json", "diff": "\"webpack-dev-server\": \"^3.11.0\"\n},\n\"dependencies\": {\n- \"@babel/polyfill\": \"^7.8.7\",\n\"@babel/runtime\": \"^7.11.1\",\n\"@fortawesome/fontawesome-svg-core\": \"^1.2.25\",\n\"@fortawesome/free-regular-svg-icons\": \"^5.11.2\",\n\"@fortawesome/free-solid-svg-icons\": \"^5.11.2\",\n\"@fortawesome/react-fontawesome\": \"^0.1.5\",\n\"classnames\": \"^2.2.5\",\n+ \"core-js\": \"^3.6.5\",\n\"dateformat\": \"^3.0.3\",\n\"detect-browser\": \"^4.0.4\",\n\"exif-js\": \"^2.3.0\",\n" }, { "change_type": "MODIFY", "old_path": "web/script.js", "new_path": "web/script.js", "diff": "// @flow\n-import '@babel/polyfill';\nimport 'isomorphic-fetch';\nimport React from 'react';\n" }, { "change_type": "MODIFY", "old_path": "web/webpack.config.cjs", "new_path": "web/webpack.config.cjs", "diff": "@@ -30,7 +30,14 @@ const browserBabelRule = {\n...babelRule.options,\npresets: [\n...babelRule.options.presets,\n- [ '@babel/preset-env', { targets: 'defaults' } ],\n+ [\n+ '@babel/preset-env',\n+ {\n+ targets: 'defaults',\n+ useBuiltIns: 'usage',\n+ corejs: '3.6',\n+ },\n+ ],\n],\n},\n};\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "\"@babel/helper-create-regexp-features-plugin\" \"^7.8.3\"\n\"@babel/helper-plugin-utils\" \"^7.8.3\"\n-\"@babel/polyfill@^7.8.7\":\n- version \"7.8.7\"\n- resolved \"https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.8.7.tgz#151ec24c7135481336168c3bd8b8bf0cf91c032f\"\n- integrity sha512-LeSfP9bNZH2UOZgcGcZ0PIHUt1ZuHub1L3CVmEyqLxCeDLm4C5Gi8jRH8ZX2PNpDhQCo0z6y/+DIs2JlliXW8w==\n- dependencies:\n- core-js \"^2.6.5\"\n- regenerator-runtime \"^0.13.4\"\n-\n\"@babel/preset-env@^7.9.0\":\nversion \"7.9.0\"\nresolved \"https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.9.0.tgz#a5fc42480e950ae8f5d9f8f2bbc03f52722df3a8\"\n@@ -4942,7 +4934,7 @@ core-js@^1.0.0:\nresolved \"https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636\"\nintegrity sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=\n-core-js@^2.2.2, core-js@^2.4.1, core-js@^2.6.5:\n+core-js@^2.2.2, core-js@^2.4.1:\nversion \"2.6.9\"\nresolved \"https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2\"\nintegrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Move from @babel/polyfill to core-js@^3.6.5 Summary: Context [here](https://babeljs.io/blog/2019/03/19/7.4.0#core-js-3-7646httpsgithubcombabelbabelpull7646) and [here](https://github.com/zloirock/core-js#babel). I had to add `core-js` to the root `package.json` so that it would get resolved correctly during Webpack builds. Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D144
129,187
18.09.2020 14:24:40
14,400
98a1b42d0b9c0eb1e93322583844a1db40bf49e0
Use ESModules for Webpack/Babel Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/babel.config.cjs", "new_path": "lib/babel.config.cjs", "diff": "@@ -5,6 +5,6 @@ module.exports = {\n'@babel/plugin-proposal-object-rest-spread',\n'@babel/plugin-proposal-optional-chaining',\n'@babel/plugin-proposal-nullish-coalescing-operator',\n- '@babel/plugin-transform-runtime',\n+ ['@babel/plugin-transform-runtime', { useESModules: true }],\n],\n};\n" }, { "change_type": "MODIFY", "old_path": "server/babel.config.cjs", "new_path": "server/babel.config.cjs", "diff": "@@ -6,6 +6,6 @@ module.exports = {\n'@babel/plugin-syntax-dynamic-import',\n'@babel/plugin-proposal-optional-chaining',\n'@babel/plugin-proposal-nullish-coalescing-operator',\n- '@babel/plugin-transform-runtime',\n+ ['@babel/plugin-transform-runtime', { useESModules: true }],\n],\n};\n" }, { "change_type": "MODIFY", "old_path": "web/babel.config.cjs", "new_path": "web/babel.config.cjs", "diff": "@@ -5,6 +5,6 @@ module.exports = {\n'@babel/plugin-proposal-object-rest-spread',\n'@babel/plugin-proposal-optional-chaining',\n'@babel/plugin-proposal-nullish-coalescing-operator',\n- '@babel/plugin-transform-runtime',\n+ ['@babel/plugin-transform-runtime', { useESModules: true }],\n],\n};\n" }, { "change_type": "MODIFY", "old_path": "web/webpack.config.cjs", "new_path": "web/webpack.config.cjs", "diff": "@@ -17,6 +17,18 @@ const cssLoader = {\n},\n},\n};\n+const cssExtractLoader = {\n+ loader: MiniCssExtractPlugin.loader,\n+ options: {\n+ esModule: true,\n+ },\n+};\n+const styleLoader = {\n+ loader: 'style-loader',\n+ options: {\n+ esModule: true,\n+ },\n+};\nconst babelRule = {\ntest: /\\.js$/,\n@@ -122,14 +134,14 @@ module.exports = function(env) {\ntest: /\\.css$/,\nexclude: /node_modules\\/.*\\.css$/,\nuse: [\n- 'style-loader',\n+ styleLoader,\ncssLoader,\n],\n},\n{\ntest: /node_modules\\/.*\\.css$/,\nuse: [\n- 'style-loader',\n+ styleLoader,\n{\n...cssLoader,\noptions: {\n@@ -193,9 +205,7 @@ module.exports = function(env) {\ntest: /\\.css$/,\nexclude: /node_modules\\/.*\\.css$/,\nuse: [\n- {\n- loader: MiniCssExtractPlugin.loader,\n- },\n+ cssExtractLoader,\n{\n...cssLoader,\noptions: {\n@@ -208,9 +218,7 @@ module.exports = function(env) {\n{\ntest: /node_modules\\/.*\\.css$/,\nuse: [\n- {\n- loader: MiniCssExtractPlugin.loader,\n- },\n+ cssExtractLoader,\n{\n...cssLoader,\noptions: {\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -4925,9 +4925,9 @@ core-js-compat@^3.6.2:\nsemver \"7.0.0\"\ncore-js-pure@^3.0.0:\n- version \"3.6.4\"\n- resolved \"https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.4.tgz#4bf1ba866e25814f149d4e9aaa08c36173506e3a\"\n- integrity sha512-epIhRLkXdgv32xIUFaaAry2wdxZYBi6bgM7cB136dzzXXa+dFyRLTZeLUJxnd8ShrmyVXBub63n2NHo2JAt8Cw==\n+ version \"3.6.5\"\n+ resolved \"https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.5.tgz#c79e75f5e38dbc85a662d91eea52b8256d53b813\"\n+ integrity sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==\ncore-js@^1.0.0:\nversion \"1.2.7\"\n@@ -4939,12 +4939,7 @@ core-js@^2.2.2, core-js@^2.4.1:\nresolved \"https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2\"\nintegrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==\n-core-js@^3.2.1:\n- version \"3.2.1\"\n- resolved \"https://registry.yarnpkg.com/core-js/-/core-js-3.2.1.tgz#cd41f38534da6cc59f7db050fe67307de9868b09\"\n- integrity sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw==\n-\n-core-js@^3.6.5:\n+core-js@^3.2.1, core-js@^3.6.5:\nversion \"3.6.5\"\nresolved \"https://registry.yarnpkg.com/core-js/-/core-js-3.6.5.tgz#7395dc273af37fb2e50e9bd3d9fe841285231d1a\"\nintegrity sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Use ESModules for Webpack/Babel Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D145
129,187
18.09.2020 14:40:00
14,400
15134b6c7c1f77cb822d889b029712d014b29312
[native] Update SDWebImage so react-native-fast-image works on iOS 14 Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -393,9 +393,9 @@ PODS:\n- React\n- RNVectorIcons (6.6.0):\n- React\n- - SDWebImage (5.7.2):\n- - SDWebImage/Core (= 5.7.2)\n- - SDWebImage/Core (5.7.2)\n+ - SDWebImage (5.9.1):\n+ - SDWebImage/Core (= 5.9.1)\n+ - SDWebImage/Core (5.9.1)\n- SDWebImageWebPCoder (0.2.5):\n- libwebp (~> 1.0)\n- SDWebImage/Core (~> 5.0)\n@@ -753,7 +753,7 @@ SPEC CHECKSUMS:\nRNReanimated: 89f5e0a04d1dd52fbf27e7e7030d8f80a646a3fc\nRNScreens: c526239bbe0e957b988dacc8d75ac94ec9cb19da\nRNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4\n- SDWebImage: d9ea4959d99c52276dfada481987018fcaea3d58\n+ SDWebImage: a990c053fff71e388a10f3357edb0be17929c9c5\nSDWebImageWebPCoder: 947093edd1349d820c40afbd9f42acb6cdecd987\nSPTPersistentCache: df36ea46762d7cf026502bbb86a8b79d0080dff4\nUMAppLoader: 90273a65f9b1d789214e0c913dfcabc7a1b1590e\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Update SDWebImage so react-native-fast-image works on iOS 14 Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D146
129,187
18.09.2020 15:17:32
14,400
f8d585f6065dc1bcac54c3c3d724a84f55a77142
[lib] Only list sidebars that pass threadInChatList Summary: For a sidebar to appear in the `ChatThreadList`, the viewer must be a member and has the `VISIBLE` permission Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/selectors/chat-selectors.js", "new_path": "lib/selectors/chat-selectors.js", "diff": "@@ -112,7 +112,10 @@ function createChatThreadItem(\nlet lastUpdatedTimeIncludingSidebars = lastUpdatedTime;\nif (childThreads) {\nfor (const childThreadInfo of childThreads) {\n- if (childThreadInfo.type !== threadTypes.SIDEBAR) {\n+ if (\n+ !threadInChatList(childThreadInfo) ||\n+ childThreadInfo.type !== threadTypes.SIDEBAR\n+ ) {\ncontinue;\n}\nconst sidebarLastUpdatedTime = getLastUpdatedTime(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Only list sidebars that pass threadInChatList Summary: For a sidebar to appear in the `ChatThreadList`, the viewer must be a member and has the `VISIBLE` permission Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D147
129,187
21.09.2020 13:10:18
14,400
be5b55381bae081aefb29746bb1decb142d591bb
[server] Make sure -1 role gets overwritten by 0 role in updateDescendantPermissions Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-permission-updaters.js", "new_path": "server/src/updaters/thread-permission-updaters.js", "diff": "@@ -296,7 +296,8 @@ async function updateDescendantPermissions(\npermissionsFromParent,\n] of usersToPermissionsFromParent) {\nconst userInfo = userInfos.get(userID);\n- const role = userInfo ? userInfo.role : '0';\n+ const role =\n+ userInfo && Number(userInfo.role) > 0 ? userInfo.role : '0';\nconst rolePermissions = userInfo ? userInfo.rolePermissions : null;\nconst oldPermissions = userInfo ? userInfo.permissions : null;\nconst oldPermissionsForChildren = userInfo\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Make sure -1 role gets overwritten by 0 role in updateDescendantPermissions Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D148
129,187
23.09.2020 03:54:52
14,400
ec88456c1848d0021b3bdbd045bd6054ced36aa2
[server] Move to Summary: The `apn` package isn't being maintained anymore: This is necessary to fix this security vulnerability: Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "DELETE", "old_path": "server/flow-typed/npm/apn_vx.x.x.js", "new_path": null, "diff": "-// flow-typed signature: 6d909c0b9769ca9165add464ead2d40e\n-// flow-typed version: <<STUB>>/apn_v^2.2.0/flow_v0.98.0\n-\n-/**\n- * This is an autogenerated libdef stub for:\n- *\n- * 'apn'\n- *\n- * Fill this stub out by replacing all the `any` types.\n- *\n- * Once filled out, we encourage you to share your work with the\n- * community by sending a pull request to:\n- * https://github.com/flowtype/flow-typed\n- */\n-\n-declare module 'apn' {\n- declare module.exports: any;\n-}\n-\n-/**\n- * We include stubs for each file inside this npm package in case you need to\n- * require those files directly. Feel free to delete any files that aren't\n- * needed.\n- */\n-declare module 'apn/examples/sending-multiple-notifications' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/examples/sending-to-multiple-devices' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/client' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/config' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/ca/prepare' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/certificate/APNCertificate' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/certificate/APNKey' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/certificate/load' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/certificate/oids' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/certificate/parse' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/certificate/parsePemCertificate' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/certificate/parsePemKey' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/certificate/parsePkcs12' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/certificate/prepare' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/certificate/validate' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/index' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/resolve' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/credentials/token/prepare' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/notification/apsProperties' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/notification/index' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/protocol/endpoint' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/protocol/endpointManager' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/provider' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/token' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/lib/util/extend' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/mock/client' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/mock/index' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/client' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/config' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/ca/prepare' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/certificate/APNCertificate' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/certificate/APNKey' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/certificate/load' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/certificate/parse' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/certificate/parsePemCertificate' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/certificate/parsePemKey' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/certificate/parsePkcs12' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/certificate/prepare' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/certificate/validate' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/resolve' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/credentials/token/prepare' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/notification/apsProperties' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/notification/index' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/protocol/endpoint' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/protocol/endpointManager' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/provider' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/support' {\n- declare module.exports: any;\n-}\n-\n-declare module 'apn/test/token' {\n- declare module.exports: any;\n-}\n-\n-// Filename aliases\n-declare module 'apn/examples/sending-multiple-notifications.js' {\n- declare module.exports: $Exports<'apn/examples/sending-multiple-notifications'>;\n-}\n-declare module 'apn/examples/sending-to-multiple-devices.js' {\n- declare module.exports: $Exports<'apn/examples/sending-to-multiple-devices'>;\n-}\n-declare module 'apn/index' {\n- declare module.exports: $Exports<'apn'>;\n-}\n-declare module 'apn/index.js' {\n- declare module.exports: $Exports<'apn'>;\n-}\n-declare module 'apn/lib/client.js' {\n- declare module.exports: $Exports<'apn/lib/client'>;\n-}\n-declare module 'apn/lib/config.js' {\n- declare module.exports: $Exports<'apn/lib/config'>;\n-}\n-declare module 'apn/lib/credentials/ca/prepare.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/ca/prepare'>;\n-}\n-declare module 'apn/lib/credentials/certificate/APNCertificate.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/certificate/APNCertificate'>;\n-}\n-declare module 'apn/lib/credentials/certificate/APNKey.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/certificate/APNKey'>;\n-}\n-declare module 'apn/lib/credentials/certificate/load.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/certificate/load'>;\n-}\n-declare module 'apn/lib/credentials/certificate/oids.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/certificate/oids'>;\n-}\n-declare module 'apn/lib/credentials/certificate/parse.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/certificate/parse'>;\n-}\n-declare module 'apn/lib/credentials/certificate/parsePemCertificate.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/certificate/parsePemCertificate'>;\n-}\n-declare module 'apn/lib/credentials/certificate/parsePemKey.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/certificate/parsePemKey'>;\n-}\n-declare module 'apn/lib/credentials/certificate/parsePkcs12.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/certificate/parsePkcs12'>;\n-}\n-declare module 'apn/lib/credentials/certificate/prepare.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/certificate/prepare'>;\n-}\n-declare module 'apn/lib/credentials/certificate/validate.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/certificate/validate'>;\n-}\n-declare module 'apn/lib/credentials/index.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/index'>;\n-}\n-declare module 'apn/lib/credentials/resolve.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/resolve'>;\n-}\n-declare module 'apn/lib/credentials/token/prepare.js' {\n- declare module.exports: $Exports<'apn/lib/credentials/token/prepare'>;\n-}\n-declare module 'apn/lib/notification/apsProperties.js' {\n- declare module.exports: $Exports<'apn/lib/notification/apsProperties'>;\n-}\n-declare module 'apn/lib/notification/index.js' {\n- declare module.exports: $Exports<'apn/lib/notification/index'>;\n-}\n-declare module 'apn/lib/protocol/endpoint.js' {\n- declare module.exports: $Exports<'apn/lib/protocol/endpoint'>;\n-}\n-declare module 'apn/lib/protocol/endpointManager.js' {\n- declare module.exports: $Exports<'apn/lib/protocol/endpointManager'>;\n-}\n-declare module 'apn/lib/provider.js' {\n- declare module.exports: $Exports<'apn/lib/provider'>;\n-}\n-declare module 'apn/lib/token.js' {\n- declare module.exports: $Exports<'apn/lib/token'>;\n-}\n-declare module 'apn/lib/util/extend.js' {\n- declare module.exports: $Exports<'apn/lib/util/extend'>;\n-}\n-declare module 'apn/mock/client.js' {\n- declare module.exports: $Exports<'apn/mock/client'>;\n-}\n-declare module 'apn/mock/index.js' {\n- declare module.exports: $Exports<'apn/mock/index'>;\n-}\n-declare module 'apn/test/client.js' {\n- declare module.exports: $Exports<'apn/test/client'>;\n-}\n-declare module 'apn/test/config.js' {\n- declare module.exports: $Exports<'apn/test/config'>;\n-}\n-declare module 'apn/test/credentials/ca/prepare.js' {\n- declare module.exports: $Exports<'apn/test/credentials/ca/prepare'>;\n-}\n-declare module 'apn/test/credentials/certificate/APNCertificate.js' {\n- declare module.exports: $Exports<'apn/test/credentials/certificate/APNCertificate'>;\n-}\n-declare module 'apn/test/credentials/certificate/APNKey.js' {\n- declare module.exports: $Exports<'apn/test/credentials/certificate/APNKey'>;\n-}\n-declare module 'apn/test/credentials/certificate/load.js' {\n- declare module.exports: $Exports<'apn/test/credentials/certificate/load'>;\n-}\n-declare module 'apn/test/credentials/certificate/parse.js' {\n- declare module.exports: $Exports<'apn/test/credentials/certificate/parse'>;\n-}\n-declare module 'apn/test/credentials/certificate/parsePemCertificate.js' {\n- declare module.exports: $Exports<'apn/test/credentials/certificate/parsePemCertificate'>;\n-}\n-declare module 'apn/test/credentials/certificate/parsePemKey.js' {\n- declare module.exports: $Exports<'apn/test/credentials/certificate/parsePemKey'>;\n-}\n-declare module 'apn/test/credentials/certificate/parsePkcs12.js' {\n- declare module.exports: $Exports<'apn/test/credentials/certificate/parsePkcs12'>;\n-}\n-declare module 'apn/test/credentials/certificate/prepare.js' {\n- declare module.exports: $Exports<'apn/test/credentials/certificate/prepare'>;\n-}\n-declare module 'apn/test/credentials/certificate/validate.js' {\n- declare module.exports: $Exports<'apn/test/credentials/certificate/validate'>;\n-}\n-declare module 'apn/test/credentials/resolve.js' {\n- declare module.exports: $Exports<'apn/test/credentials/resolve'>;\n-}\n-declare module 'apn/test/credentials/token/prepare.js' {\n- declare module.exports: $Exports<'apn/test/credentials/token/prepare'>;\n-}\n-declare module 'apn/test/notification/apsProperties.js' {\n- declare module.exports: $Exports<'apn/test/notification/apsProperties'>;\n-}\n-declare module 'apn/test/notification/index.js' {\n- declare module.exports: $Exports<'apn/test/notification/index'>;\n-}\n-declare module 'apn/test/protocol/endpoint.js' {\n- declare module.exports: $Exports<'apn/test/protocol/endpoint'>;\n-}\n-declare module 'apn/test/protocol/endpointManager.js' {\n- declare module.exports: $Exports<'apn/test/protocol/endpointManager'>;\n-}\n-declare module 'apn/test/provider.js' {\n- declare module.exports: $Exports<'apn/test/provider'>;\n-}\n-declare module 'apn/test/support.js' {\n- declare module.exports: $Exports<'apn/test/support'>;\n-}\n-declare module 'apn/test/token.js' {\n- declare module.exports: $Exports<'apn/test/token'>;\n-}\n" }, { "change_type": "MODIFY", "old_path": "server/package.json", "new_path": "server/package.json", "diff": "},\n\"dependencies\": {\n\"@babel/runtime\": \"^7.11.1\",\n+ \"@parse/node-apn\": \"^3.2.0\",\n\"@vingle/bmp-js\": \"^0.2.5\",\n\"JSONStream\": \"^1.3.5\",\n- \"apn\": \"git+https://github.com/node-apn/node-apn.git#3.0.0\",\n\"common-tags\": \"^1.7.2\",\n\"cookie-parser\": \"^1.4.3\",\n\"dateformat\": \"^3.0.3\",\n" }, { "change_type": "MODIFY", "old_path": "server/src/push/rescind.js", "new_path": "server/src/push/rescind.js", "diff": "import { threadPermissions } from 'lib/types/thread-types';\nimport { threadSubscriptions } from 'lib/types/subscription-types';\n-import apn from 'apn';\n+import apn from '@parse/node-apn';\nimport invariant from 'invariant';\nimport { promiseAll } from 'lib/utils/promises';\n" }, { "change_type": "MODIFY", "old_path": "server/src/push/send.js", "new_path": "server/src/push/send.js", "diff": "@@ -10,7 +10,7 @@ import type { DeviceType } from 'lib/types/device-types';\nimport type { CollapsableNotifInfo } from '../fetchers/message-fetchers';\nimport { updateTypes } from 'lib/types/update-types';\n-import apn from 'apn';\n+import apn from '@parse/node-apn';\nimport invariant from 'invariant';\nimport uuidv4 from 'uuid/v4';\nimport _flow from 'lodash/fp/flow';\n" }, { "change_type": "MODIFY", "old_path": "server/src/push/utils.js", "new_path": "server/src/push/utils.js", "diff": "import { threadPermissions } from 'lib/types/thread-types';\nimport { threadSubscriptions } from 'lib/types/subscription-types';\n-import apn from 'apn';\n+import apn from '@parse/node-apn';\nimport fcmAdmin from 'firebase-admin';\nimport invariant from 'invariant';\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "dependencies:\n\"@types/node\" \">= 8\"\n+\"@parse/node-apn@^3.2.0\":\n+ version \"3.2.0\"\n+ resolved \"https://registry.yarnpkg.com/@parse/node-apn/-/node-apn-3.2.0.tgz#5bb84391fd9db527a65ee26b6c407240dc5a021d\"\n+ integrity sha512-Xa2paSzLY18k0ekvVAa9YbwwxGjzFnnAu7fqwlrFhaWCv1IaQ9u7r/TGuLml1zWbvhFTdy4XXB4soDS1pek3uA==\n+ dependencies:\n+ debug \"3.1.0\"\n+ jsonwebtoken \"8.1.0\"\n+ node-forge \"0.10.0\"\n+ verror \"1.10.0\"\n+\n\"@protobufjs/aspromise@^1.1.1\", \"@protobufjs/aspromise@^1.1.2\":\nversion \"1.1.2\"\nresolved \"https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf\"\n@@ -3374,16 +3384,6 @@ anymatch@~3.1.1:\nnormalize-path \"^3.0.0\"\npicomatch \"^2.0.4\"\n-\"apn@git+https://github.com/node-apn/node-apn.git#3.0.0\":\n- version \"3.0.0\"\n- resolved \"git+https://github.com/node-apn/node-apn.git#38a357ed0c153aad09c2857e48a710527e685bfc\"\n- dependencies:\n- debug \"^3.1.0\"\n- http2 \"https://github.com/node-apn/node-http2/archive/apn-2.1.4.tar.gz\"\n- jsonwebtoken \"^8.1.0\"\n- node-forge \"^0.7.1\"\n- verror \"^1.10.0\"\n-\nappend-field@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/append-field/-/append-field-1.0.0.tgz#1e3440e915f0b1203d23748e78edd7b9b5b43e56\"\n@@ -5313,6 +5313,13 @@ debug@2.6.9, debug@^2.1.0, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9:\ndependencies:\nms \"2.0.0\"\n+debug@3.1.0:\n+ version \"3.1.0\"\n+ resolved \"https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261\"\n+ integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==\n+ dependencies:\n+ ms \"2.0.0\"\n+\ndebug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:\nversion \"4.1.1\"\nresolved \"https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791\"\n@@ -5320,7 +5327,7 @@ debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:\ndependencies:\nms \"^2.1.1\"\n-debug@^3.1.0, debug@^3.1.1, debug@^3.2.5, debug@^3.2.6:\n+debug@^3.1.1, debug@^3.2.5, debug@^3.2.6:\nversion \"3.2.6\"\nresolved \"https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b\"\nintegrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==\n@@ -7687,10 +7694,6 @@ http-signature@~1.2.0:\njsprim \"^1.2.2\"\nsshpk \"^1.7.0\"\n-\"http2@https://github.com/node-apn/node-http2/archive/apn-2.1.4.tar.gz\":\n- version \"3.3.6\"\n- resolved \"https://github.com/node-apn/node-http2/archive/apn-2.1.4.tar.gz#8333dee2d6e0089152cefad30f41ced502f9c366\"\n-\nhttps-browserify@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73\"\n@@ -9070,7 +9073,23 @@ jsonparse@^1.2.0:\nresolved \"https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280\"\nintegrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=\n-jsonwebtoken@^8.1.0, jsonwebtoken@^8.5.1:\n+jsonwebtoken@8.1.0:\n+ version \"8.1.0\"\n+ resolved \"https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.1.0.tgz#c6397cd2e5fd583d65c007a83dc7bb78e6982b83\"\n+ integrity sha1-xjl80uX9WD1lwAeoPce7eOaYK4M=\n+ dependencies:\n+ jws \"^3.1.4\"\n+ lodash.includes \"^4.3.0\"\n+ lodash.isboolean \"^3.0.3\"\n+ lodash.isinteger \"^4.0.4\"\n+ lodash.isnumber \"^3.0.3\"\n+ lodash.isplainobject \"^4.0.6\"\n+ lodash.isstring \"^4.0.1\"\n+ lodash.once \"^4.0.0\"\n+ ms \"^2.0.0\"\n+ xtend \"^4.0.1\"\n+\n+jsonwebtoken@^8.5.1:\nversion \"8.5.1\"\nresolved \"https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d\"\nintegrity sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==\n@@ -9122,7 +9141,7 @@ jwa@^2.0.0:\necdsa-sig-formatter \"1.0.11\"\nsafe-buffer \"^5.0.1\"\n-jws@^3.2.2:\n+jws@^3.1.4, jws@^3.2.2:\nversion \"3.2.2\"\nresolved \"https://registry.yarnpkg.com/jws/-/jws-3.2.2.tgz#001099f3639468c9414000e99995fa52fb478304\"\nintegrity sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==\n@@ -10254,7 +10273,7 @@ ms@2.1.1:\nresolved \"https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a\"\nintegrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==\n-ms@^2.1.1:\n+ms@^2.0.0, ms@^2.1.1:\nversion \"2.1.2\"\nresolved \"https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009\"\nintegrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==\n@@ -10411,16 +10430,11 @@ node-fetch@^2.2.0, node-fetch@^2.3.0, node-fetch@^2.6.0:\nresolved \"https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd\"\nintegrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==\n-node-forge@^0.10.0:\n+node-forge@0.10.0, node-forge@^0.10.0:\nversion \"0.10.0\"\nresolved \"https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3\"\nintegrity sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==\n-node-forge@^0.7.1:\n- version \"0.7.6\"\n- resolved \"https://registry.yarnpkg.com/node-forge/-/node-forge-0.7.6.tgz#fdf3b418aee1f94f0ef642cd63486c77ca9724ac\"\n- integrity sha512-sol30LUpz1jQFBjOKwbjxijiE3b6pjd74YwfD0fJOKPjF+fONKb2Yg8rYgS6+bK6VDl+/wfr4IYpC7jDzLUIfw==\n-\nnode-gyp-build@~3.7.0:\nversion \"3.7.0\"\nresolved \"https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-3.7.0.tgz#daa77a4f547b9aed3e2aac779eaf151afd60ec8d\"\n@@ -15136,7 +15150,7 @@ vendors@^1.0.0:\nresolved \"https://registry.yarnpkg.com/vendors/-/vendors-1.0.3.tgz#a6467781abd366217c050f8202e7e50cc9eef8c0\"\nintegrity sha512-fOi47nsJP5Wqefa43kyWSg80qF+Q3XA6MUkgi7Hp1HQaKDQW4cQrK2D0P7mmbFtsV1N89am55Yru/nyEwRubcw==\n-verror@1.10.0, verror@^1.10.0:\n+verror@1.10.0:\nversion \"1.10.0\"\nresolved \"https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400\"\nintegrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=\n@@ -15625,7 +15639,7 @@ xregexp@^4.3.0:\ndependencies:\n\"@babel/runtime-corejs3\" \"^7.8.3\"\n-xtend@^4.0.0, xtend@~4.0.1:\n+xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1:\nversion \"4.0.2\"\nresolved \"https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54\"\nintegrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Move to @parse/node-apn Summary: The `apn` package isn't being maintained anymore: https://github.com/node-apn/node-apn/issues/664 This is necessary to fix this security vulnerability: https://github.com/advisories/GHSA-92xj-mqp7-vmcj Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D149
129,187
24.09.2020 23:12:05
14,400
6f8dcdc912b1dbb175182a3d210829127e3df45b
[native] Use hook instead of connect functions and HOC in ChatList Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-list.react.js", "new_path": "native/chat/chat-list.react.js", "diff": "@@ -8,10 +8,9 @@ import type { ChatNavigationProp } from './chat.react';\nimport type { TabNavigationProp } from '../navigation/app-navigator.react';\nimport type { ChatMessageItemWithHeight } from './message-list-container.react';\nimport type { ViewStyle } from '../types/styles';\n-import type { AppState } from '../redux/redux-setup';\nimport {\ntype KeyboardState,\n- withKeyboardState,\n+ KeyboardContext,\n} from '../keyboard/keyboard-state';\nimport type { ChatMessageItem } from 'lib/selectors/chat-selectors';\n@@ -26,9 +25,9 @@ import {\n} from 'react-native';\nimport invariant from 'invariant';\nimport _sum from 'lodash/fp/sum';\n+import { useSelector } from 'react-redux';\nimport { messageKey } from 'lib/shared/message-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport { messageItemHeight } from './message.react';\nimport NewMessagesPill from './new-messages-pill.react';\n@@ -52,20 +51,27 @@ const animationSpec = {\nuseNativeDriver: true,\n};\n-type Props = {\n- ...React.Config<\n+type BaseProps = {|\n+ ...$ReadOnly<\n+ $Exact<\n+ React.Config<\nFlatListProps<ChatMessageItemWithHeight>,\nFlatListDefaultProps,\n>,\n- navigation: ChatNavigationProp<'MessageList'>,\n- data: $ReadOnlyArray<ChatMessageItemWithHeight>,\n+ >,\n+ >,\n+ +navigation: ChatNavigationProp<'MessageList'>,\n+ +data: $ReadOnlyArray<ChatMessageItemWithHeight>,\n+|};\n+type Props = {|\n+ ...BaseProps,\n// Redux state\n- viewerID: ?string,\n+ +viewerID: ?string,\n// withKeyboardState\n- keyboardState: ?KeyboardState,\n-};\n+ +keyboardState: ?KeyboardState,\n+|};\ntype State = {|\n- newMessageCount: number,\n+ +newMessageCount: number,\n|};\nclass ChatList extends React.PureComponent<Props, State> {\nstate = {\n@@ -302,8 +308,16 @@ const styles = StyleSheet.create({\n},\n});\n-const ConnectedChatList = connect((state: AppState) => ({\n- viewerID: state.currentUserInfo && state.currentUserInfo.id,\n-}))(withKeyboardState(ChatList));\n+const ConnectedChatList = React.memo<BaseProps>(function ConnectedChatList(\n+ props: BaseProps,\n+) {\n+ const keyboardState = React.useContext(KeyboardContext);\n+ const viewerID = useSelector(\n+ state => state.currentUserInfo && state.currentUserInfo.id,\n+ );\n+ return (\n+ <ChatList {...props} keyboardState={keyboardState} viewerID={viewerID} />\n+ );\n+});\nexport { ConnectedChatList as ChatList, chatMessageItemKey };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in ChatList Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D150
129,187
24.09.2020 23:13:10
14,400
c523c01d028d5a27a982912d5a56e4118707dec8
[native] Use hook instead of connect functions and HOC in MessageList Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "// @flow\n-import type { AppState } from '../redux/redux-setup';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { ViewToken } from '../types/react-native';\nimport type { FetchMessageInfosPayload } from 'lib/types/message-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { ChatMessageItemWithHeight } from './message-list-container.react';\nimport type { VerticalBounds } from '../types/layout-types';\nimport {\n@@ -21,9 +19,9 @@ import { View, TouchableWithoutFeedback } from 'react-native';\nimport _find from 'lodash/fp/find';\nimport { createSelector } from 'reselect';\nimport invariant from 'invariant';\n+import { useSelector } from 'react-redux';\nimport { messageKey } from 'lib/shared/message-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport {\nfetchMessagesBeforeCursorActionTypes,\nfetchMessagesBeforeCursor,\n@@ -33,55 +31,63 @@ import {\nimport threadWatcher from 'lib/shared/thread-watcher';\nimport { threadInChatList } from 'lib/shared/thread-utils';\nimport { registerFetchKey } from 'lib/reducers/loading-reducer';\n+import {\n+ type DispatchActionPromise,\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport { Message, type ChatMessageInfoItemWithHeight } from './message.react';\nimport ListLoadingIndicator from '../components/list-loading-indicator.react';\nimport {\n- styleSelector,\n+ useStyles,\ntype IndicatorStyle,\nindicatorStylePropType,\n- indicatorStyleSelector,\n+ useIndicatorStyle,\n} from '../themes/colors';\nimport {\n- withOverlayContext,\n+ OverlayContext,\ntype OverlayContextType,\noverlayContextPropType,\n} from '../navigation/overlay-context';\nimport {\ntype KeyboardState,\nkeyboardStatePropType,\n- withKeyboardState,\n+ KeyboardContext,\n} from '../keyboard/keyboard-state';\nimport { ChatList } from './chat-list.react';\n+type BaseProps = {|\n+ +threadInfo: ThreadInfo,\n+ +messageListData: $ReadOnlyArray<ChatMessageItemWithHeight>,\n+ +navigation: ChatNavigationProp<'MessageList'>,\n+ +route: NavigationRoute<'MessageList'>,\n+|};\ntype Props = {|\n- threadInfo: ThreadInfo,\n- messageListData: $ReadOnlyArray<ChatMessageItemWithHeight>,\n- navigation: ChatNavigationProp<'MessageList'>,\n- route: NavigationRoute<'MessageList'>,\n+ ...BaseProps,\n// Redux state\n- startReached: boolean,\n- styles: typeof styles,\n- indicatorStyle: IndicatorStyle,\n+ +startReached: boolean,\n+ +styles: typeof unboundStyles,\n+ +indicatorStyle: IndicatorStyle,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- fetchMessagesBeforeCursor: (\n+ +fetchMessagesBeforeCursor: (\nthreadID: string,\nbeforeMessageID: string,\n) => Promise<FetchMessageInfosPayload>,\n- fetchMostRecentMessages: (\n+ +fetchMostRecentMessages: (\nthreadID: string,\n) => Promise<FetchMessageInfosPayload>,\n// withOverlayContext\n- overlayContext: ?OverlayContextType,\n+ +overlayContext: ?OverlayContextType,\n// withKeyboardState\n- keyboardState: ?KeyboardState,\n+ +keyboardState: ?KeyboardState,\n|};\ntype State = {|\n- focusedMessageKey: ?string,\n- messageListVerticalBounds: ?VerticalBounds,\n- loadingFromScroll: boolean,\n+ +focusedMessageKey: ?string,\n+ +messageListVerticalBounds: ?VerticalBounds,\n+ +loadingFromScroll: boolean,\n|};\ntype PropsAndState = {|\n...Props,\n@@ -350,7 +356,7 @@ class MessageList extends React.PureComponent<Props, State> {\n}\n}\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nbackgroundColor: 'listBackground',\nflex: 1,\n@@ -362,22 +368,45 @@ const styles = {\nflex: 1,\n},\n};\n-const stylesSelector = styleSelector(styles);\nregisterFetchKey(fetchMessagesBeforeCursorActionTypes);\nregisterFetchKey(fetchMostRecentMessagesActionTypes);\n-export default connect(\n- (state: AppState, ownProps: { threadInfo: ThreadInfo }) => {\n- const threadID = ownProps.threadInfo.id;\n- return {\n- startReached: !!(\n+export default React.memo<BaseProps>(function ConnectedMessageList(\n+ props: BaseProps,\n+) {\n+ const keyboardState = React.useContext(KeyboardContext);\n+ const overlayContext = React.useContext(OverlayContext);\n+\n+ const threadID = props.threadInfo.id;\n+ const startReached = useSelector(\n+ state =>\n+ !!(\nstate.messageStore.threads[threadID] &&\nstate.messageStore.threads[threadID].startReached\n),\n- styles: stylesSelector(state),\n- indicatorStyle: indicatorStyleSelector(state),\n- };\n- },\n- { fetchMessagesBeforeCursor, fetchMostRecentMessages },\n-)(withKeyboardState(withOverlayContext(MessageList)));\n+ );\n+\n+ const styles = useStyles(unboundStyles);\n+ const indicatorStyle = useIndicatorStyle();\n+\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callFetchMessagesBeforeCursor = useServerCall(\n+ fetchMessagesBeforeCursor,\n+ );\n+ const callFetchMostRecentMessages = useServerCall(fetchMostRecentMessages);\n+\n+ return (\n+ <MessageList\n+ {...props}\n+ startReached={startReached}\n+ styles={styles}\n+ indicatorStyle={indicatorStyle}\n+ dispatchActionPromise={dispatchActionPromise}\n+ fetchMessagesBeforeCursor={callFetchMessagesBeforeCursor}\n+ fetchMostRecentMessages={callFetchMostRecentMessages}\n+ overlayContext={overlayContext}\n+ keyboardState={keyboardState}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in MessageList Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D151
129,187
24.09.2020 23:14:04
14,400
6dd7572195900807f423c07141e82673f9d63295
[native] Use hook instead of connect functions and HOC in Message Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -15,7 +15,7 @@ import {\nimport {\ntype KeyboardState,\nkeyboardStatePropType,\n- withKeyboardState,\n+ KeyboardContext,\n} from '../keyboard/keyboard-state';\nimport type { ChatNavigationProp } from './chat.react';\nimport type { NavigationRoute } from '../navigation/route-names';\n@@ -62,15 +62,18 @@ function messageItemHeight(item: ChatMessageInfoItemWithHeight) {\nreturn height;\n}\n+type BaseProps = {|\n+ +item: ChatMessageInfoItemWithHeight,\n+ +focused: boolean,\n+ +navigation: ChatNavigationProp<'MessageList'>,\n+ +route: NavigationRoute<'MessageList'>,\n+ +toggleFocus: (messageKey: string) => void,\n+ +verticalBounds: ?VerticalBounds,\n+|};\ntype Props = {|\n- item: ChatMessageInfoItemWithHeight,\n- focused: boolean,\n- navigation: ChatNavigationProp<'MessageList'>,\n- route: NavigationRoute<'MessageList'>,\n- toggleFocus: (messageKey: string) => void,\n- verticalBounds: ?VerticalBounds,\n+ ...BaseProps,\n// withKeyboardState\n- keyboardState: ?KeyboardState,\n+ +keyboardState: ?KeyboardState,\n|};\nclass Message extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -170,6 +173,11 @@ class Message extends React.PureComponent<Props> {\n};\n}\n-const WrappedMessage = withKeyboardState(Message);\n+const ConnectedMessage = React.memo<BaseProps>(function ConnectedMessage(\n+ props: BaseProps,\n+) {\n+ const keyboardState = React.useContext(KeyboardContext);\n+ return <Message {...props} keyboardState={keyboardState} />;\n+});\n-export { WrappedMessage as Message, messageItemHeight };\n+export { ConnectedMessage as Message, messageItemHeight };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in Message Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D152
129,187
24.09.2020 23:15:02
14,400
11ba485b9c492cb16cdab3278bc80dea57ee9a2a
[native] Move KeyboardContext data-binding to hook in KeyboardAvoidingView Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/components/keyboard-avoiding-view.react.js", "new_path": "native/components/keyboard-avoiding-view.react.js", "diff": "@@ -5,7 +5,7 @@ import type { ScreenRect, KeyboardEvent } from '../keyboard/keyboard';\nimport type { ViewStyle } from '../types/styles';\nimport {\ntype KeyboardState,\n- withKeyboardState,\n+ KeyboardContext,\n} from '../keyboard/keyboard-state';\nimport * as React from 'react';\n@@ -21,24 +21,22 @@ import invariant from 'invariant';\nimport { androidKeyboardResizesFrame } from '../keyboard/keyboard';\ntype ViewProps = React.ElementConfig<typeof View>;\n-type Props = {|\n+type BaseProps = {|\n...ViewProps,\n- behavior: 'height' | 'position' | 'padding',\n- contentContainerStyle?: ?ViewStyle,\n- // withKeyboardState\n- keyboardState: ?KeyboardState,\n+ +behavior: 'height' | 'position' | 'padding',\n+ +contentContainerStyle?: ?ViewStyle,\n|};\n-function KeyboardAvoidingView(props: Props) {\n+export default React.memo<BaseProps>(function KeyboardAvoidingView(\n+ props: BaseProps,\n+) {\n+ const keyboardState = React.useContext(KeyboardContext);\nif (!androidKeyboardResizesFrame) {\n- return <InnerKeyboardAvoidingView {...props} />;\n+ return (\n+ <InnerKeyboardAvoidingView {...props} keyboardState={keyboardState} />\n+ );\n}\n- const {\n- behavior,\n- contentContainerStyle,\n- keyboardState,\n- ...viewProps\n- } = props;\n+ const { behavior, contentContainerStyle, ...viewProps } = props;\nif (behavior !== 'position') {\nreturn <View {...viewProps} />;\n}\n@@ -49,12 +47,17 @@ function KeyboardAvoidingView(props: Props) {\n<View style={contentContainerStyle}>{children}</View>\n</View>\n);\n-}\n+});\n-type Subscription = { +remove: () => void };\n+type Props = {|\n+ ...BaseProps,\n+ // withKeyboardState\n+ +keyboardState: ?KeyboardState,\n+|};\ntype State = {|\n- bottom: number,\n+ +bottom: number,\n|};\n+type Subscription = { +remove: () => void, ... };\nclass InnerKeyboardAvoidingView extends React.PureComponent<Props, State> {\nstate = {\nbottom: 0,\n@@ -192,5 +195,3 @@ class InnerKeyboardAvoidingView extends React.PureComponent<Props, State> {\ninvariant(false, `invalid KeyboardAvoidingView behavior ${behavior}`);\n}\n}\n-\n-export default withKeyboardState(KeyboardAvoidingView);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Move KeyboardContext data-binding to hook in KeyboardAvoidingView Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D153
129,187
24.09.2020 23:23:14
14,400
5c8e9a609de2df88c5d99a698af68fe198d67d12
[native] Use hook instead of connect functions and HOC in TextMessage Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/text-message.react.js", "new_path": "native/chat/text-message.react.js", "diff": "@@ -34,10 +34,10 @@ import textMessageSendFailed from './text-message-send-failed';\nimport {\ntype KeyboardState,\nkeyboardStatePropType,\n- withKeyboardState,\n+ KeyboardContext,\n} from '../keyboard/keyboard-state';\nimport {\n- withOverlayContext,\n+ OverlayContext,\ntype OverlayContextType,\noverlayContextPropType,\n} from '../navigation/overlay-context';\n@@ -70,18 +70,21 @@ function textMessageItemHeight(item: ChatTextMessageInfoItemWithHeight) {\nreturn height;\n}\n-type Props = {|\n+type BaseProps = {|\n...React.ElementConfig<typeof View>,\n- item: ChatTextMessageInfoItemWithHeight,\n- navigation: ChatNavigationProp<'MessageList'>,\n- route: NavigationRoute<'MessageList'>,\n- focused: boolean,\n- toggleFocus: (messageKey: string) => void,\n- verticalBounds: ?VerticalBounds,\n+ +item: ChatTextMessageInfoItemWithHeight,\n+ +navigation: ChatNavigationProp<'MessageList'>,\n+ +route: NavigationRoute<'MessageList'>,\n+ +focused: boolean,\n+ +toggleFocus: (messageKey: string) => void,\n+ +verticalBounds: ?VerticalBounds,\n+|};\n+type Props = {|\n+ ...BaseProps,\n// withKeyboardState\n- keyboardState: ?KeyboardState,\n+ +keyboardState: ?KeyboardState,\n// withOverlayContext\n- overlayContext: ?OverlayContextType,\n+ +overlayContext: ?OverlayContextType,\n|};\nclass TextMessage extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -194,6 +197,18 @@ class TextMessage extends React.PureComponent<Props> {\n};\n}\n-const WrappedTextMessage = withKeyboardState(withOverlayContext(TextMessage));\n+const ConnectedTextMessage = React.memo<BaseProps>(\n+ function ConnectedTextMessage(props: BaseProps) {\n+ const keyboardState = React.useContext(KeyboardContext);\n+ const overlayContext = React.useContext(OverlayContext);\n+ return (\n+ <TextMessage\n+ {...props}\n+ overlayContext={overlayContext}\n+ keyboardState={keyboardState}\n+ />\n+ );\n+ },\n+);\n-export { WrappedTextMessage as TextMessage, textMessageItemHeight };\n+export { ConnectedTextMessage as TextMessage, textMessageItemHeight };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in TextMessage Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D154
129,187
24.09.2020 23:28:42
14,400
7d80ae4d8b5cf31f49bbfc1aeaf71192df84031e
[native] Use hook instead of connect functions and HOC in MultimediaMessageMultimedia Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -19,7 +19,6 @@ import {\nmessageListRoutePropType,\nmessageListNavPropType,\n} from './message-list-types';\n-import type { AppState } from '../redux/redux-setup';\nimport type { ChatNavigationProp } from './chat.react';\nimport type { NavigationRoute } from '../navigation/route-names';\n@@ -31,18 +30,17 @@ import invariant from 'invariant';\nimport { messageKey } from 'lib/shared/message-utils';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n-import { connect } from 'lib/utils/redux-utils';\nimport InlineMultimedia from './inline-multimedia.react';\nimport { multimediaTooltipHeight } from './multimedia-tooltip-modal.react';\n-import { type Colors, colorsPropType, colorsSelector } from '../themes/colors';\n+import { type Colors, colorsPropType, useColors } from '../themes/colors';\nimport {\ntype KeyboardState,\nkeyboardStatePropType,\n- withKeyboardState,\n+ KeyboardContext,\n} from '../keyboard/keyboard-state';\nimport {\n- withOverlayContext,\n+ OverlayContext,\ntype OverlayContextType,\noverlayContextPropType,\n} from '../navigation/overlay-context';\n@@ -51,27 +49,30 @@ import {\nconst { Value, sub, interpolate, Extrapolate } = Animated;\n/* eslint-enable import/no-named-as-default-member */\n+type BaseProps = {|\n+ +mediaInfo: MediaInfo,\n+ +item: ChatMultimediaMessageInfoItem,\n+ +navigation: ChatNavigationProp<'MessageList'>,\n+ +route: NavigationRoute<'MessageList'>,\n+ +verticalBounds: ?VerticalBounds,\n+ +verticalOffset: number,\n+ +style: ImageStyle,\n+ +postInProgress: boolean,\n+ +pendingUpload: ?PendingMultimediaUpload,\n+ +messageFocused: boolean,\n+ +toggleMessageFocus: (messageKey: string) => void,\n+|};\ntype Props = {|\n- mediaInfo: MediaInfo,\n- item: ChatMultimediaMessageInfoItem,\n- navigation: ChatNavigationProp<'MessageList'>,\n- route: NavigationRoute<'MessageList'>,\n- verticalBounds: ?VerticalBounds,\n- verticalOffset: number,\n- style: ImageStyle,\n- postInProgress: boolean,\n- pendingUpload: ?PendingMultimediaUpload,\n- messageFocused: boolean,\n- toggleMessageFocus: (messageKey: string) => void,\n+ ...BaseProps,\n// Redux state\n- colors: Colors,\n+ +colors: Colors,\n// withKeyboardState\n- keyboardState: ?KeyboardState,\n+ +keyboardState: ?KeyboardState,\n// withOverlayContext\n- overlayContext: ?OverlayContextType,\n+ +overlayContext: ?OverlayContextType,\n|};\ntype State = {|\n- opacity: number | Value,\n+ +opacity: number | Value,\n|};\nclass MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nstatic propTypes = {\n@@ -318,6 +319,18 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect((state: AppState) => ({\n- colors: colorsSelector(state),\n-}))(withOverlayContext(withKeyboardState(MultimediaMessageMultimedia)));\n+export default React.memo<BaseProps>(\n+ function ConnectedMultimediaMessageMultimedia(props: BaseProps) {\n+ const colors = useColors();\n+ const keyboardState = React.useContext(KeyboardContext);\n+ const overlayContext = React.useContext(OverlayContext);\n+ return (\n+ <MultimediaMessageMultimedia\n+ {...props}\n+ colors={colors}\n+ keyboardState={keyboardState}\n+ overlayContext={overlayContext}\n+ />\n+ );\n+ },\n+);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in MultimediaMessageMultimedia Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D155
129,187
24.09.2020 23:37:35
14,400
af8e6fa6c2a7e254fdbb25ca92f4710be2381e66
[native] Use hook instead of connect functions and HOC in ThreadSettingsMember Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-member.react.js", "new_path": "native/chat/settings/thread-settings-member.react.js", "diff": "@@ -7,7 +7,6 @@ import {\nthreadPermissions,\nrelativeMemberInfoPropType,\n} from 'lib/types/thread-types';\n-import type { AppState } from '../../redux/redux-setup';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\nimport {\n@@ -27,10 +26,10 @@ import {\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n+import { useSelector } from 'react-redux';\nimport { threadHasPermission, memberIsAdmin } from 'lib/shared/thread-utils';\nimport { stringForUser } from 'lib/shared/user-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport {\nremoveUsersFromThreadActionTypes,\nchangeThreadMemberRolesActionTypes,\n@@ -41,38 +40,41 @@ import PencilIcon from '../../components/pencil-icon.react';\nimport {\ntype Colors,\ncolorsPropType,\n- colorsSelector,\n- styleSelector,\n+ useColors,\n+ useStyles,\n} from '../../themes/colors';\nimport {\ntype KeyboardState,\nkeyboardStatePropType,\n- withKeyboardState,\n+ KeyboardContext,\n} from '../../keyboard/keyboard-state';\nimport {\n- withOverlayContext,\n+ OverlayContext,\ntype OverlayContextType,\noverlayContextPropType,\n} from '../../navigation/overlay-context';\nimport { SingleLine } from '../../components/single-line.react';\n+type BaseProps = {|\n+ +memberInfo: RelativeMemberInfo,\n+ +threadInfo: ThreadInfo,\n+ +canEdit: boolean,\n+ +navigate: ThreadSettingsNavigate,\n+ +lastListItem: boolean,\n+ +verticalBounds: ?VerticalBounds,\n+ +threadSettingsRouteKey: string,\n+|};\ntype Props = {|\n- memberInfo: RelativeMemberInfo,\n- threadInfo: ThreadInfo,\n- canEdit: boolean,\n- navigate: ThreadSettingsNavigate,\n- lastListItem: boolean,\n- verticalBounds: ?VerticalBounds,\n- threadSettingsRouteKey: string,\n+ ...BaseProps,\n// Redux state\n- removeUserLoadingStatus: LoadingStatus,\n- changeRoleLoadingStatus: LoadingStatus,\n- colors: Colors,\n- styles: typeof styles,\n+ +removeUserLoadingStatus: LoadingStatus,\n+ +changeRoleLoadingStatus: LoadingStatus,\n+ +colors: Colors,\n+ +styles: typeof unboundStyles,\n// withKeyboardState\n- keyboardState: ?KeyboardState,\n+ +keyboardState: ?KeyboardState,\n// withOverlayContext\n- overlayContext: ?OverlayContextType,\n+ +overlayContext: ?OverlayContextType,\n|};\nclass ThreadSettingsMember extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -262,7 +264,7 @@ class ThreadSettingsMember extends React.PureComponent<Props> {\n};\n}\n-const styles = {\n+const unboundStyles = {\nanonymous: {\ncolor: 'panelForegroundTertiaryLabel',\nfontStyle: 'italic',\n@@ -303,19 +305,37 @@ const styles = {\nlineHeight: 20,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect(\n- (state: AppState, ownProps: { memberInfo: RelativeMemberInfo }) => ({\n- removeUserLoadingStatus: createLoadingStatusSelector(\n+export default React.memo<BaseProps>(function ConnectedThreadSettingsMember(\n+ props: BaseProps,\n+) {\n+ const memberID = props.memberInfo.id;\n+ const removeUserLoadingStatus = useSelector(state =>\n+ createLoadingStatusSelector(\nremoveUsersFromThreadActionTypes,\n- `${removeUsersFromThreadActionTypes.started}:${ownProps.memberInfo.id}`,\n+ `${removeUsersFromThreadActionTypes.started}:${memberID}`,\n)(state),\n- changeRoleLoadingStatus: createLoadingStatusSelector(\n+ );\n+ const changeRoleLoadingStatus = useSelector(state =>\n+ createLoadingStatusSelector(\nchangeThreadMemberRolesActionTypes,\n- `${changeThreadMemberRolesActionTypes.started}:${ownProps.memberInfo.id}`,\n+ `${changeThreadMemberRolesActionTypes.started}:${memberID}`,\n)(state),\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- }),\n-)(withKeyboardState(withOverlayContext(ThreadSettingsMember)));\n+ );\n+\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ const keyboardState = React.useContext(KeyboardContext);\n+ const overlayContext = React.useContext(OverlayContext);\n+ return (\n+ <ThreadSettingsMember\n+ {...props}\n+ removeUserLoadingStatus={removeUserLoadingStatus}\n+ changeRoleLoadingStatus={changeRoleLoadingStatus}\n+ colors={colors}\n+ styles={styles}\n+ keyboardState={keyboardState}\n+ overlayContext={overlayContext}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hook instead of connect functions and HOC in ThreadSettingsMember Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D156
129,187
25.09.2020 00:01:08
14,400
0bca83d30f37c47a0a851b2dca1f3760560be079
[native] Convert RobotextMessage to hook Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/robotext-message.react.js", "new_path": "native/chat/robotext-message.react.js", "diff": "// @flow\n-import { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n-import type { AppState } from '../redux/redux-setup';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport type { RobotextMessageInfo } from 'lib/types/message-types';\n-import {\n- type KeyboardState,\n- keyboardStatePropType,\n- withKeyboardState,\n-} from '../keyboard/keyboard-state';\n-import { messageListNavPropType } from './message-list-types';\n+import { KeyboardContext } from '../keyboard/keyboard-state';\nimport type { ChatNavigationProp } from './chat.react';\n-import { type GlobalTheme, globalThemePropType } from '../types/themes';\nimport * as React from 'react';\nimport { Text, TouchableWithoutFeedback, View } from 'react-native';\n-import PropTypes from 'prop-types';\nimport invariant from 'invariant';\nimport {\n@@ -25,11 +16,11 @@ import {\nrobotextToRawString,\n} from 'lib/shared/message-utils';\nimport { threadInfoSelector } from 'lib/selectors/thread-selectors';\n-import { connect } from 'lib/utils/redux-utils';\n+import { useSelector } from 'react-redux';\nimport { MessageListRouteName } from '../navigation/route-names';\nimport { Timestamp } from './timestamp.react';\n-import { styleSelector } from '../themes/colors';\n+import { useStyles } from '../themes/colors';\nimport Markdown from '../markdown/markdown.react';\nimport { inlineMarkdownRules } from '../markdown/rules.react';\n@@ -53,64 +44,34 @@ function robotextMessageItemHeight(\nfunction dummyNodeForRobotextMessageHeightMeasurement(robotext: string) {\nreturn (\n- <View style={styles.robotextContainer}>\n- <Text style={styles.dummyRobotext}>{robotextToRawString(robotext)}</Text>\n+ <View style={unboundStyles.robotextContainer}>\n+ <Text style={unboundStyles.dummyRobotext}>\n+ {robotextToRawString(robotext)}\n+ </Text>\n</View>\n);\n}\ntype Props = {|\n...React.ElementConfig<typeof View>,\n- item: ChatRobotextMessageInfoItemWithHeight,\n- navigation: ChatNavigationProp<'MessageList'>,\n- focused: boolean,\n- toggleFocus: (messageKey: string) => void,\n- // withKeyboardState\n- keyboardState: ?KeyboardState,\n- // Redux state\n- styles: typeof styles,\n- activeTheme: ?GlobalTheme,\n+ +item: ChatRobotextMessageInfoItemWithHeight,\n+ +navigation: ChatNavigationProp<'MessageList'>,\n+ +focused: boolean,\n+ +toggleFocus: (messageKey: string) => void,\n|};\n-class RobotextMessage extends React.PureComponent<Props> {\n- static propTypes = {\n- item: chatMessageItemPropType.isRequired,\n- navigation: messageListNavPropType.isRequired,\n- focused: PropTypes.bool.isRequired,\n- toggleFocus: PropTypes.func.isRequired,\n- keyboardState: keyboardStatePropType,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- activeTheme: globalThemePropType,\n- };\n+function RobotextMessage(props: Props) {\n+ const { item, navigation, focused, toggleFocus, ...viewProps } = props;\n+\n+ const activeTheme = useSelector(state => state.globalThemeInfo.activeTheme);\n+ const styles = useStyles(unboundStyles);\n- render() {\n- const {\n- item,\n- navigation,\n- focused,\n- toggleFocus,\n- keyboardState,\n- styles,\n- activeTheme,\n- ...viewProps\n- } = this.props;\nlet timestamp = null;\nif (focused || item.startsConversation) {\ntimestamp = (\n<Timestamp time={item.messageInfo.time} display=\"lowContrast\" />\n);\n}\n- return (\n- <View {...viewProps}>\n- {timestamp}\n- <TouchableWithoutFeedback onPress={this.onPress}>\n- {this.linkedRobotext()}\n- </TouchableWithoutFeedback>\n- </View>\n- );\n- }\n- linkedRobotext() {\n- const { item, navigation } = this.props;\nconst robotext = item.robotext;\nconst robotextParts = splitRobotext(robotext);\nconst textParts = [];\n@@ -120,11 +81,11 @@ class RobotextMessage extends React.PureComponent<Props> {\ncontinue;\n}\nif (splitPart.charAt(0) !== '<') {\n- const darkColor = this.props.activeTheme === 'dark';\n+ const darkColor = activeTheme === 'dark';\nconst key = `text${keyIndex++}`;\ntextParts.push(\n<Markdown\n- style={this.props.styles.robotext}\n+ style={styles.robotext}\nkey={key}\nuseDarkStyle={darkColor}\nrules={inlineMarkdownRules}\n@@ -137,7 +98,7 @@ class RobotextMessage extends React.PureComponent<Props> {\nconst { rawText, entityType, id } = parseRobotextEntity(splitPart);\n- if (entityType === 't' && id !== this.props.item.messageInfo.threadID) {\n+ if (entityType === 't' && id !== item.messageInfo.threadID) {\ntextParts.push(\n<ThreadEntity\nkey={id}\n@@ -153,84 +114,71 @@ class RobotextMessage extends React.PureComponent<Props> {\n}\n}\n- const viewStyle = [this.props.styles.robotextContainer];\n+ const viewStyle = [styles.robotextContainer];\nif (!__DEV__) {\n// We don't force view height in dev mode because we\n// want to measure it in Message to see if it's correct\nviewStyle.push({ height: item.contentHeight });\n}\n+ const keyboardState = React.useContext(KeyboardContext);\n+ const didDismiss = keyboardState && keyboardState.dismissKeyboardIfShowing();\n+ const key = messageKey(item.messageInfo);\n+ const onPress = React.useCallback(() => {\n+ if (!didDismiss) {\n+ toggleFocus(key);\n+ }\n+ }, [didDismiss, toggleFocus, key]);\n+\nreturn (\n+ <View {...viewProps}>\n+ {timestamp}\n+ <TouchableWithoutFeedback onPress={onPress}>\n<View style={viewStyle}>\n- <Text style={this.props.styles.robotext}>{textParts}</Text>\n+ <Text style={styles.robotext}>{textParts}</Text>\n+ </View>\n+ </TouchableWithoutFeedback>\n</View>\n);\n}\n- onPress = () => {\n- const { keyboardState } = this.props;\n- const didDismiss =\n- keyboardState && keyboardState.dismissKeyboardIfShowing();\n- if (!didDismiss) {\n- this.props.toggleFocus(messageKey(this.props.item.messageInfo));\n- }\n- };\n-}\n-\n-const WrappedRobotextMessage = connect((state: AppState) => ({\n- styles: stylesSelector(state),\n- activeTheme: state.globalThemeInfo.activeTheme,\n-}))(withKeyboardState(RobotextMessage));\n+type ThreadEntityProps = {|\n+ +id: string,\n+ +name: string,\n+ +navigation: ChatNavigationProp<'MessageList'>,\n+|};\n+function ThreadEntity(props: ThreadEntityProps) {\n+ const threadID = props.id;\n+ const threadInfo = useSelector(state => threadInfoSelector(state)[threadID]);\n-type InnerThreadEntityProps = {\n- id: string,\n- name: string,\n- navigation: ChatNavigationProp<'MessageList'>,\n- // Redux state\n- threadInfo: ?ThreadInfo,\n- styles: typeof styles,\n-};\n-class InnerThreadEntity extends React.PureComponent<InnerThreadEntityProps> {\n- static propTypes = {\n- id: PropTypes.string.isRequired,\n- name: PropTypes.string.isRequired,\n- navigation: messageListNavPropType.isRequired,\n- threadInfo: threadInfoPropType,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- };\n+ const styles = useStyles(unboundStyles);\n- render() {\n- if (!this.props.threadInfo) {\n- return <Text>{this.props.name}</Text>;\n- }\n- return (\n- <Text style={this.props.styles.link} onPress={this.onPressThread}>\n- {this.props.name}\n- </Text>\n- );\n- }\n-\n- onPressThread = () => {\n- const { threadInfo, navigation } = this.props;\n+ const { navigate } = props.navigation;\n+ const onPressThread = React.useCallback(() => {\ninvariant(threadInfo, 'onPressThread should have threadInfo');\n- navigation.navigate({\n+ navigate({\nname: MessageListRouteName,\nparams: { threadInfo },\nkey: `${MessageListRouteName}${threadInfo.id}`,\n});\n- };\n+ }, [threadInfo, navigate]);\n+\n+ if (!threadInfo) {\n+ return <Text>{props.name}</Text>;\n+ }\n+ return (\n+ <Text style={styles.link} onPress={onPressThread}>\n+ {props.name}\n+ </Text>\n+ );\n}\n-const ThreadEntity = connect((state: AppState, ownProps: { id: string }) => ({\n- threadInfo: threadInfoSelector(state)[ownProps.id],\n- styles: stylesSelector(state),\n-}))(InnerThreadEntity);\n-function ColorEntity(props: {| color: string |}) {\n+function ColorEntity(props: {| +color: string |}) {\nconst colorStyle = { color: props.color };\nreturn <Text style={colorStyle}>{props.color}</Text>;\n}\n-const styles = {\n+const unboundStyles = {\nlink: {\ncolor: 'link',\n},\n@@ -251,10 +199,9 @@ const styles = {\ntextAlign: 'center',\n},\n};\n-const stylesSelector = styleSelector(styles);\nexport {\nrobotextMessageItemHeight,\ndummyNodeForRobotextMessageHeightMeasurement,\n- WrappedRobotextMessage as RobotextMessage,\n+ RobotextMessage,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Convert RobotextMessage to hook Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D157
129,187
25.09.2020 00:02:42
14,400
85cb25555a8d8eafdcd2e69be1110cc1ddae6427
[native] Get rid of withKeyboardState Summary: It's no longer used. Going forward, let's use hooks for data binding. Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/keyboard/keyboard-state.js", "new_path": "native/keyboard/keyboard-state.js", "diff": "@@ -27,29 +27,4 @@ const keyboardStatePropType = PropTypes.shape({\nconst KeyboardContext = React.createContext<?KeyboardState>(null);\n-function withKeyboardState<\n- AllProps: {},\n- ComponentType: React.ComponentType<AllProps>,\n->(\n- Component: ComponentType,\n-): React.ComponentType<\n- $Diff<React.ElementConfig<ComponentType>, { keyboardState: ?KeyboardState }>,\n-> {\n- class KeyboardStateHOC extends React.PureComponent<\n- $Diff<\n- React.ElementConfig<ComponentType>,\n- { keyboardState: ?KeyboardState },\n- >,\n- > {\n- render() {\n- return (\n- <KeyboardContext.Consumer>\n- {value => <Component {...this.props} keyboardState={value} />}\n- </KeyboardContext.Consumer>\n- );\n- }\n- }\n- return KeyboardStateHOC;\n-}\n-\n-export { keyboardStatePropType, KeyboardContext, withKeyboardState };\n+export { keyboardStatePropType, KeyboardContext };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Get rid of withKeyboardState Summary: It's no longer used. Going forward, let's use hooks for data binding. Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D158
129,187
28.09.2020 12:13:42
14,400
479419e297b3b10f0e33bb13e5430973bec476be
[native] Don't dismiss keyboard during RobotextMessage render Summary: Oops, made a mistake in D157... Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/robotext-message.react.js", "new_path": "native/chat/robotext-message.react.js", "diff": "@@ -122,13 +122,14 @@ function RobotextMessage(props: Props) {\n}\nconst keyboardState = React.useContext(KeyboardContext);\n- const didDismiss = keyboardState && keyboardState.dismissKeyboardIfShowing();\nconst key = messageKey(item.messageInfo);\nconst onPress = React.useCallback(() => {\n+ const didDismiss =\n+ keyboardState && keyboardState.dismissKeyboardIfShowing();\nif (!didDismiss) {\ntoggleFocus(key);\n}\n- }, [didDismiss, toggleFocus, key]);\n+ }, [keyboardState, toggleFocus, key]);\nreturn (\n<View {...viewProps}>\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't dismiss keyboard during RobotextMessage render Summary: Oops, made a mistake in D157... Reviewers: KatPo, palys-swm Reviewed By: KatPo, palys-swm Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D160
129,187
28.09.2020 12:24:44
14,400
30da831fb942a47ac1afd9b84909b04633f93e46
[web] Use flex-direction column-reverse on Firefox 81 Summary: This [bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1042151) is finally fixed in Firefox 81! Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-message-list.css", "new_path": "web/chat/chat-message-list.css", "diff": "@@ -17,11 +17,11 @@ div.messageContainer {\ndisplay: flex;\nflex-direction: column-reverse;\n}\n-div.firefoxMessageContainer {\n+div.mirroredMessageContainer {\nflex-direction: column !important;\ntransform: scaleY(-1);\n}\n-div.firefoxMessageContainer > div {\n+div.mirroredMessageContainer > div {\ntransform: scaleY(-1);\n}\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-message-list.react.js", "new_path": "web/chat/chat-message-list.react.js", "diff": "@@ -60,7 +60,7 @@ type PassedProps = {|\n+messageListData: ?$ReadOnlyArray<ChatMessageItem>,\n+startReached: boolean,\n+timeZone: ?string,\n- +firefox: boolean,\n+ +supportsReverseFlex: boolean,\n// Redux dispatch functions\n+dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -97,7 +97,7 @@ class ChatMessageList extends React.PureComponent<Props, State> {\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType),\nstartReached: PropTypes.bool.isRequired,\ntimeZone: PropTypes.string,\n- firefox: PropTypes.bool.isRequired,\n+ supportsReverseFlex: PropTypes.bool.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nfetchMessagesBeforeCursor: PropTypes.func.isRequired,\nfetchMostRecentMessages: PropTypes.func.isRequired,\n@@ -196,10 +196,10 @@ class ChatMessageList extends React.PureComponent<Props, State> {\n) {\nconst newHeight = scrollHeight - snapshot.scrollHeight;\nconst newScrollTop = Math.abs(scrollTop) + newHeight;\n- if (this.props.firefox) {\n- messageContainer.scrollTop = newScrollTop;\n- } else {\n+ if (this.props.supportsReverseFlex) {\nmessageContainer.scrollTop = -1 * newScrollTop;\n+ } else {\n+ messageContainer.scrollTop = newScrollTop;\n}\n}\n}\n@@ -289,7 +289,7 @@ class ChatMessageList extends React.PureComponent<Props, State> {\nconst messageContainerStyle = classNames({\n[css.messageContainer]: true,\n- [css.firefoxMessageContainer]: this.props.firefox,\n+ [css.mirroredMessageContainer]: !this.props.supportsReverseFlex,\n});\nreturn connectDropTarget(\n<div className={containerStyle} ref={this.containerRef}>\n@@ -389,9 +389,11 @@ export default React.memo<BaseProps>(function ConnectedChatMessageList(\nprops: BaseProps,\n) {\nconst userAgent = useSelector(state => state.userAgent);\n- const firefox = React.useMemo(() => {\n+ const supportsReverseFlex = React.useMemo(() => {\nconst browser = detectBrowser(userAgent);\n- return browser && browser.name === 'firefox';\n+ return (\n+ !browser || browser.name !== 'firefox' || parseInt(browser.version) >= 81\n+ );\n}, [userAgent]);\nconst messageListData = useSelector(webMessageListData);\n@@ -443,7 +445,7 @@ export default React.memo<BaseProps>(function ConnectedChatMessageList(\nmessageListData={messageListData}\nstartReached={startReached}\ntimeZone={timeZone}\n- firefox={firefox}\n+ supportsReverseFlex={supportsReverseFlex}\ninputState={inputState}\ndispatchActionPromise={dispatchActionPromise}\nfetchMessagesBeforeCursor={callFetchMessagesBeforeCursor}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Use flex-direction column-reverse on Firefox 81 Summary: This [bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1042151) is finally fixed in Firefox 81! Reviewers: KatPo, palys-swm Reviewed By: KatPo, palys-swm Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D161
129,183
15.09.2020 13:35:09
-7,200
c9e9bfa4c4c168b887e752881c91ecef27237a8d
[native] Add swipeable component for message Reviewers: ashoat, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/composed-message.react.js", "new_path": "native/chat/composed-message.react.js", "diff": "import type { ChatMessageInfoItemWithHeight } from './message.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { assertComposableMessageType } from 'lib/types/message-types';\n-import type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { StyleSheet, View } from 'react-native';\n+import { StyleSheet, View, Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/Feather';\n+import { useSelector } from 'react-redux';\n-import { connect } from 'lib/utils/redux-utils';\n-\n+import SwipeableMessage from './swipeable-message.react';\nimport { FailedSend } from './failed-send.react';\nimport { composedMessageMaxWidthSelector } from './composed-message-width';\nimport { MessageHeader } from './message-header.react';\n-import { type Colors, colorsPropType, colorsSelector } from '../themes/colors';\n+import { type Colors, colorsPropType, useColors } from '../themes/colors';\nconst clusterEndHeight = 7;\n-type Props = {|\n+type BaseProps = {|\n...React.ElementConfig<typeof View>,\n- item: ChatMessageInfoItemWithHeight,\n- sendFailed: boolean,\n- focused: boolean,\n- children: React.Node,\n+ +item: ChatMessageInfoItemWithHeight,\n+ +sendFailed: boolean,\n+ +focused: boolean,\n+ +canSwipe?: boolean,\n+ +children: React.Node,\n+|};\n+type Props = {|\n+ ...BaseProps,\n// Redux state\n- composedMessageMaxWidth: number,\n- colors: Colors,\n+ +composedMessageMaxWidth: number,\n+ +colors: Colors,\n|};\nclass ComposedMessage extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\nsendFailed: PropTypes.bool.isRequired,\nfocused: PropTypes.bool.isRequired,\n+ canSwipe: PropTypes.bool,\nchildren: PropTypes.node.isRequired,\ncomposedMessageMaxWidth: PropTypes.number.isRequired,\ncolors: colorsPropType.isRequired,\n@@ -45,6 +49,7 @@ class ComposedMessage extends React.PureComponent<Props> {\nitem,\nsendFailed,\nfocused,\n+ canSwipe,\nchildren,\ncomposedMessageMaxWidth,\ncolors,\n@@ -86,12 +91,28 @@ class ComposedMessage extends React.PureComponent<Props> {\n);\n}\n+ const fullMessageBoxStyle = [styles.messageBox, messageBoxStyle];\n+ let messageBox;\n+ if (canSwipe && (Platform.OS !== 'android' || Platform.Version >= 21)) {\n+ messageBox = (\n+ <SwipeableMessage\n+ onSwipeableWillOpen={this.reply}\n+ isViewer={isViewer}\n+ messageBoxStyle={fullMessageBoxStyle}\n+ >\n+ {children}\n+ </SwipeableMessage>\n+ );\n+ } else {\n+ messageBox = <View style={fullMessageBoxStyle}>{children}</View>;\n+ }\n+\nreturn (\n<View {...viewProps}>\n<MessageHeader item={item} focused={focused} display=\"lowContrast\" />\n<View style={containerStyle}>\n<View style={[styles.content, alignStyle]}>\n- <View style={[styles.messageBox, messageBoxStyle]}>{children}</View>\n+ {messageBox}\n{deliveryIcon}\n</View>\n{failedSendInfo}\n@@ -99,6 +120,8 @@ class ComposedMessage extends React.PureComponent<Props> {\n</View>\n);\n}\n+\n+ reply = () => {};\n}\nconst styles = StyleSheet.create({\n@@ -129,9 +152,20 @@ const styles = StyleSheet.create({\n},\n});\n-const ConnectedComposedMessage = connect((state: AppState) => ({\n- composedMessageMaxWidth: composedMessageMaxWidthSelector(state),\n- colors: colorsSelector(state),\n-}))(ComposedMessage);\n+const ConnectedComposedMessage = React.memo<BaseProps>(\n+ function ConnectedComposedMessage(props: BaseProps) {\n+ const composedMessageMaxWidth = useSelector(\n+ composedMessageMaxWidthSelector,\n+ );\n+ const colors = useColors();\n+ return (\n+ <ComposedMessage\n+ {...props}\n+ composedMessageMaxWidth={composedMessageMaxWidth}\n+ colors={colors}\n+ />\n+ );\n+ },\n+);\nexport { ConnectedComposedMessage as ComposedMessage, clusterEndHeight };\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/chat/swipeable-message.react.js", "diff": "+// @flow\n+\n+import type { ViewStyle } from '../types/styles';\n+\n+import * as React from 'react';\n+import { View, Platform } from 'react-native';\n+import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';\n+import { TapticFeedback } from 'react-native-in-app-message';\n+import Animated from 'react-native-reanimated';\n+import {\n+ PanGestureHandler,\n+ State as GestureState,\n+} from 'react-native-gesture-handler';\n+\n+import { useColors, useStyles } from '../themes/colors';\n+import { dividePastDistance, runSpring } from '../utils/animation-utils';\n+\n+/* eslint-disable import/no-named-as-default-member */\n+const {\n+ Value,\n+ Clock,\n+ block,\n+ event,\n+ Extrapolate,\n+ set,\n+ call,\n+ cond,\n+ not,\n+ and,\n+ greaterOrEq,\n+ eq,\n+ add,\n+ abs,\n+ max,\n+ min,\n+ stopClock,\n+ interpolate,\n+ SpringUtils,\n+} = Animated;\n+/* eslint-enable import/no-named-as-default-member */\n+\n+const threshold = 40;\n+const springConfig = {\n+ ...SpringUtils.makeConfigFromBouncinessAndSpeed({\n+ ...SpringUtils.makeDefaultConfig(),\n+ bounciness: 10,\n+ speed: 8,\n+ }),\n+ overshootClamping: true,\n+};\n+\n+type Props = {|\n+ +onSwipeableWillOpen: () => void,\n+ +isViewer: boolean,\n+ +messageBoxStyle: ViewStyle,\n+ +children: React.Node,\n+|};\n+function SwipeableMessage(props: Props) {\n+ const { isViewer, onSwipeableWillOpen } = props;\n+ const onPassThreshold = React.useCallback(() => {\n+ if (Platform.OS === 'ios') {\n+ TapticFeedback.impact();\n+ }\n+ }, []);\n+\n+ const {\n+ swipeEvent,\n+ transformMessageBoxStyle,\n+ translateReplyStyle,\n+ } = React.useMemo(() => {\n+ const swipeX = new Value(0);\n+ const swipeState = new Value(-1);\n+ const innerSwipeEvent = event([\n+ {\n+ nativeEvent: {\n+ translationX: swipeX,\n+ state: swipeState,\n+ },\n+ },\n+ ]);\n+\n+ const curX = new Value(0);\n+ const prevSwipeState = new Value(-1);\n+ const resetClock = new Clock();\n+\n+ const isActive = eq(swipeState, GestureState.ACTIVE);\n+ const baseActiveTranslation = isViewer\n+ ? min(add(curX, swipeX), 0)\n+ : max(add(curX, swipeX), 0);\n+ const activeTranslation = dividePastDistance(\n+ baseActiveTranslation,\n+ threshold,\n+ 2,\n+ );\n+\n+ const pastThreshold = greaterOrEq(abs(activeTranslation), threshold);\n+ const prevPastThreshold = new Value(0);\n+\n+ const translateX = block([\n+ cond(and(eq(prevSwipeState, GestureState.ACTIVE), not(isActive)), [\n+ set(curX, activeTranslation),\n+ cond(pastThreshold, call([], onSwipeableWillOpen)),\n+ ]),\n+ set(prevSwipeState, swipeState),\n+ cond(\n+ and(isActive, pastThreshold, not(prevPastThreshold)),\n+ call([], onPassThreshold),\n+ ),\n+ set(prevPastThreshold, pastThreshold),\n+ cond(\n+ isActive,\n+ [stopClock(resetClock), activeTranslation],\n+ [\n+ cond(\n+ eq(curX, 0),\n+ stopClock(resetClock),\n+ set(curX, runSpring(resetClock, curX, 0, true, springConfig)),\n+ ),\n+ curX,\n+ ],\n+ ),\n+ ]);\n+ const innerTransformMessageBoxStyle = {\n+ transform: [{ translateX }],\n+ };\n+\n+ const translateReplyIcon = interpolate(translateX, {\n+ inputRange: isViewer ? [-1 * threshold, 0] : [0, threshold],\n+ outputRange: isViewer ? [-23, -23 + threshold] : [0 - threshold, 0],\n+ extrapolate: Extrapolate.CLAMP,\n+ });\n+ const translateReplyOpacity = interpolate(translateX, {\n+ inputRange: isViewer ? [-1 * threshold, -25] : [25, threshold],\n+ outputRange: isViewer ? [1, 0] : [0, 1],\n+ extrapolate: Extrapolate.CLAMP,\n+ });\n+ const innerTranslateReplyStyle = {\n+ transform: [\n+ {\n+ translateX: translateReplyIcon,\n+ },\n+ ],\n+ opacity: translateReplyOpacity,\n+ };\n+ return {\n+ swipeEvent: innerSwipeEvent,\n+ transformMessageBoxStyle: innerTransformMessageBoxStyle,\n+ translateReplyStyle: innerTranslateReplyStyle,\n+ };\n+ }, [isViewer, onSwipeableWillOpen, onPassThreshold]);\n+\n+ const iconPosition = isViewer ? { right: 0 } : { left: 0 };\n+ const { messageBoxStyle, children } = props;\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ return (\n+ <React.Fragment>\n+ <View style={[styles.icon, iconPosition]}>\n+ <Animated.View style={translateReplyStyle}>\n+ <View style={styles.iconBackground}>\n+ <FontAwesomeIcon\n+ name=\"reply\"\n+ color={colors.blockQuoteBorder}\n+ size={16}\n+ />\n+ </View>\n+ </Animated.View>\n+ </View>\n+ <PanGestureHandler\n+ maxPointers={1}\n+ minDist={10}\n+ onGestureEvent={swipeEvent}\n+ onHandlerStateChange={swipeEvent}\n+ failOffsetX={isViewer ? 5 : -5}\n+ failOffsetY={[-5, 5]}\n+ >\n+ <Animated.View style={[messageBoxStyle, transformMessageBoxStyle]}>\n+ {children}\n+ </Animated.View>\n+ </PanGestureHandler>\n+ </React.Fragment>\n+ );\n+}\n+\n+const unboundStyles = {\n+ icon: {\n+ justifyContent: 'center',\n+ position: 'absolute',\n+ },\n+ iconBackground: {\n+ alignItems: 'center',\n+ backgroundColor: 'listChatBubble',\n+ borderRadius: 30,\n+ height: 30,\n+ justifyContent: 'center',\n+ width: 30,\n+ },\n+};\n+\n+export default SwipeableMessage;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/text-message.react.js", "new_path": "native/chat/text-message.react.js", "diff": "@@ -116,6 +116,7 @@ class TextMessage extends React.PureComponent<Props> {\nitem={item}\nsendFailed={textMessageSendFailed(item)}\nfocused={focused}\n+ canSwipe={true}\n{...viewProps}\n>\n<InnerTextMessage\n" }, { "change_type": "MODIFY", "old_path": "native/utils/animation-utils.js", "new_path": "native/utils/animation-utils.js", "diff": "@@ -16,13 +16,19 @@ const {\ngreaterThan,\nlessThan,\neq,\n+ add,\nsub,\n+ multiply,\n+ divide,\n+ abs,\nset,\nmax,\nstartClock,\nstopClock,\nclockRunning,\ntiming,\n+ spring,\n+ SpringUtils,\n} = Animated;\n/* eslint-enable import/no-named-as-default-member */\n@@ -34,6 +40,20 @@ function clamp(value: Value, minValue: Value, maxValue: Value): Value {\n);\n}\n+function dividePastDistance(\n+ value: Value,\n+ distance: number,\n+ factor: number,\n+): Value {\n+ const absValue = abs(value);\n+ const absFactor = cond(eq(absValue, 0), 1, divide(value, absValue));\n+ return cond(\n+ lessThan(absValue, distance),\n+ value,\n+ multiply(add(distance, divide(sub(absValue, distance), factor)), absFactor),\n+ );\n+}\n+\nfunction delta(value: Value) {\nconst prevValue = new Value(0);\nconst deltaValue = new Value(0);\n@@ -99,6 +119,42 @@ function runTiming(\n];\n}\n+const defaultSpringConfig = SpringUtils.makeDefaultConfig();\n+\n+type SpringConfig = $Shape<typeof defaultSpringConfig>;\n+function runSpring(\n+ clock: Clock,\n+ initialValue: Value | number,\n+ finalValue: Value | number,\n+ startStopClock: boolean = true,\n+ config: SpringConfig = defaultSpringConfig,\n+): Value {\n+ const state = {\n+ finished: new Value(0),\n+ position: new Value(0),\n+ velocity: new Value(0),\n+ time: new Value(0),\n+ };\n+ const springConfig = {\n+ ...defaultSpringConfig,\n+ ...config,\n+ toValue: new Value(0),\n+ };\n+ return [\n+ cond(not(clockRunning(clock)), [\n+ set(state.finished, 0),\n+ set(state.velocity, 0),\n+ set(state.time, 0),\n+ set(state.position, initialValue),\n+ set(springConfig.toValue, finalValue),\n+ startStopClock && startClock(clock),\n+ ]),\n+ spring(clock, state, springConfig),\n+ cond(state.finished, startStopClock && stopClock(clock)),\n+ state.position,\n+ ];\n+}\n+\n// You provide a node that performs a \"ratchet\",\n// and this function will call it as keyboard height increases\nfunction ratchetAlongWithKeyboardHeight(\n@@ -135,9 +191,11 @@ function ratchetAlongWithKeyboardHeight(\nexport {\nclamp,\n+ dividePastDistance,\ndelta,\ngestureJustStarted,\ngestureJustEnded,\nrunTiming,\n+ runSpring,\nratchetAlongWithKeyboardHeight,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Add swipeable component for message Reviewers: ashoat, palys-swm Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D109
129,183
15.09.2020 14:19:58
-7,200
c24cf64fd1012705afb35b9027b504303c16d5ea
[native] Reply by swiping on message Reviewers: ashoat, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/composed-message.react.js", "new_path": "native/chat/composed-message.react.js", "diff": "@@ -8,13 +8,21 @@ import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { StyleSheet, View, Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/Feather';\n+import invariant from 'invariant';\nimport { useSelector } from 'react-redux';\n+import { createMessageReply } from 'lib/shared/message-utils';\n+\nimport SwipeableMessage from './swipeable-message.react';\nimport { FailedSend } from './failed-send.react';\nimport { composedMessageMaxWidthSelector } from './composed-message-width';\nimport { MessageHeader } from './message-header.react';\nimport { type Colors, colorsPropType, useColors } from '../themes/colors';\n+import {\n+ inputStatePropType,\n+ type InputState,\n+ InputStateContext,\n+} from '../input/input-state';\nconst clusterEndHeight = 7;\n@@ -31,6 +39,8 @@ type Props = {|\n// Redux state\n+composedMessageMaxWidth: number,\n+colors: Colors,\n+ // withInputState\n+ +inputState: ?InputState,\n|};\nclass ComposedMessage extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -41,6 +51,7 @@ class ComposedMessage extends React.PureComponent<Props> {\nchildren: PropTypes.node.isRequired,\ncomposedMessageMaxWidth: PropTypes.number.isRequired,\ncolors: colorsPropType.isRequired,\n+ inputState: inputStatePropType,\n};\nrender() {\n@@ -53,6 +64,7 @@ class ComposedMessage extends React.PureComponent<Props> {\nchildren,\ncomposedMessageMaxWidth,\ncolors,\n+ inputState,\n...viewProps\n} = this.props;\nconst { id, creator } = item.messageInfo;\n@@ -121,7 +133,12 @@ class ComposedMessage extends React.PureComponent<Props> {\n);\n}\n- reply = () => {};\n+ reply = () => {\n+ const { inputState, item } = this.props;\n+ invariant(inputState, 'inputState should be set in reply');\n+ invariant(item.messageInfo.text, 'text should be set in reply');\n+ inputState.addReply(createMessageReply(item.messageInfo.text));\n+ };\n}\nconst styles = StyleSheet.create({\n@@ -158,14 +175,15 @@ const ConnectedComposedMessage = React.memo<BaseProps>(\ncomposedMessageMaxWidthSelector,\n);\nconst colors = useColors();\n+ const inputState = React.useContext(InputStateContext);\nreturn (\n<ComposedMessage\n{...props}\ncomposedMessageMaxWidth={composedMessageMaxWidth}\ncolors={colors}\n+ inputState={inputState}\n/>\n);\n},\n);\n-\nexport { ConnectedComposedMessage as ComposedMessage, clusterEndHeight };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Reply by swiping on message Reviewers: ashoat, palys-swm Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D110
129,183
28.09.2020 13:44:31
-7,200
1eae4459100afa0754cd81ac27b19c7b1724fcdb
[native] Prepend reply if not done earlier Reviewers: ashoat, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -491,7 +491,11 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}, 400);\nfocusAndUpdateText = (text: string) => {\n- this.updateText(text);\n+ const textFromInput = this.state.text;\n+ if (!textFromInput.startsWith(text)) {\n+ const prependedText = text.concat(textFromInput);\n+ this.updateText(prependedText);\n+ }\ninvariant(this.textInput, 'textInput should be set in focusAndUpdateText');\nthis.textInput.focus();\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Prepend reply if not done earlier Reviewers: ashoat, palys-swm Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D159
129,183
29.09.2020 09:08:35
-7,200
acc131543460bd6231d89e291a3e8794ad6997fb
[web] Prepend text on reply Reviewers: ashoat, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-input-bar.react.js", "new_path": "web/chat/chat-input-bar.react.js", "diff": "@@ -287,12 +287,17 @@ class ChatInputBar extends React.PureComponent<Props> {\n};\nfocusAndUpdateText = (text: string) => {\n- invariant(this.textarea, 'textarea should be set');\n- this.textarea.focus();\n- invariant(this.textarea, 'textarea should be set');\n- this.textarea.value = text;\n+ const { textarea } = this;\n+ invariant(textarea, 'textarea should be set');\n+ textarea.focus();\n+ const textFromInput = textarea.value;\n+\n+ if (!textFromInput.startsWith(text)) {\n+ const prependedText = text.concat(textFromInput);\n+ textarea.value = prependedText;\nthis.updateHeight();\n- this.props.inputState.setDraft(text);\n+ this.props.inputState.setDraft(prependedText);\n+ }\n};\nonKeyDown = (event: SyntheticKeyboardEvent<HTMLTextAreaElement>) => {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Prepend text on reply Reviewers: ashoat, palys-swm Reviewed By: ashoat, palys-swm Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D162
129,187
29.09.2020 15:55:42
14,400
37a2cdc739c8b7d5fed9a2650e86bc744e1efa07
[native] Immediately update ChatInputBar when making reply Summary: This makes the animation look cleaner, and makes sure that the `TextInput` is scrolled to the very bottom when it's focused. Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -182,6 +182,10 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nreturn ChatInputBar.systemKeyboardShowing(this.props);\n}\n+ immediatelyShowSendButton() {\n+ this.sendButtonContainerOpen.setValue(1);\n+ }\n+\nupdateSendButton(currentText: string) {\n// eslint-disable-next-line import/no-named-as-default-member\nAnimated.timing(this.sendButtonContainerOpen, {\n@@ -491,10 +495,12 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}, 400);\nfocusAndUpdateText = (text: string) => {\n- const textFromInput = this.state.text;\n- if (!textFromInput.startsWith(text)) {\n- const prependedText = text.concat(textFromInput);\n+ const currentText = this.state.text;\n+ if (!currentText.startsWith(text)) {\n+ const prependedText = text.concat(currentText);\nthis.updateText(prependedText);\n+ this.immediatelyShowSendButton();\n+ this.immediatelyHideButtons();\n}\ninvariant(this.textInput, 'textInput should be set in focusAndUpdateText');\nthis.textInput.focus();\n@@ -583,6 +589,11 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nthis.setState({ buttonsExpanded: false });\n}\n+ immediatelyHideButtons() {\n+ this.expandoButtonsOpacity.setValue(0);\n+ this.setState({ buttonsExpanded: false });\n+ }\n+\nopenCamera = async () => {\nthis.dismissKeyboard();\nthis.props.navigation.navigate({\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Immediately update ChatInputBar when making reply Summary: This makes the animation look cleaner, and makes sure that the `TextInput` is scrolled to the very bottom when it's focused. Reviewers: KatPo, palys-swm Reviewed By: KatPo, palys-swm Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D165
129,187
29.09.2020 16:52:09
14,400
135695541826283d3666a5bcfc6ffb5a79ce6964
[native] Use hooks for data-binding in RelationshipUpdateModal Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/more/relationship-update-modal.react.js", "new_path": "native/more/relationship-update-modal.react.js", "diff": "import type { GlobalAccountUserInfo, UserInfo } from 'lib/types/user-types';\nimport type { UserSearchResult } from 'lib/types/search-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport {\ntype RelationshipRequest,\nuserRelationshipStatus,\n@@ -18,23 +17,28 @@ import { CommonActions } from '@react-navigation/native';\nimport { createSelector } from 'reselect';\nimport _keyBy from 'lodash/fp/keyBy';\nimport invariant from 'invariant';\n+import { useSelector } from 'react-redux';\nimport { searchIndexFromUserInfos } from 'lib/selectors/user-selectors';\nimport { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport { getUserSearchResults } from 'lib/shared/search-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport { values } from 'lib/utils/objects';\nimport { searchUsersActionTypes, searchUsers } from 'lib/actions/user-actions';\nimport {\nupdateRelationshipsActionTypes,\nupdateRelationships,\n} from 'lib/actions/relationship-actions';\n+import {\n+ type DispatchActionPromise,\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport UserList from '../components/user-list.react';\nimport Modal from '../components/modal.react';\nimport Button from '../components/button.react';\nimport TagInput from '../components/tag-input.react';\n-import { styleSelector } from '../themes/colors';\n+import { useStyles } from '../themes/colors';\nconst tagInputProps = {\nautoFocus: true,\n@@ -45,28 +49,28 @@ export type RelationshipUpdateModalParams = {|\n+target: 'friends' | 'blocked',\n|};\n+type BaseProps = {|\n+ +navigation: RootNavigationProp<'RelationshipUpdateModal'>,\n+ +route: NavigationRoute<'RelationshipUpdateModal'>,\n+|};\ntype Props = {|\n- navigation: RootNavigationProp<'RelationshipUpdateModal'>,\n- route: NavigationRoute<'RelationshipUpdateModal'>,\n+ ...BaseProps,\n// Redux state\n- userInfos: { [id: string]: UserInfo },\n- viewerID: ?string,\n- styles: typeof styles,\n+ +userInfos: { [id: string]: UserInfo },\n+ +viewerID: ?string,\n+ +styles: typeof unboundStyles,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- searchUsers: (usernamePrefix: string) => Promise<UserSearchResult>,\n- updateRelationships: (request: RelationshipRequest) => Promise<void>,\n+ +searchUsers: (usernamePrefix: string) => Promise<UserSearchResult>,\n+ +updateRelationships: (request: RelationshipRequest) => Promise<void>,\n|};\n-\ntype State = {|\n- usernameInputText: string,\n- userInfoInputArray: $ReadOnlyArray<GlobalAccountUserInfo>,\n- searchUserInfos: { [id: string]: GlobalAccountUserInfo },\n+ +usernameInputText: string,\n+ +userInfoInputArray: $ReadOnlyArray<GlobalAccountUserInfo>,\n+ +searchUserInfos: { [id: string]: GlobalAccountUserInfo },\n|};\n-\ntype PropsAndState = {| ...Props, ...State |};\n-\nclass RelationshipUpdateModal extends React.PureComponent<Props, State> {\nstate = {\nusernameInputText: '',\n@@ -312,7 +316,7 @@ class RelationshipUpdateModal extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\nactivityIndicator: {\npaddingRight: 6,\n},\n@@ -343,17 +347,31 @@ const styles = {\nfontSize: 18,\n},\n};\n-const stylesSelector = styleSelector(styles);\nregisterFetchKey(searchUsersActionTypes);\n-export default connect(\n- (state: AppState) => {\n- return {\n- viewerID: state.currentUserInfo && state.currentUserInfo.id,\n- userInfos: state.userStore.userInfos,\n- styles: stylesSelector(state),\n- };\n- },\n- { searchUsers, updateRelationships },\n-)(RelationshipUpdateModal);\n+export default React.memo<BaseProps>(function ConnectedRelationshipUpdateModal(\n+ props: BaseProps,\n+) {\n+ const viewerID = useSelector(\n+ (state: AppState) => state.currentUserInfo && state.currentUserInfo.id,\n+ );\n+ const userInfos = useSelector((state: AppState) => state.userStore.userInfos);\n+ const styles = useStyles(unboundStyles);\n+\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callSearchUsers = useServerCall(searchUsers);\n+ const callUpdateRelationships = useServerCall(updateRelationships);\n+\n+ return (\n+ <RelationshipUpdateModal\n+ {...props}\n+ viewerID={viewerID}\n+ userInfos={userInfos}\n+ styles={styles}\n+ dispatchActionPromise={dispatchActionPromise}\n+ searchUsers={callSearchUsers}\n+ updateRelationships={callUpdateRelationships}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hooks for data-binding in RelationshipUpdateModal Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D168
129,187
29.09.2020 16:20:43
14,400
8a44ed28d3df20a79ec090fe4bec785731c2a6a2
[web] Scroll to bottom of textarea when setting up a reply Summary: This is important for replying to larger messages Reviewers: KatPo, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-input-bar.react.js", "new_path": "web/chat/chat-input-bar.react.js", "diff": "@@ -287,17 +287,27 @@ class ChatInputBar extends React.PureComponent<Props> {\n};\nfocusAndUpdateText = (text: string) => {\n+ // We need to call focus() first on Safari, otherwise the cursor\n+ // ends up at the start instead of the end for some reason\nconst { textarea } = this;\ninvariant(textarea, 'textarea should be set');\ntextarea.focus();\n- const textFromInput = textarea.value;\n- if (!textFromInput.startsWith(text)) {\n- const prependedText = text.concat(textFromInput);\n- textarea.value = prependedText;\n- this.updateHeight();\n+ // We reset the textarea to an empty string at the start so that the cursor\n+ // always ends up at the end, even if the text doesn't actually change\n+ textarea.value = '';\n+ const currentText = this.props.inputState.draft;\n+ if (!currentText.startsWith(text)) {\n+ const prependedText = text.concat(currentText);\nthis.props.inputState.setDraft(prependedText);\n+ textarea.value = prependedText;\n+ } else {\n+ textarea.value = currentText;\n}\n+\n+ // The above strategies make sure the cursor is at the end,\n+ // but we also need to make sure that we're scrolled to the bottom\n+ textarea.scrollTop = textarea.scrollHeight;\n};\nonKeyDown = (event: SyntheticKeyboardEvent<HTMLTextAreaElement>) => {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Scroll to bottom of textarea when setting up a reply Summary: This is important for replying to larger messages Reviewers: KatPo, palys-swm Reviewed By: KatPo Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D166
129,187
30.09.2020 19:18:21
14,400
31701dbf8447690b0d4c4a8402376a2368d1a2a4
Add optional_chaining and nullish_coalescing to all .flowconfig Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/.flowconfig", "new_path": "lib/.flowconfig", "diff": "[libs]\n[options]\n+esproposal.optional_chaining=enable\n+esproposal.nullish_coalescing=enable\n[lints]\nsketchy-null-number=warn\n" }, { "change_type": "MODIFY", "old_path": "server/.flowconfig", "new_path": "server/.flowconfig", "diff": "module.file_ext=.js\nmodule.file_ext=.cjs\nmodule.file_ext=.json\n+esproposal.optional_chaining=enable\n+esproposal.nullish_coalescing=enable\n[lints]\nsketchy-null-number=warn\n" }, { "change_type": "MODIFY", "old_path": "web/.flowconfig", "new_path": "web/.flowconfig", "diff": "[options]\nmodule.name_mapper.extension='css' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'\n+esproposal.optional_chaining=enable\n+esproposal.nullish_coalescing=enable\n[lints]\nsketchy-null-number=warn\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Add optional_chaining and nullish_coalescing to all .flowconfig Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D171
129,191
30.09.2020 17:00:33
-7,200
fe5dfdf360205fbc6b27e7e102af6641a0de3996
[server] Remove unused activity update type Reviewers: ashoat Subscribers: zrebcu411, KatPo, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/types/activity-types.js", "new_path": "lib/types/activity-types.js", "diff": "@@ -4,8 +4,7 @@ import PropTypes from 'prop-types';\nexport type ActivityUpdate =\n| {| focus: true, threadID: string |}\n- | {| focus: false, threadID: string, latestMessage: ?string |}\n- | {| focus?: void, closing: true |};\n+ | {| focus: false, threadID: string, latestMessage: ?string |};\nexport const activityUpdatePropType = PropTypes.oneOfType([\nPropTypes.shape({\nfocus: PropTypes.oneOf([true]).isRequired,\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/activity-responders.js", "new_path": "server/src/responders/activity-responders.js", "diff": "@@ -22,9 +22,6 @@ const activityUpdatesInputValidator = t.list(\nthreadID: t.String,\nlatestMessage: t.maybe(t.String),\n}),\n- tShape({\n- closing: tBool(true),\n- }),\n]),\n);\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -32,10 +32,6 @@ async function activityUpdater(\nconst unverifiedThreadIDs = new Set();\nconst focusUpdatesByThreadID = new Map();\nfor (let activityUpdate of request.updates) {\n- if (activityUpdate.closing) {\n- // This was deprecated, but old clients are still sending it\n- continue;\n- }\nconst threadID = activityUpdate.threadID;\nunverifiedThreadIDs.add(threadID);\nlet updatesForThreadID = focusUpdatesByThreadID.get(threadID);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Remove unused activity update type Reviewers: ashoat Reviewed By: ashoat Subscribers: zrebcu411, KatPo, Adrian Differential Revision: https://phabricator.ashoat.com/D170
129,191
09.09.2020 16:36:15
-7,200
ba2653199f847fe47a57dc8cc21f659e1763d7c3
[native] Send thread status update to server Summary: Send a request after clicking a button. Close swipeable after click. Handling the response will be implemented in another diff Reviewers: ashoat, KatPo Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/actions/thread-actions.js", "new_path": "lib/actions/thread-actions.js", "diff": "@@ -8,6 +8,7 @@ import type {\nNewThreadResult,\nClientThreadJoinRequest,\nThreadJoinPayload,\n+ SetThreadUnreadStatusResult,\n} from '../types/thread-types';\nimport type { FetchJSON } from '../utils/fetch-json';\n@@ -154,6 +155,25 @@ async function leaveThread(\n};\n}\n+const setThreadUnreadStatusActionTypes = Object.freeze({\n+ started: 'SET_THREAD_UNREAD_STATUS_STARTED',\n+ success: 'SET_THREAD_UNREAD_STATUS_SUCCESS',\n+ failed: 'SET_THREAD_UNREAD_STATUS_FAILED',\n+});\n+async function setThreadUnreadStatus(\n+ fetchJSON: FetchJSON,\n+ threadID: string,\n+ unread: boolean,\n+): Promise<SetThreadUnreadStatusResult> {\n+ const response = await fetchJSON('set_thread_unread_status', {\n+ threadID,\n+ unread,\n+ });\n+ return {\n+ updatesResult: response.updatesResult,\n+ };\n+}\n+\nexport {\ndeleteThreadActionTypes,\ndeleteThread,\n@@ -169,4 +189,6 @@ export {\njoinThread,\nleaveThreadActionTypes,\nleaveThread,\n+ setThreadUnreadStatusActionTypes,\n+ setThreadUnreadStatus,\n};\n" }, { "change_type": "MODIFY", "old_path": "lib/types/endpoints.js", "new_path": "lib/types/endpoints.js", "diff": "@@ -68,6 +68,7 @@ const socketPreferredEndpoints = Object.freeze({\nCREATE_THREAD: 'create_thread',\nFETCH_MESSAGES: 'fetch_messages',\nJOIN_THREAD: 'join_thread',\n+ SET_THREAD_UNREAD_STATUS: 'set_thread_unread_status',\nCREATE_ERROR_REPORT: 'create_error_report',\nFETCH_ERROR_REPORT_INFOS: 'fetch_error_report_infos',\nREQUEST_ACCESS: 'request_access',\n" }, { "change_type": "MODIFY", "old_path": "lib/types/thread-types.js", "new_path": "lib/types/thread-types.js", "diff": "@@ -294,6 +294,16 @@ export type LeaveThreadPayload = {|\n},\n|};\n+export type SetThreadUnreadStatusRequest = {|\n+ +threadID: string,\n+ +unread: boolean,\n+|};\n+export type SetThreadUnreadStatusResult = {|\n+ +updatesResult: {|\n+ +newUpdates: $ReadOnlyArray<UpdateInfo>,\n+ |},\n+|};\n+\nexport type ThreadChanges = $Shape<{|\ntype: ThreadType,\nname: string,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list-item.react.js", "new_path": "native/chat/chat-thread-list-item.react.js", "diff": "@@ -5,10 +5,13 @@ import {\nchatThreadItemPropType,\n} from 'lib/selectors/chat-selectors';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n+import { useServerCall } from 'lib/utils/action-utils';\n+import { setThreadUnreadStatus } from 'lib/actions/thread-actions';\nimport * as React from 'react';\nimport { Text, View } from 'react-native';\nimport PropTypes from 'prop-types';\n+import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';\nimport Swipeable from '../components/swipeable';\nimport { useNavigation } from '@react-navigation/native';\n@@ -19,6 +22,7 @@ import MessagePreview from './message-preview.react';\nimport ColorSplotch from '../components/color-splotch.react';\nimport { useColors, useStyles } from '../themes/colors';\nimport { SingleLine } from '../components/single-line.react';\n+import { useMemo } from 'react';\nimport ChatThreadListSidebar from './chat-thread-list-sidebar.react';\ntype Props = {|\n@@ -30,12 +34,14 @@ type Props = {|\nfunction ChatThreadListItem({\ndata,\nonPressItem,\n+ onSwipeableWillOpen,\ncurrentlyOpenedSwipeableId,\n}: Props) {\nconst swipeable = React.useRef<?Swipeable>();\nconst navigation = useNavigation();\nconst styles = useStyles(unboundStyles);\nconst colors = useColors();\n+ const updateUnreadStatus = useServerCall(setThreadUnreadStatus);\nReact.useEffect(() => {\nreturn navigation.addListener('blur', () => {\n@@ -83,10 +89,44 @@ function ChatThreadListItem({\nonPressItem(data.threadInfo);\n}, [onPressItem, data.threadInfo]);\n+ const onSwipeableRightWillOpen = React.useCallback(() => {\n+ onSwipeableWillOpen(data.threadInfo);\n+ }, [onSwipeableWillOpen, data.threadInfo]);\n+\nconst lastActivity = shortAbsoluteDate(data.lastUpdatedTime);\nconst unreadStyle = data.threadInfo.currentUser.unread ? styles.unread : null;\n+\n+ const swipeableActions = useMemo(() => {\n+ const isUnread = data.threadInfo.currentUser.unread;\n+ const toggleUnreadStatus = () => {\n+ updateUnreadStatus(data.threadInfo.id, !isUnread);\n+ if (swipeable.current) {\n+ swipeable.current.close();\n+ }\n+ };\n+ return [\n+ {\n+ key: 'action1',\n+ onPress: toggleUnreadStatus,\n+ color: isUnread ? colors.redButton : colors.greenButton,\n+ content: (\n+ <MaterialIcon\n+ name={isUnread ? 'email-open-outline' : 'email-mark-as-unread'}\n+ size={24}\n+ />\n+ ),\n+ },\n+ ];\n+ }, [colors, data.threadInfo, updateUnreadStatus]);\n+\nreturn (\n<>\n+ <Swipeable\n+ buttonWidth={60}\n+ innerRef={swipeable}\n+ onSwipeableRightWillOpen={onSwipeableRightWillOpen}\n+ rightActions={swipeableActions}\n+ >\n<Button\nonPress={onPress}\niosFormat=\"highlight\"\n@@ -110,6 +150,7 @@ function ChatThreadListItem({\n</View>\n</View>\n</Button>\n+ </Swipeable>\n{sidebars}\n</>\n);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Send thread status update to server Summary: Send a request after clicking a button. Close swipeable after click. Handling the response will be implemented in another diff Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D75
129,191
09.09.2020 16:44:35
-7,200
1c3687c0b824734b27f539270c7b166a181c35e9
[server] Create new endpoint and update unread status Summary: Create a new endpoint. Update unread status in db. Sending the response will be implemented in another diff Reviewers: ashoat, KatPo Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/endpoints.js", "new_path": "server/src/endpoints.js", "diff": "@@ -42,6 +42,7 @@ import {\nthreadUpdateResponder,\nthreadCreationResponder,\nthreadJoinResponder,\n+ threadSetUnreadStatusResponder,\n} from './responders/thread-responders';\nimport {\nreportCreationResponder,\n@@ -74,6 +75,7 @@ const jsonEndpoints: { [id: Endpoint]: JSONResponder } = {\ncreate_thread: threadCreationResponder,\nfetch_messages: messageFetchResponder,\njoin_thread: threadJoinResponder,\n+ set_thread_unread_status: threadSetUnreadStatusResponder,\nlog_out: logOutResponder,\ndelete_account: accountDeletionResponder,\ncreate_account: accountCreationResponder,\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/thread-responders.js", "new_path": "server/src/responders/thread-responders.js", "diff": "@@ -12,6 +12,8 @@ import {\ntype NewThreadResponse,\ntype ServerThreadJoinRequest,\ntype ThreadJoinResult,\n+ type SetThreadUnreadStatusResult,\n+ type SetThreadUnreadStatusRequest,\nassertThreadType,\n} from 'lib/types/thread-types';\nimport type { Viewer } from '../session/viewer';\n@@ -34,6 +36,7 @@ import {\nleaveThread,\nupdateThread,\njoinThread,\n+ setThreadUnreadStatus,\n} from '../updaters/thread-updaters';\nimport createThread from '../creators/thread-creator';\nimport {\n@@ -210,6 +213,20 @@ async function threadJoinResponder(\nreturn await joinThread(viewer, request);\n}\n+const setThreadUnreadStatusValidator = tShape({\n+ threadID: t.String,\n+ unread: t.Boolean,\n+});\n+async function threadSetUnreadStatusResponder(\n+ viewer: Viewer,\n+ input: any,\n+): Promise<SetThreadUnreadStatusResult> {\n+ const request: SetThreadUnreadStatusRequest = input;\n+ await validateInput(viewer, setThreadUnreadStatusValidator, request);\n+\n+ return await setThreadUnreadStatus(viewer, request);\n+}\n+\nexport {\nthreadDeletionResponder,\nroleUpdateResponder,\n@@ -218,4 +235,5 @@ export {\nthreadUpdateResponder,\nthreadCreationResponder,\nthreadJoinResponder,\n+ threadSetUnreadStatusResponder,\n};\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -9,6 +9,8 @@ import {\ntype UpdateThreadRequest,\ntype ServerThreadJoinRequest,\ntype ThreadJoinResult,\n+ type SetThreadUnreadStatusRequest,\n+ type SetThreadUnreadStatusResult,\nthreadPermissions,\nthreadTypes,\nassertThreadType,\n@@ -625,4 +627,39 @@ async function joinThread(\nreturn response;\n}\n-export { updateRole, removeMembers, leaveThread, updateThread, joinThread };\n+async function setThreadUnreadStatus(\n+ viewer: Viewer,\n+ request: SetThreadUnreadStatusRequest,\n+): Promise<SetThreadUnreadStatusResult> {\n+ if (!viewer.loggedIn) {\n+ throw new ServerError('not_logged_in');\n+ }\n+\n+ const isMember = await viewerIsMember(viewer, request.threadID);\n+ if (!isMember) {\n+ throw new ServerError('invalid_parameters');\n+ }\n+\n+ const update = SQL`\n+ UPDATE memberships m\n+ SET m.unread = ${request.unread ? 1 : 0}\n+ WHERE m.thread = ${request.threadID} AND m.user = ${viewer.userID}\n+ `;\n+\n+ await dbQuery(update);\n+\n+ return {\n+ updatesResult: {\n+ newUpdates: [],\n+ },\n+ };\n+}\n+\n+export {\n+ updateRole,\n+ removeMembers,\n+ leaveThread,\n+ updateThread,\n+ joinThread,\n+ setThreadUnreadStatus,\n+};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Create new endpoint and update unread status Summary: Create a new endpoint. Update unread status in db. Sending the response will be implemented in another diff Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D76
129,191
10.09.2020 14:11:44
-7,200
914437e860f91363fbef0a5e3bc3b448536f7bce
[server] Send thread status updates response Summary: Create and return an update Reviewers: ashoat, KatPo Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -27,6 +27,7 @@ import { promiseAll } from 'lib/utils/promises';\nimport { permissionLookup } from 'lib/permissions/thread-permissions';\nimport { filteredThreadIDs } from 'lib/selectors/calendar-filter-selectors';\nimport { hasMinCodeVersion } from 'lib/shared/version-utils';\n+import { updateTypes } from 'lib/types/update-types';\nimport { dbQuery, SQL } from '../database';\nimport {\n@@ -48,6 +49,7 @@ import {\ngetParentThreadRelationshipRowsForNewUsers,\n} from './thread-permission-updaters';\nimport createMessages from '../creators/message-creator';\n+import { createUpdates } from '../creators/update-creator';\nimport { fetchMessageInfos } from '../fetchers/message-fetchers';\nimport { fetchEntryInfos } from '../fetchers/entry-fetchers';\nimport { updateRoles } from './role-updaters';\n@@ -646,11 +648,24 @@ async function setThreadUnreadStatus(\nWHERE m.thread = ${request.threadID} AND m.user = ${viewer.userID}\n`;\n- await dbQuery(update);\n-\n+ const queryPromise = dbQuery(update);\n+ const time = Date.now();\n+ const updatesPromise = createUpdates(\n+ [\n+ {\n+ type: updateTypes.UPDATE_THREAD_READ_STATUS,\n+ userID: viewer.userID,\n+ time: time,\n+ threadID: request.threadID,\n+ unread: request.unread,\n+ },\n+ ],\n+ { viewer, updatesForCurrentSession: 'ignore' },\n+ );\n+ const [updates] = await Promise.all([updatesPromise, queryPromise]);\nreturn {\nupdatesResult: {\n- newUpdates: [],\n+ newUpdates: updates.viewerUpdates,\n},\n};\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Send thread status updates response Summary: Create and return an update Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D80
129,191
11.09.2020 12:07:00
-7,200
32c8a7578d4e050ca12b987372130299c9b199d4
[web] Display three dots button Summary: Add a three dots button to each thread on the threads list Reviewers: ashoat, KatPo Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list-item.react.js", "new_path": "web/chat/chat-thread-list-item.react.js", "diff": "@@ -14,6 +14,8 @@ import type { DispatchActionPayload } from 'lib/utils/action-utils';\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\n+import { faEllipsisV } from '@fortawesome/free-solid-svg-icons';\n+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { shortAbsoluteDate } from 'lib/utils/date-utils';\n@@ -43,7 +45,8 @@ class ChatThreadListItem extends React.PureComponent<Props> {\nconst unread = item.threadInfo.currentUser.unread;\nconst activeStyle = this.props.active ? css.activeThread : null;\nreturn (\n- <a className={classNames(css.thread, activeStyle)} onClick={this.onClick}>\n+ <div className={classNames(css.thread, activeStyle)}>\n+ <a className={css.threadButton} onClick={this.onClick}>\n<div className={css.threadRow}>\n<div className={css.title}>{item.threadInfo.uiName}</div>\n<div className={css.colorSplotch} style={colorSplotchStyle} />\n@@ -63,6 +66,10 @@ class ChatThreadListItem extends React.PureComponent<Props> {\n</div>\n</div>\n</a>\n+ <button className={css.menu}>\n+ <FontAwesomeIcon icon={faEllipsisV} className={css.icon} />\n+ </button>\n+ </div>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list.css", "new_path": "web/chat/chat-thread-list.css", "diff": "-a.thread {\n- display: block;\n- padding: 5px 15px;\n- cursor: pointer;\n+div.thread {\n+ display: flex;\n+ flex-direction: row;\n+ padding: 5px 5px 5px 15px;\n}\n-a.thread:hover {\n+div.thread:hover {\nbackground-color: #EEEEEE;\n}\n-a.activeThread {\n+div.activeThread {\nbackground-color: #EEEEEE;\n}\n-a.thread div.title {\n+div.thread div.title {\nfont-family: 'Open Sans', sans-serif;\nfont-weight: 600;\nwhite-space: nowrap;\n@@ -17,6 +17,11 @@ a.thread div.title {\ntext-overflow: ellipsis;\ncolor: black;\n}\n+a.threadButton {\n+ flex: 1;\n+ cursor: pointer;\n+ overflow: hidden;\n+}\ndiv.threadRow {\ndisplay: flex;\njustify-content: space-between;\n@@ -49,3 +54,18 @@ div.dark {\ndiv.italic {\nfont-style: italic;\n}\n+\n+.menu {\n+ background-color: transparent;\n+ border: none;\n+ border-radius: 5px;\n+ cursor: pointer;\n+ padding: 0 10px;\n+ margin: 0 5px;\n+}\n+.menu:hover {\n+ background-color: #DDDDDD;\n+}\n+.icon {\n+ font-size: 26px;\n+}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Display three dots button Summary: Add a three dots button to each thread on the threads list Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D81
129,191
14.09.2020 12:14:36
-7,200
0c70480eec06d2e2fe8d7972771a9a7309ce6d5d
[web] Show the menu after clicking on button Summary: Show a menu with temporary buttons. Hide the menu after mouse leaves it Reviewers: ashoat, KatPo Subscribers: Adrian, zrebcu411
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list-item.react.js", "new_path": "web/chat/chat-thread-list-item.react.js", "diff": "@@ -29,7 +29,10 @@ type Props = {|\ntimeZone: ?string,\ndispatchActionPayload: DispatchActionPayload,\n|};\n-class ChatThreadListItem extends React.PureComponent<Props> {\n+type State = {|\n+ +menuVisible: boolean,\n+|};\n+class ChatThreadListItem extends React.PureComponent<Props, State> {\nstatic propTypes = {\nitem: chatThreadItemPropType.isRequired,\nactive: PropTypes.bool.isRequired,\n@@ -37,6 +40,9 @@ class ChatThreadListItem extends React.PureComponent<Props> {\ntimeZone: PropTypes.string,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\n+ state = {\n+ menuVisible: false,\n+ };\nrender() {\nconst { item, timeZone } = this.props;\n@@ -66,9 +72,28 @@ class ChatThreadListItem extends React.PureComponent<Props> {\n</div>\n</div>\n</a>\n- <button className={css.menu}>\n+ <div className={css.menu} onMouseLeave={this.hideMenu}>\n+ <button onClick={this.toggleMenu}>\n<FontAwesomeIcon icon={faEllipsisV} className={css.icon} />\n</button>\n+ <div\n+ className={classNames(css.menuContent, {\n+ [css.menuContentVisible]: this.state.menuVisible,\n+ })}\n+ >\n+ <ul>\n+ <li>\n+ <button>Mark as unread</button>\n+ </li>\n+ <li>\n+ <button>Mark as unread</button>\n+ </li>\n+ <li>\n+ <button>Mark as unread</button>\n+ </li>\n+ </ul>\n+ </div>\n+ </div>\n</div>\n);\n}\n@@ -80,6 +105,14 @@ class ChatThreadListItem extends React.PureComponent<Props> {\nactiveChatThreadID: this.props.item.threadInfo.id,\n});\n};\n+\n+ toggleMenu = () => {\n+ this.setState(state => ({ menuVisible: !state.menuVisible }));\n+ };\n+\n+ hideMenu = () => {\n+ this.setState({ menuVisible: false });\n+ };\n}\nexport default ChatThreadListItem;\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list.css", "new_path": "web/chat/chat-thread-list.css", "diff": "@@ -56,16 +56,51 @@ div.italic {\n}\n.menu {\n+ position: relative;\n+ display: flex;\n+ margin: 0 5px;\n+}\n+.menu > button {\nbackground-color: transparent;\nborder: none;\nborder-radius: 5px;\ncursor: pointer;\npadding: 0 10px;\n- margin: 0 5px;\n}\n-.menu:hover {\n+.menu > button:hover {\nbackground-color: #DDDDDD;\n}\n.icon {\nfont-size: 26px;\n}\n+\n+.menuContent {\n+ display: none;\n+ position: absolute;\n+ top: 41px;\n+ right: 0;\n+ z-index: 1;\n+ width: max-content;\n+ overflow: hidden;\n+ background-color: #EEEEEE;\n+ border-radius: 5px;\n+ box-shadow: 1px 1px 5px 2px #00000022;\n+}\n+.menuContentVisible {\n+ display: block;\n+}\n+.menuContent ul {\n+ list-style: none;\n+}\n+.menuContent li:not(:last-child) {\n+ border-bottom: 1px solid #DDDDDD;\n+}\n+.menuContent button {\n+ border: none;\n+ cursor: pointer;\n+ padding: 10px;\n+ font-size: 16px;\n+}\n+.menuContent button:hover {\n+ background-color: #DDDDDD;\n+}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Show the menu after clicking on button Summary: Show a menu with temporary buttons. Hide the menu after mouse leaves it Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: Adrian, zrebcu411 Differential Revision: https://phabricator.ashoat.com/D94
129,191
15.09.2020 14:33:29
-7,200
10a3dbd76cd7c743565c28cd09e7d74f0afdfe08
[server] Check if the latest message has changed Summary: Before updating the unread status, check if the latest message from the request matches the one from the sever Reviewers: ashoat, KatPo Subscribers: Adrian, zrebcu411
[ { "change_type": "MODIFY", "old_path": "lib/actions/thread-actions.js", "new_path": "lib/actions/thread-actions.js", "diff": "@@ -9,6 +9,7 @@ import type {\nClientThreadJoinRequest,\nThreadJoinPayload,\nSetThreadUnreadStatusResult,\n+ SetThreadUnreadStatusRequest,\n} from '../types/thread-types';\nimport type { FetchJSON } from '../utils/fetch-json';\n@@ -162,15 +163,11 @@ const setThreadUnreadStatusActionTypes = Object.freeze({\n});\nasync function setThreadUnreadStatus(\nfetchJSON: FetchJSON,\n- threadID: string,\n- unread: boolean,\n+ request: SetThreadUnreadStatusRequest,\n): Promise<SetThreadUnreadStatusResult> {\n- const response = await fetchJSON('set_thread_unread_status', {\n- threadID,\n- unread,\n- });\n+ const response = await fetchJSON('set_thread_unread_status', request);\nreturn {\n- updatesResult: response.updatesResult,\n+ unread: response.unread,\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/types/thread-types.js", "new_path": "lib/types/thread-types.js", "diff": "@@ -294,14 +294,11 @@ export type LeaveThreadPayload = {|\n},\n|};\n-export type SetThreadUnreadStatusRequest = {|\n- +threadID: string,\n- +unread: boolean,\n-|};\n+export type SetThreadUnreadStatusRequest =\n+ | {| +unread: true, +threadID: string |}\n+ | {| +unread: false, +threadID: string, +latestMessage: string |};\nexport type SetThreadUnreadStatusResult = {|\n- +updatesResult: {|\n- +newUpdates: $ReadOnlyArray<UpdateInfo>,\n- |},\n+ +resetToUnread: boolean,\n|};\nexport type ThreadChanges = $Shape<{|\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list-item.react.js", "new_path": "native/chat/chat-thread-list-item.react.js", "diff": "@@ -96,10 +96,19 @@ function ChatThreadListItem({\nconst lastActivity = shortAbsoluteDate(data.lastUpdatedTime);\nconst unreadStyle = data.threadInfo.currentUser.unread ? styles.unread : null;\n+ const mostRecentMessageId = data.mostRecentMessageInfo?.id ?? '0';\n+\nconst swipeableActions = useMemo(() => {\nconst isUnread = data.threadInfo.currentUser.unread;\nconst toggleUnreadStatus = () => {\n- updateUnreadStatus(data.threadInfo.id, !isUnread);\n+ const request = {\n+ threadID: data.threadInfo.id,\n+ unread: !isUnread,\n+ };\n+ if (isUnread) {\n+ request.latestMessage = mostRecentMessageId;\n+ }\n+ updateUnreadStatus(request);\nif (swipeable.current) {\nswipeable.current.close();\n}\n@@ -117,7 +126,7 @@ function ChatThreadListItem({\n),\n},\n];\n- }, [colors, data.threadInfo, updateUnreadStatus]);\n+ }, [colors, data.threadInfo, mostRecentMessageId, updateUnreadStatus]);\nreturn (\n<>\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/thread-responders.js", "new_path": "server/src/responders/thread-responders.js", "diff": "@@ -28,6 +28,7 @@ import {\ntNumEnum,\ntColor,\ntPassword,\n+ tBool,\n} from '../utils/validation-utils';\nimport { deleteThread } from '../deleters/thread-deleters';\nimport {\n@@ -213,10 +214,17 @@ async function threadJoinResponder(\nreturn await joinThread(viewer, request);\n}\n-const setThreadUnreadStatusValidator = tShape({\n+const setThreadUnreadStatusValidator = t.union([\n+ tShape({\nthreadID: t.String,\n- unread: t.Boolean,\n-});\n+ unread: tBool(true),\n+ }),\n+ tShape({\n+ threadID: t.String,\n+ unread: tBool(false),\n+ latestMessage: t.String,\n+ }),\n+]);\nasync function threadSetUnreadStatusResponder(\nviewer: Viewer,\ninput: any,\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -53,6 +53,7 @@ import { createUpdates } from '../creators/update-creator';\nimport { fetchMessageInfos } from '../fetchers/message-fetchers';\nimport { fetchEntryInfos } from '../fetchers/entry-fetchers';\nimport { updateRoles } from './role-updaters';\n+import { rescindPushNotifs } from '../push/rescind';\nasync function updateRole(\nviewer: Viewer,\n@@ -642,13 +643,16 @@ async function setThreadUnreadStatus(\nthrow new ServerError('invalid_parameters');\n}\n+ const resetThreadToUnread = await shouldResetThreadToUnread(viewer, request);\n+\n+ if (!resetThreadToUnread) {\nconst update = SQL`\nUPDATE memberships m\nSET m.unread = ${request.unread ? 1 : 0}\nWHERE m.thread = ${request.threadID} AND m.user = ${viewer.userID}\n`;\n-\nconst queryPromise = dbQuery(update);\n+\nconst time = Date.now();\nconst updatesPromise = createUpdates(\n[\n@@ -662,14 +666,49 @@ async function setThreadUnreadStatus(\n],\n{ viewer, updatesForCurrentSession: 'ignore' },\n);\n- const [updates] = await Promise.all([updatesPromise, queryPromise]);\n+\n+ await Promise.all([updatesPromise, queryPromise]);\n+ }\n+\n+ if (!request.unread) {\n+ const rescindCondition = SQL`\n+ n.user = ${viewer.userID} AND\n+ n.thread = ${request.threadID} AND\n+ n.message <= ${request.latestMessage}\n+ `;\n+ await rescindPushNotifs(rescindCondition);\n+ }\n+\nreturn {\n- updatesResult: {\n- newUpdates: updates.viewerUpdates,\n- },\n+ resetToUnread: resetThreadToUnread,\n};\n}\n+async function shouldResetThreadToUnread(\n+ viewer: Viewer,\n+ request: SetThreadUnreadStatusRequest,\n+): Promise<boolean> {\n+ if (request.unread || request.latestMessage.startsWith('local')) {\n+ return false;\n+ }\n+\n+ const knowOfExtractString = `$.${threadPermissions.KNOW_OF}.value`;\n+ const latestMessageQuery = SQL`\n+ SELECT MAX(m.id) AS id\n+ FROM messages m\n+ LEFT JOIN memberships stm ON m.type = ${messageTypes.CREATE_SUB_THREAD}\n+ AND stm.thread = m.content AND stm.user = ${viewer.userID}\n+ WHERE m.thread = ${request.threadID} AND\n+ (\n+ m.type != ${messageTypes.CREATE_SUB_THREAD} OR\n+ JSON_EXTRACT(stm.permissions, ${knowOfExtractString}) IS TRUE\n+ )\n+ `;\n+ const [result] = await dbQuery(latestMessageQuery);\n+\n+ return !!(result[0] && `${result[0].id}` !== request.latestMessage);\n+}\n+\nexport {\nupdateRole,\nremoveMembers,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Check if the latest message has changed Summary: Before updating the unread status, check if the latest message from the request matches the one from the sever Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: Adrian, zrebcu411 Differential Revision: https://phabricator.ashoat.com/D129
129,191
16.09.2020 15:11:37
-7,200
19dc3bb3ea552cf5918fc7f22c6d49cb3f1298db
[native] Update state after click and after successful response Summary: Update unread status just after clicking the button and when the response from the server arrives Reviewers: ashoat, KatPo Subscribers: Adrian, zrebcu411
[ { "change_type": "MODIFY", "old_path": "lib/actions/thread-actions.js", "new_path": "lib/actions/thread-actions.js", "diff": "@@ -8,8 +8,9 @@ import type {\nNewThreadResult,\nClientThreadJoinRequest,\nThreadJoinPayload,\n- SetThreadUnreadStatusResult,\nSetThreadUnreadStatusRequest,\n+ SetThreadUnreadStatusPayload,\n+ SetThreadUnreadStatusResult,\n} from '../types/thread-types';\nimport type { FetchJSON } from '../utils/fetch-json';\n@@ -164,10 +165,14 @@ const setThreadUnreadStatusActionTypes = Object.freeze({\nasync function setThreadUnreadStatus(\nfetchJSON: FetchJSON,\nrequest: SetThreadUnreadStatusRequest,\n-): Promise<SetThreadUnreadStatusResult> {\n- const response = await fetchJSON('set_thread_unread_status', request);\n+): Promise<SetThreadUnreadStatusPayload> {\n+ const response: SetThreadUnreadStatusResult = await fetchJSON(\n+ 'set_thread_unread_status',\n+ request,\n+ );\nreturn {\n- unread: response.unread,\n+ resetToUnread: response.resetToUnread,\n+ threadID: request.threadID,\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/reducers/thread-reducer.js", "new_path": "lib/reducers/thread-reducer.js", "diff": "@@ -44,6 +44,7 @@ import {\nchangeThreadMemberRolesActionTypes,\njoinThreadActionTypes,\nleaveThreadActionTypes,\n+ setThreadUnreadStatusActionTypes,\n} from '../actions/thread-actions';\nimport { saveMessagesActionType } from '../actions/message-actions';\nimport { getConfig } from '../utils/config';\n@@ -298,6 +299,43 @@ export default function reduceThreadInfos(\nthreadInfos: { ...state.threadInfos, ...updatedThreadInfos },\ninconsistencyReports: state.inconsistencyReports,\n};\n+ } else if (action.type === setThreadUnreadStatusActionTypes.started) {\n+ const { threadID, unread } = action.payload;\n+ return {\n+ ...state,\n+ threadInfos: {\n+ ...state.threadInfos,\n+ [threadID]: {\n+ ...state.threadInfos[threadID],\n+ currentUser: {\n+ ...state.threadInfos[threadID].currentUser,\n+ unread,\n+ },\n+ },\n+ },\n+ };\n+ } else if (action.type === setThreadUnreadStatusActionTypes.success) {\n+ const { threadID, resetToUnread } = action.payload;\n+ const currentUser = state.threadInfos[threadID].currentUser;\n+\n+ if (!resetToUnread || currentUser.unread) {\n+ return state;\n+ }\n+\n+ const updatedUser = {\n+ ...currentUser,\n+ unread: true,\n+ };\n+ return {\n+ ...state,\n+ threadInfos: {\n+ ...state.threadInfos,\n+ [threadID]: {\n+ ...state.threadInfos[threadID],\n+ currentUser: updatedUser,\n+ },\n+ },\n+ };\n}\nreturn state;\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/types/redux-types.js", "new_path": "lib/types/redux-types.js", "diff": "@@ -6,6 +6,7 @@ import type {\nLeaveThreadPayload,\nNewThreadResult,\nThreadJoinPayload,\n+ SetThreadUnreadStatusPayload,\n} from './thread-types';\nimport type {\nRawEntryInfo,\n@@ -791,6 +792,24 @@ export type BaseAction =\ntype: 'UPDATE_RELATIONSHIPS_SUCCESS',\npayload?: void,\nloadingInfo: LoadingInfo,\n+ |}\n+ | {|\n+ +type: 'SET_THREAD_UNREAD_STATUS_STARTED',\n+ +payload: {|\n+ +threadID: string,\n+ +unread: boolean,\n+ |},\n+ +loadingInfo: LoadingInfo,\n+ |}\n+ | {|\n+ +type: 'SET_THREAD_UNREAD_STATUS_FAILED',\n+ +error: true,\n+ +payload: Error,\n+ +loadingInfo: LoadingInfo,\n+ |}\n+ | {|\n+ +type: 'SET_THREAD_UNREAD_STATUS_SUCCESS',\n+ +payload: SetThreadUnreadStatusPayload,\n|};\nexport type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);\n" }, { "change_type": "MODIFY", "old_path": "lib/types/thread-types.js", "new_path": "lib/types/thread-types.js", "diff": "@@ -300,6 +300,10 @@ export type SetThreadUnreadStatusRequest =\nexport type SetThreadUnreadStatusResult = {|\n+resetToUnread: boolean,\n|};\n+export type SetThreadUnreadStatusPayload = {|\n+ ...SetThreadUnreadStatusResult,\n+ +threadID: string,\n+|};\nexport type ThreadChanges = $Shape<{|\ntype: ThreadType,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list-item.react.js", "new_path": "native/chat/chat-thread-list-item.react.js", "diff": "@@ -4,9 +4,19 @@ import {\ntype ChatThreadItem,\nchatThreadItemPropType,\n} from 'lib/selectors/chat-selectors';\n-import type { ThreadInfo } from 'lib/types/thread-types';\n-import { useServerCall } from 'lib/utils/action-utils';\n-import { setThreadUnreadStatus } from 'lib/actions/thread-actions';\n+import type {\n+ SetThreadUnreadStatusPayload,\n+ SetThreadUnreadStatusRequest,\n+ ThreadInfo,\n+} from 'lib/types/thread-types';\n+import {\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\n+import {\n+ setThreadUnreadStatus,\n+ setThreadUnreadStatusActionTypes,\n+} from 'lib/actions/thread-actions';\nimport * as React from 'react';\nimport { Text, View } from 'react-native';\n@@ -41,7 +51,12 @@ function ChatThreadListItem({\nconst navigation = useNavigation();\nconst styles = useStyles(unboundStyles);\nconst colors = useColors();\n- const updateUnreadStatus = useServerCall(setThreadUnreadStatus);\n+ const updateUnreadStatus: (\n+ request: SetThreadUnreadStatusRequest,\n+ ) => Promise<SetThreadUnreadStatusPayload> = useServerCall(\n+ setThreadUnreadStatus,\n+ );\n+ const dispatchActionPromise = useDispatchActionPromise();\nReact.useEffect(() => {\nreturn navigation.addListener('blur', () => {\n@@ -101,14 +116,22 @@ function ChatThreadListItem({\nconst swipeableActions = useMemo(() => {\nconst isUnread = data.threadInfo.currentUser.unread;\nconst toggleUnreadStatus = () => {\n- const request = {\n+ const request = isUnread\n+ ? {\n+ unread: false,\nthreadID: data.threadInfo.id,\n- unread: !isUnread,\n- };\n- if (isUnread) {\n- request.latestMessage = mostRecentMessageId;\n+ latestMessage: mostRecentMessageId,\n}\n- updateUnreadStatus(request);\n+ : { unread: true, threadID: data.threadInfo.id };\n+ dispatchActionPromise(\n+ setThreadUnreadStatusActionTypes,\n+ updateUnreadStatus(request),\n+ undefined,\n+ {\n+ threadID: data.threadInfo.id,\n+ unread: !isUnread,\n+ },\n+ );\nif (swipeable.current) {\nswipeable.current.close();\n}\n@@ -126,7 +149,13 @@ function ChatThreadListItem({\n),\n},\n];\n- }, [colors, data.threadInfo, mostRecentMessageId, updateUnreadStatus]);\n+ }, [\n+ colors,\n+ data.threadInfo,\n+ mostRecentMessageId,\n+ updateUnreadStatus,\n+ dispatchActionPromise,\n+ ]);\nreturn (\n<>\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Update state after click and after successful response Summary: Update unread status just after clicking the button and when the response from the server arrives Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: Adrian, zrebcu411 Differential Revision: https://phabricator.ashoat.com/D130
129,191
18.09.2020 17:54:43
-7,200
b31dd9318ab222c078248466ff062326cb81cf33
[server] Create a function which checks thread permission and membership Reviewers: ashoat, KatPo Subscribers: Adrian, zrebcu411
[ { "change_type": "MODIFY", "old_path": "server/src/fetchers/thread-permission-fetchers.js", "new_path": "server/src/fetchers/thread-permission-fetchers.js", "diff": "@@ -29,66 +29,73 @@ async function fetchThreadPermissionsBlob(\nreturn row.permissions;\n}\n-async function checkThreadPermission(\n+function checkThreadPermission(\nviewer: Viewer,\nthreadID: string,\npermission: ThreadPermission,\n): Promise<boolean> {\n- const permissionsBlob = await fetchThreadPermissionsBlob(viewer, threadID);\n- return permissionLookup(permissionsBlob, permission);\n+ return checkThread(viewer, threadID, [{ check: 'permission', permission }]);\n}\n-async function checkThreadPermissions(\n+function viewerIsMember(viewer: Viewer, threadID: string): Promise<boolean> {\n+ return checkThread(viewer, threadID, [{ check: 'is_member' }]);\n+}\n+\n+type Check =\n+ | {| +check: 'is_member' |}\n+ | {| +check: 'permission', +permission: ThreadPermission |};\n+\n+function isThreadValid(\n+ permissions: ?ThreadPermissionsBlob,\n+ role: number,\n+ checks: $ReadOnlyArray<Check>,\n+): boolean {\n+ for (const check of checks) {\n+ if (check.check === 'is_member') {\n+ if (role <= 0) {\n+ return false;\n+ }\n+ } else if (check.check === 'permission') {\n+ if (!permissionLookup(permissions, check.permission)) {\n+ return false;\n+ }\n+ }\n+ }\n+ return true;\n+}\n+\n+async function checkThreads(\nviewer: Viewer,\nthreadIDs: $ReadOnlyArray<string>,\n- permission: ThreadPermission,\n-): Promise<{ [threadID: string]: boolean }> {\n- const viewerID = viewer.id;\n+ checks: $ReadOnlyArray<Check>,\n+): Promise<Set<string>> {\nconst query = SQL`\n- SELECT thread, permissions\n+ SELECT thread, permissions, role\nFROM memberships\n- WHERE thread IN (${threadIDs}) AND user = ${viewerID}\n+ WHERE thread IN (${threadIDs}) AND user = ${viewer.userID}\n`;\nconst [result] = await dbQuery(query);\n- const permissionsBlobs = new Map();\n- for (let row of result) {\n- const threadID = row.thread.toString();\n- permissionsBlobs.set(threadID, row.permissions);\n- }\n-\n- const permissionByThread = {};\n- for (let threadID of threadIDs) {\n- const permissionsBlob = permissionsBlobs.get(threadID);\n- permissionByThread[threadID] = permissionLookup(\n- permissionsBlob,\n- permission,\n+ return new Set(\n+ result\n+ .filter(row => isThreadValid(row.permissions, row.role, checks))\n+ .map(row => row.thread.toString()),\n);\n}\n- return permissionByThread;\n-}\n-async function viewerIsMember(\n+async function checkThread(\nviewer: Viewer,\nthreadID: string,\n+ checks: $ReadOnlyArray<Check>,\n): Promise<boolean> {\n- const viewerID = viewer.id;\n- const query = SQL`\n- SELECT role\n- FROM memberships\n- WHERE user = ${viewerID} AND thread = ${threadID}\n- `;\n- const [result] = await dbQuery(query);\n- if (result.length === 0) {\n- return false;\n- }\n- const row = result[0];\n- return row.role > 0;\n+ const validThreads = await checkThreads(viewer, [threadID], checks);\n+ return validThreads.has(threadID);\n}\nexport {\nfetchThreadPermissionsBlob,\ncheckThreadPermission,\n- checkThreadPermissions,\nviewerIsMember,\n+ checkThreads,\n+ checkThread,\n};\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -19,7 +19,7 @@ import { rescindPushNotifs } from '../push/rescind';\nimport { createUpdates } from '../creators/update-creator';\nimport { deleteActivityForViewerSession } from '../deleters/activity-deleters';\nimport { earliestFocusedTimeConsideredCurrent } from '../shared/focused-times';\n-import { checkThreadPermissions } from '../fetchers/thread-permission-fetchers';\n+import { checkThreads } from '../fetchers/thread-permission-fetchers';\nasync function activityUpdater(\nviewer: Viewer,\n@@ -42,39 +42,28 @@ async function activityUpdater(\nupdatesForThreadID.push(activityUpdate);\n}\n- const permissionResults = await checkThreadPermissions(\n+ const viewerMemberThreads = await checkThreads(\nviewer,\n[...unverifiedThreadIDs],\n- threadPermissions.VISIBLE,\n+ [\n+ {\n+ check: 'is_member',\n+ },\n+ {\n+ check: 'permission',\n+ permission: threadPermissions.VISIBLE,\n+ },\n+ ],\n);\n- const verifiedThreadIDs = Object.keys(permissionResults).filter(\n- key => permissionResults[key],\n- );\n- if (verifiedThreadIDs.length === 0) {\n- return { unfocusedToUnread: [] };\n- }\n- const viewerMemberThreadsPromise = (async () => {\n- const membershipQuery = SQL`\n- SELECT thread\n- FROM memberships\n- WHERE role > 0\n- AND thread IN (${verifiedThreadIDs})\n- AND user = ${viewer.userID}\n- `;\n- const [membershipResult] = await dbQuery(membershipQuery);\n- const viewerMemberThreads = new Set();\n- for (let row of membershipResult) {\n- const threadID = row.thread.toString();\n- viewerMemberThreads.add(threadID);\n+ if (viewerMemberThreads.size === 0) {\n+ return { unfocusedToUnread: [] };\n}\n- return viewerMemberThreads;\n- })();\nconst currentlyFocused = [];\nconst unfocusedLatestMessages = new Map();\nconst rescindConditions = [];\n- for (let threadID of verifiedThreadIDs) {\n+ for (let threadID of viewerMemberThreads) {\nconst focusUpdates = focusUpdatesByThreadID.get(threadID);\ninvariant(focusUpdates, `no focusUpdate for thread ID ${threadID}`);\n@@ -102,10 +91,10 @@ async function activityUpdater(\nconst focusUpdatePromise = updateFocusedRows(viewer, currentlyFocused);\n- const [viewerMemberThreads, unfocusedToUnread] = await Promise.all([\n- viewerMemberThreadsPromise,\n- determineUnfocusedThreadsReadStatus(viewer, unfocusedLatestMessages),\n- ]);\n+ const unfocusedToUnread = await determineUnfocusedThreadsReadStatus(\n+ viewer,\n+ unfocusedLatestMessages,\n+ );\nconst setToRead = [...currentlyFocused];\nconst setToUnread = [];\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -24,7 +24,6 @@ import invariant from 'invariant';\nimport { ServerError } from 'lib/utils/errors';\nimport { promiseAll } from 'lib/utils/promises';\n-import { permissionLookup } from 'lib/permissions/thread-permissions';\nimport { filteredThreadIDs } from 'lib/selectors/calendar-filter-selectors';\nimport { hasMinCodeVersion } from 'lib/shared/version-utils';\nimport { updateTypes } from 'lib/types/update-types';\n@@ -39,7 +38,7 @@ import { fetchServerThreadInfos } from '../fetchers/thread-fetchers';\nimport {\ncheckThreadPermission,\nviewerIsMember,\n- fetchThreadPermissionsBlob,\n+ checkThread,\n} from '../fetchers/thread-permission-fetchers';\nimport {\nchangeRole,\n@@ -311,13 +310,6 @@ async function updateThread(\n}\nconst parentThreadID = request.changes.parentThreadID;\nif (parentThreadID !== undefined) {\n- if (parentThreadID !== null) {\n- validationPromises.canMoveThread = checkThreadPermission(\n- viewer,\n- parentThreadID,\n- threadPermissions.CREATE_SUBTHREADS,\n- );\n- }\n// TODO some sort of message when this changes\nsqlUpdate.parent_thread_id = parentThreadID;\n}\n@@ -332,6 +324,11 @@ async function updateThread(\nrequest.changes.newMemberIDs && request.changes.newMemberIDs.length > 0\n? [...request.changes.newMemberIDs]\n: null;\n+\n+ if (Object.keys(sqlUpdate).length === 0 && !newMemberIDs) {\n+ throw new ServerError('invalid_parameters');\n+ }\n+\nif (newMemberIDs) {\nvalidationPromises.fetchNewMembers = fetchKnownUserInfos(\nviewer,\n@@ -339,11 +336,6 @@ async function updateThread(\n);\n}\n- validationPromises.threadPermissionsBlob = fetchThreadPermissionsBlob(\n- viewer,\n- request.threadID,\n- );\n-\n// Two unrelated purposes for this query:\n// - get hash for viewer password check (users table)\n// - get current value of type, parent_thread_id (threads table)\n@@ -355,15 +347,46 @@ async function updateThread(\n`;\nvalidationPromises.validationQuery = dbQuery(validationQuery);\n+ const checks = [];\n+ if (sqlUpdate.name || sqlUpdate.description || sqlUpdate.color) {\n+ checks.push({\n+ check: 'permission',\n+ permission: threadPermissions.EDIT_THREAD,\n+ });\n+ }\n+ if (sqlUpdate.parent_thread_id !== undefined || sqlUpdate.type) {\n+ checks.push({\n+ check: 'permission',\n+ permission: threadPermissions.EDIT_PERMISSIONS,\n+ });\n+ }\n+ if (newMemberIDs) {\n+ checks.push({\n+ check: 'permission',\n+ permission: threadPermissions.ADD_MEMBERS,\n+ });\n+ }\n+ if (\n+ sqlUpdate.parent_thread_id !== null &&\n+ sqlUpdate.parent_thread_id !== undefined\n+ ) {\n+ checks.push({\n+ check: 'permission',\n+ permission: threadPermissions.CREATE_SUBTHREADS,\n+ });\n+ }\n+\n+ validationPromises.hasNecessaryPermissions = checkThread(\n+ viewer,\n+ request.threadID,\n+ checks,\n+ );\n+\nconst {\n- canMoveThread,\n- threadPermissionsBlob,\nfetchNewMembers,\nvalidationQuery: [validationResult],\n+ hasNecessaryPermissions,\n} = await promiseAll(validationPromises);\n- if (canMoveThread === false) {\n- throw new ServerError('invalid_credentials');\n- }\nif (fetchNewMembers) {\ninvariant(newMemberIDs, 'should be set');\nfor (const newMemberID of newMemberIDs) {\n@@ -373,48 +396,22 @@ async function updateThread(\n}\n}\n- if (Object.keys(sqlUpdate).length === 0 && !newMemberIDs) {\n- throw new ServerError('invalid_parameters');\n- }\n-\nif (validationResult.length === 0 || validationResult[0].type === null) {\nthrow new ServerError('internal_error');\n}\nconst validationRow = validationResult[0];\n- if (sqlUpdate.name || sqlUpdate.description || sqlUpdate.color) {\n- const canEditThread = permissionLookup(\n- threadPermissionsBlob,\n- threadPermissions.EDIT_THREAD,\n- );\n- if (!canEditThread) {\n- throw new ServerError('invalid_credentials');\n- }\n- }\n- if (sqlUpdate.parent_thread_id || sqlUpdate.type) {\n- const canEditPermissions = permissionLookup(\n- threadPermissionsBlob,\n- threadPermissions.EDIT_PERMISSIONS,\n- );\n- if (!canEditPermissions) {\n+ if (!hasNecessaryPermissions) {\nthrow new ServerError('invalid_credentials');\n}\n+\nif (\n- !request.accountPassword ||\n- !bcrypt.compareSync(request.accountPassword, validationRow.hash)\n+ (sqlUpdate.parent_thread_id !== undefined || sqlUpdate.type) &&\n+ (!request.accountPassword ||\n+ !bcrypt.compareSync(request.accountPassword, validationRow.hash))\n) {\nthrow new ServerError('invalid_credentials');\n}\n- }\n- if (newMemberIDs) {\n- const canAddMembers = permissionLookup(\n- threadPermissionsBlob,\n- threadPermissions.ADD_MEMBERS,\n- );\n- if (!canAddMembers) {\n- throw new ServerError('invalid_credentials');\n- }\n- }\nconst oldThreadType = assertThreadType(validationRow.type);\nconst oldParentThreadID = validationRow.parentThreadID\n@@ -638,8 +635,16 @@ async function setThreadUnreadStatus(\nthrow new ServerError('not_logged_in');\n}\n- const isMember = await viewerIsMember(viewer, request.threadID);\n- if (!isMember) {\n+ const isMemberAndCanViewThread = await checkThread(viewer, request.threadID, [\n+ {\n+ check: 'is_member',\n+ },\n+ {\n+ check: 'permission',\n+ permission: threadPermissions.VISIBLE,\n+ },\n+ ]);\n+ if (!isMemberAndCanViewThread) {\nthrow new ServerError('invalid_parameters');\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Create a function which checks thread permission and membership Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: Adrian, zrebcu411 Differential Revision: https://phabricator.ashoat.com/D139
129,191
18.09.2020 18:10:29
-7,200
56c3d22b8ab0be7c5c39b82ea79a43c85abddfbe
[web] Display only one button with correct message and fix icon style Reviewers: ashoat, KatPo Subscribers: Adrian, zrebcu411
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list-item.react.js", "new_path": "web/chat/chat-thread-list-item.react.js", "diff": "@@ -74,7 +74,7 @@ class ChatThreadListItem extends React.PureComponent<Props, State> {\n</a>\n<div className={css.menu} onMouseLeave={this.hideMenu}>\n<button onClick={this.toggleMenu}>\n- <FontAwesomeIcon icon={faEllipsisV} className={css.icon} />\n+ <FontAwesomeIcon icon={faEllipsisV} />\n</button>\n<div\nclassName={classNames(css.menuContent, {\n@@ -83,13 +83,11 @@ class ChatThreadListItem extends React.PureComponent<Props, State> {\n>\n<ul>\n<li>\n- <button>Mark as unread</button>\n- </li>\n- <li>\n- <button>Mark as unread</button>\n- </li>\n- <li>\n- <button>Mark as unread</button>\n+ <button>\n+ {`Mark as ${\n+ item.threadInfo.currentUser.unread ? 'read' : 'unread'\n+ }`}\n+ </button>\n</li>\n</ul>\n</div>\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list.css", "new_path": "web/chat/chat-thread-list.css", "diff": "@@ -70,7 +70,7 @@ div.italic {\n.menu > button:hover {\nbackground-color: #DDDDDD;\n}\n-.icon {\n+.menu > button svg {\nfont-size: 26px;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Display only one button with correct message and fix icon style Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: Adrian, zrebcu411 Differential Revision: https://phabricator.ashoat.com/D140
129,191
18.09.2020 18:42:04
-7,200
d88891ff15fffe7a82de24f5bbb28ea0a13ca5ba
[web] Dispatch thread unread status update Reviewers: ashoat, KatPo Subscribers: Adrian, zrebcu411
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list-item.react.js", "new_path": "web/chat/chat-thread-list-item.react.js", "diff": "@@ -4,12 +4,18 @@ import {\ntype ChatThreadItem,\nchatThreadItemPropType,\n} from 'lib/selectors/chat-selectors';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport {\ntype NavInfo,\nnavInfoPropType,\nupdateNavInfoActionType,\n} from '../redux/redux-setup';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import { setThreadUnreadStatusActionTypes } from 'lib/actions/thread-actions';\n+import type {\n+ SetThreadUnreadStatusPayload,\n+ SetThreadUnreadStatusRequest,\n+} from 'lib/types/thread-types';\nimport * as React from 'react';\nimport classNames from 'classnames';\n@@ -23,11 +29,15 @@ import css from './chat-thread-list.css';\nimport MessagePreview from './message-preview.react';\ntype Props = {|\n- item: ChatThreadItem,\n- active: boolean,\n- navInfo: NavInfo,\n- timeZone: ?string,\n- dispatchActionPayload: DispatchActionPayload,\n+ +item: ChatThreadItem,\n+ +active: boolean,\n+ +navInfo: NavInfo,\n+ +timeZone: ?string,\n+ +dispatch: Dispatch,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ +setThreadUnreadStatus: (\n+ request: SetThreadUnreadStatusRequest,\n+ ) => Promise<SetThreadUnreadStatusPayload>,\n|};\ntype State = {|\n+menuVisible: boolean,\n@@ -38,7 +48,9 @@ class ChatThreadListItem extends React.PureComponent<Props, State> {\nactive: PropTypes.bool.isRequired,\nnavInfo: navInfoPropType.isRequired,\ntimeZone: PropTypes.string,\n- dispatchActionPayload: PropTypes.func.isRequired,\n+ dispatch: PropTypes.func.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ setThreadUnreadStatus: PropTypes.func.isRequired,\n};\nstate = {\nmenuVisible: false,\n@@ -83,7 +95,7 @@ class ChatThreadListItem extends React.PureComponent<Props, State> {\n>\n<ul>\n<li>\n- <button>\n+ <button onClick={this.toggleUnreadStatus}>\n{`Mark as ${\nitem.threadInfo.currentUser.unread ? 'read' : 'unread'\n}`}\n@@ -98,9 +110,12 @@ class ChatThreadListItem extends React.PureComponent<Props, State> {\nonClick = (event: SyntheticEvent<HTMLAnchorElement>) => {\nevent.preventDefault();\n- this.props.dispatchActionPayload(updateNavInfoActionType, {\n+ this.props.dispatch({\n+ type: updateNavInfoActionType,\n+ payload: {\n...this.props.navInfo,\nactiveChatThreadID: this.props.item.threadInfo.id,\n+ },\n});\n};\n@@ -111,6 +126,31 @@ class ChatThreadListItem extends React.PureComponent<Props, State> {\nhideMenu = () => {\nthis.setState({ menuVisible: false });\n};\n+\n+ toggleUnreadStatus = () => {\n+ const { threadInfo, mostRecentMessageInfo } = this.props.item;\n+ const isUnread = threadInfo.currentUser.unread;\n+ const request = isUnread\n+ ? {\n+ threadID: threadInfo.id,\n+ unread: !isUnread,\n+ latestMessage: mostRecentMessageInfo?.id ?? '0',\n+ }\n+ : {\n+ threadID: threadInfo.id,\n+ unread: !isUnread,\n+ };\n+ this.props.dispatchActionPromise(\n+ setThreadUnreadStatusActionTypes,\n+ this.props.setThreadUnreadStatus(request),\n+ undefined,\n+ {\n+ threadID: threadInfo.id,\n+ unread: !threadInfo.currentUser.unread,\n+ },\n+ );\n+ this.hideMenu();\n+ };\n}\nexport default ChatThreadListItem;\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list.react.js", "new_path": "web/chat/chat-thread-list.react.js", "diff": "// @flow\n-import {\n- type AppState,\n- type NavInfo,\n- navInfoPropType,\n-} from '../redux/redux-setup';\n+import { type NavInfo, navInfoPropType } from '../redux/redux-setup';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport {\ntype ChatThreadItem,\nchatThreadItemPropType,\n} from 'lib/selectors/chat-selectors';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import type { ThreadInfo } from 'lib/types/thread-types';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type {\n+ SetThreadUnreadStatusPayload,\n+ SetThreadUnreadStatusRequest,\n+ ThreadInfo,\n+} from 'lib/types/thread-types';\n+import { setThreadUnreadStatus } from 'lib/actions/thread-actions';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n+import { useDispatch, useSelector } from 'react-redux';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\nimport { webChatListData } from '../selectors/chat-selectors';\nimport ChatThreadListItem from './chat-thread-list-item.react';\n+type BaseProps = {|\n+ +filterThreads: (threadItem: ThreadInfo) => boolean,\n+ +emptyItem?: React.ComponentType<{||}>,\n+|};\ntype Props = {|\n- filterThreads: (threadItem: ThreadInfo) => boolean,\n- emptyItem?: React.ComponentType<{||}>,\n+ ...BaseProps,\n// Redux state\n- chatListData: $ReadOnlyArray<ChatThreadItem>,\n- navInfo: NavInfo,\n- timeZone: ?string,\n+ +chatListData: $ReadOnlyArray<ChatThreadItem>,\n+ +navInfo: NavInfo,\n+ +timeZone: ?string,\n// Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n+ +dispatch: Dispatch,\n+ +dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ +setThreadUnreadStatus: (\n+ request: SetThreadUnreadStatusRequest,\n+ ) => Promise<SetThreadUnreadStatusPayload>,\n|};\nclass ChatThreadList extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -37,7 +51,9 @@ class ChatThreadList extends React.PureComponent<Props> {\nchatListData: PropTypes.arrayOf(chatThreadItemPropType).isRequired,\nnavInfo: navInfoPropType.isRequired,\ntimeZone: PropTypes.string,\n- dispatchActionPayload: PropTypes.func.isRequired,\n+ dispatch: PropTypes.func.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ setThreadUnreadStatus: PropTypes.func.isRequired,\n};\nrender() {\n@@ -49,7 +65,9 @@ class ChatThreadList extends React.PureComponent<Props> {\nactive={item.threadInfo.id === this.props.navInfo.activeChatThreadID}\nnavInfo={this.props.navInfo}\ntimeZone={this.props.timeZone}\n- dispatchActionPayload={this.props.dispatchActionPayload}\n+ dispatch={this.props.dispatch}\n+ dispatchActionPromise={this.props.dispatchActionPromise}\n+ setThreadUnreadStatus={this.props.setThreadUnreadStatus}\nkey={item.threadInfo.id}\n/>\n));\n@@ -63,12 +81,25 @@ class ChatThreadList extends React.PureComponent<Props> {\n}\n}\n-export default connect(\n- (state: AppState) => ({\n- chatListData: webChatListData(state),\n- navInfo: state.navInfo,\n- timeZone: state.timeZone,\n- }),\n- null,\n- true,\n-)(ChatThreadList);\n+export default React.memo<BaseProps>(function ConnectedChatThreadList(\n+ props: BaseProps,\n+) {\n+ const chatListData = useSelector(webChatListData);\n+ const navInfo = useSelector(state => state.navInfo);\n+ const timeZone = useSelector(state => state.timeZone);\n+ const dispatch = useDispatch();\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callSetThreadUnreadStatus = useServerCall(setThreadUnreadStatus);\n+\n+ return (\n+ <ChatThreadList\n+ {...props}\n+ chatListData={chatListData}\n+ navInfo={navInfo}\n+ timeZone={timeZone}\n+ dispatch={dispatch}\n+ dispatchActionPromise={dispatchActionPromise}\n+ setThreadUnreadStatus={callSetThreadUnreadStatus}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Dispatch thread unread status update Reviewers: ashoat, KatPo Reviewed By: ashoat Subscribers: Adrian, zrebcu411 Differential Revision: https://phabricator.ashoat.com/D141
129,191
30.09.2020 16:36:40
-7,200
1cf189f43757c81af65cab2e6cc9f3cf778a80e2
[server] Use existing determineUnfocusedThreadsReadStatus function Summary: Instead of creating a new function, it's possible to use the existing one Reviewers: ashoat Subscribers: zrebcu411, KatPo, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -190,7 +190,7 @@ async function updateFocusedRows(\n// is no longer the latest message ID.\n// Returns the set of unfocused threads that should be set to unread on\n// the client because a new message arrived since they were unfocused.\n-async function determineUnfocusedThreadsReadStatus(\n+export async function determineUnfocusedThreadsReadStatus(\nviewer: Viewer,\nunfocusedLatestMessages: Map<string, string>,\n): Promise<string[]> {\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -53,6 +53,7 @@ import { fetchMessageInfos } from '../fetchers/message-fetchers';\nimport { fetchEntryInfos } from '../fetchers/entry-fetchers';\nimport { updateRoles } from './role-updaters';\nimport { rescindPushNotifs } from '../push/rescind';\n+import { determineUnfocusedThreadsReadStatus } from './activity-updaters';\nasync function updateRole(\nviewer: Viewer,\n@@ -697,21 +698,12 @@ async function shouldResetThreadToUnread(\nreturn false;\n}\n- const knowOfExtractString = `$.${threadPermissions.KNOW_OF}.value`;\n- const latestMessageQuery = SQL`\n- SELECT MAX(m.id) AS id\n- FROM messages m\n- LEFT JOIN memberships stm ON m.type = ${messageTypes.CREATE_SUB_THREAD}\n- AND stm.thread = m.content AND stm.user = ${viewer.userID}\n- WHERE m.thread = ${request.threadID} AND\n- (\n- m.type != ${messageTypes.CREATE_SUB_THREAD} OR\n- JSON_EXTRACT(stm.permissions, ${knowOfExtractString}) IS TRUE\n- )\n- `;\n- const [result] = await dbQuery(latestMessageQuery);\n+ const resetToUnread = await determineUnfocusedThreadsReadStatus(\n+ viewer,\n+ new Map([[request.threadID, request.latestMessage]]),\n+ );\n- return !!(result[0] && `${result[0].id}` !== request.latestMessage);\n+ return resetToUnread.some(threadID => threadID === request.threadID);\n}\nexport {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Use existing determineUnfocusedThreadsReadStatus function Summary: Instead of creating a new function, it's possible to use the existing one Reviewers: ashoat Reviewed By: ashoat Subscribers: zrebcu411, KatPo, Adrian Differential Revision: https://phabricator.ashoat.com/D169
129,187
01.10.2020 22:29:02
14,400
0ae85889a67e1d4845537d459a5af876d699dcaf
[native] Use hooks for data-binding in ThreadSettingsHomeNotifs Reviewers: palys-swm, KatPo Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-home-notifs.react.js", "new_path": "native/chat/settings/thread-settings-home-notifs.react.js", "diff": "// @flow\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import type { AppState } from '../../redux/redux-setup';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type {\nSubscriptionUpdateRequest,\n@@ -12,27 +11,33 @@ import * as React from 'react';\nimport { Text, View, Switch } from 'react-native';\nimport PropTypes from 'prop-types';\n-import { connect } from 'lib/utils/redux-utils';\nimport {\nupdateSubscriptionActionTypes,\nupdateSubscription,\n} from 'lib/actions/user-actions';\n+import {\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\n-import { styleSelector } from '../../themes/colors';\n+import { useStyles } from '../../themes/colors';\n+type BaseProps = {|\n+ +threadInfo: ThreadInfo,\n+|};\ntype Props = {|\n- threadInfo: ThreadInfo,\n+ ...BaseProps,\n// Redux state\n- styles: typeof styles,\n+ +styles: typeof unboundStyles,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- updateSubscription: (\n+ +updateSubscription: (\nsubscriptionUpdate: SubscriptionUpdateRequest,\n) => Promise<SubscriptionUpdateResult>,\n|};\ntype State = {|\n- currentValue: boolean,\n+ +currentValue: boolean,\n|};\nclass ThreadSettingsHomeNotifs extends React.PureComponent<Props, State> {\nstatic propTypes = {\n@@ -77,7 +82,7 @@ class ThreadSettingsHomeNotifs extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ncurrentValue: {\nalignItems: 'flex-end',\nflex: 1,\n@@ -99,11 +104,19 @@ const styles = {\npaddingVertical: 3,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect(\n- (state: AppState) => ({\n- styles: stylesSelector(state),\n- }),\n- { updateSubscription },\n-)(ThreadSettingsHomeNotifs);\n+export default React.memo<BaseProps>(function ConnectedThreadSettingsHomeNotifs(\n+ props: BaseProps,\n+) {\n+ const styles = useStyles(unboundStyles);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callUpdateSubscription = useServerCall(updateSubscription);\n+ return (\n+ <ThreadSettingsHomeNotifs\n+ {...props}\n+ styles={styles}\n+ dispatchActionPromise={dispatchActionPromise}\n+ updateSubscription={callUpdateSubscription}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hooks for data-binding in ThreadSettingsHomeNotifs Reviewers: palys-swm, KatPo Reviewed By: palys-swm, KatPo Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D174
129,191
01.10.2020 15:23:59
-7,200
1707d140ac196a4005815abc0c5f5ea8b82077b5
[server] Move shouldResetThreadToUnread to activity-updaters Reviewers: ashoat Subscribers: zrebcu411, KatPo, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/endpoints.js", "new_path": "server/src/endpoints.js", "diff": "@@ -8,7 +8,10 @@ import {\nmessageFetchResponder,\nmultimediaMessageCreationResponder,\n} from './responders/message-responders';\n-import { updateActivityResponder } from './responders/activity-responders';\n+import {\n+ updateActivityResponder,\n+ threadSetUnreadStatusResponder,\n+} from './responders/activity-responders';\nimport { deviceTokenUpdateResponder } from './responders/device-responders';\nimport {\nuserSubscriptionUpdateResponder,\n@@ -42,7 +45,6 @@ import {\nthreadUpdateResponder,\nthreadCreationResponder,\nthreadJoinResponder,\n- threadSetUnreadStatusResponder,\n} from './responders/thread-responders';\nimport {\nreportCreationResponder,\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/activity-responders.js", "new_path": "server/src/responders/activity-responders.js", "diff": "@@ -5,10 +5,17 @@ import type {\nUpdateActivityResult,\nUpdateActivityRequest,\n} from 'lib/types/activity-types';\n+import type {\n+ SetThreadUnreadStatusRequest,\n+ SetThreadUnreadStatusResult,\n+} from 'lib/types/thread-types';\nimport t from 'tcomb';\n-import { activityUpdater } from '../updaters/activity-updaters';\n+import {\n+ activityUpdater,\n+ setThreadUnreadStatus,\n+} from '../updaters/activity-updaters';\nimport { validateInput, tBool, tShape } from '../utils/validation-utils';\nconst activityUpdatesInputValidator = t.list(\n@@ -38,4 +45,29 @@ async function updateActivityResponder(\nreturn await activityUpdater(viewer, request);\n}\n-export { activityUpdatesInputValidator, updateActivityResponder };\n+const setThreadUnreadStatusValidator = t.union([\n+ tShape({\n+ threadID: t.String,\n+ unread: tBool(true),\n+ }),\n+ tShape({\n+ threadID: t.String,\n+ unread: tBool(false),\n+ latestMessage: t.String,\n+ }),\n+]);\n+async function threadSetUnreadStatusResponder(\n+ viewer: Viewer,\n+ input: any,\n+): Promise<SetThreadUnreadStatusResult> {\n+ const request: SetThreadUnreadStatusRequest = input;\n+ await validateInput(viewer, setThreadUnreadStatusValidator, request);\n+\n+ return await setThreadUnreadStatus(viewer, request);\n+}\n+\n+export {\n+ activityUpdatesInputValidator,\n+ updateActivityResponder,\n+ threadSetUnreadStatusResponder,\n+};\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/thread-responders.js", "new_path": "server/src/responders/thread-responders.js", "diff": "@@ -12,8 +12,6 @@ import {\ntype NewThreadResponse,\ntype ServerThreadJoinRequest,\ntype ThreadJoinResult,\n- type SetThreadUnreadStatusResult,\n- type SetThreadUnreadStatusRequest,\nassertThreadType,\n} from 'lib/types/thread-types';\nimport type { Viewer } from '../session/viewer';\n@@ -28,7 +26,6 @@ import {\ntNumEnum,\ntColor,\ntPassword,\n- tBool,\n} from '../utils/validation-utils';\nimport { deleteThread } from '../deleters/thread-deleters';\nimport {\n@@ -37,7 +34,6 @@ import {\nleaveThread,\nupdateThread,\njoinThread,\n- setThreadUnreadStatus,\n} from '../updaters/thread-updaters';\nimport createThread from '../creators/thread-creator';\nimport {\n@@ -214,27 +210,6 @@ async function threadJoinResponder(\nreturn await joinThread(viewer, request);\n}\n-const setThreadUnreadStatusValidator = t.union([\n- tShape({\n- threadID: t.String,\n- unread: tBool(true),\n- }),\n- tShape({\n- threadID: t.String,\n- unread: tBool(false),\n- latestMessage: t.String,\n- }),\n-]);\n-async function threadSetUnreadStatusResponder(\n- viewer: Viewer,\n- input: any,\n-): Promise<SetThreadUnreadStatusResult> {\n- const request: SetThreadUnreadStatusRequest = input;\n- await validateInput(viewer, setThreadUnreadStatusValidator, request);\n-\n- return await setThreadUnreadStatus(viewer, request);\n-}\n-\nexport {\nthreadDeletionResponder,\nroleUpdateResponder,\n@@ -243,5 +218,4 @@ export {\nthreadUpdateResponder,\nthreadCreationResponder,\nthreadJoinResponder,\n- threadSetUnreadStatusResponder,\n};\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -6,7 +6,11 @@ import type {\nUpdateActivityRequest,\n} from 'lib/types/activity-types';\nimport { messageTypes } from 'lib/types/message-types';\n-import { threadPermissions } from 'lib/types/thread-types';\n+import {\n+ threadPermissions,\n+ type SetThreadUnreadStatusRequest,\n+ type SetThreadUnreadStatusResult,\n+} from 'lib/types/thread-types';\nimport { updateTypes } from 'lib/types/update-types';\nimport invariant from 'invariant';\n@@ -19,7 +23,10 @@ import { rescindPushNotifs } from '../push/rescind';\nimport { createUpdates } from '../creators/update-creator';\nimport { deleteActivityForViewerSession } from '../deleters/activity-deleters';\nimport { earliestFocusedTimeConsideredCurrent } from '../shared/focused-times';\n-import { checkThreads } from '../fetchers/thread-permission-fetchers';\n+import {\n+ checkThread,\n+ checkThreads,\n+} from '../fetchers/thread-permission-fetchers';\nasync function activityUpdater(\nviewer: Viewer,\n@@ -190,7 +197,7 @@ async function updateFocusedRows(\n// is no longer the latest message ID.\n// Returns the set of unfocused threads that should be set to unread on\n// the client because a new message arrived since they were unfocused.\n-export async function determineUnfocusedThreadsReadStatus(\n+async function determineUnfocusedThreadsReadStatus(\nviewer: Viewer,\nunfocusedLatestMessages: Map<string, string>,\n): Promise<string[]> {\n@@ -266,6 +273,84 @@ async function checkThreadsFocused(\nreturn focusedThreadIDs;\n}\n+async function setThreadUnreadStatus(\n+ viewer: Viewer,\n+ request: SetThreadUnreadStatusRequest,\n+): Promise<SetThreadUnreadStatusResult> {\n+ if (!viewer.loggedIn) {\n+ throw new ServerError('not_logged_in');\n+ }\n+\n+ const isMemberAndCanViewThread = await checkThread(viewer, request.threadID, [\n+ {\n+ check: 'is_member',\n+ },\n+ {\n+ check: 'permission',\n+ permission: threadPermissions.VISIBLE,\n+ },\n+ ]);\n+ if (!isMemberAndCanViewThread) {\n+ throw new ServerError('invalid_parameters');\n+ }\n+\n+ const resetThreadToUnread = await shouldResetThreadToUnread(viewer, request);\n+\n+ if (!resetThreadToUnread) {\n+ const update = SQL`\n+ UPDATE memberships m\n+ SET m.unread = ${request.unread ? 1 : 0}\n+ WHERE m.thread = ${request.threadID} AND m.user = ${viewer.userID}\n+ `;\n+ const queryPromise = dbQuery(update);\n+\n+ const time = Date.now();\n+ const updatesPromise = createUpdates(\n+ [\n+ {\n+ type: updateTypes.UPDATE_THREAD_READ_STATUS,\n+ userID: viewer.userID,\n+ time: time,\n+ threadID: request.threadID,\n+ unread: request.unread,\n+ },\n+ ],\n+ { viewer, updatesForCurrentSession: 'ignore' },\n+ );\n+\n+ await Promise.all([updatesPromise, queryPromise]);\n+ }\n+\n+ if (!request.unread) {\n+ const rescindCondition = SQL`\n+ n.user = ${viewer.userID} AND\n+ n.thread = ${request.threadID} AND\n+ n.message <= ${request.latestMessage}\n+ `;\n+ await rescindPushNotifs(rescindCondition);\n+ }\n+\n+ return {\n+ resetToUnread: resetThreadToUnread,\n+ };\n+}\n+\n+async function shouldResetThreadToUnread(\n+ viewer: Viewer,\n+ request: SetThreadUnreadStatusRequest,\n+): Promise<boolean> {\n+ if (request.unread || request.latestMessage.startsWith('local')) {\n+ return false;\n+ }\n+\n+ const resetToUnread = await determineUnfocusedThreadsReadStatus(\n+ viewer,\n+ new Map([[request.threadID, request.latestMessage]]),\n+ );\n+\n+ return resetToUnread.some(threadID => threadID === request.threadID);\n+}\n+\n// The `focused` table tracks which chat threads are currently in view for a\n// given cookie. We track this so that if a user is currently viewing a thread's\n// messages, then notifications on that thread are not sent. This function does\n@@ -284,4 +369,4 @@ async function updateActivityTime(viewer: Viewer): Promise<void> {\nawait dbQuery(focusedQuery);\n}\n-export { activityUpdater, updateActivityTime };\n+export { activityUpdater, updateActivityTime, setThreadUnreadStatus };\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -9,8 +9,6 @@ import {\ntype UpdateThreadRequest,\ntype ServerThreadJoinRequest,\ntype ThreadJoinResult,\n- type SetThreadUnreadStatusRequest,\n- type SetThreadUnreadStatusResult,\nthreadPermissions,\nthreadTypes,\nassertThreadType,\n@@ -26,7 +24,6 @@ import { ServerError } from 'lib/utils/errors';\nimport { promiseAll } from 'lib/utils/promises';\nimport { filteredThreadIDs } from 'lib/selectors/calendar-filter-selectors';\nimport { hasMinCodeVersion } from 'lib/shared/version-utils';\n-import { updateTypes } from 'lib/types/update-types';\nimport { dbQuery, SQL } from '../database';\nimport {\n@@ -48,12 +45,9 @@ import {\ngetParentThreadRelationshipRowsForNewUsers,\n} from './thread-permission-updaters';\nimport createMessages from '../creators/message-creator';\n-import { createUpdates } from '../creators/update-creator';\nimport { fetchMessageInfos } from '../fetchers/message-fetchers';\nimport { fetchEntryInfos } from '../fetchers/entry-fetchers';\nimport { updateRoles } from './role-updaters';\n-import { rescindPushNotifs } from '../push/rescind';\n-import { determineUnfocusedThreadsReadStatus } from './activity-updaters';\nasync function updateRole(\nviewer: Viewer,\n@@ -628,89 +622,4 @@ async function joinThread(\nreturn response;\n}\n-async function setThreadUnreadStatus(\n- viewer: Viewer,\n- request: SetThreadUnreadStatusRequest,\n-): Promise<SetThreadUnreadStatusResult> {\n- if (!viewer.loggedIn) {\n- throw new ServerError('not_logged_in');\n- }\n-\n- const isMemberAndCanViewThread = await checkThread(viewer, request.threadID, [\n- {\n- check: 'is_member',\n- },\n- {\n- check: 'permission',\n- permission: threadPermissions.VISIBLE,\n- },\n- ]);\n- if (!isMemberAndCanViewThread) {\n- throw new ServerError('invalid_parameters');\n- }\n-\n- const resetThreadToUnread = await shouldResetThreadToUnread(viewer, request);\n-\n- if (!resetThreadToUnread) {\n- const update = SQL`\n- UPDATE memberships m\n- SET m.unread = ${request.unread ? 1 : 0}\n- WHERE m.thread = ${request.threadID} AND m.user = ${viewer.userID}\n- `;\n- const queryPromise = dbQuery(update);\n-\n- const time = Date.now();\n- const updatesPromise = createUpdates(\n- [\n- {\n- type: updateTypes.UPDATE_THREAD_READ_STATUS,\n- userID: viewer.userID,\n- time: time,\n- threadID: request.threadID,\n- unread: request.unread,\n- },\n- ],\n- { viewer, updatesForCurrentSession: 'ignore' },\n- );\n-\n- await Promise.all([updatesPromise, queryPromise]);\n- }\n-\n- if (!request.unread) {\n- const rescindCondition = SQL`\n- n.user = ${viewer.userID} AND\n- n.thread = ${request.threadID} AND\n- n.message <= ${request.latestMessage}\n- `;\n- await rescindPushNotifs(rescindCondition);\n- }\n-\n- return {\n- resetToUnread: resetThreadToUnread,\n- };\n-}\n-\n-async function shouldResetThreadToUnread(\n- viewer: Viewer,\n- request: SetThreadUnreadStatusRequest,\n-): Promise<boolean> {\n- if (request.unread || request.latestMessage.startsWith('local')) {\n- return false;\n- }\n-\n- const resetToUnread = await determineUnfocusedThreadsReadStatus(\n- viewer,\n- new Map([[request.threadID, request.latestMessage]]),\n- );\n-\n- return resetToUnread.some(threadID => threadID === request.threadID);\n-}\n-\n-export {\n- updateRole,\n- removeMembers,\n- leaveThread,\n- updateThread,\n- joinThread,\n- setThreadUnreadStatus,\n-};\n+export { updateRole, removeMembers, leaveThread, updateThread, joinThread };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Move shouldResetThreadToUnread to activity-updaters Reviewers: ashoat Reviewed By: ashoat Subscribers: zrebcu411, KatPo, Adrian Differential Revision: https://phabricator.ashoat.com/D173
129,187
02.10.2020 06:46:51
14,400
bff96bbdee8077179a6dc4caa5b94e6fa34023b5
[native] Use hooks for data-binding in ThreadSettingsPushNotifs Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-push-notifs.react.js", "new_path": "native/chat/settings/thread-settings-push-notifs.react.js", "diff": "// @flow\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import type { AppState } from '../../redux/redux-setup';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type {\nSubscriptionUpdateRequest,\n@@ -12,27 +11,33 @@ import * as React from 'react';\nimport { Text, View, Switch } from 'react-native';\nimport PropTypes from 'prop-types';\n-import { connect } from 'lib/utils/redux-utils';\nimport {\nupdateSubscriptionActionTypes,\nupdateSubscription,\n} from 'lib/actions/user-actions';\n+import {\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\n-import { styleSelector } from '../../themes/colors';\n+import { useStyles } from '../../themes/colors';\n+type BaseProps = {|\n+ +threadInfo: ThreadInfo,\n+|};\ntype Props = {|\n- threadInfo: ThreadInfo,\n+ ...BaseProps,\n// Redux state\n- styles: typeof styles,\n+ +styles: typeof unboundStyles,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- updateSubscription: (\n+ +updateSubscription: (\nsubscriptionUpdate: SubscriptionUpdateRequest,\n) => Promise<SubscriptionUpdateResult>,\n|};\ntype State = {|\n- currentValue: boolean,\n+ +currentValue: boolean,\n|};\nclass ThreadSettingsPushNotifs extends React.PureComponent<Props, State> {\nstatic propTypes = {\n@@ -77,7 +82,7 @@ class ThreadSettingsPushNotifs extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ncurrentValue: {\nalignItems: 'flex-end',\nflex: 1,\n@@ -99,11 +104,19 @@ const styles = {\npaddingVertical: 3,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect(\n- (state: AppState) => ({\n- styles: stylesSelector(state),\n- }),\n- { updateSubscription },\n-)(ThreadSettingsPushNotifs);\n+export default React.memo<BaseProps>(function ConnectedThreadSettingsPushNotifs(\n+ props: BaseProps,\n+) {\n+ const styles = useStyles(unboundStyles);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callUpdateSubscription = useServerCall(updateSubscription);\n+ return (\n+ <ThreadSettingsPushNotifs\n+ {...props}\n+ styles={styles}\n+ dispatchActionPromise={dispatchActionPromise}\n+ updateSubscription={callUpdateSubscription}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hooks for data-binding in ThreadSettingsPushNotifs Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D175
129,187
04.10.2020 22:38:52
14,400
91ad6a478da5e054de3d0be2b54776172c094a15
[native] Use hooks for data-binding in ThreadSettingsColor Reviewers: palys-swm, KatPo Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-color.react.js", "new_path": "native/chat/settings/thread-settings-color.react.js", "diff": "import { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\n-import type { AppState } from '../../redux/redux-setup';\nimport type { ThreadSettingsNavigate } from './thread-settings.react';\nimport * as React from 'react';\nimport { Text, ActivityIndicator, View, Platform } from 'react-native';\nimport PropTypes from 'prop-types';\n+import { useSelector } from 'react-redux';\n-import { connect } from 'lib/utils/redux-utils';\nimport { changeThreadSettingsActionTypes } from 'lib/actions/thread-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n@@ -20,21 +19,24 @@ import { ColorPickerModalRouteName } from '../../navigation/route-names';\nimport {\ntype Colors,\ncolorsPropType,\n- colorsSelector,\n- styleSelector,\n+ useColors,\n+ useStyles,\n} from '../../themes/colors';\n+type BaseProps = {|\n+ +threadInfo: ThreadInfo,\n+ +colorEditValue: string,\n+ +setColorEditValue: (color: string) => void,\n+ +canChangeSettings: boolean,\n+ +navigate: ThreadSettingsNavigate,\n+ +threadSettingsRouteKey: string,\n+|};\ntype Props = {|\n- threadInfo: ThreadInfo,\n- colorEditValue: string,\n- setColorEditValue: (color: string) => void,\n- canChangeSettings: boolean,\n- navigate: ThreadSettingsNavigate,\n- threadSettingsRouteKey: string,\n+ ...BaseProps,\n// Redux state\n- loadingStatus: LoadingStatus,\n- colors: Colors,\n- styles: typeof styles,\n+ +loadingStatus: LoadingStatus,\n+ +colors: Colors,\n+ +styles: typeof unboundStyles,\n|};\nclass ThreadSettingsColor extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -95,7 +97,7 @@ class ThreadSettingsColor extends React.PureComponent<Props> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ncolorLine: {\nlineHeight: Platform.select({ android: 22, default: 25 }),\n},\n@@ -116,15 +118,24 @@ const styles = {\nwidth: 96,\n},\n};\n-const stylesSelector = styleSelector(styles);\nconst loadingStatusSelector = createLoadingStatusSelector(\nchangeThreadSettingsActionTypes,\n`${changeThreadSettingsActionTypes.started}:color`,\n);\n-export default connect((state: AppState) => ({\n- loadingStatus: loadingStatusSelector(state),\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n-}))(ThreadSettingsColor);\n+export default React.memo<BaseProps>(function ConnectedThreadSettingsColor(\n+ props: BaseProps,\n+) {\n+ const loadingStatus = useSelector(loadingStatusSelector);\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ return (\n+ <ThreadSettingsColor\n+ {...props}\n+ loadingStatus={loadingStatus}\n+ colors={colors}\n+ styles={styles}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use hooks for data-binding in ThreadSettingsColor Reviewers: palys-swm, KatPo Reviewed By: palys-swm, KatPo Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D177
129,187
05.10.2020 10:37:52
14,400
c8572bc89315b5fc4d408a70799ba33d5c9b2bc9
[lib] Ignore errors about failed pings when closing socket Summary: When you close a socket right now we sometimes get errors about failed ping requests. This diff silences those errors since they don't really matter. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/socket/socket.react.js", "new_path": "lib/socket/socket.react.js", "diff": "@@ -424,15 +424,27 @@ class Socket extends React.PureComponent<Props, State> {\nif (!message) {\nreturn;\n}\n+\n+ const { inflightRequests } = this.state;\n+ if (!inflightRequests) {\n+ // inflightRequests can be falsey here if we receive a message after we've\n+ // begun shutting down the socket. It's possible for a React Native\n+ // WebSocket to deliver a message even after close() is called on it. In\n+ // this case the message is probably a PONG, which we can safely ignore.\n+ // If it's not a PONG, it has to be something server-initiated (like\n+ // UPDATES or MESSAGES), since InflightRequests.allRequestsResolvedExcept\n+ // will wait for all responses to client-initiated requests to be\n+ // delivered before closing a socket. UPDATES and MESSAGES are both\n+ // checkpointed on the client, so should be okay to just ignore here and\n+ // redownload them later, probably in an incremental STATE_SYNC.\n+ return;\n+ }\n+\n// If we receive any message, that indicates that our connection is healthy,\n// so we can reset the ping timeout.\nthis.resetPing();\n- invariant(\n- this.state.inflightRequests,\n- 'inflightRequests falsey inside receiveMessage',\n- );\n- this.state.inflightRequests.resolveRequestsForMessage(message);\n+ inflightRequests.resolveRequestsForMessage(message);\nconst { status } = this.props.connection;\nif (status === 'disconnecting' || status === 'forcedDisconnecting') {\nthis.finishClosingSocket(\n@@ -691,9 +703,7 @@ class Socket extends React.PureComponent<Props, State> {\nmessageID,\nserverSocketMessageTypes.PONG,\n);\n- } catch (e) {\n- console.log(e);\n- }\n+ } catch (e) {}\n}\nsetLateResponse = (messageID: number, isLate: boolean) => {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Ignore errors about failed pings when closing socket Summary: When you close a socket right now we sometimes get errors about failed ping requests. This diff silences those errors since they don't really matter. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D178
129,187
05.10.2020 14:00:46
14,400
a33889ae4b12ffeedf38bedf320c7608c583aebe
[native] Socket active prop should be false if !dataLoaded Summary: This makes sure that the socket immediately closes on `LOG_OUT_STARTED`, and that it doesn't try to reopen if the session changes between then and `LOG_OUT_SUCCESS`. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/socket.react.js", "new_path": "native/socket.react.js", "diff": "@@ -10,6 +10,7 @@ import {\nuseServerCall,\nuseDispatchActionPromise,\n} from 'lib/utils/action-utils';\n+import { isLoggedIn } from 'lib/selectors/user-selectors';\nimport {\nopenSocketSelector,\n@@ -34,12 +35,7 @@ export default React.memo<BaseSocketProps>(function NativeSocket(\nconst urlPrefix = useSelector(state => state.urlPrefix);\nconst connection = useSelector(state => state.connection);\nconst frozen = useSelector(state => state.frozen);\n- const active = useSelector(\n- state =>\n- !!state.currentUserInfo &&\n- !state.currentUserInfo.anonymous &&\n- state.foreground,\n- );\n+ const active = useSelector(state => isLoggedIn(state) && state.foreground);\nconst openSocket = useSelector(openSocketSelector);\nconst sessionIdentification = useSelector(sessionIdentificationSelector);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Socket active prop should be false if !dataLoaded Summary: This makes sure that the socket immediately closes on `LOG_OUT_STARTED`, and that it doesn't try to reopen if the session changes between then and `LOG_OUT_SUCCESS`. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D184
129,187
05.10.2020 23:32:11
14,400
f4482716c552a0ab5c320d64168a6e65cb35ad08
[native] Don't resize KeyboardAvoidingView when keyboard height changes on Android Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/components/keyboard-avoiding-view.react.js", "new_path": "native/components/keyboard-avoiding-view.react.js", "diff": "@@ -94,6 +94,17 @@ class InnerKeyboardAvoidingView extends React.PureComponent<Props, State> {\n}\nconst { duration, easing, endCoordinates } = event;\n+ if (\n+ Platform.OS === 'android' &&\n+ this.keyboardFrame?.height &&\n+ endCoordinates.height\n+ ) {\n+ // On Android, we don't update the keyboard height when it changes. This\n+ // is because the Android keyboard has pop-up menus and the such, and we\n+ // want those pop-up menus to simply overlay over our screen instead of\n+ // moving it up.\n+ return;\n+ }\nthis.keyboardFrame = endCoordinates;\nconst { keyboardState } = this.props;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't resize KeyboardAvoidingView when keyboard height changes on Android Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D186
129,187
05.10.2020 10:40:50
14,400
dbc4b7da04be99574b3239b0c5c4882c9d6f5882
[native] Fix expo-splash-screen issue where Android emulator crashes on refrresh Summary: This fixes an issue where the Android emulator crashes when you refresh while using a debugger. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "ADD", "old_path": null, "new_path": "patches/expo-splash-screen+0.3.1.patch", "diff": "+diff --git a/node_modules/expo-splash-screen/android/src/main/java/expo/modules/splashscreen/SplashScreenController.kt b/node_modules/expo-splash-screen/android/src/main/java/expo/modules/splashscreen/SplashScreenController.kt\n+index 6496976..1e3550e 100644\n+--- a/node_modules/expo-splash-screen/android/src/main/java/expo/modules/splashscreen/SplashScreenController.kt\n++++ b/node_modules/expo-splash-screen/android/src/main/java/expo/modules/splashscreen/SplashScreenController.kt\n+@@ -30,6 +30,7 @@ class SplashScreenController(\n+\n+ fun showSplashScreen(successCallback: () -> Unit = {}) {\n+ weakActivity.get()?.runOnUiThread {\n++ (splashScreenView.parent as? ViewGroup)?.removeView(splashScreenView)\n+ contentView.addView(splashScreenView)\n+ splashScreenShown = true\n+ successCallback()\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "\"@types/hammerjs\" \"^2.0.36\"\n\"@expo/configure-splash-screen@~0.1.0\":\n- version \"0.1.15\"\n- resolved \"https://registry.yarnpkg.com/@expo/configure-splash-screen/-/configure-splash-screen-0.1.15.tgz#4e30bae340026c3737a0778a249d945ab6b0411f\"\n- integrity sha512-jKall/3aq3g/dQd0gPijsCxHyPXWh8rq/F2h0IYf1mcixlrMGTTFl/0um48SMJzyEg4HYMe4w8thn79vseI+AA==\n+ version \"0.1.19\"\n+ resolved \"https://registry.yarnpkg.com/@expo/configure-splash-screen/-/configure-splash-screen-0.1.19.tgz#22257cd63e4e21036dda55851a28b6e9b02a9b1a\"\n+ integrity sha512-9rVtF3BwHcNWom8crn6Rc09U3gnmUKroZL6ta04hUTpikMpGaZYdES2gj2ZryHvIACGHbxtM9MErSWH3B6iz5w==\ndependencies:\n\"@react-native-community/cli-platform-android\" \"^4.10.0\"\n\"@react-native-community/cli-platform-ios\" \"^4.10.0\"\ncore-js \"^3.6.5\"\ndeep-equal \"^2.0.3\"\nfs-extra \"^9.0.0\"\n+ lodash \"^4.17.15\"\npngjs \"^5.0.0\"\nxcode \"^3.0.0\"\nxml-js \"^1.6.11\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix expo-splash-screen issue where Android emulator crashes on refrresh Summary: This fixes an issue where the Android emulator crashes when you refresh while using a debugger. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D179
129,187
07.10.2020 21:34:35
14,400
a5e66f29b7e2753dff1c610b80dcf2cc93c51fe3
[lib] Move firstLine from native to lib Summary: Want to use it on web Reviewers: palys-swm, KatPo Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "ADD", "old_path": null, "new_path": "lib/utils/string-utils.js", "diff": "+// @flow\n+\n+const newlineRegex = /[\\r\\n]/;\n+function firstLine(text: ?string): string {\n+ if (!text) {\n+ return '';\n+ }\n+ return text.split(newlineRegex, 1)[0];\n+}\n+\n+export { firstLine };\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-preview.react.js", "new_path": "native/chat/message-preview.react.js", "diff": "@@ -19,9 +19,10 @@ import {\n} from 'lib/shared/thread-utils';\nimport { stringForUser } from 'lib/shared/user-utils';\nimport { connect } from 'lib/utils/redux-utils';\n+import { firstLine } from 'lib/utils/string-utils';\nimport { styleSelector } from '../themes/colors';\n-import { firstLine, SingleLine } from '../components/single-line.react';\n+import { SingleLine } from '../components/single-line.react';\ntype Props = {|\nmessageInfo: MessageInfo,\n" }, { "change_type": "MODIFY", "old_path": "native/components/single-line.react.js", "new_path": "native/components/single-line.react.js", "diff": "import * as React from 'react';\nimport { Text } from 'react-native';\n-const newlineRegex = /[\\r\\n]/;\n-function firstLine(text: ?string): string {\n- if (!text) {\n- return '';\n- }\n- return text.split(newlineRegex, 1)[0];\n-}\n+import { firstLine } from 'lib/utils/string-utils';\ntype Props = {|\n...React.ElementConfig<typeof Text>,\n@@ -24,4 +18,4 @@ function SingleLine(props: Props) {\n);\n}\n-export { firstLine, SingleLine };\n+export { SingleLine };\n" }, { "change_type": "MODIFY", "old_path": "native/more/more-screen.react.js", "new_path": "native/more/more-screen.react.js", "diff": "@@ -35,6 +35,7 @@ import {\n} from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { preRequestUserStateSelector } from 'lib/selectors/account-selectors';\n+import { firstLine } from 'lib/utils/string-utils';\nimport {\ngetNativeSharedWebCredentials,\n@@ -58,7 +59,7 @@ import {\ncolorsSelector,\nstyleSelector,\n} from '../themes/colors';\n-import { firstLine, SingleLine } from '../components/single-line.react';\n+import { SingleLine } from '../components/single-line.react';\ntype Props = {\nnavigation: MoreNavigationProp<'MoreScreen'>,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Move firstLine from native to lib Summary: Want to use it on web Reviewers: palys-swm, KatPo Reviewed By: palys-swm, KatPo Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D192
129,187
07.10.2020 21:40:06
14,400
371e224f652b5f0bfaec73a46004b043d96bb37b
[web] Only display first line of message in ChatThreadListItem MessagePreview Reviewers: palys-swm, KatPo Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "web/chat/message-preview.react.js", "new_path": "web/chat/message-preview.react.js", "diff": "@@ -16,6 +16,7 @@ import {\nthreadIsTwoPersonChat,\n} from 'lib/shared/thread-utils';\nimport { stringForUser } from 'lib/shared/user-utils';\n+import { firstLine } from 'lib/utils/string-utils';\nimport css from './chat-thread-list.css';\n@@ -54,7 +55,7 @@ class MessagePreview extends React.PureComponent<Props> {\nreturn (\n<div className={classNames(css.lastMessage, colorStyle)}>\n{usernameText}\n- {messageInfo.text}\n+ {firstLine(messageInfo.text)}\n</div>\n);\n} else {\n@@ -62,7 +63,7 @@ class MessagePreview extends React.PureComponent<Props> {\nconst colorStyle = unread ? css.black : css.light;\nreturn (\n<div className={classNames([css.lastMessage, colorStyle])}>\n- {preview}\n+ {firstLine(preview)}\n</div>\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Only display first line of message in ChatThreadListItem MessagePreview Reviewers: palys-swm, KatPo Reviewed By: palys-swm, KatPo Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D193
129,191
06.10.2020 12:57:56
-7,200
8ede7a686509ab42a7e3c73bdb3d3eb9dabb1488
[server] Do not send local id while updating the focus Reviewers: ashoat Subscribers: Adrian, KatPo, zrebcu411
[ { "change_type": "MODIFY", "old_path": "lib/socket/activity-handler.react.js", "new_path": "lib/socket/activity-handler.react.js", "diff": "@@ -35,9 +35,9 @@ function ActivityHandler(props: Props) {\nconst prevConnectionStatus = prevConnectionStatusRef.current;\nconst activeThreadLatestMessage = useSelector(state =>\n- activeThread && state.messageStore.threads[activeThread]\n- ? state.messageStore.threads[activeThread].messageIDs[0]\n- : null,\n+ state.messageStore.threads[activeThread]?.messageIDs.find(\n+ id => !id.startsWith('local'),\n+ ),\n);\nconst prevActiveThreadLatestMessageRef = React.useRef();\nReact.useEffect(() => {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Do not send local id while updating the focus Reviewers: ashoat Reviewed By: ashoat Subscribers: Adrian, KatPo, zrebcu411 Differential Revision: https://phabricator.ashoat.com/D188
129,191
08.10.2020 10:49:01
-7,200
3c3162b5acb6cb3fa63cacf8e57d27feb2b4628b
Move unread status related code to activity Reviewers: ashoat Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/actions/activity-actions.js", "new_path": "lib/actions/activity-actions.js", "diff": "@@ -4,6 +4,9 @@ import type { FetchJSON } from '../utils/fetch-json';\nimport type {\nActivityUpdate,\nActivityUpdateSuccessPayload,\n+ SetThreadUnreadStatusPayload,\n+ SetThreadUnreadStatusRequest,\n+ SetThreadUnreadStatusResult,\n} from '../types/activity-types';\nconst updateActivityActionTypes = Object.freeze({\n@@ -26,4 +29,28 @@ async function updateActivity(\n};\n}\n-export { updateActivityActionTypes, updateActivity };\n+const setThreadUnreadStatusActionTypes = Object.freeze({\n+ started: 'SET_THREAD_UNREAD_STATUS_STARTED',\n+ success: 'SET_THREAD_UNREAD_STATUS_SUCCESS',\n+ failed: 'SET_THREAD_UNREAD_STATUS_FAILED',\n+});\n+async function setThreadUnreadStatus(\n+ fetchJSON: FetchJSON,\n+ request: SetThreadUnreadStatusRequest,\n+): Promise<SetThreadUnreadStatusPayload> {\n+ const response: SetThreadUnreadStatusResult = await fetchJSON(\n+ 'set_thread_unread_status',\n+ request,\n+ );\n+ return {\n+ resetToUnread: response.resetToUnread,\n+ threadID: request.threadID,\n+ };\n+}\n+\n+export {\n+ updateActivityActionTypes,\n+ updateActivity,\n+ setThreadUnreadStatusActionTypes,\n+ setThreadUnreadStatus,\n+};\n" }, { "change_type": "MODIFY", "old_path": "lib/actions/thread-actions.js", "new_path": "lib/actions/thread-actions.js", "diff": "@@ -8,9 +8,6 @@ import type {\nNewThreadResult,\nClientThreadJoinRequest,\nThreadJoinPayload,\n- SetThreadUnreadStatusRequest,\n- SetThreadUnreadStatusPayload,\n- SetThreadUnreadStatusResult,\n} from '../types/thread-types';\nimport type { FetchJSON } from '../utils/fetch-json';\n@@ -157,25 +154,6 @@ async function leaveThread(\n};\n}\n-const setThreadUnreadStatusActionTypes = Object.freeze({\n- started: 'SET_THREAD_UNREAD_STATUS_STARTED',\n- success: 'SET_THREAD_UNREAD_STATUS_SUCCESS',\n- failed: 'SET_THREAD_UNREAD_STATUS_FAILED',\n-});\n-async function setThreadUnreadStatus(\n- fetchJSON: FetchJSON,\n- request: SetThreadUnreadStatusRequest,\n-): Promise<SetThreadUnreadStatusPayload> {\n- const response: SetThreadUnreadStatusResult = await fetchJSON(\n- 'set_thread_unread_status',\n- request,\n- );\n- return {\n- resetToUnread: response.resetToUnread,\n- threadID: request.threadID,\n- };\n-}\n-\nexport {\ndeleteThreadActionTypes,\ndeleteThread,\n@@ -191,6 +169,4 @@ export {\njoinThread,\nleaveThreadActionTypes,\nleaveThread,\n- setThreadUnreadStatusActionTypes,\n- setThreadUnreadStatus,\n};\n" }, { "change_type": "MODIFY", "old_path": "lib/reducers/thread-reducer.js", "new_path": "lib/reducers/thread-reducer.js", "diff": "@@ -15,7 +15,10 @@ import {\nfullStateSyncActionType,\nincrementalStateSyncActionType,\n} from '../types/socket-types';\n-import { updateActivityActionTypes } from '../actions/activity-actions';\n+import {\n+ setThreadUnreadStatusActionTypes,\n+ updateActivityActionTypes,\n+} from '../actions/activity-actions';\nimport {\nsendReportActionTypes,\nsendReportsActionTypes,\n@@ -44,7 +47,6 @@ import {\nchangeThreadMemberRolesActionTypes,\njoinThreadActionTypes,\nleaveThreadActionTypes,\n- setThreadUnreadStatusActionTypes,\n} from '../actions/thread-actions';\nimport { saveMessagesActionType } from '../actions/message-actions';\nimport { getConfig } from '../utils/config';\n" }, { "change_type": "MODIFY", "old_path": "lib/types/activity-types.js", "new_path": "lib/types/activity-types.js", "diff": "@@ -34,3 +34,14 @@ export const queueActivityUpdatesActionType = 'QUEUE_ACTIVITY_UPDATES';\nexport type QueueActivityUpdatesPayload = {|\nactivityUpdates: $ReadOnlyArray<ActivityUpdate>,\n|};\n+\n+export type SetThreadUnreadStatusRequest =\n+ | {| +unread: true, +threadID: string |}\n+ | {| +unread: false, +threadID: string, +latestMessage: string |};\n+export type SetThreadUnreadStatusResult = {|\n+ +resetToUnread: boolean,\n+|};\n+export type SetThreadUnreadStatusPayload = {|\n+ ...SetThreadUnreadStatusResult,\n+ +threadID: string,\n+|};\n" }, { "change_type": "MODIFY", "old_path": "lib/types/redux-types.js", "new_path": "lib/types/redux-types.js", "diff": "@@ -6,7 +6,6 @@ import type {\nLeaveThreadPayload,\nNewThreadResult,\nThreadJoinPayload,\n- SetThreadUnreadStatusPayload,\n} from './thread-types';\nimport type {\nRawEntryInfo,\n@@ -66,6 +65,7 @@ import type { UpdatesResultWithUserInfos } from './update-types';\nimport type {\nActivityUpdateSuccessPayload,\nQueueActivityUpdatesPayload,\n+ SetThreadUnreadStatusPayload,\n} from './activity-types';\nimport type { UpdateMultimediaMessageMediaPayload } from './media-types';\n" }, { "change_type": "MODIFY", "old_path": "lib/types/thread-types.js", "new_path": "lib/types/thread-types.js", "diff": "@@ -294,17 +294,6 @@ export type LeaveThreadPayload = {|\n},\n|};\n-export type SetThreadUnreadStatusRequest =\n- | {| +unread: true, +threadID: string |}\n- | {| +unread: false, +threadID: string, +latestMessage: string |};\n-export type SetThreadUnreadStatusResult = {|\n- +resetToUnread: boolean,\n-|};\n-export type SetThreadUnreadStatusPayload = {|\n- ...SetThreadUnreadStatusResult,\n- +threadID: string,\n-|};\n-\nexport type ThreadChanges = $Shape<{|\ntype: ThreadType,\nname: string,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list-item.react.js", "new_path": "native/chat/chat-thread-list-item.react.js", "diff": "@@ -4,11 +4,11 @@ import {\ntype ChatThreadItem,\nchatThreadItemPropType,\n} from 'lib/selectors/chat-selectors';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport type {\nSetThreadUnreadStatusPayload,\nSetThreadUnreadStatusRequest,\n- ThreadInfo,\n-} from 'lib/types/thread-types';\n+} from 'lib/types/activity-types';\nimport {\nuseDispatchActionPromise,\nuseServerCall,\n@@ -16,7 +16,7 @@ import {\nimport {\nsetThreadUnreadStatus,\nsetThreadUnreadStatusActionTypes,\n-} from 'lib/actions/thread-actions';\n+} from 'lib/actions/activity-actions';\nimport * as React from 'react';\nimport { Text, View } from 'react-native';\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/activity-responders.js", "new_path": "server/src/responders/activity-responders.js", "diff": "@@ -4,11 +4,9 @@ import type { Viewer } from '../session/viewer';\nimport type {\nUpdateActivityResult,\nUpdateActivityRequest,\n-} from 'lib/types/activity-types';\n-import type {\nSetThreadUnreadStatusRequest,\nSetThreadUnreadStatusResult,\n-} from 'lib/types/thread-types';\n+} from 'lib/types/activity-types';\nimport t from 'tcomb';\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -4,13 +4,11 @@ import type { Viewer } from '../session/viewer';\nimport type {\nUpdateActivityResult,\nUpdateActivityRequest,\n+ SetThreadUnreadStatusRequest,\n+ SetThreadUnreadStatusResult,\n} from 'lib/types/activity-types';\nimport { messageTypes } from 'lib/types/message-types';\n-import {\n- threadPermissions,\n- type SetThreadUnreadStatusRequest,\n- type SetThreadUnreadStatusResult,\n-} from 'lib/types/thread-types';\n+import { threadPermissions } from 'lib/types/thread-types';\nimport { updateTypes } from 'lib/types/update-types';\nimport invariant from 'invariant';\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list-item.react.js", "new_path": "web/chat/chat-thread-list-item.react.js", "diff": "@@ -11,11 +11,11 @@ import {\nupdateNavInfoActionType,\n} from '../redux/redux-setup';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { setThreadUnreadStatusActionTypes } from 'lib/actions/thread-actions';\n+import { setThreadUnreadStatusActionTypes } from 'lib/actions/activity-actions';\nimport type {\nSetThreadUnreadStatusPayload,\nSetThreadUnreadStatusRequest,\n-} from 'lib/types/thread-types';\n+} from 'lib/types/activity-types';\nimport * as React from 'react';\nimport classNames from 'classnames';\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list.react.js", "new_path": "web/chat/chat-thread-list.react.js", "diff": "@@ -7,12 +7,12 @@ import {\nchatThreadItemPropType,\n} from 'lib/selectors/chat-selectors';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport type {\nSetThreadUnreadStatusPayload,\nSetThreadUnreadStatusRequest,\n- ThreadInfo,\n-} from 'lib/types/thread-types';\n-import { setThreadUnreadStatus } from 'lib/actions/thread-actions';\n+} from 'lib/types/activity-types';\n+import { setThreadUnreadStatus } from 'lib/actions/activity-actions';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Move unread status related code to activity Reviewers: ashoat Reviewed By: ashoat Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D194
129,191
08.10.2020 11:59:24
-7,200
5b6b7773914d49e5718f1cd593fd5f0576b4f01a
Always include latest message in requests Reviewers: ashoat Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/types/activity-types.js", "new_path": "lib/types/activity-types.js", "diff": "@@ -35,9 +35,11 @@ export type QueueActivityUpdatesPayload = {|\nactivityUpdates: $ReadOnlyArray<ActivityUpdate>,\n|};\n-export type SetThreadUnreadStatusRequest =\n- | {| +unread: true, +threadID: string |}\n- | {| +unread: false, +threadID: string, +latestMessage: string |};\n+export type SetThreadUnreadStatusRequest = {|\n+ +unread: boolean,\n+ +threadID: string,\n+ +latestMessage: ?string,\n+|};\nexport type SetThreadUnreadStatusResult = {|\n+resetToUnread: boolean,\n|};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list-item.react.js", "new_path": "native/chat/chat-thread-list-item.react.js", "diff": "@@ -111,18 +111,16 @@ function ChatThreadListItem({\nconst lastActivity = shortAbsoluteDate(data.lastUpdatedTime);\nconst unreadStyle = data.threadInfo.currentUser.unread ? styles.unread : null;\n- const mostRecentMessageId = data.mostRecentMessageInfo?.id ?? '0';\n+ const mostRecentMessageId = data.mostRecentMessageInfo?.id;\nconst swipeableActions = useMemo(() => {\nconst isUnread = data.threadInfo.currentUser.unread;\nconst toggleUnreadStatus = () => {\n- const request = isUnread\n- ? {\n- unread: false,\n+ const request = {\n+ unread: !isUnread,\nthreadID: data.threadInfo.id,\nlatestMessage: mostRecentMessageId,\n- }\n- : { unread: true, threadID: data.threadInfo.id };\n+ };\ndispatchActionPromise(\nsetThreadUnreadStatusActionTypes,\nupdateUnreadStatus(request),\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/activity-responders.js", "new_path": "server/src/responders/activity-responders.js", "diff": "@@ -43,17 +43,11 @@ async function updateActivityResponder(\nreturn await activityUpdater(viewer, request);\n}\n-const setThreadUnreadStatusValidator = t.union([\n- tShape({\n- threadID: t.String,\n- unread: tBool(true),\n- }),\n- tShape({\n+const setThreadUnreadStatusValidator = tShape({\nthreadID: t.String,\n- unread: tBool(false),\n- latestMessage: t.String,\n- }),\n-]);\n+ unread: t.Bool,\n+ latestMessage: t.maybe(t.String),\n+});\nasync function threadSetUnreadStatusResponder(\nviewer: Viewer,\ninput: any,\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -337,13 +337,13 @@ async function shouldResetThreadToUnread(\nviewer: Viewer,\nrequest: SetThreadUnreadStatusRequest,\n): Promise<boolean> {\n- if (request.unread || request.latestMessage.startsWith('local')) {\n+ if (request.unread || request.latestMessage?.startsWith('local')) {\nreturn false;\n}\nconst resetToUnread = await determineUnfocusedThreadsReadStatus(\nviewer,\n- new Map([[request.threadID, request.latestMessage]]),\n+ new Map([[request.threadID, request.latestMessage ?? '0']]),\n);\nreturn resetToUnread.some(threadID => threadID === request.threadID);\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list-item.react.js", "new_path": "web/chat/chat-thread-list-item.react.js", "diff": "@@ -130,15 +130,10 @@ class ChatThreadListItem extends React.PureComponent<Props, State> {\ntoggleUnreadStatus = () => {\nconst { threadInfo, mostRecentMessageInfo } = this.props.item;\nconst isUnread = threadInfo.currentUser.unread;\n- const request = isUnread\n- ? {\n- threadID: threadInfo.id,\n- unread: !isUnread,\n- latestMessage: mostRecentMessageInfo?.id ?? '0',\n- }\n- : {\n+ const request = {\nthreadID: threadInfo.id,\nunread: !isUnread,\n+ latestMessage: mostRecentMessageInfo?.id,\n};\nthis.props.dispatchActionPromise(\nsetThreadUnreadStatusActionTypes,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Always include latest message in requests Reviewers: ashoat Reviewed By: ashoat Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D195
129,187
07.10.2020 22:56:01
14,400
d9f9bd62c88300007064c3113740918bc466d524
[native] Only render LongPressGestureHandler in GestureTouchableOpacity when we need it Summary: `LongPressGestureHandler` can interfere with `TapGestureHandler`. Also setting `maxDurationMs` here because on Android it defaults to 500ms. (We weren't noticing because the `LongPressGestureHandler` was set to active after 370ms.) Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/components/gesture-touchable-opacity.react.js", "new_path": "native/components/gesture-touchable-opacity.react.js", "diff": "import type { ViewStyle } from '../types/styles';\nimport * as React from 'react';\n+import { StyleSheet } from 'react-native';\nimport {\nLongPressGestureHandler,\nTapGestureHandler,\n@@ -162,18 +163,31 @@ function GestureTouchableOpacity(props: Props) {\n};\n}, [onPress, onLongPress, activeOpacity, activeValue, stickyActiveEnabled]);\n+ const tapHandler = (\n+ <TapGestureHandler onHandlerStateChange={tapEvent} maxDurationMs={100000}>\n+ <Animated.View style={[transformStyle, props.style]}>\n+ {props.children}\n+ </Animated.View>\n+ </TapGestureHandler>\n+ );\n+ if (!innerOnLongPress) {\n+ return tapHandler;\n+ }\n+\nreturn (\n<LongPressGestureHandler\nonHandlerStateChange={longPressEvent}\nminDurationMs={370}\n>\n- <Animated.View style={transformStyle}>\n- <TapGestureHandler onHandlerStateChange={tapEvent}>\n- <Animated.View style={props.style}>{props.children}</Animated.View>\n- </TapGestureHandler>\n- </Animated.View>\n+ <Animated.View style={styles.fill}>{tapHandler}</Animated.View>\n</LongPressGestureHandler>\n);\n}\n+const styles = StyleSheet.create({\n+ fill: {\n+ flex: 1,\n+ },\n+});\n+\nexport default GestureTouchableOpacity;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Only render LongPressGestureHandler in GestureTouchableOpacity when we need it Summary: `LongPressGestureHandler` can interfere with `TapGestureHandler`. Also setting `maxDurationMs` here because on Android it defaults to 500ms. (We weren't noticing because the `LongPressGestureHandler` was set to active after 370ms.) Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D199
129,191
09.10.2020 12:21:10
-7,200
dc70e8fd62bb86ea4bdf49f9c0a5eba70ffb0ef9
[lib] Send the most recent non local message Reviewers: ashoat Subscribers: Adrian, zrebcu411, KatPo
[ { "change_type": "MODIFY", "old_path": "lib/selectors/chat-selectors.js", "new_path": "lib/selectors/chat-selectors.js", "diff": "@@ -40,6 +40,7 @@ export type ChatThreadItem = {|\n+type: 'chatThreadItem',\n+threadInfo: ThreadInfo,\n+mostRecentMessageInfo: ?MessageInfo,\n+ +mostRecentNonLocalMessage: ?string,\n+lastUpdatedTime: number,\n+lastUpdatedTimeIncludingSidebars: number,\n+sidebars: $ReadOnlyArray<{|\n@@ -51,6 +52,7 @@ const chatThreadItemPropType = PropTypes.exact({\ntype: PropTypes.oneOf(['chatThreadItem']),\nthreadInfo: threadInfoPropType.isRequired,\nmostRecentMessageInfo: messageInfoPropType,\n+ mostRecentNonLocalMessage: PropTypes.string,\nlastUpdatedTime: PropTypes.number.isRequired,\nlastUpdatedTimeIncludingSidebars: PropTypes.number.isRequired,\nsidebars: PropTypes.arrayOf(\n@@ -86,6 +88,14 @@ function getMostRecentMessageInfo(\nreturn null;\n}\n+function getMostRecentNonLocalMessage(\n+ threadInfo: ThreadInfo,\n+ messageStore: MessageStore,\n+): ?string {\n+ const thread = messageStore.threads[threadInfo.id];\n+ return thread?.messageIDs.find(id => !id.startsWith('local'));\n+}\n+\nfunction getLastUpdatedTime(\nthreadInfo: ThreadInfo,\nmostRecentMessageInfo: ?MessageInfo,\n@@ -106,6 +116,10 @@ function createChatThreadItem(\nmessageStore,\nmessages,\n);\n+ const mostRecentNonLocalMessage = getMostRecentNonLocalMessage(\n+ threadInfo,\n+ messageStore,\n+ );\nconst lastUpdatedTime = getLastUpdatedTime(threadInfo, mostRecentMessageInfo);\nconst unorderedSidebars = [];\n@@ -137,6 +151,7 @@ function createChatThreadItem(\ntype: 'chatThreadItem',\nthreadInfo,\nmostRecentMessageInfo,\n+ mostRecentNonLocalMessage,\nlastUpdatedTime,\nlastUpdatedTimeIncludingSidebars,\nsidebars,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list-item.react.js", "new_path": "native/chat/chat-thread-list-item.react.js", "diff": "@@ -111,15 +111,13 @@ function ChatThreadListItem({\nconst lastActivity = shortAbsoluteDate(data.lastUpdatedTime);\nconst unreadStyle = data.threadInfo.currentUser.unread ? styles.unread : null;\n- const mostRecentMessageId = data.mostRecentMessageInfo?.id;\n-\nconst swipeableActions = useMemo(() => {\nconst isUnread = data.threadInfo.currentUser.unread;\nconst toggleUnreadStatus = () => {\nconst request = {\nunread: !isUnread,\nthreadID: data.threadInfo.id,\n- latestMessage: mostRecentMessageId,\n+ latestMessage: data.mostRecentNonLocalMessage,\n};\ndispatchActionPromise(\nsetThreadUnreadStatusActionTypes,\n@@ -150,7 +148,7 @@ function ChatThreadListItem({\n}, [\ncolors,\ndata.threadInfo,\n- mostRecentMessageId,\n+ data.mostRecentNonLocalMessage,\nupdateUnreadStatus,\ndispatchActionPromise,\n]);\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -337,7 +337,7 @@ async function shouldResetThreadToUnread(\nviewer: Viewer,\nrequest: SetThreadUnreadStatusRequest,\n): Promise<boolean> {\n- if (request.unread || request.latestMessage?.startsWith('local')) {\n+ if (request.unread) {\nreturn false;\n}\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-thread-list-item.react.js", "new_path": "web/chat/chat-thread-list-item.react.js", "diff": "@@ -128,12 +128,12 @@ class ChatThreadListItem extends React.PureComponent<Props, State> {\n};\ntoggleUnreadStatus = () => {\n- const { threadInfo, mostRecentMessageInfo } = this.props.item;\n+ const { threadInfo, mostRecentNonLocalMessage } = this.props.item;\nconst isUnread = threadInfo.currentUser.unread;\nconst request = {\nthreadID: threadInfo.id,\nunread: !isUnread,\n- latestMessage: mostRecentMessageInfo?.id,\n+ latestMessage: mostRecentNonLocalMessage,\n};\nthis.props.dispatchActionPromise(\nsetThreadUnreadStatusActionTypes,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Send the most recent non local message Reviewers: ashoat Reviewed By: ashoat Subscribers: Adrian, zrebcu411, KatPo Differential Revision: https://phabricator.ashoat.com/D206
129,183
08.10.2020 12:32:00
-7,200
71abf82aa6e56416ae95e8e0ec686455670cf2a2
Handle createSquadbotThread throwing exception Reviewers: ashoat, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/bots/app-version-update.js", "new_path": "server/src/bots/app-version-update.js", "diff": "@@ -15,6 +15,14 @@ import { createBotViewer } from '../session/bots';\nconst thirtyDays = 30 * 24 * 60 * 60 * 1000;\nconst { squadbot } = bots;\n+async function tryCreateSquadbotThread(userID: string) {\n+ try {\n+ return await createSquadbotThread(userID);\n+ } catch {\n+ return null;\n+ }\n+}\n+\nasync function botherMonthlyActivesToUpdateAppVersion(): Promise<void> {\nconst cutoff = Date.now() - thirtyDays;\nconst query = SQL`\n@@ -63,13 +71,16 @@ async function botherMonthlyActivesToUpdateAppVersion(): Promise<void> {\nconst squadbotThread = row.squadbot_thread.toString();\nsquadbotThreads.set(userID, squadbotThread);\n} else {\n- usersToSquadbotThreadPromises[userID] = createSquadbotThread(userID);\n+ usersToSquadbotThreadPromises[userID] = tryCreateSquadbotThread(userID);\n}\n}\nconst newSquadbotThreads = await promiseAll(usersToSquadbotThreadPromises);\n- for (let userID in newSquadbotThreads) {\n- squadbotThreads.set(userID, newSquadbotThreads[userID]);\n+ for (const userID in newSquadbotThreads) {\n+ const newSquadbotThreadID = newSquadbotThreads[userID];\n+ if (newSquadbotThreadID) {\n+ squadbotThreads.set(userID, newSquadbotThreadID);\n+ }\n}\nconst time = Date.now();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Handle createSquadbotThread throwing exception Reviewers: ashoat, palys-swm Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D196
129,183
06.10.2020 15:01:36
-7,200
dcaedc28c913238000a495a3f563ed730afc740c
[native] Display friend and blocked list Reviewers: ashoat, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/more/more-screen.react.js", "new_path": "native/more/more-screen.react.js", "diff": "@@ -229,7 +229,7 @@ class MoreScreen extends React.PureComponent<Props> {\n/>\n</View>\n</View>\n- {/* <View style={this.props.styles.slightlyPaddedSection}>\n+ <View style={this.props.styles.slightlyPaddedSection}>\n<Button\nonPress={this.onPressFriendList}\nstyle={this.props.styles.submenuButton}\n@@ -248,7 +248,7 @@ class MoreScreen extends React.PureComponent<Props> {\n<Text style={this.props.styles.submenuText}>Block list</Text>\n<Icon name=\"ios-arrow-forward\" size={20} color={linkColor} />\n</Button>\n- </View> */}\n+ </View>\n<Text style={this.props.styles.header}>PREFERENCES</Text>\n<View style={this.props.styles.slightlyPaddedSection}>\n<Button\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Display friend and blocked list Reviewers: ashoat, palys-swm Reviewed By: ashoat, palys-swm Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D190
129,183
09.10.2020 09:27:04
-7,200
60b701582bf2d04393515fbfbf8d011e305438a2
[server] Create friend relationships between thread members Reviewers: ashoat, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "ADD", "old_path": null, "new_path": "server/src/creators/relationship-creators.js", "diff": "+// @flow\n+\n+import _flow from 'lodash/fp/flow';\n+import _groupBy from 'lodash/fp/groupBy';\n+import _mapValues from 'lodash/fp/mapValues';\n+import _map from 'lodash/fp/map';\n+import _values from 'lodash/fp/values';\n+import _flatten from 'lodash/fp/flatten';\n+import _uniqWith from 'lodash/fp/uniqWith';\n+import _isEqual from 'lodash/fp/isEqual';\n+\n+import { getAllTuples } from 'lib/utils/array';\n+\n+import { updateUndirectedRelationships } from '../updaters/relationship-updaters';\n+\n+type QueryResult = {|\n+ +thread: number,\n+ +user: number,\n+|};\n+async function createUndirectedRelationships(\n+ dbQueryResult: $ReadOnlyArray<QueryResult>,\n+ setStatus: number,\n+) {\n+ const changeset = _flow([\n+ _groupBy(membership => membership.thread),\n+ _mapValues(_flow([_map(membership => membership.user), getAllTuples])),\n+ _values,\n+ _flatten,\n+ _uniqWith(_isEqual),\n+ _map(([user1, user2]) => ({\n+ user1,\n+ user2,\n+ status: setStatus,\n+ })),\n+ ])(dbQueryResult);\n+\n+ await updateUndirectedRelationships(changeset);\n+}\n+\n+export { createUndirectedRelationships };\n" }, { "change_type": "ADD", "old_path": null, "new_path": "server/src/scripts/create-friend-relationships.js", "diff": "+// @flow\n+\n+import { undirectedStatus } from 'lib/types/relationship-types';\n+\n+import { createUndirectedRelationships } from '../creators/relationship-creators';\n+import { dbQuery, SQL } from '../database';\n+import { endScript } from './utils';\n+\n+async function main() {\n+ try {\n+ await createFriendRelationshipsForThreadMembers();\n+ endScript();\n+ } catch (e) {\n+ endScript();\n+ console.warn(e);\n+ }\n+}\n+\n+async function createFriendRelationshipsForThreadMembers() {\n+ const [result] = await dbQuery(SQL`\n+ SELECT thread, user\n+ FROM memberships\n+ WHERE role > 0\n+ ORDER BY user ASC\n+ `);\n+\n+ await createUndirectedRelationships(result, undirectedStatus.FRIEND);\n+}\n+\n+main();\n" }, { "change_type": "MODIFY", "old_path": "server/src/scripts/create-relationships.js", "new_path": "server/src/scripts/create-relationships.js", "diff": "import { undirectedStatus } from 'lib/types/relationship-types';\n-import _flow from 'lodash/fp/flow';\n-import _groupBy from 'lodash/fp/groupBy';\n-import _mapValues from 'lodash/fp/mapValues';\n-import _map from 'lodash/fp/map';\n-import _values from 'lodash/fp/values';\n-import _flatten from 'lodash/fp/flatten';\n-import _uniqWith from 'lodash/fp/uniqWith';\n-import _isEqual from 'lodash/fp/isEqual';\n-\n-import { getAllTuples } from 'lib/utils/array';\n-\n-import { updateUndirectedRelationships } from '../updaters/relationship-updaters';\n+import { createUndirectedRelationships } from '../creators/relationship-creators';\nimport { saveMemberships } from '../updaters/thread-permission-updaters';\nimport { dbQuery, SQL } from '../database';\nimport { endScript } from './utils';\n@@ -68,20 +57,7 @@ async function createKnowOfRelationships() {\nORDER BY user ASC\n`);\n- const changeset = _flow([\n- _groupBy(membership => membership.thread),\n- _mapValues(_flow([_map(membership => membership.user), getAllTuples])),\n- _values,\n- _flatten,\n- _uniqWith(_isEqual),\n- _map(([user1, user2]) => ({\n- user1,\n- user2,\n- status: undirectedStatus.KNOW_OF,\n- })),\n- ])(result);\n-\n- await updateUndirectedRelationships(changeset);\n+ await createUndirectedRelationships(result, undirectedStatus.KNOW_OF);\n}\nmain();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Create friend relationships between thread members Reviewers: ashoat, palys-swm Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D205
129,183
01.10.2020 13:17:35
-7,200
93d889b872594ded025594beecd5910457de1995
[native] Stop listing non-friends and blocked users as option to join thread Reviewers: ashoat, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/selectors/user-selectors.js", "new_path": "lib/selectors/user-selectors.js", "diff": "@@ -12,10 +12,10 @@ import {\ntype RelativeMemberInfo,\nthreadPermissions,\n} from '../types/thread-types';\n+import { userRelationshipStatus } from '../types/relationship-types';\nimport { createSelector } from 'reselect';\nimport _memoize from 'lodash/memoize';\n-import _keys from 'lodash/keys';\nimport SearchIndex from '../shared/search-index';\nimport { threadActualMembers } from '../shared/thread-utils';\n@@ -102,42 +102,51 @@ const relativeMemberInfoSelectorForMembersOfThread: (\nbaseRelativeMemberInfoSelectorForMembersOfThread,\n);\n-// If threadID is null, then all users except the logged-in user are returned\n-const baseUserInfoSelectorForOtherMembersOfThread = (threadID: ?string) =>\n+// We're returning users that might be a thread members:\n+// friends and not blocked users in parent thread if it exists\n+const baseUserInfoSelectorForPotentialMembers = (parentThreadID: ?string) =>\ncreateSelector(\n(state: BaseAppState<*>) => state.userStore.userInfos,\n(state: BaseAppState<*>) =>\nstate.currentUserInfo && state.currentUserInfo.id,\n(state: BaseAppState<*>) =>\n- threadID && state.threadStore.threadInfos[threadID]\n- ? state.threadStore.threadInfos[threadID].members\n+ parentThreadID && state.threadStore.threadInfos[parentThreadID]\n+ ? state.threadStore.threadInfos[parentThreadID].members\n: null,\n(\nuserInfos: { [id: string]: UserInfo },\ncurrentUserID: ?string,\n- members: ?$ReadOnlyArray<MemberInfo>,\n+ parentThreadMembers: ?$ReadOnlyArray<MemberInfo>,\n): { [id: string]: AccountUserInfo } => {\n- const others = {};\n- const memberUserIDs = members\n- ? threadActualMembers(members)\n- : _keys(userInfos);\n- for (let memberID of memberUserIDs) {\n- if (\n- memberID !== currentUserID &&\n- userInfos[memberID] &&\n- userInfos[memberID].username\n+ const availableUsers = {};\n+\n+ const parentThreadMembersIDs = parentThreadMembers\n+ ? threadActualMembers(parentThreadMembers)\n+ : [];\n+\n+ for (const id in userInfos) {\n+ const userInfo = userInfos[id];\n+ const { relationshipStatus } = userInfo;\n+ if (relationshipStatus === userRelationshipStatus.FRIEND) {\n+ availableUsers[id] = userInfo;\n+ } else if (\n+ parentThreadMembersIDs.includes(id) &&\n+ id !== currentUserID &&\n+ relationshipStatus !== userRelationshipStatus.BLOCKED_BY_VIEWER &&\n+ relationshipStatus !== userRelationshipStatus.BLOCKED_VIEWER &&\n+ relationshipStatus !== userRelationshipStatus.BOTH_BLOCKED\n) {\n- others[memberID] = userInfos[memberID];\n+ availableUsers[id] = userInfo;\n}\n}\n- return others;\n+ return availableUsers;\n},\n);\n-const userInfoSelectorForOtherMembersOfThread: (\n+const userInfoSelectorForPotentialMembers: (\nthreadID: ?string,\n) => (state: BaseAppState<*>) => { [id: string]: AccountUserInfo } = _memoize(\n- baseUserInfoSelectorForOtherMembersOfThread,\n+ baseUserInfoSelectorForPotentialMembers,\n);\nfunction searchIndexFromUserInfos(userInfos: {\n@@ -150,16 +159,16 @@ function searchIndexFromUserInfos(userInfos: {\nreturn searchIndex;\n}\n-const baseUserSearchIndexForOtherMembersOfThread = (threadID: ?string) =>\n+const baseUserSearchIndexForPotentialMembers = (threadID: ?string) =>\ncreateSelector(\n- userInfoSelectorForOtherMembersOfThread(threadID),\n+ userInfoSelectorForPotentialMembers(threadID),\nsearchIndexFromUserInfos,\n);\n-const userSearchIndexForOtherMembersOfThread: (\n+const userSearchIndexForPotentialMembers: (\nthreadID: ?string,\n) => (state: BaseAppState<*>) => SearchIndex = _memoize(\n- baseUserSearchIndexForOtherMembersOfThread,\n+ baseUserSearchIndexForPotentialMembers,\n);\nconst isLoggedIn = (state: BaseAppState<*>) =>\n@@ -172,8 +181,8 @@ const isLoggedIn = (state: BaseAppState<*>) =>\nexport {\nuserIDsToRelativeUserInfos,\nrelativeMemberInfoSelectorForMembersOfThread,\n- userInfoSelectorForOtherMembersOfThread,\n+ userInfoSelectorForPotentialMembers,\nsearchIndexFromUserInfos,\n- userSearchIndexForOtherMembersOfThread,\n+ userSearchIndexForPotentialMembers,\nisLoggedIn,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/compose-thread.react.js", "new_path": "native/chat/compose-thread.react.js", "diff": "// @flow\n-import type { AppState } from '../redux/redux-setup';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\nimport {\n@@ -28,18 +27,22 @@ import _flow from 'lodash/fp/flow';\nimport _filter from 'lodash/fp/filter';\nimport _sortBy from 'lodash/fp/sortBy';\nimport { createSelector } from 'reselect';\n+import { useSelector } from 'react-redux';\n-import { connect } from 'lib/utils/redux-utils';\nimport { newThreadActionTypes, newThread } from 'lib/actions/thread-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport {\n- userInfoSelectorForOtherMembersOfThread,\n- userSearchIndexForOtherMembersOfThread,\n+ userInfoSelectorForPotentialMembers,\n+ userSearchIndexForPotentialMembers,\n} from 'lib/selectors/user-selectors';\nimport SearchIndex from 'lib/shared/search-index';\nimport { threadInFilterList, userIsMember } from 'lib/shared/thread-utils';\nimport { getUserSearchResults } from 'lib/shared/search-utils';\nimport { threadInfoSelector } from 'lib/selectors/thread-selectors';\n+import {\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport TagInput from '../components/tag-input.react';\nimport UserList from '../components/user-list.react';\n@@ -50,8 +53,8 @@ import ThreadVisibility from '../components/thread-visibility.react';\nimport {\ntype Colors,\ncolorsPropType,\n- colorsSelector,\n- styleSelector,\n+ useColors,\n+ useStyles,\n} from '../themes/colors';\nconst tagInputProps = {\n@@ -65,25 +68,28 @@ export type ComposeThreadParams = {|\nparentThreadInfo?: ThreadInfo,\n|};\n+type BaseProps = {|\n+ +navigation: ChatNavigationProp<'ComposeThread'>,\n+ +route: NavigationRoute<'ComposeThread'>,\n+|};\ntype Props = {|\n- navigation: ChatNavigationProp<'ComposeThread'>,\n- route: NavigationRoute<'ComposeThread'>,\n+ ...BaseProps,\n// Redux state\n- parentThreadInfo: ?ThreadInfo,\n- loadingStatus: LoadingStatus,\n- otherUserInfos: { [id: string]: AccountUserInfo },\n- userSearchIndex: SearchIndex,\n- threadInfos: { [id: string]: ThreadInfo },\n- colors: Colors,\n- styles: typeof styles,\n+ +parentThreadInfo: ?ThreadInfo,\n+ +loadingStatus: LoadingStatus,\n+ +otherUserInfos: { [id: string]: AccountUserInfo },\n+ +userSearchIndex: SearchIndex,\n+ +threadInfos: { [id: string]: ThreadInfo },\n+ +colors: Colors,\n+ +styles: typeof unboundStyles,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- newThread: (request: NewThreadRequest) => Promise<NewThreadResult>,\n+ +newThread: (request: NewThreadRequest) => Promise<NewThreadResult>,\n|};\ntype State = {|\n- usernameInputText: string,\n- userInfoInputArray: $ReadOnlyArray<AccountUserInfo>,\n+ +usernameInputText: string,\n+ +userInfoInputArray: $ReadOnlyArray<AccountUserInfo>,\n|};\ntype PropsAndState = {| ...Props, ...State |};\nclass ComposeThread extends React.PureComponent<Props, State> {\n@@ -416,7 +422,7 @@ class ComposeThread extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nflex: 1,\n},\n@@ -486,34 +492,41 @@ const styles = {\npaddingVertical: 6,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-const loadingStatusSelector = createLoadingStatusSelector(newThreadActionTypes);\n+export default React.memo<BaseProps>(function ConnectedComposeThread(\n+ props: BaseProps,\n+) {\n+ const parentThreadInfoID = props.route.params.parentThreadInfo?.id;\n-export default connect(\n- (\n- state: AppState,\n- ownProps: {\n- route: NavigationRoute<'ComposeThread'>,\n- },\n- ) => {\n- let reduxParentThreadInfo = null;\n- const parentThreadInfo = ownProps.route.params.parentThreadInfo;\n- if (parentThreadInfo) {\n- reduxParentThreadInfo = threadInfoSelector(state)[parentThreadInfo.id];\n- }\n- return {\n- parentThreadInfo: reduxParentThreadInfo,\n- loadingStatus: loadingStatusSelector(state),\n- otherUserInfos: userInfoSelectorForOtherMembersOfThread((null: ?string))(\n- state,\n- ),\n- userSearchIndex: userSearchIndexForOtherMembersOfThread(null)(state),\n- threadInfos: threadInfoSelector(state),\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- viewerID: state.currentUserInfo && state.currentUserInfo.id,\n- };\n- },\n- { newThread },\n-)(ComposeThread);\n+ const reduxParentThreadInfo = useSelector(state =>\n+ parentThreadInfoID ? threadInfoSelector(state)[parentThreadInfoID] : null,\n+ );\n+ const loadingStatus = useSelector(\n+ createLoadingStatusSelector(newThreadActionTypes),\n+ );\n+ const otherUserInfos = useSelector(\n+ userInfoSelectorForPotentialMembers(parentThreadInfoID),\n+ );\n+ const userSearchIndex = useSelector(\n+ userSearchIndexForPotentialMembers(parentThreadInfoID),\n+ );\n+ const threadInfos = useSelector(threadInfoSelector);\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callNewThread = useServerCall(newThread);\n+ return (\n+ <ComposeThread\n+ {...props}\n+ parentThreadInfo={reduxParentThreadInfo}\n+ loadingStatus={loadingStatus}\n+ otherUserInfos={otherUserInfos}\n+ userSearchIndex={userSearchIndex}\n+ threadInfos={threadInfos}\n+ colors={colors}\n+ styles={styles}\n+ dispatchActionPromise={dispatchActionPromise}\n+ newThread={callNewThread}\n+ />\n+ );\n+});\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": "// @flow\n-import type { AppState } from '../../redux/redux-setup';\nimport {\ntype ThreadInfo,\nthreadInfoPropType,\n@@ -22,14 +21,14 @@ import { View, Text, ActivityIndicator, Alert } from 'react-native';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\nimport { createSelector } from 'reselect';\n+import { useSelector } from 'react-redux';\nimport {\n- userInfoSelectorForOtherMembersOfThread,\n- userSearchIndexForOtherMembersOfThread,\n+ userInfoSelectorForPotentialMembers,\n+ userSearchIndexForPotentialMembers,\n} from 'lib/selectors/user-selectors';\nimport SearchIndex from 'lib/shared/search-index';\nimport { getUserSearchResults } from 'lib/shared/search-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport {\nchangeThreadSettingsActionTypes,\nchangeThreadSettings,\n@@ -37,12 +36,16 @@ import {\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { threadActualMembers } from 'lib/shared/thread-utils';\nimport { threadInfoSelector } from 'lib/selectors/thread-selectors';\n+import {\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport UserList from '../../components/user-list.react';\nimport TagInput from '../../components/tag-input.react';\nimport Button from '../../components/button.react';\nimport Modal from '../../components/modal.react';\n-import { styleSelector } from '../../themes/colors';\n+import { useStyles } from '../../themes/colors';\nconst tagInputProps = {\nplaceholder: 'Select users to add',\n@@ -55,25 +58,28 @@ export type AddUsersModalParams = {|\nthreadInfo: ThreadInfo,\n|};\n+type BaseProps = {|\n+ +navigation: RootNavigationProp<'AddUsersModal'>,\n+ +route: NavigationRoute<'AddUsersModal'>,\n+|};\ntype Props = {|\n- navigation: RootNavigationProp<'AddUsersModal'>,\n- route: NavigationRoute<'AddUsersModal'>,\n+ ...BaseProps,\n// Redux state\n- parentThreadInfo: ?ThreadInfo,\n- otherUserInfos: { [id: string]: AccountUserInfo },\n- userSearchIndex: SearchIndex,\n- changeThreadSettingsLoadingStatus: LoadingStatus,\n- styles: typeof styles,\n+ +parentThreadInfo: ?ThreadInfo,\n+ +otherUserInfos: { [id: string]: AccountUserInfo },\n+ +userSearchIndex: SearchIndex,\n+ +changeThreadSettingsLoadingStatus: LoadingStatus,\n+ +styles: typeof unboundStyles,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- changeThreadSettings: (\n+ +changeThreadSettings: (\nrequest: UpdateThreadRequest,\n) => Promise<ChangeThreadSettingsPayload>,\n|};\ntype State = {|\n- usernameInputText: string,\n- userInfoInputArray: $ReadOnlyArray<AccountUserInfo>,\n+ +usernameInputText: string,\n+ +userInfoInputArray: $ReadOnlyArray<AccountUserInfo>,\n|};\ntype PropsAndState = {| ...Props, ...State |};\nclass AddUsersModal extends React.PureComponent<Props, State> {\n@@ -292,7 +298,7 @@ class AddUsersModal extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\nactivityIndicator: {\npaddingRight: 6,\n},\n@@ -323,35 +329,37 @@ const styles = {\nfontSize: 18,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-const changeThreadSettingsLoadingStatusSelector = createLoadingStatusSelector(\n- changeThreadSettingsActionTypes,\n-);\n+export default React.memo<BaseProps>(function ConnectedAddUsersModal(\n+ props: BaseProps,\n+) {\n+ const { parentThreadID } = props.route.params.threadInfo;\n-export default connect(\n- (\n- state: AppState,\n- ownProps: {\n- route: NavigationRoute<'AddUsersModal'>,\n- },\n- ) => {\n- let parentThreadInfo = null;\n- const { parentThreadID } = ownProps.route.params.threadInfo;\n- if (parentThreadID) {\n- parentThreadInfo = threadInfoSelector(state)[parentThreadID];\n- }\n- return {\n- parentThreadInfo,\n- otherUserInfos: userInfoSelectorForOtherMembersOfThread((null: ?string))(\n- state,\n- ),\n- userSearchIndex: userSearchIndexForOtherMembersOfThread(null)(state),\n- changeThreadSettingsLoadingStatus: changeThreadSettingsLoadingStatusSelector(\n- state,\n- ),\n- styles: stylesSelector(state),\n- };\n- },\n- { changeThreadSettings },\n-)(AddUsersModal);\n+ const parentThreadInfo = useSelector(state =>\n+ parentThreadID ? threadInfoSelector(state)[parentThreadID] : null,\n+ );\n+ const otherUserInfos = useSelector(\n+ userInfoSelectorForPotentialMembers(parentThreadID),\n+ );\n+ const userSearchIndex = useSelector(\n+ userSearchIndexForPotentialMembers(parentThreadID),\n+ );\n+ const changeThreadSettingsLoadingStatus = useSelector(\n+ createLoadingStatusSelector(changeThreadSettingsActionTypes),\n+ );\n+ const styles = useStyles(unboundStyles);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callChangeThreadSettings = useServerCall(changeThreadSettings);\n+ return (\n+ <AddUsersModal\n+ {...props}\n+ parentThreadInfo={parentThreadInfo}\n+ otherUserInfos={otherUserInfos}\n+ userSearchIndex={userSearchIndex}\n+ changeThreadSettingsLoadingStatus={changeThreadSettingsLoadingStatus}\n+ styles={styles}\n+ dispatchActionPromise={dispatchActionPromise}\n+ changeThreadSettings={callChangeThreadSettings}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Stop listing non-friends and blocked users as option to join thread Reviewers: ashoat, palys-swm Reviewed By: ashoat, palys-swm Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D172
129,183
06.10.2020 14:56:57
-7,200
420c7d625619ec920f7aa7c3cf37f2918da56598
[server] Don't allow to create/add to thread non friends and blocked users from parent thread Reviewers: ashoat, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/creators/thread-creator.js", "new_path": "server/src/creators/thread-creator.js", "diff": "@@ -7,6 +7,7 @@ import {\nthreadPermissions,\n} from 'lib/types/thread-types';\nimport { messageTypes } from 'lib/types/message-types';\n+import { userRelationshipStatus } from 'lib/types/relationship-types';\nimport type { Viewer } from '../session/viewer';\nimport invariant from 'invariant';\n@@ -21,6 +22,7 @@ import { checkThreadPermission } from '../fetchers/thread-permission-fetchers';\nimport createIDs from './id-creator';\nimport { createInitialRolesForNewThread } from './role-creator';\nimport { fetchKnownUserInfos } from '../fetchers/user-fetchers';\n+import { fetchServerThreadInfos } from '../fetchers/thread-fetchers';\nimport {\nchangeRole,\nrecalculateAllPermissions,\n@@ -31,10 +33,16 @@ import {\n} from '../updaters/thread-permission-updaters';\nimport createMessages from './message-creator';\n+// If forceAddMembers is set, we will allow the viewer to add random users who\n+// they aren't friends with. We will only fail if the viewer is trying to add\n+// somebody who they have blocked or has blocked them. On the other hand, if\n+// forceAddMembers is not set, we will fail if the viewer tries to add somebody\n+// who they aren't friends with and doesn't have a membership row with a\n+// nonnegative role for the parent thread.\nasync function createThread(\nviewer: Viewer,\nrequest: NewThreadRequest,\n- createRelationships?: boolean = false,\n+ forceAddMembers?: boolean = false,\n): Promise<NewThreadResponse> {\nif (!viewer.loggedIn) {\nthrow new ServerError('not_logged_in');\n@@ -58,6 +66,9 @@ async function createThread(\nparentThreadID,\nthreadPermissions.CREATE_SUBTHREADS,\n);\n+ checkPromises.parentThread = fetchServerThreadInfos(\n+ SQL`t.id = ${parentThreadID}`,\n+ );\n}\nif (initialMemberIDs) {\ncheckPromises.fetchInitialMembers = fetchKnownUserInfos(\n@@ -65,23 +76,51 @@ async function createThread(\ninitialMemberIDs,\n);\n}\n- const checkResults = await promiseAll(checkPromises);\n+ const {\n+ hasParentPermission,\n+ parentThread,\n+ fetchInitialMembers,\n+ } = await promiseAll(checkPromises);\n- if (checkResults.hasParentPermission === false) {\n+ if (hasParentPermission === false) {\nthrow new ServerError('invalid_credentials');\n}\n+ let parentThreadMembers;\n+ if (parentThread && parentThreadID) {\n+ parentThreadMembers = parentThread.threadInfos[parentThreadID].members.map(\n+ userInfo => userInfo.id,\n+ );\n+ }\n+\nconst viewerNeedsRelationshipsWith = [];\n- if (checkResults.fetchInitialMembers) {\n+ if (fetchInitialMembers) {\ninvariant(initialMemberIDs, 'should be set');\nfor (const initialMemberID of initialMemberIDs) {\n- if (checkResults.fetchInitialMembers[initialMemberID]) {\n+ const initialMember = fetchInitialMembers[initialMemberID];\n+ if (!initialMember && forceAddMembers) {\n+ viewerNeedsRelationshipsWith.push(initialMemberID);\ncontinue;\n+ } else if (!initialMember) {\n+ throw new ServerError('invalid_credentials');\n}\n- if (!createRelationships) {\n+ const { relationshipStatus } = initialMember;\n+ if (relationshipStatus === userRelationshipStatus.FRIEND) {\n+ continue;\n+ } else if (\n+ relationshipStatus === userRelationshipStatus.BLOCKED_BY_VIEWER ||\n+ relationshipStatus === userRelationshipStatus.BLOCKED_VIEWER ||\n+ relationshipStatus === userRelationshipStatus.BOTH_BLOCKED\n+ ) {\n+ throw new ServerError('invalid_credentials');\n+ } else if (\n+ parentThreadMembers &&\n+ parentThreadMembers.includes(initialMemberID)\n+ ) {\n+ continue;\n+ } else if (!forceAddMembers) {\nthrow new ServerError('invalid_credentials');\n}\n- viewerNeedsRelationshipsWith.push(initialMemberID);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -15,6 +15,7 @@ import {\n} from 'lib/types/thread-types';\nimport type { Viewer } from '../session/viewer';\nimport { messageTypes, defaultNumberPerThread } from 'lib/types/message-types';\n+import { userRelationshipStatus } from 'lib/types/relationship-types';\nimport bcrypt from 'twin-bcrypt';\nimport _find from 'lodash/fp/find';\n@@ -382,14 +383,6 @@ async function updateThread(\nvalidationQuery: [validationResult],\nhasNecessaryPermissions,\n} = await promiseAll(validationPromises);\n- if (fetchNewMembers) {\n- invariant(newMemberIDs, 'should be set');\n- for (const newMemberID of newMemberIDs) {\n- if (!fetchNewMembers[newMemberID]) {\n- throw new ServerError('invalid_credentials');\n- }\n- }\n- }\nif (validationResult.length === 0 || validationResult[0].type === null) {\nthrow new ServerError('internal_error');\n@@ -409,8 +402,8 @@ async function updateThread(\n}\nconst oldThreadType = assertThreadType(validationRow.type);\n- const oldParentThreadID = validationRow.parentThreadID\n- ? validationRow.parentThreadID.toString()\n+ const oldParentThreadID = validationRow.parent_thread_id\n+ ? validationRow.parent_thread_id.toString()\n: null;\n// If the thread is being switched to nested, a parent must be specified\n@@ -431,6 +424,39 @@ async function updateThread(\n? parentThreadID\n: oldParentThreadID;\n+ let parentThreadMembers;\n+ if (nextParentThreadID) {\n+ const parentThread = await fetchServerThreadInfos(\n+ SQL`t.id = ${nextParentThreadID}`,\n+ );\n+ parentThreadMembers = parentThread.threadInfos[\n+ nextParentThreadID\n+ ].members.map(userInfo => userInfo.id);\n+ }\n+\n+ if (fetchNewMembers) {\n+ invariant(newMemberIDs, 'should be set');\n+ for (const newMemberID of newMemberIDs) {\n+ if (!fetchNewMembers[newMemberID]) {\n+ throw new ServerError('invalid_credentials');\n+ }\n+ const { relationshipStatus } = fetchNewMembers[newMemberID];\n+\n+ if (relationshipStatus === userRelationshipStatus.FRIEND) {\n+ continue;\n+ } else if (\n+ parentThreadMembers &&\n+ parentThreadMembers.includes(newMemberID) &&\n+ relationshipStatus !== userRelationshipStatus.BLOCKED_BY_VIEWER &&\n+ relationshipStatus !== userRelationshipStatus.BLOCKED_VIEWER &&\n+ relationshipStatus !== userRelationshipStatus.BOTH_BLOCKED\n+ ) {\n+ continue;\n+ }\n+ throw new ServerError('invalid_credentials');\n+ }\n+ }\n+\nconst intermediatePromises = {};\nif (Object.keys(sqlUpdate).length > 0) {\nconst updateQuery = SQL`\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Don't allow to create/add to thread non friends and blocked users from parent thread Reviewers: ashoat, palys-swm Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D189
129,187
09.10.2020 12:13:04
14,400
8be98c4deb18bc99e5b83da80da9fb991238f124
[server] Generate updates for friendship migration Summary: We need to generate updates to make sure that the `userStore` on clients has our new friendship rows. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/creators/relationship-creators.js", "new_path": "server/src/creators/relationship-creators.js", "diff": "// @flow\n+import {\n+ type UndirectedStatus,\n+ undirectedStatus,\n+} from 'lib/types/relationship-types';\n+\nimport _flow from 'lodash/fp/flow';\nimport _groupBy from 'lodash/fp/groupBy';\nimport _mapValues from 'lodash/fp/mapValues';\n@@ -11,7 +16,11 @@ import _isEqual from 'lodash/fp/isEqual';\nimport { getAllTuples } from 'lib/utils/array';\n-import { updateUndirectedRelationships } from '../updaters/relationship-updaters';\n+import {\n+ updateUndirectedRelationships,\n+ updateDatasForUserPairs,\n+} from '../updaters/relationship-updaters';\n+import { createUpdates } from '../creators/update-creator';\ntype QueryResult = {|\n+thread: number,\n@@ -19,22 +28,28 @@ type QueryResult = {|\n|};\nasync function createUndirectedRelationships(\ndbQueryResult: $ReadOnlyArray<QueryResult>,\n- setStatus: number,\n+ setStatus: UndirectedStatus,\n) {\n- const changeset = _flow([\n+ const userPairs = _flow([\n_groupBy(membership => membership.thread),\n_mapValues(_flow([_map(membership => membership.user), getAllTuples])),\n_values,\n_flatten,\n_uniqWith(_isEqual),\n- _map(([user1, user2]) => ({\n+ ])(dbQueryResult);\n+\n+ const changeset = userPairs.map(([user1, user2]) => ({\nuser1,\nuser2,\nstatus: setStatus,\n- })),\n- ])(dbQueryResult);\n-\n+ }));\nawait updateUndirectedRelationships(changeset);\n+\n+ if (setStatus !== undirectedStatus.KNOW_OF) {\n+ // We don't call createUpdates for KNOW_OF because the KNOW_OF\n+ // migration shouldn't lead to any changes in the userStore\n+ await createUpdates(updateDatasForUserPairs(userPairs));\n+ }\n}\nexport { createUndirectedRelationships };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Generate updates for friendship migration Summary: We need to generate updates to make sure that the `userStore` on clients has our new friendship rows. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D209
129,187
09.10.2020 12:40:28
14,400
4d1a2cfb7323dd69d78cb335dad514fcc631898c
[server] Fix return type of updateRelationshipsResponder Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/responders/relationship-responders.js", "new_path": "server/src/responders/relationship-responders.js", "diff": "// @flow\n-import type { RelationshipRequest } from 'lib/types/relationship-types';\n-import { relationshipActionsList } from 'lib/types/relationship-types';\n+import {\n+ type RelationshipRequest,\n+ type RelationshipErrors,\n+ relationshipActionsList,\n+} from 'lib/types/relationship-types';\nimport type { Viewer } from '../session/viewer';\nimport t from 'tcomb';\n@@ -17,7 +20,7 @@ const updateRelationshipInputValidator = tShape({\nasync function updateRelationshipsResponder(\nviewer: Viewer,\ninput: any,\n-): Promise<void> {\n+): Promise<RelationshipErrors> {\nconst request: RelationshipRequest = input;\nawait validateInput(viewer, updateRelationshipInputValidator, request);\nreturn await updateRelationships(viewer, request);\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/relationship-updaters.js", "new_path": "server/src/updaters/relationship-updaters.js", "diff": "@@ -25,7 +25,7 @@ import { dbQuery, SQL } from '../database';\nasync function updateRelationships(\nviewer: Viewer,\nrequest: RelationshipRequest,\n-) {\n+): Promise<RelationshipErrors> {\nconst { action } = request;\nif (!viewer.loggedIn) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Fix return type of updateRelationshipsResponder Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D211
129,187
09.10.2020 12:40:44
14,400
0c45ef47e1f53d18dd5723e81ed24a82008e37d9
[server] Don't add anonymous users to the friend list Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/scripts/create-friend-relationships.js", "new_path": "server/src/scripts/create-friend-relationships.js", "diff": "@@ -18,10 +18,11 @@ async function main() {\nasync function createFriendRelationshipsForThreadMembers() {\nconst [result] = await dbQuery(SQL`\n- SELECT thread, user\n- FROM memberships\n- WHERE role > 0\n- ORDER BY user ASC\n+ SELECT m.thread, m.user\n+ FROM memberships m\n+ LEFT JOIN users u ON u.id = m.user\n+ WHERE m.role > 0 AND u.id IS NOT NULL\n+ ORDER BY m.user ASC\n`);\nawait createUndirectedRelationships(result, undirectedStatus.FRIEND);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Don't add anonymous users to the friend list Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D212
129,187
09.10.2020 11:47:41
14,400
687716be7be2e290d124149344a93ae24012b6c1
[native] codeVersion -> 68 Had to throw away 67 after uploading an Android build to test if the `targetSdkVersion` would work and then realizing I had a couple bugs I still had to fix.
[ { "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 66\n- versionName \"0.0.66\"\n+ versionCode 68\n+ versionName \"0.0.68\"\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.66</string>\n+ <string>0.0.68</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>66</string>\n+ <string>68</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.66</string>\n+ <string>0.0.68</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>66</string>\n+ <string>68</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": "@@ -190,7 +190,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 66;\n+const codeVersion = 68;\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 -> 68 Had to throw away 67 after uploading an Android build to test if the `targetSdkVersion` would work and then realizing I had a couple bugs I still had to fix.
129,187
11.10.2020 19:42:16
14,400
c963b3bab4879b5ee2c46de977ac8b1aab6ea32a
[native] Convert ThreadSettings data-binding to hook Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "@@ -19,6 +19,7 @@ import PropTypes from 'prop-types';\nimport { View, FlatList } from 'react-native';\nimport invariant from 'invariant';\nimport { createSelector } from 'reselect';\n+import { useSelector } from 'react-redux';\nimport { relativeMemberInfoSelectorForMembersOfThread } from 'lib/selectors/user-selectors';\nimport {\n@@ -38,7 +39,6 @@ import {\nthreadInChatList,\n} from 'lib/shared/thread-utils';\nimport threadWatcher from 'lib/shared/thread-watcher';\n-import { connect } from 'lib/utils/redux-utils';\nimport {\nThreadSettingsCategoryHeader,\n@@ -65,13 +65,13 @@ import {\nComposeSubthreadModalRouteName,\n} from '../../navigation/route-names';\nimport {\n- styleSelector,\n+ useStyles,\ntype IndicatorStyle,\nindicatorStylePropType,\n- indicatorStyleSelector,\n+ useIndicatorStyle,\n} from '../../themes/colors';\nimport {\n- withOverlayContext,\n+ OverlayContext,\ntype OverlayContextType,\noverlayContextPropType,\n} from '../../navigation/overlay-context';\n@@ -190,28 +190,31 @@ type ChatSettingsItem =\ncanLeaveThread: boolean,\n|};\n+type BaseProps = {|\n+ +navigation: ChatNavigationProp<'ThreadSettings'>,\n+ +route: NavigationRoute<'ThreadSettings'>,\n+|};\ntype Props = {|\n- navigation: ChatNavigationProp<'ThreadSettings'>,\n- route: NavigationRoute<'ThreadSettings'>,\n+ ...BaseProps,\n// Redux state\n- threadInfo: ?ThreadInfo,\n- threadMembers: RelativeMemberInfo[],\n- childThreadInfos: ?(ThreadInfo[]),\n- somethingIsSaving: boolean,\n- styles: typeof styles,\n- indicatorStyle: IndicatorStyle,\n+ +threadInfo: ?ThreadInfo,\n+ +threadMembers: RelativeMemberInfo[],\n+ +childThreadInfos: ?(ThreadInfo[]),\n+ +somethingIsSaving: boolean,\n+ +styles: typeof unboundStyles,\n+ +indicatorStyle: IndicatorStyle,\n// withOverlayContext\n- overlayContext: ?OverlayContextType,\n+ +overlayContext: ?OverlayContextType,\n|};\ntype State = {|\n- showMaxMembers: number,\n- showMaxChildThreads: number,\n- nameEditValue: ?string,\n- descriptionEditValue: ?string,\n- nameTextHeight: ?number,\n- descriptionTextHeight: ?number,\n- colorEditValue: string,\n- verticalBounds: ?VerticalBounds,\n+ +showMaxMembers: number,\n+ +showMaxChildThreads: number,\n+ +nameEditValue: ?string,\n+ +descriptionEditValue: ?string,\n+ +nameTextHeight: ?number,\n+ +descriptionTextHeight: ?number,\n+ +colorEditValue: string,\n+ +verticalBounds: ?VerticalBounds,\n|};\ntype PropsAndState = {| ...Props, ...State |};\nclass ThreadSettings extends React.PureComponent<Props, State> {\n@@ -838,7 +841,7 @@ class ThreadSettings extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nbackgroundColor: 'panelBackground',\nflex: 1,\n@@ -847,7 +850,6 @@ const styles = {\npaddingVertical: 16,\n},\n};\n-const stylesSelector = styleSelector(styles);\nconst editNameLoadingStatusSelector = createLoadingStatusSelector(\nchangeThreadSettingsActionTypes,\n@@ -896,24 +898,33 @@ const somethingIsSaving = (\nreturn false;\n};\n-export default connect(\n- (\n- state: AppState,\n- ownProps: {\n- route: NavigationRoute<'ThreadSettings'>,\n- },\n- ) => {\n- const threadID = ownProps.route.params.threadInfo.id;\n- const threadMembers = relativeMemberInfoSelectorForMembersOfThread(\n- threadID,\n- )(state);\n- return {\n- threadInfo: threadInfoSelector(state)[threadID],\n- threadMembers,\n- childThreadInfos: childThreadInfos(state)[threadID],\n- somethingIsSaving: somethingIsSaving(state, threadMembers),\n- styles: stylesSelector(state),\n- indicatorStyle: indicatorStyleSelector(state),\n- };\n- },\n-)(withOverlayContext(ThreadSettings));\n+export default React.memo<BaseProps>(function ConnectedThreadSettings(\n+ props: BaseProps,\n+) {\n+ const threadID = props.route.params.threadInfo.id;\n+ const threadInfo = useSelector(state => threadInfoSelector(state)[threadID]);\n+ const threadMembers = useSelector(\n+ relativeMemberInfoSelectorForMembersOfThread(threadID),\n+ );\n+ const boundChildThreadInfos = useSelector(\n+ state => childThreadInfos(state)[threadID],\n+ );\n+ const boundSomethingIsSaving = useSelector(state =>\n+ somethingIsSaving(state, threadMembers),\n+ );\n+ const styles = useStyles(unboundStyles);\n+ const indicatorStyle = useIndicatorStyle();\n+ const overlayContext = React.useContext(OverlayContext);\n+ return (\n+ <ThreadSettings\n+ {...props}\n+ threadInfo={threadInfo}\n+ threadMembers={threadMembers}\n+ childThreadInfos={boundChildThreadInfos}\n+ somethingIsSaving={boundSomethingIsSaving}\n+ styles={styles}\n+ indicatorStyle={indicatorStyle}\n+ overlayContext={overlayContext}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Convert ThreadSettings data-binding to hook Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D221
129,187
11.10.2020 19:45:53
14,400
402384fe27f766c62374dfadd2ff7a9020cecb15
[native] Convert MultimediaModal data-binding to hook Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -5,7 +5,6 @@ import {\nmediaInfoPropType,\ntype Dimensions,\n} from 'lib/types/media-types';\n-import type { AppState } from '../redux/redux-setup';\nimport {\ntype VerticalBounds,\nverticalBoundsPropType,\n@@ -37,8 +36,7 @@ import Orientation from 'react-native-orientation-locker';\nimport Animated from 'react-native-reanimated';\nimport Icon from 'react-native-vector-icons/Ionicons';\nimport invariant from 'invariant';\n-\n-import { connect } from 'lib/utils/redux-utils';\n+import { useSelector } from 'react-redux';\nimport Multimedia from './multimedia.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n@@ -50,7 +48,7 @@ import {\n} from '../utils/animation-utils';\nimport { intentionalSaveMedia } from './save-media';\nimport {\n- withOverlayContext,\n+ OverlayContext,\ntype OverlayContextType,\noverlayContextPropType,\n} from '../navigation/overlay-context';\n@@ -161,17 +159,20 @@ type TouchableOpacityInstance = React.AbstractComponent<\nNativeMethodsMixinType,\n>;\n+type BaseProps = {|\n+ +navigation: AppNavigationProp<'MultimediaModal'>,\n+ +route: NavigationRoute<'MultimediaModal'>,\n+|};\ntype Props = {|\n- navigation: AppNavigationProp<'MultimediaModal'>,\n- route: NavigationRoute<'MultimediaModal'>,\n+ ...BaseProps,\n// Redux state\n- dimensions: DerivedDimensionsInfo,\n+ +dimensions: DerivedDimensionsInfo,\n// withOverlayContext\n- overlayContext: ?OverlayContextType,\n+ +overlayContext: ?OverlayContextType,\n|};\ntype State = {|\n- closeButtonEnabled: boolean,\n- actionLinksEnabled: boolean,\n+ +closeButtonEnabled: boolean,\n+ +actionLinksEnabled: boolean,\n|};\nclass MultimediaModal extends React.PureComponent<Props, State> {\nstatic propTypes = {\n@@ -1247,6 +1248,16 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect((state: AppState) => ({\n- dimensions: derivedDimensionsInfoSelector(state),\n-}))(withOverlayContext(MultimediaModal));\n+export default React.memo<BaseProps>(function ConnectedMultimediaModal(\n+ props: BaseProps,\n+) {\n+ const dimensions = useSelector(derivedDimensionsInfoSelector);\n+ const overlayContext = React.useContext(OverlayContext);\n+ return (\n+ <MultimediaModal\n+ {...props}\n+ dimensions={dimensions}\n+ overlayContext={overlayContext}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Convert MultimediaModal data-binding to hook Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D215
129,187
11.10.2020 19:52:20
14,400
963ded8662788f2ad0444cab06aa48d336c76609
[native] Convert RelationshipList data-binding to hook Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/more/relationship-list.react.js", "new_path": "native/more/relationship-list.react.js", "diff": "@@ -4,25 +4,24 @@ import type { UserInfo } from 'lib/types/user-types';\nimport type { UserRelationships } from 'lib/types/relationship-types';\nimport type { VerticalBounds } from '../types/layout-types';\nimport type { NavigationRoute } from '../navigation/route-names';\n-import type { AppState } from '../redux/redux-setup';\nimport type { MoreNavigationProp } from './more.react';\nimport * as React from 'react';\nimport { View, Text, FlatList } from 'react-native';\nimport invariant from 'invariant';\nimport { createSelector } from 'reselect';\n+import { useSelector } from 'react-redux';\n-import { connect } from 'lib/utils/redux-utils';\nimport { userRelationshipsSelector } from 'lib/selectors/relationship-selectors';\nimport {\n- withOverlayContext,\n+ OverlayContext,\ntype OverlayContextType,\n} from '../navigation/overlay-context';\nimport {\n- styleSelector,\n+ useStyles,\ntype IndicatorStyle,\n- indicatorStyleSelector,\n+ useIndicatorStyle,\n} from '../themes/colors';\nimport RelationshipListItem from './relationship-list-item.react';\n@@ -43,19 +42,21 @@ type ListItem =\nverticalBounds: ?VerticalBounds,\n|};\n+type BaseProps = {|\n+ +navigation: MoreNavigationProp<>,\n+ +route: NavigationRoute<'FriendList' | 'BlockList'>,\n+|};\ntype Props = {|\n- navigation: MoreNavigationProp<>,\n- route: NavigationRoute<'FriendList' | 'BlockList'>,\n- verticalBounds: ?VerticalBounds,\n+ ...BaseProps,\n// Redux state\n- relationships: UserRelationships,\n- styles: typeof styles,\n- indicatorStyle: IndicatorStyle,\n+ +relationships: UserRelationships,\n+ +styles: typeof unboundStyles,\n+ +indicatorStyle: IndicatorStyle,\n// withOverlayContext\n- overlayContext: ?OverlayContextType,\n+ +overlayContext: ?OverlayContextType,\n|};\ntype State = {|\n- verticalBounds: ?VerticalBounds,\n+ +verticalBounds: ?VerticalBounds,\n|};\ntype PropsAndState = {| ...Props, ...State |};\nclass RelationshipList extends React.PureComponent<Props, State> {\n@@ -195,7 +196,7 @@ class RelationshipList extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nflex: 1,\nbackgroundColor: 'panelBackground',\n@@ -219,10 +220,20 @@ const styles = {\n},\n};\n-const stylesSelector = styleSelector(styles);\n-\n-export default connect((state: AppState) => ({\n- relationships: userRelationshipsSelector(state),\n- styles: stylesSelector(state),\n- indicatorStyle: indicatorStyleSelector(state),\n-}))(withOverlayContext(RelationshipList));\n+export default React.memo<BaseProps>(function ConnectedRelationshipList(\n+ props: BaseProps,\n+) {\n+ const relationships = useSelector(userRelationshipsSelector);\n+ const styles = useStyles(unboundStyles);\n+ const indicatorStyle = useIndicatorStyle();\n+ const overlayContext = React.useContext(OverlayContext);\n+ return (\n+ <RelationshipList\n+ {...props}\n+ relationships={relationships}\n+ styles={styles}\n+ indicatorStyle={indicatorStyle}\n+ overlayContext={overlayContext}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Convert RelationshipList data-binding to hook Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D216
129,187
11.10.2020 20:01:03
14,400
3990e700055011a6209c1f2a5029d9f034e3662e
[native] Convert RelationshipListItem data-binding to hook Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/more/relationship-list-item.react.js", "new_path": "native/more/relationship-list-item.react.js", "diff": "// @flow\nimport type { LoadingStatus } from 'lib/types/loading-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport {\ntype RelationshipRequest,\nuserRelationshipStatus,\n@@ -9,7 +8,6 @@ import {\n} from 'lib/types/relationship-types';\nimport type { NavigationRoute } from '../navigation/route-names';\nimport type { VerticalBounds } from '../types/layout-types';\n-import type { AppState } from '../redux/redux-setup';\nimport type { RelationshipListNavigate } from './relationship-list.react';\nimport * as React from 'react';\n@@ -21,52 +19,59 @@ import {\nActivityIndicator,\n} from 'react-native';\nimport invariant from 'invariant';\n+import { useSelector } from 'react-redux';\n-import { connect } from 'lib/utils/redux-utils';\nimport { type UserInfo } from 'lib/types/user-types';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport {\nupdateRelationshipsActionTypes,\nupdateRelationships,\n} from 'lib/actions/relationship-actions';\n+import {\n+ type DispatchActionPromise,\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport PencilIcon from '../components/pencil-icon.react';\nimport { SingleLine } from '../components/single-line.react';\nimport {\n- withOverlayContext,\n+ OverlayContext,\ntype OverlayContextType,\n} from '../navigation/overlay-context';\nimport { RelationshipListItemTooltipModalRouteName } from '../navigation/route-names';\n-import { type Colors, colorsSelector, styleSelector } from '../themes/colors';\n+import { type Colors, useColors, useStyles } from '../themes/colors';\n-type Props = {|\n- userInfo: UserInfo,\n- lastListItem: boolean,\n- verticalBounds: ?VerticalBounds,\n- relationshipListRouteKey: string,\n- relationshipListRouteName: $PropertyType<\n+type BaseProps = {|\n+ +userInfo: UserInfo,\n+ +lastListItem: boolean,\n+ +verticalBounds: ?VerticalBounds,\n+ +relationshipListRouteKey: string,\n+ +relationshipListRouteName: $PropertyType<\nNavigationRoute<'FriendList' | 'BlockList'>,\n'name',\n>,\n- navigate: RelationshipListNavigate,\n+ +navigate: RelationshipListNavigate,\n+|};\n+type Props = {|\n+ ...BaseProps,\n// Redux state\n- removeUserLoadingStatus: LoadingStatus,\n- colors: Colors,\n- styles: typeof styles,\n+ +removeUserLoadingStatus: LoadingStatus,\n+ +colors: Colors,\n+ +styles: typeof unboundStyles,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // withOverlayContext\n- overlayContext: ?OverlayContextType,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- updateRelationships: (request: RelationshipRequest) => Promise<void>,\n+ +updateRelationships: (request: RelationshipRequest) => Promise<void>,\n+ // withOverlayContext\n+ +overlayContext: ?OverlayContextType,\n|};\n-\nclass RelationshipListItem extends React.PureComponent<Props> {\neditButton = React.createRef<React.ElementRef<typeof View>>();\nrender() {\nconst { lastListItem, removeUserLoadingStatus, userInfo } = this.props;\n- const borderBottom = lastListItem ? null : styles.borderBottom;\n+ const borderBottom = lastListItem ? null : this.props.styles.borderBottom;\nlet editButton = null;\nif (removeUserLoadingStatus === 'loading') {\n@@ -81,7 +86,10 @@ class RelationshipListItem extends React.PureComponent<Props> {\nuserInfo.relationshipStatus === userRelationshipStatus.BLOCKED_BY_VIEWER\n) {\neditButton = (\n- <TouchableOpacity onPress={this.onPressEdit} style={styles.editButton}>\n+ <TouchableOpacity\n+ onPress={this.onPressEdit}\n+ style={this.props.styles.editButton}\n+ >\n<View onLayout={this.onLayout} ref={this.editButton}>\n<PencilIcon />\n</View>\n@@ -93,7 +101,7 @@ class RelationshipListItem extends React.PureComponent<Props> {\neditButton = (\n<TouchableOpacity\nonPress={this.onPressUpdateFriendship}\n- style={styles.editButton}\n+ style={this.props.styles.editButton}\n>\n<Text style={this.props.styles.accept}>Accept</Text>\n</TouchableOpacity>\n@@ -104,7 +112,7 @@ class RelationshipListItem extends React.PureComponent<Props> {\neditButton = (\n<TouchableOpacity\nonPress={this.onPressUpdateFriendship}\n- style={styles.editButton}\n+ style={this.props.styles.editButton}\n>\n<Text style={this.props.styles.cancel}>Cancel request</Text>\n</TouchableOpacity>\n@@ -212,7 +220,7 @@ class RelationshipListItem extends React.PureComponent<Props> {\n}\n}\n-const styles = {\n+const unboundStyles = {\neditButton: {\npaddingLeft: 10,\n},\n@@ -247,16 +255,30 @@ const styles = {\npaddingLeft: 6,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect(\n- (state: AppState, ownProps: { userInfo: UserInfo }) => ({\n- removeUserLoadingStatus: createLoadingStatusSelector(\n+export default React.memo<BaseProps>(function ConnectedRelationshipListItem(\n+ props: BaseProps,\n+) {\n+ const removeUserLoadingStatus = useSelector(state =>\n+ createLoadingStatusSelector(\nupdateRelationshipsActionTypes,\n- `${updateRelationshipsActionTypes.started}:${ownProps.userInfo.id}`,\n+ `${updateRelationshipsActionTypes.started}:${props.userInfo.id}`,\n)(state),\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- }),\n- { updateRelationships },\n-)(withOverlayContext(RelationshipListItem));\n+ );\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const boundUpdateRelationships = useServerCall(updateRelationships);\n+ const overlayContext = React.useContext(OverlayContext);\n+ return (\n+ <RelationshipListItem\n+ {...props}\n+ removeUserLoadingStatus={removeUserLoadingStatus}\n+ colors={colors}\n+ styles={styles}\n+ dispatchActionPromise={dispatchActionPromise}\n+ updateRelationships={boundUpdateRelationships}\n+ overlayContext={overlayContext}\n+ />\n+ );\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Convert RelationshipListItem data-binding to hook Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D217
129,187
11.10.2020 20:02:29
14,400
36320d10a79d61aed635142039dd3bd324c3da33
[native] Get rid of withOverlayContext Summary: It's no longer used. Going forward, let's use hooks for data binding. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/navigation/overlay-context.js", "new_path": "native/navigation/overlay-context.js", "diff": "@@ -41,32 +41,4 @@ const overlayContextPropType = PropTypes.shape({\nsetScrollBlockingModalStatus: PropTypes.func.isRequired,\n});\n-function withOverlayContext<\n- AllProps: {},\n- ComponentType: React.ComponentType<AllProps>,\n->(\n- Component: ComponentType,\n-): React.ComponentType<\n- $Diff<\n- React.ElementConfig<ComponentType>,\n- { overlayContext: ?OverlayContextType },\n- >,\n-> {\n- class OverlayContextHOC extends React.PureComponent<\n- $Diff<\n- React.ElementConfig<ComponentType>,\n- { overlayContext: ?OverlayContextType },\n- >,\n- > {\n- render() {\n- return (\n- <OverlayContext.Consumer>\n- {value => <Component {...this.props} overlayContext={value} />}\n- </OverlayContext.Consumer>\n- );\n- }\n- }\n- return OverlayContextHOC;\n-}\n-\n-export { OverlayContext, overlayContextPropType, withOverlayContext };\n+export { OverlayContext, overlayContextPropType };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Get rid of withOverlayContext Summary: It's no longer used. Going forward, let's use hooks for data binding. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D218
129,187
11.10.2020 21:40:59
14,400
6c9f2251d1c7c13c9848a0b3b89cfcdf16ac6a12
[native] Convert PushHandler data-binding to hook Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/push/push-handler.react.js", "new_path": "native/push/push-handler.react.js", "diff": "// @flow\n-import type { AppState } from '../redux/redux-setup';\nimport type { DeviceType } from 'lib/types/device-types';\n-import type {\n- DispatchActionPayload,\n- DispatchActionPromise,\n-} from 'lib/utils/action-utils';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\nimport {\ntype NotifPermissionAlertInfo,\n@@ -33,8 +29,8 @@ import {\nNotification as InAppNotification,\nTapticFeedback,\n} from 'react-native-in-app-message';\n+import { useSelector, useDispatch } from 'react-redux';\n-import { connect } from 'lib/utils/redux-utils';\nimport {\nunreadCount,\nthreadInfoSelector,\n@@ -45,6 +41,11 @@ import {\n} from 'lib/actions/device-actions';\nimport { mergePrefixIntoBody } from 'lib/shared/notif-utils';\nimport { isLoggedIn } from 'lib/selectors/user-selectors';\n+import {\n+ useServerCall,\n+ useDispatchActionPromise,\n+ type DispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport {\nrecordNotifPermissionAlertActionType,\n@@ -63,12 +64,9 @@ import {\nimport { getFirebase } from './firebase';\nimport { saveMessageInfos } from './utils';\nimport InAppNotif from './in-app-notif.react';\n+import { NavContext } from '../navigation/navigation-context';\nimport {\n- connectNav,\n- type NavContextType,\n-} from '../navigation/navigation-context';\n-import {\n- withRootContext,\n+ RootContext,\ntype RootContextType,\nrootContextPropType,\n} from '../root-context';\n@@ -90,32 +88,35 @@ const msInDay = 24 * 60 * 60 * 1000;\nconst supportsTapticFeedback =\nPlatform.OS === 'ios' && parseInt(Platform.Version, 10) >= 10;\n-type Props = {\n- navigation: RootNavigationProp<'App'>,\n+type BaseProps = {|\n+ +navigation: RootNavigationProp<'App'>,\n+|};\n+type Props = {|\n+ ...BaseProps,\n// Navigation state\n- activeThread: ?string,\n+ +activeThread: ?string,\n// Redux state\n- unreadCount: number,\n- deviceToken: ?string,\n- threadInfos: { [id: string]: ThreadInfo },\n- notifPermissionAlertInfo: NotifPermissionAlertInfo,\n- connection: ConnectionInfo,\n- updatesCurrentAsOf: number,\n- activeTheme: ?GlobalTheme,\n- loggedIn: boolean,\n+ +unreadCount: number,\n+ +deviceToken: ?string,\n+ +threadInfos: { [id: string]: ThreadInfo },\n+ +notifPermissionAlertInfo: NotifPermissionAlertInfo,\n+ +connection: ConnectionInfo,\n+ +updatesCurrentAsOf: number,\n+ +activeTheme: ?GlobalTheme,\n+ +loggedIn: boolean,\n// Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatch: Dispatch,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- setDeviceToken: (\n+ +setDeviceToken: (\ndeviceToken: string,\ndeviceType: DeviceType,\n) => Promise<string>,\n// withRootContext\n- rootContext: ?RootContextType,\n-};\n+ +rootContext: ?RootContextType,\n+|};\ntype State = {|\n- inAppNotifProps: ?{|\n+ +inAppNotifProps: ?{|\ncustomComponent: React.Node,\nblurType: ?('xlight' | 'dark'),\nonPress: () => void,\n@@ -135,7 +136,7 @@ class PushHandler extends React.PureComponent<Props, State> {\nupdatesCurrentAsOf: PropTypes.number.isRequired,\nactiveTheme: globalThemePropType,\nloggedIn: PropTypes.bool.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n+ dispatch: PropTypes.func.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nsetDeviceToken: PropTypes.func.isRequired,\nrootContext: rootContextPropType,\n@@ -334,8 +335,9 @@ class PushHandler extends React.PureComponent<Props, State> {\n),\n);\n} else if (Platform.OS === 'android') {\n- this.props.dispatchActionPayload(clearAndroidNotificationsActionType, {\n- threadID: activeThread,\n+ this.props.dispatch({\n+ type: clearAndroidNotificationsActionType,\n+ payload: { threadID: activeThread },\n});\n}\n}\n@@ -452,8 +454,9 @@ class PushHandler extends React.PureComponent<Props, State> {\n) {\nreturn;\n}\n- this.props.dispatchActionPayload(recordNotifPermissionAlertActionType, {\n- time: Date.now(),\n+ this.props.dispatch({\n+ type: recordNotifPermissionAlertActionType,\n+ payload: { time: Date.now() },\n});\nif (deviceType === 'ios') {\n@@ -628,20 +631,41 @@ AppRegistry.registerHeadlessTask(\n() => androidBackgroundMessageTask,\n);\n-export default connectNav((context: ?NavContextType) => ({\n- activeThread: activeMessageListSelector(context),\n-}))(\n- connect(\n- (state: AppState) => ({\n- unreadCount: unreadCount(state),\n- deviceToken: state.deviceToken,\n- threadInfos: threadInfoSelector(state),\n- notifPermissionAlertInfo: state.notifPermissionAlertInfo,\n- connection: state.connection,\n- updatesCurrentAsOf: state.updatesCurrentAsOf,\n- activeTheme: state.globalThemeInfo.activeTheme,\n- loggedIn: isLoggedIn(state),\n- }),\n- { setDeviceToken },\n- )(withRootContext(PushHandler)),\n+export default React.memo<BaseProps>(function ConnectedPushHandler(\n+ props: BaseProps,\n+) {\n+ const navContext = React.useContext(NavContext);\n+ const activeThread = activeMessageListSelector(navContext);\n+ const boundUnreadCount = useSelector(unreadCount);\n+ const deviceToken = useSelector(state => state.deviceToken);\n+ const threadInfos = useSelector(threadInfoSelector);\n+ const notifPermissionAlertInfo = useSelector(\n+ state => state.notifPermissionAlertInfo,\n+ );\n+ const connection = useSelector(state => state.connection);\n+ const updatesCurrentAsOf = useSelector(state => state.updatesCurrentAsOf);\n+ const activeTheme = useSelector(state => state.globalThemeInfo.activeTheme);\n+ const loggedIn = useSelector(isLoggedIn);\n+ const dispatch = useDispatch();\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const boundSetDeviceToken = useServerCall(setDeviceToken);\n+ const rootContext = React.useContext(RootContext);\n+ return (\n+ <PushHandler\n+ {...props}\n+ activeThread={activeThread}\n+ unreadCount={boundUnreadCount}\n+ deviceToken={deviceToken}\n+ threadInfos={threadInfos}\n+ notifPermissionAlertInfo={notifPermissionAlertInfo}\n+ connection={connection}\n+ updatesCurrentAsOf={updatesCurrentAsOf}\n+ activeTheme={activeTheme}\n+ loggedIn={loggedIn}\n+ dispatch={dispatch}\n+ dispatchActionPromise={dispatchActionPromise}\n+ setDeviceToken={boundSetDeviceToken}\n+ rootContext={rootContext}\n+ />\n);\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Convert PushHandler data-binding to hook Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D219
129,187
11.10.2020 21:42:47
14,400
31cbafa97bcabdf9387d025f1fa3206c17449011
[native] Get rid of withRootContext Summary: It's no longer used. Going forward, let's use hooks for data binding. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "native/root-context.js", "new_path": "native/root-context.js", "diff": "@@ -10,34 +10,9 @@ export type RootContextType = {|\nconst RootContext = React.createContext<?RootContextType>(null);\n-function withRootContext<\n- AllProps: {},\n- ComponentType: React.ComponentType<AllProps>,\n->(\n- Component: ComponentType,\n-): React.ComponentType<\n- $Diff<React.ElementConfig<ComponentType>, { rootContext: ?RootContextType }>,\n-> &\n- ComponentType {\n- function RootContextHOC(\n- props: $Diff<\n- React.ElementConfig<ComponentType>,\n- { rootContext: ?RootContextType },\n- >,\n- ) {\n- return (\n- <RootContext.Consumer>\n- {value => <Component {...props} rootContext={value} />}\n- </RootContext.Consumer>\n- );\n- }\n- // $FlowFixMe React.memo typing fixed in later version of Flow\n- return React.memo(RootContextHOC);\n-}\n-\nconst rootContextPropType = PropTypes.shape({\ndetectUnsupervisedBackground: PropTypes.func,\nsetNavStateInitialized: PropTypes.func.isRequired,\n});\n-export { RootContext, withRootContext, rootContextPropType };\n+export { RootContext, rootContextPropType };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Get rid of withRootContext Summary: It's no longer used. Going forward, let's use hooks for data binding. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D220
129,187
12.10.2020 12:28:10
14,400
678adc13e3c7736bada509cdf38bd94d4148051b
[server] Enable --trace-warnings on prod Summary: I'm seeing a lot of `MaxListenersExceededWarning` in the logs, and would like to understand a bit more about where they're coming from. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/package.json", "new_path": "server/package.json", "diff": "\"rsync\": \"rsync -rLpmuv --exclude '*/package.json' --exclude '*/node_modules/*' --include '*.json' --include '*.cjs' --exclude '*.*' src/ dist/\",\n\"prod-build\": \"yarn babel-build && yarn rsync && yarn update-geoip\",\n\"update-geoip\": \"yarn script dist/scripts/update-geoip.js\",\n- \"prod\": \"node --experimental-json-modules --loader ./loader.mjs --es-module-specifier-resolution node dist/server\",\n+ \"prod\": \"node --trace-warnings --experimental-json-modules --loader ./loader.mjs --es-module-specifier-resolution node dist/server\",\n\"dev-rsync\": \"yarn --silent chokidar --initial --silent -s 'src/**/*.json' 'src/**/*.cjs' -c 'yarn rsync > /dev/null 2>&1'\",\n\"dev\": \"yarn concurrently --names=\\\"BABEL,RSYNC,NODEM\\\" -c \\\"bgBlue.bold,bgMagenta.bold,bgGreen.bold\\\" \\\"yarn babel-build --watch\\\" \\\"yarn dev-rsync\\\" \\\". bash/source-nvm.sh && NODE_ENV=dev nodemon -e js,json,cjs --watch dist --experimental-json-modules --loader ./loader.mjs --es-module-specifier-resolution node dist/server\\\"\",\n\"script\": \". bash/source-nvm.sh && node --experimental-json-modules --loader ./loader.mjs --es-module-specifier-resolution node\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Enable --trace-warnings on prod Summary: I'm seeing a lot of `MaxListenersExceededWarning` in the logs, and would like to understand a bit more about where they're coming from. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D223
129,187
12.10.2020 20:56:13
14,400
f5e3e52b1b9051af16cc872d4265ff26fb15817a
[server] Get rid of SSR hack for visibilityjs Summary: Setting `window = {}` on the server breaks `react-dnd`'s `useIsomorphicLayoutEffect` [hack](https://github.com/react-dnd/react-dnd/blob/64c4060f00c0dd9858a4911086245f1887b5b6f8/packages/core/react-dnd/src/hooks/internal/useIsomorphicLayoutEffect.ts). Replaced with a new hack in D228. Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/responders/website-responders.js", "new_path": "server/src/responders/website-responders.js", "diff": "@@ -27,7 +27,6 @@ import { mostRecentReadThread } from 'lib/selectors/thread-selectors';\nimport { threadHasPermission } from 'lib/shared/thread-utils';\nimport { promiseAll } from 'lib/utils/promises';\n-import 'web/server-rendering';\nimport * as ReduxSetup from 'web/redux/redux-setup';\nimport App from 'web/dist/app.build.cjs';\nimport { navInfoFromURL } from 'web/url-utils';\n" }, { "change_type": "MODIFY", "old_path": "web/redux/focus-handler.react.js", "new_path": "web/redux/focus-handler.react.js", "diff": "@@ -7,7 +7,10 @@ import { updateWindowActiveActionType } from './action-types';\nfunction FocusHandler() {\nconst [focused, setFocused] = React.useState(\n- !window || !window.hasFocus || window.hasFocus(),\n+ typeof window === 'undefined' ||\n+ !window ||\n+ !window.hasFocus ||\n+ window.hasFocus(),\n);\nconst onFocus = React.useCallback(() => {\nsetFocused(true);\n@@ -16,6 +19,9 @@ function FocusHandler() {\nsetFocused(false);\n}, []);\nReact.useEffect(() => {\n+ if (typeof window === 'undefined') {\n+ return;\n+ }\nwindow.addEventListener('focus', onFocus);\nwindow.addEventListener('blur', onBlur);\nreturn () => {\n" }, { "change_type": "MODIFY", "old_path": "web/redux/redux-setup.js", "new_path": "web/redux/redux-setup.js", "diff": "@@ -159,6 +159,7 @@ function validateState(oldState: AppState, state: AppState): AppState {\nif (\nactiveThread &&\n!Visibility.hidden() &&\n+ typeof document !== 'undefined' &&\ndocument &&\ndocument.hasFocus &&\ndocument.hasFocus() &&\n" }, { "change_type": "DELETE", "old_path": "web/server-rendering.js", "new_path": null, "diff": "-/* eslint-disable */\n-\n-// We do this because we need to render this app on the server, but visibilityjs\n-// expects the window global to be initialized\n-if (!process.env.BROWSER) {\n- global.window = {};\n- global.document = {};\n-}\n" }, { "change_type": "MODIFY", "old_path": "web/webpack.config.cjs", "new_path": "web/webpack.config.cjs", "diff": "@@ -61,9 +61,7 @@ const imageRule = {\nconst baseBrowserConfig = {\nname: 'browser',\n- entry: {\n- browser: [ './script.js' ],\n- },\n+ entry: [ './script.js' ],\noutput: {\nfilename: 'prod.[hash:12].build.js',\npath: path.join(__dirname, 'dist'),\n@@ -94,13 +92,10 @@ module.exports = function(env) {\nif (env === 'dev') {\nbrowserConfig = {\n...browserConfig,\n- entry: {\n- ...browserConfig.entry,\n- browser: [\n+ entry: [\n'react-hot-loader/patch',\n- ...browserConfig.entry.browser,\n+ ...browserConfig.entry,\n],\n- },\nmode: 'development',\noutput: {\n...browserConfig.output,\n@@ -238,9 +233,7 @@ module.exports = function(env) {\ntarget: 'node',\nexternals: [ 'react', 'react-dom', 'react-redux' ],\nmode: env === 'dev' ? 'development' : 'production',\n- entry: {\n- server: [ './server-rendering.js', './app.react.js' ],\n- },\n+ entry: [ './app.react.js' ],\noutput: {\nfilename: 'app.build.cjs',\nlibrary: 'app',\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Get rid of SSR hack for visibilityjs Summary: Setting `window = {}` on the server breaks `react-dnd`'s `useIsomorphicLayoutEffect` [hack](https://github.com/react-dnd/react-dnd/blob/64c4060f00c0dd9858a4911086245f1887b5b6f8/packages/core/react-dnd/src/hooks/internal/useIsomorphicLayoutEffect.ts). Replaced with a new hack in D228. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D227
129,187
12.10.2020 21:01:46
14,400
4e41ca65aed17972e210f2a297986432aed61e2b
[web] Shim visibilityjs on server side Summary: This lets us avoid setting `window = {}` on the server, which breaks `react-dnd`'s `useIsomorphicLayoutEffect` [hack](https://github.com/react-dnd/react-dnd/blob/64c4060f00c0dd9858a4911086245f1887b5b6f8/packages/core/react-dnd/src/hooks/internal/useIsomorphicLayoutEffect.ts). Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "web/redux/redux-setup.js", "new_path": "web/redux/redux-setup.js", "diff": "@@ -15,7 +15,6 @@ import type { ClientReportCreationRequest } from 'lib/types/report-types';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n-import Visibility from 'visibilityjs';\nimport baseReducer from 'lib/reducers/master-reducer';\nimport { mostRecentReadThreadSelector } from 'lib/selectors/thread-selectors';\n@@ -27,6 +26,7 @@ import {\nimport { activeThreadSelector } from '../selectors/nav-selectors';\nimport { updateWindowActiveActionType } from './action-types';\n+import { getVisibility } from './visibility';\nexport type NavInfo = {|\n...$Exact<BaseNavInfo>,\n@@ -158,7 +158,7 @@ function validateState(oldState: AppState, state: AppState): AppState {\nconst activeThread = activeThreadSelector(state);\nif (\nactiveThread &&\n- !Visibility.hidden() &&\n+ !getVisibility().hidden() &&\ntypeof document !== 'undefined' &&\ndocument &&\ndocument.hasFocus &&\n" }, { "change_type": "MODIFY", "old_path": "web/redux/visibility-handler.react.js", "new_path": "web/redux/visibility-handler.react.js", "diff": "import * as React from 'react';\nimport { useDispatch, useSelector } from 'react-redux';\n-import Visibility from 'visibilityjs';\nimport {\nbackgroundActionType,\nforegroundActionType,\n} from 'lib/reducers/foreground-reducer';\n+import { getVisibility } from './visibility';\n+\nfunction VisibilityHandler() {\n- const [visible, setVisible] = React.useState(!Visibility.hidden());\n+ const [visible, setVisible] = React.useState(!getVisibility().hidden());\nconst onVisibilityChange = React.useCallback((event, state: string) => {\nsetVisible(state === 'visible');\n}, []);\n+ const visibility = getVisibility();\nReact.useEffect(() => {\n- const listener = Visibility.change(onVisibilityChange);\n+ const listener = visibility.change(onVisibilityChange);\nreturn () => {\n- Visibility.unbind(listener);\n+ visibility.unbind(listener);\n};\n- }, [onVisibilityChange]);\n+ }, [visibility, onVisibilityChange]);\nconst dispatch = useDispatch();\nconst curForeground = useSelector(state => state.foreground);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "web/redux/visibility.js", "diff": "+// @flow\n+\n+/* eslint-disable no-unused-vars */\n+let visibility = {\n+ hidden: () => false,\n+ change: (callback: (event: Object, state: string) => mixed) => 0,\n+ unbind: (callbackID: number) => {},\n+};\n+/* eslint-enable no-unused-vars */\n+\n+(async () => {\n+ if (typeof window === 'undefined') {\n+ return;\n+ }\n+ try {\n+ const visibilityjs = await import('visibilityjs');\n+ visibility = visibilityjs.default;\n+ } catch {}\n+})();\n+\n+function getVisibility() {\n+ return visibility;\n+}\n+\n+export { getVisibility };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Shim visibilityjs on server side Summary: This lets us avoid setting `window = {}` on the server, which breaks `react-dnd`'s `useIsomorphicLayoutEffect` [hack](https://github.com/react-dnd/react-dnd/blob/64c4060f00c0dd9858a4911086245f1887b5b6f8/packages/core/react-dnd/src/hooks/internal/useIsomorphicLayoutEffect.ts). Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D228
129,187
12.10.2020 20:19:40
14,400
33000e82671ed5ea8ed806c4115b8e0db6a77abb
[server] Introduce DatabaseMonitor Summary: This adds some logging for database performance issues Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/database/database.js", "new_path": "server/src/database/database.js", "diff": "@@ -6,11 +6,14 @@ import SQL from 'sql-template-strings';\nimport dbConfig from '../../secrets/db_config';\nimport { getScriptContext } from '../scripts/script-context';\n+import DatabaseMonitor from './monitor';\nconst SQLStatement = SQL.SQLStatement;\nexport type QueryResult = [any[] & { insertId?: number }, any[]];\n+const connectionLimit = 10;\n+\nlet pool;\nfunction getPool() {\nif (pool) {\n@@ -19,11 +22,12 @@ function getPool() {\nconst scriptContext = getScriptContext();\npool = mysqlPromise.createPool({\n...dbConfig,\n- connectionLimit: 10,\n+ connectionLimit,\nmultipleStatements: !!(\nscriptContext && scriptContext.allowMultiStatementSQLQueries\n),\n});\n+ new DatabaseMonitor(pool);\nreturn pool;\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "server/src/database/monitor.js", "diff": "+// @flow\n+\n+type Pool = {\n+ +on: ('acquire' | 'connection' | 'enqueue' | 'release', () => mixed) => void,\n+ +pool: {\n+ +_connectionQueue: $ReadOnlyArray<mixed>,\n+ ...\n+ },\n+ ...\n+};\n+\n+function countDecimals(num: number) {\n+ return 1 + (num === 0 ? 0 : Math.floor(Math.log10(num)));\n+}\n+\n+class DatabaseMonitor {\n+ pool: Pool;\n+ activeQueries = 0;\n+ lastDecimalCount = 1;\n+\n+ constructor(pool: Pool) {\n+ this.pool = pool;\n+ pool.on('acquire', this.onAcquire);\n+ pool.on('release', this.onRelease);\n+ pool.on('enqueue', this.onEnqueue);\n+ }\n+\n+ get queuedQueries() {\n+ return this.pool.pool._connectionQueue.length;\n+ }\n+\n+ get outstandingQueries() {\n+ return this.activeQueries + this.queuedQueries;\n+ }\n+\n+ countOutstandingQueries() {\n+ const count = this.outstandingQueries;\n+ const decimalCount = countDecimals(count);\n+ if (decimalCount > this.lastDecimalCount) {\n+ const lowerBound = Math.pow(10, this.lastDecimalCount);\n+ console.log(`more than ${lowerBound - 1} queries outstanding`);\n+ } else if (decimalCount < this.lastDecimalCount) {\n+ const upperBound = Math.pow(10, decimalCount);\n+ console.log(`fewer than ${upperBound} queries outstanding`);\n+ }\n+ this.lastDecimalCount = decimalCount;\n+ return count;\n+ }\n+\n+ onAcquire = () => {\n+ this.activeQueries += 1;\n+ this.countOutstandingQueries();\n+ };\n+\n+ onRelease = () => {\n+ this.activeQueries -= 1;\n+ this.countOutstandingQueries();\n+ };\n+\n+ onEnqueue = () => {\n+ this.countOutstandingQueries();\n+ };\n+}\n+\n+export default DatabaseMonitor;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Introduce DatabaseMonitor Summary: This adds some logging for database performance issues Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D229
129,187
12.10.2020 22:43:21
14,400
46421050a541a1f4b054de1e6dc6461518390ced
[server] QueryMonitor.reportLaggingQuery Summary: Add some logging for MySQL queries that take a while to complete Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "ADD", "old_path": null, "new_path": "server/src/database/consts.js", "diff": "+// @flow\n+\n+export const connectionLimit = 10;\n+export const queryWarnTime = 3000; // in ms\n" }, { "change_type": "MODIFY", "old_path": "server/src/database/database.js", "new_path": "server/src/database/database.js", "diff": "@@ -7,14 +7,13 @@ import SQL from 'sql-template-strings';\nimport dbConfig from '../../secrets/db_config';\nimport { getScriptContext } from '../scripts/script-context';\nimport DatabaseMonitor from './monitor';\n+import { connectionLimit, queryWarnTime } from './consts';\nconst SQLStatement = SQL.SQLStatement;\nexport type QueryResult = [any[] & { insertId?: number }, any[]];\n-const connectionLimit = 10;\n-\n-let pool;\n+let pool, databaseMonitor;\nfunction getPool() {\nif (pool) {\nreturn pool;\n@@ -27,7 +26,7 @@ function getPool() {\nscriptContext && scriptContext.allowMultiStatementSQLQueries\n),\n});\n- new DatabaseMonitor(pool);\n+ databaseMonitor = new DatabaseMonitor(pool);\nreturn pool;\n}\n@@ -78,6 +77,11 @@ FakeSQLResult.prototype = Array.prototype;\nconst fakeResult: any = new FakeSQLResult();\nasync function dbQuery(statement: SQLStatement, triesLeft?: number = 2) {\n+ const connectionPool = getPool();\n+ const timeoutID = setTimeout(\n+ () => databaseMonitor.reportLaggingQuery(statement.sql),\n+ queryWarnTime,\n+ );\nconst scriptContext = getScriptContext();\ntry {\nconst sql = statement.sql.trim();\n@@ -91,7 +95,7 @@ async function dbQuery(statement: SQLStatement, triesLeft?: number = 2) {\nconsole.log(rawSQL(statement));\nreturn [fakeResult];\n}\n- return await getPool().query(statement);\n+ return await connectionPool.query(statement);\n} catch (e) {\nif (e.errno === 1213 && triesLeft > 0) {\nconsole.log('deadlock occurred, trying again', e);\n@@ -99,6 +103,8 @@ async function dbQuery(statement: SQLStatement, triesLeft?: number = 2) {\n}\ne.query = statement.sql;\nthrow e;\n+ } finally {\n+ clearTimeout(timeoutID);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "server/src/database/monitor.js", "new_path": "server/src/database/monitor.js", "diff": "// @flow\n+import { queryWarnTime } from './consts';\n+\ntype Pool = {\n+on: ('acquire' | 'connection' | 'enqueue' | 'release', () => mixed) => void,\n+pool: {\n@@ -60,6 +62,14 @@ class DatabaseMonitor {\nonEnqueue = () => {\nthis.countOutstandingQueries();\n};\n+\n+ reportLaggingQuery = (query: string) => {\n+ const count = this.countOutstandingQueries();\n+ console.log(\n+ `a query is taking more than ${queryWarnTime}ms to execute. ` +\n+ `there are currently ${count} queries outstanding. query: ${query}`,\n+ );\n+ };\n}\nexport default DatabaseMonitor;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] QueryMonitor.reportLaggingQuery Summary: Add some logging for MySQL queries that take a while to complete Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D230
129,187
13.10.2020 09:00:21
14,400
c1e3bfbb222549517e9edb6303bb631eb9d9bf1e
[server] Update to Node 14.13.1 Summary: Node 14.13 [introduces support](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V14.md#2020-09-29-version-14130-current-mylesborins) for named exports from CJS! This lets us remove a whole bunch of hacks. Reviewers: 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": "import { queueActivityUpdatesActionType } from '../types/activity-types';\nimport * as React from 'react';\n-import * as ReactRedux from 'react-redux';\n+import { useSelector, useDispatch } from 'react-redux';\nimport {\nupdateActivityActionTypes,\n@@ -11,8 +11,6 @@ import {\n} from '../actions/activity-actions';\nimport { useServerCall, useDispatchActionPromise } from '../utils/action-utils';\n-const { useSelector, useDispatch } = ReactRedux;\n-\ntype Props = {|\nactiveThread: ?string,\nfrozen: boolean,\n" }, { "change_type": "MODIFY", "old_path": "lib/utils/action-utils.js", "new_path": "lib/utils/action-utils.js", "diff": "@@ -26,15 +26,13 @@ import _mapValues from 'lodash/fp/mapValues';\nimport { createSelector } from 'reselect';\nimport _memoize from 'lodash/memoize';\nimport * as React from 'react';\n-import * as ReactRedux from 'react-redux';\n+import { useSelector, useDispatch } from 'react-redux';\nimport fetchJSON from './fetch-json';\nimport { getConfig } from './config';\nimport { cookieInvalidationResolutionAttempt } from '../actions/user-actions';\nimport { serverCallStateSelector } from '../selectors/server-calls';\n-const { useSelector, useDispatch } = ReactRedux;\n-\nlet nextPromiseIndex = 0;\nexport type ActionTypes<AT: string, BT: string, CT: string> = {\n" }, { "change_type": "MODIFY", "old_path": "server/.nvmrc", "new_path": "server/.nvmrc", "diff": "-14.7\n+14.13.1\n" }, { "change_type": "MODIFY", "old_path": "server/loader.mjs", "new_path": "server/loader.mjs", "diff": "-import fs from 'fs';\n-import { promisify } from 'util';\n-\n-const readFile = promisify(fs.readFile);\n-\n-// We prefer to resolve packages as modules.\n-// (1) It allows us to do destructuring imports in Node\n-// (2) Sometimes a CJS module won't specify a default export, in which case\n-// Node won't allow a default import either. This prevents all imports\n-// (3) Sometimes Flow libdefs don't specify a default export\n-const forceResolveAsModule = {\n- 'reselect': 'module',\n- 'redux': 'module',\n- 'reselect-map': 'jsnext:main',\n-};\n-\nasync function resolve(\nspecifier,\ncontext,\n@@ -30,38 +14,7 @@ async function resolve(\nreturn { url };\n}\n- const forceModuleKey = forceResolveAsModule[specifier];\n- if (forceModuleKey) {\n- const moduleFolder = defaultResult.url.match(\n- new RegExp(`file://(.*node_modules\\/${specifier})`),\n- )[1];\n- const packageConfig = await readFile(`${moduleFolder}/package.json`);\n- const packageJSON = JSON.parse(packageConfig);\n- const pathToModule = packageJSON[forceModuleKey];\n- if (pathToModule) {\n- return {\n- url: `file://${moduleFolder}/${pathToModule}`,\n- };\n- }\n- }\n-\nreturn defaultResult;\n}\n-async function getFormat(\n- url,\n- context,\n- defaultGetFormat,\n-) {\n- for (let packageName in forceResolveAsModule) {\n- if (url.indexOf(`node_modules/${packageName}`) >= 0) {\n- return { format: 'module' };\n- }\n- }\n- return defaultGetFormat(url, context, defaultGetFormat);\n-}\n-\n-export {\n- resolve,\n- getFormat,\n-};\n+export { resolve };\n" }, { "change_type": "MODIFY", "old_path": "server/src/emails/access-request.js", "new_path": "server/src/emails/access-request.js", "diff": "import type { AccessRequest } from 'lib/types/account-types';\nimport React from 'react';\n-import ReactHTML from 'react-html-email';\n+import { Item, Span, renderEmail } from 'react-html-email';\nimport _shuffle from 'lodash/fp/shuffle';\nimport ashoat from 'lib/facts/ashoat';\n@@ -11,8 +11,6 @@ import ashoat from 'lib/facts/ashoat';\nimport sendmail from './sendmail';\nimport Template from './template.react';\n-const { Item, Span, renderEmail } = ReactHTML;\n-\nconst someHeadings = [\n'What is UP my man??',\n'Ayy this that code you wrote',\n" }, { "change_type": "MODIFY", "old_path": "server/src/emails/reset-password.js", "new_path": "server/src/emails/reset-password.js", "diff": "// @flow\nimport React from 'react';\n-import ReactHTML from 'react-html-email';\n+import { Item, Span, A, renderEmail } from 'react-html-email';\nimport { verifyField } from 'lib/types/verify-types';\n@@ -10,7 +10,6 @@ import { createVerificationCode } from '../models/verification';\nimport sendmail from './sendmail';\nimport Template from './template.react';\n-const { Item, Span, A, renderEmail } = ReactHTML;\nconst { baseDomain, basePath } = urlFacts;\nasync function sendPasswordResetEmail(\n" }, { "change_type": "MODIFY", "old_path": "server/src/emails/template.react.js", "new_path": "server/src/emails/template.react.js", "diff": "import React from 'react';\nimport * as React2 from 'react';\n-import ReactHTML from 'react-html-email';\n-\n-const { Email, Box } = ReactHTML;\n+import { Email, Box } from 'react-html-email';\nconst css = `\n@media only screen and (max-device-width: 480px) {\n" }, { "change_type": "MODIFY", "old_path": "server/src/emails/verification.js", "new_path": "server/src/emails/verification.js", "diff": "// @flow\nimport React from 'react';\n-import ReactHTML from 'react-html-email';\n+import { Item, Span, A, renderEmail } from 'react-html-email';\nimport { verifyField } from 'lib/types/verify-types';\n@@ -10,7 +10,6 @@ import { createVerificationCode } from '../models/verification';\nimport sendmail from './sendmail';\nimport Template from './template.react';\n-const { Item, Span, A, renderEmail } = ReactHTML;\nconst { baseDomain, basePath } = urlFacts;\nasync function sendEmailAddressVerificationEmail(\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/website-responders.js", "new_path": "server/src/responders/website-responders.js", "diff": "@@ -10,8 +10,8 @@ import type { ServerVerificationResult } from 'lib/types/verify-types';\nimport html from 'common-tags/lib/html';\nimport { createStore, type Store } from 'redux';\nimport ReactDOMServer from 'react-dom/server';\n-import ReactRedux from 'react-redux';\n-import ReactRouter from 'react-router';\n+import { Provider } from 'react-redux';\n+import { Route, StaticRouter } from 'react-router';\nimport React from 'react';\nimport _keyBy from 'lodash/fp/keyBy';\nimport fs from 'fs';\n@@ -27,7 +27,7 @@ import { mostRecentReadThread } from 'lib/selectors/thread-selectors';\nimport { threadHasPermission } from 'lib/shared/thread-utils';\nimport { promiseAll } from 'lib/utils/promises';\n-import * as ReduxSetup from 'web/redux/redux-setup';\n+import { reducer } from 'web/redux/redux-setup';\nimport App from 'web/dist/app.build.cjs';\nimport { navInfoFromURL } from 'web/url-utils';\n@@ -46,9 +46,6 @@ import { streamJSON, waitForStream } from '../utils/json-stream';\nconst { basePath, baseDomain } = urlFacts;\nconst { renderToNodeStream } = ReactDOMServer;\n-const { Provider } = ReactRedux;\n-const { reducer } = ReduxSetup;\n-const { Route, StaticRouter } = ReactRouter;\nconst baseURL = basePath.replace(/\\/$/, '');\nconst baseHref = baseDomain + baseURL;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Update to Node 14.13.1 Summary: Node 14.13 [introduces support](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V14.md#2020-09-29-version-14130-current-mylesborins) for named exports from CJS! This lets us remove a whole bunch of hacks. Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D234
129,187
13.10.2020 09:29:34
14,400
eff0a2f570c6f8c700b701228b72fbb6220a417c
[web] Fix entry names in webpack.config.js Summary: I broke this in D227. These names matter specifically for the `assets.json` file which is only used on prod. (That's why I didn't notice it while testing initially.) Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "web/webpack.config.cjs", "new_path": "web/webpack.config.cjs", "diff": "@@ -61,7 +61,9 @@ const imageRule = {\nconst baseBrowserConfig = {\nname: 'browser',\n- entry: [ './script.js' ],\n+ entry: {\n+ browser: [ './script.js' ],\n+ },\noutput: {\nfilename: 'prod.[hash:12].build.js',\npath: path.join(__dirname, 'dist'),\n@@ -92,10 +94,13 @@ module.exports = function(env) {\nif (env === 'dev') {\nbrowserConfig = {\n...browserConfig,\n- entry: [\n- 'react-hot-loader/patch',\n+ entry: {\n...browserConfig.entry,\n+ browser: [\n+ 'react-hot-loader/patch',\n+ ...browserConfig.entry.browser,\n],\n+ },\nmode: 'development',\noutput: {\n...browserConfig.output,\n@@ -233,7 +238,9 @@ module.exports = function(env) {\ntarget: 'node',\nexternals: [ 'react', 'react-dom', 'react-redux' ],\nmode: env === 'dev' ? 'development' : 'production',\n- entry: [ './app.react.js' ],\n+ entry: {\n+ server: [ './app.react.js' ],\n+ },\noutput: {\nfilename: 'app.build.cjs',\nlibrary: 'app',\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Fix entry names in webpack.config.js Summary: I broke this in D227. These names matter specifically for the `assets.json` file which is only used on prod. (That's why I didn't notice it while testing initially.) Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D235
129,191
07.10.2020 11:50:10
-7,200
6f94285cb4c07523a03c955c52a53c72b6e4ecec
[server] Save last read message Summary: Save the last message from activity update. The idea was to make the change insignificant for older clients. Initialy, I had couple of commits, but decided to squash them together info one diff. Reviewers: ashoat Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/socket/activity-handler.react.js", "new_path": "lib/socket/activity-handler.react.js", "diff": "@@ -69,6 +69,7 @@ function ActivityHandler(props: Props) {\nactivityUpdates.push({\nfocus: true,\nthreadID: activeThread,\n+ latestMessage: activeThreadLatestMessage,\n});\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/types/activity-types.js", "new_path": "lib/types/activity-types.js", "diff": "import PropTypes from 'prop-types';\n-export type ActivityUpdate =\n- | {| focus: true, threadID: string |}\n- | {| focus: false, threadID: string, latestMessage: ?string |};\n-export const activityUpdatePropType = PropTypes.oneOfType([\n- PropTypes.shape({\n- focus: PropTypes.oneOf([true]).isRequired,\n- threadID: PropTypes.string.isRequired,\n- }),\n- PropTypes.shape({\n- focus: PropTypes.oneOf([false]).isRequired,\n+export type ActivityUpdate = {|\n+ +focus: boolean,\n+ +threadID: string,\n+ +latestMessage: ?string,\n+|};\n+export const activityUpdatePropType = PropTypes.shape({\n+ focus: PropTypes.bool.isRequired,\nthreadID: PropTypes.string.isRequired,\nlatestMessage: PropTypes.string,\n- }),\n-]);\n+});\nexport type UpdateActivityRequest = {|\nupdates: $ReadOnlyArray<ActivityUpdate>,\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/activity-responders.js", "new_path": "server/src/responders/activity-responders.js", "diff": "@@ -14,20 +14,14 @@ import {\nactivityUpdater,\nsetThreadUnreadStatus,\n} from '../updaters/activity-updaters';\n-import { validateInput, tBool, tShape } from '../utils/validation-utils';\n+import { validateInput, tShape } from '../utils/validation-utils';\nconst activityUpdatesInputValidator = t.list(\n- t.union([\ntShape({\n- focus: tBool(true),\n- threadID: t.String,\n- }),\n- tShape({\n- focus: tBool(false),\n+ focus: t.Bool,\nthreadID: t.String,\nlatestMessage: t.maybe(t.String),\n}),\n- ]),\n);\nconst inputValidator = tShape({\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -13,6 +13,7 @@ import { updateTypes } from 'lib/types/update-types';\nimport invariant from 'invariant';\nimport _difference from 'lodash/fp/difference';\n+import _max from 'lodash/fp/max';\nimport { ServerError } from 'lib/utils/errors';\n@@ -34,19 +35,19 @@ async function activityUpdater(\nthrow new ServerError('not_logged_in');\n}\n- const unverifiedThreadIDs = new Set();\nconst focusUpdatesByThreadID = new Map();\n- for (let activityUpdate of request.updates) {\n+ for (const activityUpdate of request.updates) {\nconst threadID = activityUpdate.threadID;\n- unverifiedThreadIDs.add(threadID);\n- let updatesForThreadID = focusUpdatesByThreadID.get(threadID);\n- if (!updatesForThreadID) {\n- updatesForThreadID = [];\n+ const updatesForThreadID = focusUpdatesByThreadID.get(threadID) ?? [];\n+ if (!focusUpdatesByThreadID.has(threadID)) {\nfocusUpdatesByThreadID.set(threadID, updatesForThreadID);\n}\nupdatesForThreadID.push(activityUpdate);\n}\n+ const unverifiedThreadIDs: $ReadOnlySet<string> = new Set(\n+ request.updates.map(update => update.threadID),\n+ );\nconst viewerMemberThreads = await checkThreads(\nviewer,\n[...unverifiedThreadIDs],\n@@ -66,62 +67,64 @@ async function activityUpdater(\n}\nconst currentlyFocused = [];\n- const unfocusedLatestMessages = new Map();\n+ const unfocusedLatestMessages = new Map<string, number>();\n+ const latestMessages = new Map<string, number>();\nconst rescindConditions = [];\n- for (let threadID of viewerMemberThreads) {\n+ for (const threadID of viewerMemberThreads) {\nconst focusUpdates = focusUpdatesByThreadID.get(threadID);\ninvariant(focusUpdates, `no focusUpdate for thread ID ${threadID}`);\n- let focusEndedAt = null;\n- for (let focusUpdate of focusUpdates) {\n- if (focusUpdate.focus === false) {\n- focusEndedAt = focusUpdate.latestMessage\n- ? focusUpdate.latestMessage\n- : '0';\n- // There should only ever be one of these in a request anyways\n- break;\n- }\n+ const latestMessage = _max(\n+ focusUpdates\n+ .filter(\n+ update =>\n+ update.latestMessage && !update.latestMessage.startsWith('local'),\n+ )\n+ .map(update => parseInt(update.latestMessage)),\n+ );\n+ if (latestMessage) {\n+ latestMessages.set(threadID, latestMessage);\n}\n- if (!focusEndedAt) {\n+ const focusEnded = focusUpdates.some(update => !update.focus);\n+\n+ if (!focusEnded) {\ncurrentlyFocused.push(threadID);\nrescindConditions.push(SQL`n.thread = ${threadID}`);\n} else {\n- unfocusedLatestMessages.set(threadID, focusEndedAt);\n+ unfocusedLatestMessages.set(threadID, latestMessage ?? 0);\n+ if (latestMessage) {\nrescindConditions.push(\n- SQL`(n.thread = ${threadID} AND n.message <= ${focusEndedAt})`,\n+ SQL`(n.thread = ${threadID} AND n.message <= ${latestMessage})`,\n);\n}\n}\n+ }\nconst focusUpdatePromise = updateFocusedRows(viewer, currentlyFocused);\n- const unfocusedToUnread = await determineUnfocusedThreadsReadStatus(\n+ const outdatedUnfocused = await checkUnfocusedLatestMessage(\nviewer,\nunfocusedLatestMessages,\n);\nconst setToRead = [...currentlyFocused];\nconst setToUnread = [];\n- for (let [threadID] of unfocusedLatestMessages) {\n- if (!unfocusedToUnread.includes(threadID)) {\n+ for (const [threadID] of unfocusedLatestMessages) {\n+ if (!outdatedUnfocused.includes(threadID)) {\nsetToRead.push(threadID);\n} else {\nsetToUnread.push(threadID);\n}\n}\n- const filterFunc = threadID => viewerMemberThreads.has(threadID);\n- const memberSetToRead = setToRead.filter(filterFunc);\n- const memberSetToUnread = setToUnread.filter(filterFunc);\n-\nconst time = Date.now();\nconst updateDatas = [];\nconst appendUpdateDatas = (\nthreadIDs: $ReadOnlyArray<string>,\nunread: boolean,\n) => {\n- for (let threadID of threadIDs) {\n+ for (const threadID of threadIDs) {\nupdateDatas.push({\ntype: updateTypes.UPDATE_THREAD_READ_STATUS,\nuserID: viewer.userID,\n@@ -132,41 +135,36 @@ async function activityUpdater(\n}\n};\n- const promises = [focusUpdatePromise];\n- if (memberSetToRead.length > 0) {\n- promises.push(\n- dbQuery(SQL`\n- UPDATE memberships\n- SET unread = 0\n- WHERE thread IN (${memberSetToRead})\n- AND user = ${viewer.userID}\n- `),\n- );\n- appendUpdateDatas(memberSetToRead, false);\n- }\n- if (memberSetToUnread.length > 0) {\n- promises.push(\n- dbQuery(SQL`\n- UPDATE memberships\n- SET unread = 1\n- WHERE thread IN (${memberSetToUnread})\n- AND user = ${viewer.userID}\n- `),\n+ appendUpdateDatas(setToRead, false);\n+ appendUpdateDatas(setToUnread, true);\n+\n+ const updateLatestReadMessagePromise = updateLastReadMessage(\n+ viewer,\n+ latestMessages,\n);\n- appendUpdateDatas(memberSetToUnread, true);\n- }\n- promises.push(\n- createUpdates(updateDatas, { viewer, updatesForCurrentSession: 'ignore' }),\n+ const updatesPromise = createUpdates(updateDatas, {\n+ viewer,\n+ updatesForCurrentSession: 'ignore',\n+ });\n+ const setUnreadStatusPromise = updateUnreadStatus(\n+ viewer,\n+ setToRead,\n+ setToUnread,\n);\n- await Promise.all(promises);\n+ await Promise.all([\n+ focusUpdatePromise,\n+ updateLatestReadMessagePromise,\n+ updatesPromise,\n+ setUnreadStatusPromise,\n+ ]);\n// We do this afterwards so the badge count is correct\nconst rescindCondition = SQL`n.user = ${viewer.userID} AND `;\nrescindCondition.append(mergeOrConditions(rescindConditions));\nawait rescindPushNotifs(rescindCondition);\n- return { unfocusedToUnread };\n+ return { unfocusedToUnread: outdatedUnfocused };\n}\nasync function updateFocusedRows(\n@@ -195,9 +193,9 @@ async function updateFocusedRows(\n// is no longer the latest message ID.\n// Returns the set of unfocused threads that should be set to unread on\n// the client because a new message arrived since they were unfocused.\n-async function determineUnfocusedThreadsReadStatus(\n+async function checkUnfocusedLatestMessage(\nviewer: Viewer,\n- unfocusedLatestMessages: Map<string, string>,\n+ unfocusedLatestMessages: Map<string, number>,\n): Promise<string[]> {\nif (unfocusedLatestMessages.size === 0 || !viewer.loggedIn) {\nreturn [];\n@@ -222,6 +220,7 @@ async function determineUnfocusedThreadsReadStatus(\nLEFT JOIN memberships stm ON m.type = ${messageTypes.CREATE_SUB_THREAD}\nAND stm.thread = m.content AND stm.user = ${viewer.userID}\nWHERE m.thread IN (${unreadCandidates}) AND\n+ m.user != ${viewer.userID} AND\n(\nm.type != ${messageTypes.CREATE_SUB_THREAD} OR\nJSON_EXTRACT(stm.permissions, ${knowOfExtractString}) IS TRUE\n@@ -231,18 +230,15 @@ async function determineUnfocusedThreadsReadStatus(\nconst [result] = await dbQuery(query);\nconst resetToUnread = [];\n- for (let row of result) {\n+ for (const row of result) {\nconst threadID = row.thread.toString();\n- const serverLatestMessage = row.latest_message.toString();\n+ const serverLatestMessage = row.latest_message;\nconst clientLatestMessage = unfocusedLatestMessages.get(threadID);\ninvariant(\nclientLatestMessage,\n'latest message should be set for all provided threads',\n);\n- if (\n- !clientLatestMessage.startsWith('local') &&\n- clientLatestMessage !== serverLatestMessage\n- ) {\n+ if (clientLatestMessage < serverLatestMessage) {\nresetToUnread.push(threadID);\n}\n}\n@@ -265,12 +261,67 @@ async function checkThreadsFocused(\nconst [result] = await dbQuery(query);\nconst focusedThreadIDs = [];\n- for (let row of result) {\n+ for (const row of result) {\nfocusedThreadIDs.push(row.thread.toString());\n}\nreturn focusedThreadIDs;\n}\n+async function updateLastReadMessage(\n+ viewer: Viewer,\n+ lastReadMessages: $ReadOnlyMap<string, number>,\n+) {\n+ if (lastReadMessages.size === 0) {\n+ return;\n+ }\n+\n+ const query = SQL`\n+ UPDATE memberships\n+ SET last_read_message = GREATEST(last_read_message, CASE\n+ `;\n+ lastReadMessages.forEach((lastMessage, threadID) => {\n+ query.append(SQL`WHEN thread = ${threadID} THEN ${lastMessage} `);\n+ });\n+ query.append(SQL`\n+ ELSE last_read_message\n+ END)\n+ WHERE thread IN (${[...lastReadMessages.keys()]})\n+ AND user = ${viewer.userID}\n+ `);\n+\n+ return await dbQuery(query);\n+}\n+\n+async function updateUnreadStatus(\n+ viewer: Viewer,\n+ setToRead: $ReadOnlyArray<string>,\n+ setToUnread: $ReadOnlyArray<string>,\n+) {\n+ const promises = [];\n+ if (setToRead.length > 0) {\n+ promises.push(\n+ dbQuery(SQL`\n+ UPDATE memberships\n+ SET unread = 0\n+ WHERE thread IN (${setToRead})\n+ AND user = ${viewer.userID}\n+ `),\n+ );\n+ }\n+ if (setToUnread.length > 0) {\n+ promises.push(\n+ dbQuery(SQL`\n+ UPDATE memberships\n+ SET unread = 1\n+ WHERE thread IN (${setToUnread})\n+ AND user = ${viewer.userID}\n+ `),\n+ );\n+ }\n+\n+ return await Promise.all(promises);\n+}\n+\nasync function setThreadUnreadStatus(\nviewer: Viewer,\nrequest: SetThreadUnreadStatusRequest,\n@@ -341,9 +392,9 @@ async function shouldResetThreadToUnread(\nreturn false;\n}\n- const resetToUnread = await determineUnfocusedThreadsReadStatus(\n+ const resetToUnread = await checkUnfocusedLatestMessage(\nviewer,\n- new Map([[request.threadID, request.latestMessage ?? '0']]),\n+ new Map([[request.threadID, parseInt(request.latestMessage) || 0]]),\n);\nreturn resetToUnread.some(threadID => threadID === request.threadID);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Save last read message Summary: Save the last message from activity update. The idea was to make the change insignificant for older clients. Initialy, I had couple of commits, but decided to squash them together info one diff. Reviewers: ashoat Reviewed By: ashoat Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D191
129,191
09.10.2020 13:13:54
-7,200
70c4a8129e4e89496700da8aa9738d602278e0df
[server] Improve SQL queries formatting Reviewers: ashoat Subscribers: Adrian, zrebcu411, KatPo
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -277,10 +277,12 @@ async function updateLastReadMessage(\nconst query = SQL`\nUPDATE memberships\n- SET last_read_message = GREATEST(last_read_message, CASE\n+ SET last_read_message = GREATEST(last_read_message,\n+ CASE\n`;\nlastReadMessages.forEach((lastMessage, threadID) => {\n- query.append(SQL`WHEN thread = ${threadID} THEN ${lastMessage} `);\n+ query.append(SQL`\n+ WHEN thread = ${threadID} THEN ${lastMessage} `);\n});\nquery.append(SQL`\nELSE last_read_message\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Improve SQL queries formatting Reviewers: ashoat Reviewed By: ashoat Subscribers: Adrian, zrebcu411, KatPo Differential Revision: https://phabricator.ashoat.com/D207
129,191
09.10.2020 13:37:36
-7,200
e31c847ec42bae08b1f70908ca66c2902e974956
[server] Update last read message during updating unread status Reviewers: ashoat Subscribers: Adrian, zrebcu411, KatPo
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -346,13 +346,19 @@ async function setThreadUnreadStatus(\n}\nconst resetThreadToUnread = await shouldResetThreadToUnread(viewer, request);\n-\nif (!resetThreadToUnread) {\n+ const lastReadMessage = request.unread\n+ ? SQL`0`\n+ : SQL`GREATEST(m.last_read_message, ${request.latestMessage ?? 0})`;\nconst update = SQL`\nUPDATE memberships m\n- SET m.unread = ${request.unread ? 1 : 0}\n- WHERE m.thread = ${request.threadID} AND m.user = ${viewer.userID}\n+ SET m.unread = ${request.unread ? 1 : 0},\n+ m.last_read_message =\n`;\n+ update.append(lastReadMessage);\n+ update.append(SQL`\n+ WHERE m.thread = ${request.threadID} AND m.user = ${viewer.userID}\n+ `);\nconst queryPromise = dbQuery(update);\nconst time = Date.now();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Update last read message during updating unread status Reviewers: ashoat Reviewed By: ashoat Subscribers: Adrian, zrebcu411, KatPo Differential Revision: https://phabricator.ashoat.com/D208
129,191
14.10.2020 15:31:46
-7,200
2ce47ecd2082d31474023f904a26c3cbceb91201
[server] Update last message and last read message when creating a new message Reviewers: ashoat Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/creators/message-creator.js", "new_path": "server/src/creators/message-creator.js", "diff": "@@ -37,6 +37,39 @@ import { publisher } from '../socket/redis';\nimport { fetchMessageInfoForLocalID } from '../fetchers/message-fetchers';\nimport { creationString } from '../utils/idempotent';\n+type UserThreadInfo = {|\n+ +devices: Map<\n+ string,\n+ {|\n+ +deviceType: string,\n+ +deviceToken: string,\n+ +codeVersion: ?string,\n+ |},\n+ >,\n+ +threadIDs: Set<string>,\n+ +notFocusedThreadIDs: Set<string>,\n+ +subthreadsCanNotify: Set<string>,\n+ +subthreadsCanSetToUnread: Set<string>,\n+|};\n+\n+type LatestMessagesPerUser = Map<\n+ string,\n+ $ReadOnlyMap<\n+ string,\n+ {|\n+ +latestMessage: string,\n+ +latestReadMessage?: string,\n+ |},\n+ >,\n+>;\n+\n+type LatestMessages = $ReadOnlyArray<{|\n+ +userID: string,\n+ +threadID: string,\n+ +latestMessage: string,\n+ +latestReadMessage: ?string,\n+|}>;\n+\n// Does not do permission checks! (checkThreadPermission)\nasync function createMessages(\nviewer: Viewer,\n@@ -122,7 +155,7 @@ async function createMessages(\nmessageData.type === messageTypes.MULTIMEDIA\n) {\nconst mediaIDs = [];\n- for (let { id } of messageData.media) {\n+ for (const { id } of messageData.media) {\nmediaIDs.push(parseInt(id, 10));\n}\ncontent = JSON.stringify(mediaIDs);\n@@ -176,7 +209,7 @@ async function postMessageSend(\nlet joinIndex = 0;\nlet subthreadSelects = '';\nconst subthreadJoins = [];\n- for (let subthread of subthreadPermissionsToCheck) {\n+ for (const subthread of subthreadPermissionsToCheck) {\nconst index = joinIndex++;\nsubthreadSelects += `\n,\n@@ -210,9 +243,9 @@ async function postMessageSend(\nm.thread IN (${[...threadsToMessageIndices.keys()]})\n`);\n- const perUserInfo = new Map();\n+ const perUserInfo = new Map<string, UserThreadInfo>();\nconst [result] = await dbQuery(query);\n- for (let row of result) {\n+ for (const row of result) {\nconst userID = row.user.toString();\nconst threadID = row.thread.toString();\nconst deviceToken = row.device_token;\n@@ -230,7 +263,7 @@ async function postMessageSend(\nperUserInfo.set(userID, thisUserInfo);\n// Subthread info will be the same for each subthread, so we only parse\n// it once\n- for (let subthread of subthreadPermissionsToCheck) {\n+ for (const subthread of subthreadPermissionsToCheck) {\nconst isSubthreadMember = !!row[`subthread${subthread}_role`];\nconst permissions = row[`subthread${subthread}_permissions`];\nconst canSeeSubthread = permissionLookup(\n@@ -264,10 +297,11 @@ async function postMessageSend(\n}\n}\n- const pushInfo = {},\n- setUnreadPairs = [],\n- messageInfosPerUser = {};\n- for (let pair of perUserInfo) {\n+ const pushInfo = {};\n+ const setUnreadPairs = [];\n+ const messageInfosPerUser = {};\n+ const latestMessagesPerUser: LatestMessagesPerUser = new Map();\n+ for (const pair of perUserInfo) {\nconst [userID, preUserPushInfo] = pair;\nconst { subthreadsCanSetToUnread, subthreadsCanNotify } = preUserPushInfo;\nconst userPushInfo = {\n@@ -275,10 +309,10 @@ async function postMessageSend(\nmessageInfos: [],\n};\nconst threadIDsToSetToUnread = new Set();\n- for (let threadID of preUserPushInfo.notFocusedThreadIDs) {\n+ for (const threadID of preUserPushInfo.notFocusedThreadIDs) {\nconst messageIndices = threadsToMessageIndices.get(threadID);\ninvariant(messageIndices, `indices should exist for thread ${threadID}`);\n- for (let messageIndex of messageIndices) {\n+ for (const messageIndex of messageIndices) {\nconst messageInfo = messageInfos[messageIndex];\nif (messageInfo.creatorID === userID) {\ncontinue;\n@@ -306,14 +340,14 @@ async function postMessageSend(\n) {\npushInfo[userID] = userPushInfo;\n}\n- for (let threadID of threadIDsToSetToUnread) {\n+ for (const threadID of threadIDsToSetToUnread) {\nsetUnreadPairs.push({ userID, threadID });\n}\nconst userMessageInfos = [];\n- for (let threadID of preUserPushInfo.threadIDs) {\n+ for (const threadID of preUserPushInfo.threadIDs) {\nconst messageIndices = threadsToMessageIndices.get(threadID);\ninvariant(messageIndices, `indices should exist for thread ${threadID}`);\n- for (let messageIndex of messageIndices) {\n+ for (const messageIndex of messageIndices) {\nconst messageInfo = messageInfos[messageIndex];\nuserMessageInfos.push(messageInfo);\n}\n@@ -321,11 +355,24 @@ async function postMessageSend(\nif (userMessageInfos.length > 0) {\nmessageInfosPerUser[userID] = userMessageInfos;\n}\n+\n+ latestMessagesPerUser.set(\n+ userID,\n+ determineLatestMessagesPerThread(\n+ preUserPushInfo,\n+ userID,\n+ threadsToMessageIndices,\n+ messageInfos,\n+ ),\n+ );\n}\n+ const latestMessages = flattenLatestMessagesPerUser(latestMessagesPerUser);\n+\nawait Promise.all([\nupdateUnreadStatus(setUnreadPairs),\nredisPublish(viewer, messageInfosPerUser),\n+ updateLatestMessages(latestMessages),\n]);\nawait sendPushNotifs(pushInfo);\n@@ -366,7 +413,7 @@ async function redisPublish(\nviewer: Viewer,\nmessageInfosPerUser: { [userID: string]: $ReadOnlyArray<RawMessageInfo> },\n) {\n- for (let userID in messageInfosPerUser) {\n+ for (const userID in messageInfosPerUser) {\nif (userID === viewer.userID && viewer.hasSessionInfo) {\ncontinue;\n}\n@@ -384,7 +431,7 @@ async function redisPublish(\nreturn;\n}\nconst sessionIDs = await fetchOtherSessionsForViewer(viewer);\n- for (let sessionID of sessionIDs) {\n+ for (const sessionID of sessionIDs) {\npublisher.sendMessage(\n{ userID: viewer.userID, sessionID },\n{\n@@ -395,4 +442,121 @@ async function redisPublish(\n}\n}\n+function determineLatestMessagesPerThread(\n+ preUserPushInfo: UserThreadInfo,\n+ userID: string,\n+ threadsToMessageIndices: $ReadOnlyMap<string, $ReadOnlyArray<number>>,\n+ messageInfos: $ReadOnlyArray<RawMessageInfo>,\n+) {\n+ const {\n+ threadIDs,\n+ notFocusedThreadIDs,\n+ subthreadsCanSetToUnread,\n+ } = preUserPushInfo;\n+ const latestMessagesPerThread = new Map();\n+ for (const threadID of threadIDs) {\n+ const messageIndices = threadsToMessageIndices.get(threadID);\n+ invariant(messageIndices, `indices should exist for thread ${threadID}`);\n+ for (const messageIndex of messageIndices) {\n+ const messageInfo = messageInfos[messageIndex];\n+ if (\n+ messageInfo.type === messageTypes.CREATE_SUB_THREAD &&\n+ !subthreadsCanSetToUnread.has(messageInfo.childThreadID)\n+ ) {\n+ continue;\n+ }\n+\n+ const messageID = messageInfo.id;\n+ invariant(\n+ messageID,\n+ 'message ID should exist in determineLatestMessagesPerThread',\n+ );\n+\n+ if (\n+ notFocusedThreadIDs.has(threadID) &&\n+ messageInfo.creatorID !== userID\n+ ) {\n+ latestMessagesPerThread.set(threadID, {\n+ latestMessage: messageID,\n+ });\n+ } else {\n+ latestMessagesPerThread.set(threadID, {\n+ latestMessage: messageID,\n+ latestReadMessage: messageID,\n+ });\n+ }\n+ }\n+ }\n+ return latestMessagesPerThread;\n+}\n+\n+function flattenLatestMessagesPerUser(\n+ latestMessagesPerUser: LatestMessagesPerUser,\n+): LatestMessages {\n+ const result = [];\n+ for (const [userID, latestMessagesPerThread] of latestMessagesPerUser) {\n+ for (const [threadID, latestMessages] of latestMessagesPerThread) {\n+ result.push({\n+ userID,\n+ threadID,\n+ latestMessage: latestMessages.latestMessage,\n+ latestReadMessage: latestMessages.latestReadMessage,\n+ });\n+ }\n+ }\n+ return result;\n+}\n+\n+function updateLatestMessages(latestMessages: LatestMessages) {\n+ const query = SQL`\n+ UPDATE memberships\n+ SET\n+ `;\n+\n+ const lastMessageExpression = SQL`\n+ last_message = GREATEST(last_message, CASE\n+ `;\n+ const lastReadMessageExpression = SQL`\n+ , last_read_message = GREATEST(last_read_message, CASE\n+ `;\n+ let shouldUpdateLastReadMessage = false;\n+ for (const {\n+ userID,\n+ threadID,\n+ latestMessage,\n+ latestReadMessage,\n+ } of latestMessages) {\n+ lastMessageExpression.append(SQL`\n+ WHEN user = ${userID} AND thread = ${threadID} THEN ${latestMessage}\n+ `);\n+ if (latestReadMessage) {\n+ shouldUpdateLastReadMessage = true;\n+ lastReadMessageExpression.append(SQL`\n+ WHEN user = ${userID} AND thread = ${threadID} THEN ${latestReadMessage}\n+ `);\n+ }\n+ }\n+ lastMessageExpression.append(SQL`\n+ ELSE last_message\n+ END)\n+ `);\n+ lastReadMessageExpression.append(SQL`\n+ ELSE last_read_message\n+ END)\n+ `);\n+\n+ const conditions = latestMessages.map(\n+ ({ userID, threadID }) => SQL`(user = ${userID} AND thread = ${threadID})`,\n+ );\n+\n+ query.append(lastMessageExpression);\n+ if (shouldUpdateLastReadMessage) {\n+ query.append(lastReadMessageExpression);\n+ }\n+ query.append(SQL`WHERE `);\n+ query.append(mergeOrConditions(conditions));\n+\n+ return dbQuery(query);\n+}\n+\nexport default createMessages;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Update last message and last read message when creating a new message Reviewers: ashoat Reviewed By: ashoat Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D238
129,187
16.10.2020 11:28:43
14,400
fade2581aa3d9020f54f88aa12782579733159c6
[web] Style modal form footer using flexbox Summary: This handles overflow and vertical positioning much better. Test Plan: I made sure the modals looked good on the website Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "web/modals/account/forgot-password-modal.react.js", "new_path": "web/modals/account/forgot-password-modal.react.js", "diff": "@@ -70,17 +70,15 @@ class ForgotPasswordModal extends React.PureComponent<Props, State> {\n</div>\n</div>\n<div className={css['form-footer']}>\n- <span className={css['modal-form-error']}>\n- {this.state.errorMessage}\n- </span>\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Reset\"\nonClick={this.onSubmit}\ndisabled={this.props.inputDisabled}\n/>\n- </span>\n+ <div className={css['modal-form-error']}>\n+ {this.state.errorMessage}\n+ </div>\n</div>\n</form>\n</div>\n" }, { "change_type": "MODIFY", "old_path": "web/modals/account/log-in-modal.react.js", "new_path": "web/modals/account/log-in-modal.react.js", "diff": "@@ -94,17 +94,15 @@ class LogInModal extends React.PureComponent<Props, State> {\n</div>\n</div>\n<div className={css['form-footer']}>\n- <span className={css['modal-form-error']}>\n- {this.state.errorMessage}\n- </span>\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Log in\"\nonClick={this.onSubmit}\ndisabled={this.props.inputDisabled}\n/>\n- </span>\n+ <div className={css['modal-form-error']}>\n+ {this.state.errorMessage}\n+ </div>\n</div>\n</form>\n</div>\n" }, { "change_type": "MODIFY", "old_path": "web/modals/account/register-modal.react.js", "new_path": "web/modals/account/register-modal.react.js", "diff": "@@ -118,17 +118,15 @@ class RegisterModal extends React.PureComponent<Props, State> {\n</div>\n</div>\n<div className={css['form-footer']}>\n- <span className={css['modal-form-error']}>\n- {this.state.errorMessage}\n- </span>\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Register\"\nonClick={this.onSubmit}\ndisabled={this.props.inputDisabled}\n/>\n- </span>\n+ <div className={css['modal-form-error']}>\n+ {this.state.errorMessage}\n+ </div>\n</div>\n</form>\n</div>\n" }, { "change_type": "MODIFY", "old_path": "web/modals/account/reset-password-modal.react.js", "new_path": "web/modals/account/reset-password-modal.react.js", "diff": "@@ -97,17 +97,15 @@ class ResetPasswordModal extends React.PureComponent<Props, State> {\n</div>\n</div>\n<div className={css['form-footer']}>\n- <span className={css['modal-form-error']}>\n- {this.state.errorMessage}\n- </span>\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Update\"\nonClick={this.onSubmit}\ndisabled={this.props.inputDisabled}\n/>\n- </span>\n+ <div className={css['modal-form-error']}>\n+ {this.state.errorMessage}\n+ </div>\n</div>\n</form>\n</div>\n" }, { "change_type": "MODIFY", "old_path": "web/modals/account/user-settings-modal.react.js", "new_path": "web/modals/account/user-settings-modal.react.js", "diff": "@@ -224,25 +224,21 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\nlet buttons = null;\nif (this.state.currentTabType === 'delete') {\nbuttons = (\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Delete account\"\nonClick={this.onDelete}\ndisabled={this.props.inputDisabled}\n/>\n- </span>\n);\n} else {\nbuttons = (\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Update account\"\nonClick={this.onSubmit}\ndisabled={this.props.inputDisabled}\n/>\n- </span>\n);\n}\n@@ -284,10 +280,10 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\n</div>\n</div>\n<div className={css['form-footer']}>\n- <span className={css['modal-form-error']}>\n- {this.state.errorMessage}\n- </span>\n{buttons}\n+ <div className={css['modal-form-error']}>\n+ {this.state.errorMessage}\n+ </div>\n</div>\n</form>\n</div>\n" }, { "change_type": "MODIFY", "old_path": "web/modals/concurrent-modification-modal.react.js", "new_path": "web/modals/concurrent-modification-modal.react.js", "diff": "@@ -19,13 +19,11 @@ export default function ConcurrentModificationModal(props: Props) {\ntime as you! Please refresh the entry and try again.\n</p>\n<div className={css['form-footer']}>\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Refresh entry\"\nonClick={props.onRefresh}\n/>\n- </span>\n</div>\n</div>\n</Modal>\n" }, { "change_type": "MODIFY", "old_path": "web/modals/threads/confirm-leave-thread-modal.react.js", "new_path": "web/modals/threads/confirm-leave-thread-modal.react.js", "diff": "@@ -27,13 +27,11 @@ class ConfirmLeaveThreadModal extends React.PureComponent<Props> {\n{'\"?'}\n</p>\n<div className={css['form-footer']}>\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Leave thread\"\nonClick={this.props.onConfirm}\n/>\n- </span>\n</div>\n</div>\n</Modal>\n" }, { "change_type": "MODIFY", "old_path": "web/modals/threads/new-thread-modal.react.js", "new_path": "web/modals/threads/new-thread-modal.react.js", "diff": "@@ -176,17 +176,15 @@ class NewThreadModal extends React.PureComponent<Props, State> {\n</div>\n</div>\n<div className={css['form-footer']}>\n- <span className={css['modal-form-error']}>\n- {this.state.errorMessage}\n- </span>\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Save\"\nonClick={this.onSubmit}\ndisabled={this.props.inputDisabled}\n/>\n- </span>\n+ <div className={css['modal-form-error']}>\n+ {this.state.errorMessage}\n+ </div>\n</div>\n</form>\n</div>\n" }, { "change_type": "MODIFY", "old_path": "web/modals/threads/thread-settings-modal.react.js", "new_path": "web/modals/threads/thread-settings-modal.react.js", "diff": "@@ -256,25 +256,21 @@ class ThreadSettingsModal extends React.PureComponent<Props, State> {\nlet buttons = null;\nif (this.state.currentTabType === 'delete') {\nbuttons = (\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Delete\"\nonClick={this.onDelete}\ndisabled={this.props.inputDisabled}\n/>\n- </span>\n);\n} else {\nbuttons = (\n- <span className={css['form-submit']}>\n<input\ntype=\"submit\"\nvalue=\"Save\"\nonClick={this.onSubmit}\ndisabled={this.props.inputDisabled || !this.changeQueued()}\n/>\n- </span>\n);\n}\n@@ -334,10 +330,10 @@ class ThreadSettingsModal extends React.PureComponent<Props, State> {\n</div>\n</div>\n<div className={css['form-footer']}>\n- <span className={css['modal-form-error']}>\n- {this.state.errorMessage}\n- </span>\n{buttons}\n+ <div className={css['modal-form-error']}>\n+ {this.state.errorMessage}\n+ </div>\n</div>\n</form>\n</div>\n" }, { "change_type": "MODIFY", "old_path": "web/style.css", "new_path": "web/style.css", "diff": "@@ -404,21 +404,21 @@ div.color-title {\n}\ndiv.modal-body div.form-footer {\n+ display: flex;\n+ flex-direction: row-reverse;\n+ justify-content: space-between;\n+ align-items: start;\nmargin-top: 5px;\nborder-top: 2px solid #EFEFEF;\nmin-height: 26px;\npadding: 7px 4px 4px 0;\n}\n-div.modal-body div.form-footer span.modal-form-error {\n- display: inline-block;\n- font-size: 14px;\n+div.modal-body div.form-footer div.modal-form-error {\n+ font-size: 12px;\ncolor: red;\nfont-style: italic;\n- padding-top: 5px;\n-}\n-div.modal-body div.form-footer span.form-submit {\n- display: inline-block;\n- float: right;\n+ padding-left: 6px;\n+ align-self: center;\n}\ndiv.form-text > div.form-title {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Style modal form footer using flexbox Summary: This handles overflow and vertical positioning much better. Test Plan: I made sure the modals looked good on the website Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D250
129,187
15.10.2020 19:51:39
14,400
fe73077c7ac88f1213cb80f3968913bb710323ba
[lib] Restrict valid usernames Summary: They must now be at least six characters long, and cannot begin with a special character. Test Plan: I tested the RegEx in a JavaScript REPL Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/shared/account-utils.js", "new_path": "lib/shared/account-utils.js", "diff": "@@ -10,7 +10,8 @@ import {\nsocketAuthErrorResolutionAttempt,\n} from '../actions/user-actions';\n-const validUsernameRegex = /^[a-zA-Z0-9-_]+$/;\n+const validUsernameRegex = /^[a-zA-Z0-9][a-zA-Z0-9-_]{5,}$/;\n+const oldValidUsernameRegex = /^[a-zA-Z0-9-_]+$/;\nconst validEmailRegex = new RegExp(\n/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+/.source +\n/@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?/.source +\n@@ -63,6 +64,7 @@ function invalidSessionRecovery(\nexport {\nvalidUsernameRegex,\n+ oldValidUsernameRegex,\nvalidEmailRegex,\ninvalidSessionDowngrade,\ninvalidSessionRecovery,\n" }, { "change_type": "MODIFY", "old_path": "native/account/forgot-password-panel.react.js", "new_path": "native/account/forgot-password-panel.react.js", "diff": "@@ -17,7 +17,10 @@ import {\nforgotPassword,\n} from 'lib/actions/user-actions';\nimport { connect } from 'lib/utils/redux-utils';\n-import { validUsernameRegex, validEmailRegex } from 'lib/shared/account-utils';\n+import {\n+ oldValidUsernameRegex,\n+ validEmailRegex,\n+} from 'lib/shared/account-utils';\nimport {\nTextInput,\n@@ -25,21 +28,21 @@ import {\n} from './modal-components.react';\nimport { PanelButton, Panel } from './panel-components.react';\n-type Props = {\n- setActiveAlert: (activeAlert: boolean) => void,\n- opacityValue: Animated.Value,\n- onSuccess: () => void,\n+type Props = {|\n+ +setActiveAlert: (activeAlert: boolean) => void,\n+ +opacityValue: Animated.Value,\n+ +onSuccess: () => void,\n// Redux state\n- loadingStatus: LoadingStatus,\n- usernamePlaceholder: string,\n+ +loadingStatus: LoadingStatus,\n+ +usernamePlaceholder: string,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- forgotPassword: (usernameOrEmail: string) => Promise<void>,\n-};\n-type State = {\n- usernameOrEmailInputText: string,\n-};\n+ +forgotPassword: (usernameOrEmail: string) => Promise<void>,\n+|};\n+type State = {|\n+ +usernameOrEmailInputText: string,\n+|};\nclass ForgotPasswordPanel extends React.PureComponent<Props, State> {\nstatic propTypes = {\nsetActiveAlert: PropTypes.func.isRequired,\n@@ -96,7 +99,8 @@ class ForgotPasswordPanel extends React.PureComponent<Props, State> {\nonSubmit = () => {\nthis.props.setActiveAlert(true);\nif (\n- this.state.usernameOrEmailInputText.search(validUsernameRegex) === -1 &&\n+ this.state.usernameOrEmailInputText.search(oldValidUsernameRegex) ===\n+ -1 &&\nthis.state.usernameOrEmailInputText.search(validEmailRegex) === -1\n) {\nAlert.alert(\n" }, { "change_type": "MODIFY", "old_path": "native/account/log-in-panel.react.js", "new_path": "native/account/log-in-panel.react.js", "diff": "@@ -21,7 +21,10 @@ import invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport Animated from 'react-native-reanimated';\n-import { validUsernameRegex, validEmailRegex } from 'lib/shared/account-utils';\n+import {\n+ oldValidUsernameRegex,\n+ validEmailRegex,\n+} from 'lib/shared/account-utils';\nimport { connect } from 'lib/utils/redux-utils';\nimport { logInActionTypes, logIn } from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n@@ -41,24 +44,24 @@ import {\ntype NavContextType,\n} from '../navigation/navigation-context';\n-export type LogInState = {\n- usernameOrEmailInputText: string,\n- passwordInputText: string,\n-};\n-type Props = {\n- setActiveAlert: (activeAlert: boolean) => void,\n- opacityValue: Animated.Value,\n- innerRef: (logInPanel: ?LogInPanel) => void,\n- state: StateContainer<LogInState>,\n+export type LogInState = {|\n+ +usernameOrEmailInputText: string,\n+ +passwordInputText: string,\n+|};\n+type Props = {|\n+ +setActiveAlert: (activeAlert: boolean) => void,\n+ +opacityValue: Animated.Value,\n+ +innerRef: (logInPanel: ?LogInPanel) => void,\n+ +state: StateContainer<LogInState>,\n// Redux state\n- loadingStatus: LoadingStatus,\n- logInExtraInfo: () => LogInExtraInfo,\n- usernamePlaceholder: string,\n+ +loadingStatus: LoadingStatus,\n+ +logInExtraInfo: () => LogInExtraInfo,\n+ +usernamePlaceholder: string,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- logIn: (logInInfo: LogInInfo) => Promise<LogInResult>,\n-};\n+ +logIn: (logInInfo: LogInInfo) => Promise<LogInResult>,\n+|};\nclass LogInPanel extends React.PureComponent<Props> {\nstatic propTypes = {\nsetActiveAlert: PropTypes.func.isRequired,\n@@ -190,7 +193,7 @@ class LogInPanel extends React.PureComponent<Props> {\nthis.props.setActiveAlert(true);\nif (\nthis.props.state.state.usernameOrEmailInputText.search(\n- validUsernameRegex,\n+ oldValidUsernameRegex,\n) === -1 &&\nthis.props.state.state.usernameOrEmailInputText.search(\nvalidEmailRegex,\n" }, { "change_type": "MODIFY", "old_path": "server/src/creators/account-creator.js", "new_path": "server/src/creators/account-creator.js", "diff": "@@ -11,7 +11,10 @@ import { messageTypes } from 'lib/types/message-types';\nimport bcrypt from 'twin-bcrypt';\nimport invariant from 'invariant';\n-import { validUsernameRegex, validEmailRegex } from 'lib/shared/account-utils';\n+import {\n+ oldValidUsernameRegex,\n+ validEmailRegex,\n+} from 'lib/shared/account-utils';\nimport { ServerError } from 'lib/utils/errors';\nimport { values } from 'lib/utils/objects';\nimport ashoat from 'lib/facts/ashoat';\n@@ -40,7 +43,7 @@ async function createAccount(\nif (request.password.trim() === '') {\nthrow new ServerError('empty_password');\n}\n- if (request.username.search(validUsernameRegex) === -1) {\n+ if (request.username.search(oldValidUsernameRegex) === -1) {\nthrow new ServerError('invalid_username');\n}\nif (request.email.search(validEmailRegex) === -1) {\n" }, { "change_type": "MODIFY", "old_path": "web/modals/account/forgot-password-modal.react.js", "new_path": "web/modals/account/forgot-password-modal.react.js", "diff": "@@ -7,7 +7,10 @@ import * as React from 'react';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\n-import { validUsernameRegex, validEmailRegex } from 'lib/shared/account-utils';\n+import {\n+ oldValidUsernameRegex,\n+ validEmailRegex,\n+} from 'lib/shared/account-utils';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\nforgotPasswordActionTypes,\n@@ -19,20 +22,19 @@ import css from '../../style.css';\nimport Modal from '../modal.react';\nimport PasswordResetEmailModal from './password-reset-email-modal.react';\n-type Props = {\n- setModal: (modal: ?React.Node) => void,\n+type Props = {|\n+ +setModal: (modal: ?React.Node) => void,\n// Redux state\n- inputDisabled: boolean,\n+ +inputDisabled: boolean,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- forgotPassword: (usernameOrEmail: string) => Promise<void>,\n-};\n-type State = {\n- usernameOrEmail: string,\n- errorMessage: string,\n-};\n-\n+ +forgotPassword: (usernameOrEmail: string) => Promise<void>,\n+|};\n+type State = {|\n+ +usernameOrEmail: string,\n+ +errorMessage: string,\n+|};\nclass ForgotPasswordModal extends React.PureComponent<Props, State> {\nprops: Props;\nstate: State;\n@@ -100,7 +102,7 @@ class ForgotPasswordModal extends React.PureComponent<Props, State> {\nevent.preventDefault();\nif (\n- this.state.usernameOrEmail.search(validUsernameRegex) === -1 &&\n+ this.state.usernameOrEmail.search(oldValidUsernameRegex) === -1 &&\nthis.state.usernameOrEmail.search(validEmailRegex) === -1\n) {\nthis.setState(\n" }, { "change_type": "MODIFY", "old_path": "web/modals/account/log-in-modal.react.js", "new_path": "web/modals/account/log-in-modal.react.js", "diff": "@@ -13,7 +13,10 @@ import * as React from 'react';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\n-import { validUsernameRegex, validEmailRegex } from 'lib/shared/account-utils';\n+import {\n+ oldValidUsernameRegex,\n+ validEmailRegex,\n+} from 'lib/shared/account-utils';\nimport { connect } from 'lib/utils/redux-utils';\nimport { logInActionTypes, logIn } from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n@@ -23,22 +26,21 @@ import Modal from '../modal.react';\nimport ForgotPasswordModal from './forgot-password-modal.react';\nimport { webLogInExtraInfoSelector } from '../../selectors/account-selectors';\n-type Props = {\n- setModal: (modal: ?React.Node) => void,\n+type Props = {|\n+ +setModal: (modal: ?React.Node) => void,\n// Redux state\n- inputDisabled: boolean,\n- logInExtraInfo: () => LogInExtraInfo,\n+ +inputDisabled: boolean,\n+ +logInExtraInfo: () => LogInExtraInfo,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- logIn: (logInInfo: LogInInfo) => Promise<LogInResult>,\n-};\n-type State = {\n- usernameOrEmail: string,\n- password: string,\n- errorMessage: string,\n-};\n-\n+ +logIn: (logInInfo: LogInInfo) => Promise<LogInResult>,\n+|};\n+type State = {|\n+ +usernameOrEmail: string,\n+ +password: string,\n+ +errorMessage: string,\n+|};\nclass LogInModal extends React.PureComponent<Props, State> {\nusernameOrEmailInput: ?HTMLInputElement;\npasswordInput: ?HTMLInputElement;\n@@ -139,7 +141,7 @@ class LogInModal extends React.PureComponent<Props, State> {\nevent.preventDefault();\nif (\n- this.state.usernameOrEmail.search(validUsernameRegex) === -1 &&\n+ this.state.usernameOrEmail.search(oldValidUsernameRegex) === -1 &&\nthis.state.usernameOrEmail.search(validEmailRegex) === -1\n) {\nthis.setState(\n" }, { "change_type": "MODIFY", "old_path": "web/style.css", "new_path": "web/style.css", "diff": "@@ -420,6 +420,9 @@ div.modal-body div.form-footer div.modal-form-error {\npadding-left: 6px;\nalign-self: center;\n}\n+div.modal-body div.form-footer div.modal-form-error ol {\n+ padding-left: 20px;\n+}\ndiv.form-text > div.form-title {\nvertical-align: initial;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Restrict valid usernames Summary: They must now be at least six characters long, and cannot begin with a special character. Test Plan: I tested the RegEx in a JavaScript REPL Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D244
129,187
15.10.2020 20:44:40
14,400
b340c0bf60c3a930c89aded7ffeced803061258b
[server] Ignore notif settings if a user is Summary: This way somebody can make sure somebody else gets a notif. Test Plan: I tested the RegEx logic extensively in a JavaScript REPL Reviewers: palys-swm Subscribers: KatPo, zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "server/src/push/send.js", "new_path": "server/src/push/send.js", "diff": "@@ -28,6 +28,7 @@ import {\nthreadInfoFromRawThreadInfo,\n} from 'lib/shared/thread-utils';\nimport { promiseAll } from 'lib/utils/promises';\n+import { oldValidUsernameRegex } from 'lib/shared/account-utils';\nimport { dbQuery, SQL, mergeOrConditions } from '../database/database';\nimport { apnPush, fcmPush, getUnreadCounts } from './utils';\n@@ -117,10 +118,18 @@ async function sendPushNotifs(pushInfo: PushInfo) {\nconst threadID = firstNewMessageInfo.threadID;\nconst threadInfo = threadInfos[threadID];\n- const badgeOnly = !threadInfo.currentUser.subscription.pushNotifs;\n- if (badgeOnly && !threadInfo.currentUser.subscription.home) {\n+ const updateBadge = threadInfo.currentUser.subscription.home;\n+ const displayBanner = threadInfo.currentUser.subscription.pushNotifs;\n+ const username = userInfos[userID] && userInfos[userID].username;\n+ const userWasMentioned =\n+ username &&\n+ oldValidUsernameRegex.test(username) &&\n+ firstNewMessageInfo.type === messageTypes.TEXT &&\n+ new RegExp(`\\\\B@${username}\\\\b`).test(firstNewMessageInfo.text);\n+ if (!updateBadge && !displayBanner && !userWasMentioned) {\ncontinue;\n}\n+ const badgeOnly = !displayBanner && !userWasMentioned;\nconst dbID = dbIDs.shift();\ninvariant(dbID, 'should have sufficient DB IDs');\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Ignore notif settings if a user is @mentioned Summary: This way somebody can make sure somebody else gets a notif. Test Plan: I tested the RegEx logic extensively in a JavaScript REPL Reviewers: palys-swm Reviewed By: palys-swm Subscribers: KatPo, zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D246
129,183
19.10.2020 14:40:21
-7,200
739eb7cb0ce3f7e006aed5d31e5acec17f399e95
[native] Sort friend list Summary: Display friend list items in this order: not accepted yet, request sent, friends Test Plan: Opened friend list and checked if order is correct Reviewers: ashoat, palys-swm Subscribers: zrebcu411, Adrian
[ { "change_type": "MODIFY", "old_path": "lib/selectors/relationship-selectors.js", "new_path": "lib/selectors/relationship-selectors.js", "diff": "@@ -8,31 +8,37 @@ import {\n} from '../types/relationship-types';\nimport { createSelector } from 'reselect';\n+import _orderBy from 'lodash/fp/orderBy';\nconst userRelationshipsSelector: (\nstate: BaseAppState<*>,\n) => UserRelationships = createSelector(\n(state: BaseAppState<*>) => state.userStore.userInfos,\n(userInfos: { [id: string]: UserInfo }) => {\n- const friends = [];\n+ const unorderedFriendRequests = [];\n+ const unorderedFriends = [];\nconst blocked = [];\nfor (const userID in userInfos) {\nconst userInfo = userInfos[userID];\nconst { relationshipStatus } = userInfo;\nif (\n- relationshipStatus === userRelationshipStatus.FRIEND ||\nrelationshipStatus === userRelationshipStatus.REQUEST_RECEIVED ||\nrelationshipStatus === userRelationshipStatus.REQUEST_SENT\n) {\n- friends.push(userInfo);\n- }\n- if (\n+ unorderedFriendRequests.push(userInfo);\n+ } else if (relationshipStatus === userRelationshipStatus.FRIEND) {\n+ unorderedFriends.push(userInfo);\n+ } else if (\nrelationshipStatus === userRelationshipStatus.BLOCKED_BY_VIEWER ||\nrelationshipStatus === userRelationshipStatus.BOTH_BLOCKED\n) {\nblocked.push(userInfo);\n}\n}\n+ const friendRequests = _orderBy('relationshipStatus')('desc')(\n+ unorderedFriendRequests,\n+ );\n+ const friends = friendRequests.concat(unorderedFriends);\nreturn { friends, blocked };\n},\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Sort friend list Summary: Display friend list items in this order: not accepted yet, request sent, friends Test Plan: Opened friend list and checked if order is correct Reviewers: ashoat, palys-swm Reviewed By: ashoat Subscribers: zrebcu411, Adrian Differential Revision: https://phabricator.ashoat.com/D255
129,191
12.10.2020 13:39:03
-7,200
5caa46ba8e0a3b6d6fe7241373e36c115b1c0af3
[server] Compute unread status based on last read message Reviewers: ashoat Subscribers: Adrian, zrebcu411, KatPo
[ { "change_type": "MODIFY", "old_path": "server/src/fetchers/thread-fetchers.js", "new_path": "server/src/fetchers/thread-fetchers.js", "diff": "@@ -21,7 +21,8 @@ async function fetchServerThreadInfos(\nSELECT t.id, t.name, t.parent_thread_id, t.color, t.description,\nt.type, t.creation_time, t.default_role, r.id AS role,\nr.name AS role_name, r.permissions AS role_permissions, m.user,\n- m.permissions, m.subscription, m.unread\n+ m.permissions, m.subscription,\n+ m.last_read_message < m.last_message AS unread\nFROM threads t\nLEFT JOIN (\nSELECT thread, id, name, permissions\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Compute unread status based on last read message Reviewers: ashoat Reviewed By: ashoat Subscribers: Adrian, zrebcu411, KatPo Differential Revision: https://phabricator.ashoat.com/D222
129,191
15.10.2020 12:54:24
-7,200
2458e0ed63aea2680194a2a2a063e0f592c4475d
[server] Do not update unread column Summary: Remove updating of unread column. Send updates based on latestMessages. Reviewers: ashoat Subscribers: Adrian, zrebcu411, KatPo
[ { "change_type": "MODIFY", "old_path": "server/src/creators/message-creator.js", "new_path": "server/src/creators/message-creator.js", "diff": "@@ -298,37 +298,26 @@ async function postMessageSend(\n}\nconst pushInfo = {};\n- const setUnreadPairs = [];\nconst messageInfosPerUser = {};\nconst latestMessagesPerUser: LatestMessagesPerUser = new Map();\nfor (const pair of perUserInfo) {\nconst [userID, preUserPushInfo] = pair;\n- const { subthreadsCanSetToUnread, subthreadsCanNotify } = preUserPushInfo;\n+ const { subthreadsCanNotify } = preUserPushInfo;\nconst userPushInfo = {\ndevices: [...preUserPushInfo.devices.values()],\nmessageInfos: [],\n};\n- const threadIDsToSetToUnread = new Set();\n+\nfor (const threadID of preUserPushInfo.notFocusedThreadIDs) {\nconst messageIndices = threadsToMessageIndices.get(threadID);\ninvariant(messageIndices, `indices should exist for thread ${threadID}`);\nfor (const messageIndex of messageIndices) {\nconst messageInfo = messageInfos[messageIndex];\n- if (messageInfo.creatorID === userID) {\n- continue;\n- }\n- if (\n- messageInfo.type !== messageTypes.CREATE_SUB_THREAD ||\n- subthreadsCanSetToUnread.has(messageInfo.childThreadID)\n- ) {\n- threadIDsToSetToUnread.add(threadID);\n- }\n- if (!messageTypeGeneratesNotifs(messageInfo.type)) {\n- continue;\n- }\nif (\n- messageInfo.type !== messageTypes.CREATE_SUB_THREAD ||\n- subthreadsCanNotify.has(messageInfo.childThreadID)\n+ (messageInfo.type !== messageTypes.CREATE_SUB_THREAD ||\n+ subthreadsCanNotify.has(messageInfo.childThreadID)) &&\n+ messageTypeGeneratesNotifs(messageInfo.type) &&\n+ messageInfo.creatorID !== userID\n) {\nuserPushInfo.messageInfos.push(messageInfo);\n}\n@@ -340,9 +329,6 @@ async function postMessageSend(\n) {\npushInfo[userID] = userPushInfo;\n}\n- for (const threadID of threadIDsToSetToUnread) {\n- setUnreadPairs.push({ userID, threadID });\n- }\nconst userMessageInfos = [];\nfor (const threadID of preUserPushInfo.threadIDs) {\nconst messageIndices = threadsToMessageIndices.get(threadID);\n@@ -370,7 +356,7 @@ async function postMessageSend(\nconst latestMessages = flattenLatestMessagesPerUser(latestMessagesPerUser);\nawait Promise.all([\n- updateUnreadStatus(setUnreadPairs),\n+ createReadStatusUpdates(latestMessages),\nredisPublish(viewer, messageInfosPerUser),\nupdateLatestMessages(latestMessages),\n]);\n@@ -378,37 +364,6 @@ async function postMessageSend(\nawait sendPushNotifs(pushInfo);\n}\n-async function updateUnreadStatus(\n- setUnreadPairs: $ReadOnlyArray<{| userID: string, threadID: string |}>,\n-) {\n- if (setUnreadPairs.length === 0) {\n- return;\n- }\n- const updateConditions = setUnreadPairs.map(\n- pair => SQL`(user = ${pair.userID} AND thread = ${pair.threadID})`,\n- );\n- const updateQuery = SQL`\n- UPDATE memberships\n- SET unread = 1\n- WHERE\n- `;\n- updateQuery.append(mergeOrConditions(updateConditions));\n-\n- const now = Date.now();\n- await Promise.all([\n- dbQuery(updateQuery),\n- createUpdates(\n- setUnreadPairs.map(pair => ({\n- type: updateTypes.UPDATE_THREAD_READ_STATUS,\n- userID: pair.userID,\n- time: now,\n- threadID: pair.threadID,\n- unread: true,\n- })),\n- ),\n- ]);\n-}\n-\nasync function redisPublish(\nviewer: Viewer,\nmessageInfosPerUser: { [userID: string]: $ReadOnlyArray<RawMessageInfo> },\n@@ -507,6 +462,25 @@ function flattenLatestMessagesPerUser(\nreturn result;\n}\n+async function createReadStatusUpdates(latestMessages: LatestMessages) {\n+ const now = Date.now();\n+ const readStatusUpdates = latestMessages\n+ .filter(message => !message.latestReadMessage)\n+ .map(({ userID, threadID }) => ({\n+ type: updateTypes.UPDATE_THREAD_READ_STATUS,\n+ userID,\n+ time: now,\n+ threadID,\n+ unread: true,\n+ }));\n+\n+ if (readStatusUpdates.length === 0) {\n+ return;\n+ }\n+\n+ return await createUpdates(readStatusUpdates);\n+}\n+\nfunction updateLatestMessages(latestMessages: LatestMessages) {\nconst query = SQL`\nUPDATE memberships\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Do not update unread column Summary: Remove updating of unread column. Send updates based on latestMessages. Reviewers: ashoat Reviewed By: ashoat Subscribers: Adrian, zrebcu411, KatPo Differential Revision: https://phabricator.ashoat.com/D239