author int64 658 755k | date stringlengths 19 19 | timezone int64 -46,800 43.2k | hash stringlengths 40 40 | message stringlengths 5 490 | mods list | language stringclasses 20 values | license stringclasses 3 values | repo stringlengths 5 68 | original_message stringlengths 12 491 |
|---|---|---|---|---|---|---|---|---|---|
129,183 | 03.12.2020 13:10:07 | -3,600 | f12a734c74ff3799f27ce153943f381bc3954841 | [native] Use hook instead of connect functions and HOC in ThreadSettingsName
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-name.react.js",
"new_path": "native/chat/settings/thread-settings-name.react.js",
"diff": "@@ -7,27 +7,22 @@ import {\n} from 'lib/actions/thread-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n-import { loadingStatusPropType } from 'lib/types/loading-types';\nimport {\ntype ThreadInfo,\n- threadInfoPropType,\ntype ChangeThreadSettingsPayload,\ntype UpdateThreadRequest,\n} from 'lib/types/thread-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n-import PropTypes from 'prop-types';\n+import {\n+ type DispatchActionPromise,\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport * as React from 'react';\nimport { Text, Alert, ActivityIndicator, TextInput, View } from 'react-native';\nimport EditSettingButton from '../../components/edit-setting-button.react';\n-import type { AppState } from '../../redux/redux-setup';\n-import {\n- type Colors,\n- colorsPropType,\n- colorsSelector,\n- styleSelector,\n-} from '../../themes/colors';\n+import { useSelector } from '../../redux/redux-utils';\n+import { type Colors, useStyles, useColors } from '../../themes/colors';\nimport type {\nLayoutEvent,\nContentSizeChangeEvent,\n@@ -35,38 +30,28 @@ import type {\nimport SaveSettingButton from './save-setting-button.react';\n+type BaseProps = {|\n+ +threadInfo: ThreadInfo,\n+ +nameEditValue: ?string,\n+ +setNameEditValue: (value: ?string, callback?: () => void) => void,\n+ +nameTextHeight: ?number,\n+ +setNameTextHeight: (number: number) => void,\n+ +canChangeSettings: boolean,\n+|};\ntype Props = {|\n- threadInfo: ThreadInfo,\n- nameEditValue: ?string,\n- setNameEditValue: (value: ?string, callback?: () => void) => void,\n- nameTextHeight: ?number,\n- setNameTextHeight: (number: number) => void,\n- canChangeSettings: boolean,\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// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- changeThreadSettings: (\n+ +changeThreadSettings: (\nupdate: UpdateThreadRequest,\n) => Promise<ChangeThreadSettingsPayload>,\n|};\nclass ThreadSettingsName extends React.PureComponent<Props> {\n- static propTypes = {\n- threadInfo: threadInfoPropType.isRequired,\n- nameEditValue: PropTypes.string,\n- setNameEditValue: PropTypes.func.isRequired,\n- nameTextHeight: PropTypes.number,\n- setNameTextHeight: PropTypes.func.isRequired,\n- canChangeSettings: PropTypes.bool.isRequired,\n- loadingStatus: loadingStatusPropType.isRequired,\n- colors: colorsPropType.isRequired,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- changeThreadSettings: PropTypes.func.isRequired,\n- };\ntextInput: ?React.ElementRef<typeof TextInput>;\nrender() {\n@@ -207,7 +192,7 @@ class ThreadSettingsName extends React.PureComponent<Props> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ncurrentValue: {\ncolor: 'panelForegroundSecondaryLabel',\nflex: 1,\n@@ -231,18 +216,30 @@ const styles = {\npaddingVertical: 8,\n},\n};\n-const stylesSelector = styleSelector(styles);\nconst loadingStatusSelector = createLoadingStatusSelector(\nchangeThreadSettingsActionTypes,\n`${changeThreadSettingsActionTypes.started}:name`,\n);\n-export default connect(\n- (state: AppState) => ({\n- loadingStatus: loadingStatusSelector(state),\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- }),\n- { changeThreadSettings },\n-)(ThreadSettingsName);\n+export default React.memo<BaseProps>(function ConnectedThreadSettingsName(\n+ props: BaseProps,\n+) {\n+ const styles = useStyles(unboundStyles);\n+ const colors = useColors();\n+ const loadingStatus = useSelector(loadingStatusSelector);\n+\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callChangeThreadSettings = useServerCall(changeThreadSettings);\n+\n+ return (\n+ <ThreadSettingsName\n+ {...props}\n+ styles={styles}\n+ colors={colors}\n+ loadingStatus={loadingStatus}\n+ dispatchActionPromise={dispatchActionPromise}\n+ changeThreadSettings={callChangeThreadSettings}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in ThreadSettingsName
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D474 |
129,183 | 03.12.2020 13:29:37 | -3,600 | c06fb639035cfbcebe0c134196ad9fd9af1506d0 | [native] Use hook instead of connect functions and HOC in ThreadList
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/components/thread-list.react.js",
"new_path": "native/components/thread-list.react.js",
"diff": "import invariant from 'invariant';\nimport SearchIndex from 'lib/shared/search-index';\n-import { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import { connect } from 'lib/utils/redux-utils';\n-import PropTypes from 'prop-types';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport * as React from 'react';\n-import { FlatList, ViewPropTypes, Text, TextInput } from 'react-native';\n+import { FlatList, TextInput } from 'react-native';\nimport { createSelector } from 'reselect';\n-import type { AppState } from '../redux/redux-setup';\nimport {\n- styleSelector,\ntype IndicatorStyle,\n- indicatorStylePropType,\n- indicatorStyleSelector,\n+ useStyles,\n+ useIndicatorStyle,\n} from '../themes/colors';\nimport type { ViewStyle, TextStyle } from '../types/styles';\nimport { waitForModalInputFocus } from '../utils/timers';\n@@ -22,31 +18,25 @@ import { waitForModalInputFocus } from '../utils/timers';\nimport Search from './search.react';\nimport ThreadListThread from './thread-list-thread.react';\n+type BaseProps = {|\n+ +threadInfos: $ReadOnlyArray<ThreadInfo>,\n+ +onSelect: (threadID: string) => void,\n+ +itemStyle?: ViewStyle,\n+ +itemTextStyle?: TextStyle,\n+ +searchIndex?: SearchIndex,\n+|};\ntype Props = {|\n- threadInfos: $ReadOnlyArray<ThreadInfo>,\n- onSelect: (threadID: string) => void,\n- itemStyle?: ViewStyle,\n- itemTextStyle?: TextStyle,\n- searchIndex?: SearchIndex,\n+ ...BaseProps,\n// Redux state\n- styles: typeof styles,\n- indicatorStyle: IndicatorStyle,\n+ +styles: typeof unboundStyles,\n+ +indicatorStyle: IndicatorStyle,\n|};\ntype State = {|\n- searchText: string,\n- searchResults: Set<string>,\n+ +searchText: string,\n+ +searchResults: Set<string>,\n|};\ntype PropsAndState = {| ...Props, ...State |};\nclass ThreadList extends React.PureComponent<Props, State> {\n- static propTypes = {\n- threadInfos: PropTypes.arrayOf(threadInfoPropType).isRequired,\n- onSelect: PropTypes.func.isRequired,\n- itemStyle: ViewPropTypes.style,\n- itemTextStyle: Text.propTypes.style,\n- searchIndex: PropTypes.instanceOf(SearchIndex),\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- indicatorStyle: indicatorStylePropType.isRequired,\n- };\nstate: State = {\nsearchText: '',\nsearchResults: new Set(),\n@@ -141,14 +131,19 @@ class ThreadList extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\nsearch: {\nmarginBottom: 8,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect((state: AppState) => ({\n- styles: stylesSelector(state),\n- indicatorStyle: indicatorStyleSelector(state),\n-}))(ThreadList);\n+export default React.memo<BaseProps>(function ConnectedThreadList(\n+ props: BaseProps,\n+) {\n+ const styles = useStyles(unboundStyles);\n+ const indicatorStyle = useIndicatorStyle();\n+\n+ return (\n+ <ThreadList {...props} styles={styles} indicatorStyle={indicatorStyle} />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in ThreadList
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D475 |
129,183 | 03.12.2020 13:34:52 | -3,600 | f0e86adf26fa2dbed4f22ca963494e76bcccd8cd | [native] Use hook instead of connect functions and HOC in UserList
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/components/user-list.react.js",
"new_path": "native/components/user-list.react.js",
"diff": "// @flow\n-import { type UserListItem, userListItemPropType } from 'lib/types/user-types';\n-import { connect } from 'lib/utils/redux-utils';\n+import type { UserListItem } from 'lib/types/user-types';\nimport _sum from 'lodash/fp/sum';\n-import PropTypes from 'prop-types';\nimport React from 'react';\n-import { FlatList, Text } from 'react-native';\n+import { FlatList } from 'react-native';\n-import type { AppState } from '../redux/redux-setup';\n-import {\n- type IndicatorStyle,\n- indicatorStylePropType,\n- indicatorStyleSelector,\n-} from '../themes/colors';\n+import { type IndicatorStyle, useIndicatorStyle } from '../themes/colors';\nimport type { TextStyle } from '../types/styles';\nimport { UserListUser, getUserListItemHeight } from './user-list-user.react';\n+type BaseProps = {|\n+ +userInfos: $ReadOnlyArray<UserListItem>,\n+ +onSelect: (userID: string) => void,\n+ +itemTextStyle?: TextStyle,\n+|};\ntype Props = {\n- userInfos: $ReadOnlyArray<UserListItem>,\n- onSelect: (userID: string) => void,\n- itemTextStyle?: TextStyle,\n+ ...BaseProps,\n// Redux state\n- indicatorStyle: IndicatorStyle,\n+ +indicatorStyle: IndicatorStyle,\n};\nclass UserList extends React.PureComponent<Props> {\n- static propTypes = {\n- userInfos: PropTypes.arrayOf(userListItemPropType).isRequired,\n- onSelect: PropTypes.func.isRequired,\n- itemTextStyle: Text.propTypes.style,\n- indicatorStyle: indicatorStylePropType.isRequired,\n- };\n-\nrender() {\nreturn (\n<FlatList\n@@ -74,6 +63,9 @@ class UserList extends React.PureComponent<Props> {\n}\n}\n-export default connect((state: AppState) => ({\n- indicatorStyle: indicatorStyleSelector(state),\n-}))(UserList);\n+export default React.memo<BaseProps>(function ConnectedUserList(\n+ props: BaseProps,\n+) {\n+ const indicatorStyle = useIndicatorStyle();\n+ return <UserList {...props} indicatorStyle={indicatorStyle} />;\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in UserList
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D476 |
129,183 | 03.12.2020 13:51:24 | -3,600 | 90739100330de4f7b0d7b17d40ad6ac0b2621a4d | [native] Use hook instead of connect functions and HOC in ForgotPasswordPanel
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/account/forgot-password-panel.react.js",
"new_path": "native/account/forgot-password-panel.react.js",
"diff": "@@ -11,15 +11,17 @@ import {\nvalidEmailRegex,\n} from 'lib/shared/account-utils';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n-import PropTypes from 'prop-types';\n+import {\n+ type DispatchActionPromise,\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport React from 'react';\nimport { StyleSheet, View, Alert, Keyboard } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n-import type { AppState } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\nimport {\nTextInput,\n@@ -27,10 +29,13 @@ import {\n} from './modal-components.react';\nimport { PanelButton, Panel } from './panel-components.react';\n-type Props = {|\n+type BaseProps = {|\n+setActiveAlert: (activeAlert: boolean) => void,\n+opacityValue: Animated.Value,\n+onSuccess: () => void,\n+|};\n+type Props = {|\n+ ...BaseProps,\n// Redux state\n+loadingStatus: LoadingStatus,\n+usernamePlaceholder: string,\n@@ -43,15 +48,6 @@ type State = {|\n+usernameOrEmailInputText: string,\n|};\nclass ForgotPasswordPanel extends React.PureComponent<Props, State> {\n- static propTypes = {\n- setActiveAlert: PropTypes.func.isRequired,\n- opacityValue: PropTypes.object.isRequired,\n- onSuccess: PropTypes.func.isRequired,\n- loadingStatus: PropTypes.string.isRequired,\n- usernamePlaceholder: PropTypes.string.isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- forgotPassword: PropTypes.func.isRequired,\n- };\nstate: State = {\nusernameOrEmailInputText: '',\n};\n@@ -172,10 +168,22 @@ const loadingStatusSelector = createLoadingStatusSelector(\nforgotPasswordActionTypes,\n);\n-export default connect(\n- (state: AppState) => ({\n- loadingStatus: loadingStatusSelector(state),\n- usernamePlaceholder: usernamePlaceholderSelector(state),\n- }),\n- { forgotPassword },\n-)(ForgotPasswordPanel);\n+export default React.memo<BaseProps>(function ConnectedForgotPasswordPanel(\n+ props: BaseProps,\n+) {\n+ const loadingStatus = useSelector(loadingStatusSelector);\n+ const usernamePlaceholder = useSelector(usernamePlaceholderSelector);\n+\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callForgotPassword = useServerCall(forgotPassword);\n+\n+ return (\n+ <ForgotPasswordPanel\n+ {...props}\n+ loadingStatus={loadingStatus}\n+ usernamePlaceholder={usernamePlaceholder}\n+ dispatchActionPromise={dispatchActionPromise}\n+ forgotPassword={callForgotPassword}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in ForgotPasswordPanel
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D477 |
129,183 | 03.12.2020 15:07:29 | -3,600 | e11ca98bdb5ec6355833bd59eb074e397a22386b | [native] Use hook instead of connect functions and HOC in ThreadSettingsDescription
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-description.react.js",
"new_path": "native/chat/settings/thread-settings-description.react.js",
"diff": "@@ -8,30 +8,25 @@ import {\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { threadHasPermission } from 'lib/shared/thread-utils';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n-import { loadingStatusPropType } from 'lib/types/loading-types';\nimport {\ntype ThreadInfo,\n- threadInfoPropType,\nthreadPermissions,\ntype ChangeThreadSettingsPayload,\ntype UpdateThreadRequest,\n} from 'lib/types/thread-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n-import PropTypes from 'prop-types';\n+import {\n+ type DispatchActionPromise,\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport * as React from 'react';\nimport { Text, Alert, ActivityIndicator, TextInput, View } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport Button from '../../components/button.react';\nimport EditSettingButton from '../../components/edit-setting-button.react';\n-import type { AppState } from '../../redux/redux-setup';\n-import {\n- type Colors,\n- colorsPropType,\n- colorsSelector,\n- styleSelector,\n-} from '../../themes/colors';\n+import { useSelector } from '../../redux/redux-utils';\n+import { type Colors, useStyles, useColors } from '../../themes/colors';\nimport type {\nLayoutEvent,\nContentSizeChangeEvent,\n@@ -43,38 +38,28 @@ import {\nThreadSettingsCategoryFooter,\n} from './thread-settings-category.react';\n+type BaseProps = {|\n+ +threadInfo: ThreadInfo,\n+ +descriptionEditValue: ?string,\n+ +setDescriptionEditValue: (value: ?string, callback?: () => void) => void,\n+ +descriptionTextHeight: ?number,\n+ +setDescriptionTextHeight: (number: number) => void,\n+ +canChangeSettings: boolean,\n+|};\ntype Props = {|\n- threadInfo: ThreadInfo,\n- descriptionEditValue: ?string,\n- setDescriptionEditValue: (value: ?string, callback?: () => void) => void,\n- descriptionTextHeight: ?number,\n- setDescriptionTextHeight: (number: number) => void,\n- canChangeSettings: boolean,\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// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- changeThreadSettings: (\n+ +changeThreadSettings: (\nupdate: UpdateThreadRequest,\n) => Promise<ChangeThreadSettingsPayload>,\n|};\nclass ThreadSettingsDescription extends React.PureComponent<Props> {\n- static propTypes = {\n- threadInfo: threadInfoPropType.isRequired,\n- descriptionEditValue: PropTypes.string,\n- setDescriptionEditValue: PropTypes.func.isRequired,\n- descriptionTextHeight: PropTypes.number,\n- setDescriptionTextHeight: PropTypes.func.isRequired,\n- canChangeSettings: PropTypes.bool.isRequired,\n- loadingStatus: loadingStatusPropType.isRequired,\n- colors: colorsPropType.isRequired,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- changeThreadSettings: PropTypes.func.isRequired,\n- };\ntextInput: ?React.ElementRef<typeof TextInput>;\nrender() {\n@@ -246,7 +231,7 @@ class ThreadSettingsDescription extends React.PureComponent<Props> {\n};\n}\n-const styles = {\n+const unboundStyles = {\naddDescriptionButton: {\nflexDirection: 'row',\npaddingHorizontal: 24,\n@@ -287,18 +272,29 @@ const styles = {\nborderBottomColor: 'transparent',\n},\n};\n-const stylesSelector = styleSelector(styles);\nconst loadingStatusSelector = createLoadingStatusSelector(\nchangeThreadSettingsActionTypes,\n`${changeThreadSettingsActionTypes.started}:description`,\n);\n-export default connect(\n- (state: AppState) => ({\n- loadingStatus: loadingStatusSelector(state),\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- }),\n- { changeThreadSettings },\n-)(ThreadSettingsDescription);\n+export default React.memo<BaseProps>(\n+ function ConnectedThreadSettingsDescription(props: BaseProps) {\n+ const loadingStatus = useSelector(loadingStatusSelector);\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callChangeThreadSettings = useServerCall(changeThreadSettings);\n+ return (\n+ <ThreadSettingsDescription\n+ {...props}\n+ loadingStatus={loadingStatus}\n+ colors={colors}\n+ styles={styles}\n+ dispatchActionPromise={dispatchActionPromise}\n+ changeThreadSettings={callChangeThreadSettings}\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 ThreadSettingsDescription
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D478 |
129,183 | 03.12.2020 15:14:43 | -3,600 | 43c03528ddd40a58f89ccfe50a52e392ba134e4f | [native] Use hook instead of connect functions and HOC in ThreadSettingsVisibility
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-visibility.react.js",
"new_path": "native/chat/settings/thread-settings-visibility.react.js",
"diff": "// @flow\nimport type { ThreadInfo } from 'lib/types/thread-types';\n-import { connect } from 'lib/utils/redux-utils';\nimport * as React from 'react';\nimport { Text, View } from 'react-native';\nimport ThreadVisibility from '../../components/thread-visibility.react';\n-import type { AppState } from '../../redux/redux-setup';\n-import type { Colors } from '../../themes/colors';\n-import { colorsSelector, styleSelector } from '../../themes/colors';\n+import { useStyles, useColors } from '../../themes/colors';\ntype Props = {|\n- threadInfo: ThreadInfo,\n- // Redux state\n- colors: Colors,\n- styles: typeof styles,\n+ +threadInfo: ThreadInfo,\n|};\nfunction ThreadSettingsVisibility(props: Props) {\n+ const styles = useStyles(unboundStyles);\n+ const colors = useColors();\n+\nreturn (\n- <View style={props.styles.row}>\n- <Text style={props.styles.label}>Visibility</Text>\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Visibility</Text>\n<ThreadVisibility\nthreadType={props.threadInfo.type}\n- color={props.colors.panelForegroundSecondaryLabel}\n+ color={colors.panelForegroundSecondaryLabel}\n/>\n</View>\n);\n}\n-const styles = {\n+const unboundStyles = {\nlabel: {\ncolor: 'panelForegroundTertiaryLabel',\nfontSize: 16,\n@@ -41,9 +38,5 @@ const styles = {\npaddingVertical: 8,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect((state: AppState) => ({\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n-}))(ThreadSettingsVisibility);\n+export default ThreadSettingsVisibility;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in ThreadSettingsVisibility
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D479 |
129,183 | 03.12.2020 15:19:15 | -3,600 | 7b6a31fb3b9745b9cd8b5d5f441bba56c37aca9c | [native] Use hook instead of connect functions and HOC in MessageHeader
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-header.react.js",
"new_path": "native/chat/message-header.react.js",
"diff": "// @flow\nimport { stringForUser } from 'lib/shared/user-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport * as React from 'react';\nimport { View } from 'react-native';\nimport { SingleLine } from '../components/single-line.react';\n-import type { AppState } from '../redux/redux-setup';\n-import { styleSelector } from '../themes/colors';\n+import { useStyles } from '../themes/colors';\nimport { clusterEndHeight } from './composed-message.react';\nimport type { ChatMessageInfoItemWithHeight } from './message.react';\n@@ -15,13 +13,12 @@ import type { DisplayType } from './timestamp.react';\nimport { Timestamp, timestampHeight } from './timestamp.react';\ntype Props = {|\n- item: ChatMessageInfoItemWithHeight,\n- focused: boolean,\n- display: DisplayType,\n- // Redux state\n- styles: typeof styles,\n+ +item: ChatMessageInfoItemWithHeight,\n+ +focused: boolean,\n+ +display: DisplayType,\n|};\nfunction MessageHeader(props: Props) {\n+ const styles = useStyles(unboundStyles);\nconst { item, focused, display } = props;\nconst { creator, time } = item.messageInfo;\nconst { isViewer } = creator;\n@@ -29,9 +26,9 @@ function MessageHeader(props: Props) {\nlet authorName = null;\nif (!isViewer && (modalDisplay || item.startsCluster)) {\n- const style = [props.styles.authorName];\n+ const style = [styles.authorName];\nif (modalDisplay) {\n- style.push(props.styles.modal);\n+ style.push(styles.modal);\n}\nauthorName = (\n<SingleLine style={style}>{stringForUser(creator)}</SingleLine>\n@@ -65,7 +62,7 @@ function MessageHeader(props: Props) {\nconst authorNameHeight = 25;\n-const styles = {\n+const unboundStyles = {\nauthorName: {\nbottom: 0,\ncolor: 'listBackgroundSecondaryLabel',\n@@ -81,10 +78,5 @@ const styles = {\ncolor: 'white',\n},\n};\n-const stylesSelector = styleSelector(styles);\n-const ConnectedMessageHeader = connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(MessageHeader);\n-\n-export { ConnectedMessageHeader as MessageHeader, authorNameHeight };\n+export { MessageHeader, authorNameHeight };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in MessageHeader
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D480 |
129,183 | 03.12.2020 15:24:47 | -3,600 | 534474074ce1fd4ce568b8b28f9708dd7a05b59b | [native] Use hook instead of connect functions and HOC in Timestamp
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/timestamp.react.js",
"new_path": "native/chat/timestamp.react.js",
"diff": "// @flow\nimport { longAbsoluteDate } from 'lib/utils/date-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport * as React from 'react';\nimport { SingleLine } from '../components/single-line.react';\n-import type { AppState } from '../redux/redux-setup';\n-import { styleSelector } from '../themes/colors';\n+import { useStyles } from '../themes/colors';\nexport type DisplayType = 'lowContrast' | 'modal';\ntype Props = {|\n- time: number,\n- display: DisplayType,\n- // Redux state\n- styles: typeof styles,\n+ +time: number,\n+ +display: DisplayType,\n|};\nfunction Timestamp(props: Props) {\n- const style = [props.styles.timestamp];\n+ const styles = useStyles(unboundStyles);\n+ const style = [styles.timestamp];\nif (props.display === 'modal') {\n- style.push(props.styles.modal);\n+ style.push(styles.modal);\n}\nreturn (\n<SingleLine style={style}>\n@@ -30,7 +27,7 @@ function Timestamp(props: Props) {\nconst timestampHeight = 26;\n-const styles = {\n+const unboundStyles = {\nmodal: {\n// high contrast framed against OverlayNavigator-dimmed background\ncolor: 'white',\n@@ -44,10 +41,5 @@ const styles = {\npaddingVertical: 3,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-const WrappedTimestamp = connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(Timestamp);\n-\n-export { WrappedTimestamp as Timestamp, timestampHeight };\n+export { Timestamp, timestampHeight };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in Timestamp
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D481 |
129,183 | 03.12.2020 15:26:01 | -3,600 | bbc7c7ae0d7e5e0a5802cdc91b2db4acd15e1e59 | [native] Use hook instead of connect functions and HOC in EditSettingButton
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/components/edit-setting-button.react.js",
"new_path": "native/components/edit-setting-button.react.js",
"diff": "// @flow\n-import { connect } from 'lib/utils/redux-utils';\nimport * as React from 'react';\nimport { TouchableOpacity, StyleSheet, Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n-import type { AppState } from '../redux/redux-setup';\n-import type { Colors } from '../themes/colors';\n-import { colorsSelector } from '../themes/colors';\n+import { useColors } from '../themes/colors';\nimport type { TextStyle } from '../types/styles';\ntype Props = {|\n- onPress: () => void,\n- canChangeSettings: boolean,\n- style?: TextStyle,\n- // Redux state\n- colors: Colors,\n+ +onPress: () => void,\n+ +canChangeSettings: boolean,\n+ +style?: TextStyle,\n|};\nfunction EditSettingButton(props: Props) {\n+ const colors = useColors();\nif (!props.canChangeSettings) {\nreturn null;\n}\n@@ -25,7 +21,7 @@ function EditSettingButton(props: Props) {\nif (props.style) {\nappliedStyles.push(props.style);\n}\n- const { link: linkColor } = props.colors;\n+ const { link: linkColor } = colors;\nreturn (\n<TouchableOpacity onPress={props.onPress}>\n<Icon name=\"pencil\" size={16} style={appliedStyles} color={linkColor} />\n@@ -41,6 +37,4 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect((state: AppState) => ({\n- colors: colorsSelector(state),\n-}))(EditSettingButton);\n+export default EditSettingButton;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in EditSettingButton
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D482 |
129,183 | 03.12.2020 15:30:10 | -3,600 | 6f3cd5a14d32b86bec9c0892a75d367e89420a05 | [native] Use hook instead of connect functions and HOC in ListLoadingIndicator
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/components/list-loading-indicator.react.js",
"new_path": "native/components/list-loading-indicator.react.js",
"diff": "// @flow\n-import { connect } from 'lib/utils/redux-utils';\nimport * as React from 'react';\nimport { ActivityIndicator } from 'react-native';\n-import type { AppState } from '../redux/redux-setup';\n-import type { Colors } from '../themes/colors';\n-import { colorsSelector, styleSelector } from '../themes/colors';\n+import { useStyles, useColors } from '../themes/colors';\n-type Props = {|\n- // Redux state\n- colors: Colors,\n- styles: typeof styles,\n-|};\n-function ListLoadingIndicator(props: Props) {\n- const { listBackgroundLabel } = props.colors;\n+function ListLoadingIndicator() {\n+ const styles = useStyles(unboundStyles);\n+ const colors = useColors();\n+ const { listBackgroundLabel } = colors;\nreturn (\n<ActivityIndicator\ncolor={listBackgroundLabel}\nsize=\"large\"\n- style={props.styles.loadingIndicator}\n+ style={styles.loadingIndicator}\n/>\n);\n}\n-const styles = {\n+const unboundStyles = {\nloadingIndicator: {\nbackgroundColor: 'listBackground',\nflex: 1,\npadding: 10,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect((state: AppState) => ({\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n-}))(ListLoadingIndicator);\n+export default ListLoadingIndicator;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in ListLoadingIndicator
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D483 |
129,187 | 02.12.2020 23:50:25 | 18,000 | d9a27cb4f3b36f813162e270f81c313ee20071a4 | [web] Convert ChatTabs to Hook
Test Plan: Flow
Reviewers: KatPo, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-tabs.react.js",
"new_path": "web/chat/chat-tabs.react.js",
"diff": "// @flow\nimport { unreadBackgroundCount } from 'lib/selectors/thread-selectors';\n-import { connect } from 'lib/utils/redux-utils';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\n-import type { AppState } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\nimport css from './chat-tabs.css';\nimport ChatThreadBackground from './chat-thread-background.react';\nimport ChatThreadHome from './chat-thread-home.react';\nimport ChatThreadTab from './chat-thread-tab.react';\n-type Props = {|\n- unreadBackgroundCount: ?number,\n-|};\n-type State = {|\n- activeTab: string,\n-|};\n-class ChatTabs extends React.PureComponent<Props, State> {\n- static propTypes = {\n- unreadBackgroundCount: PropTypes.number,\n- };\n- state: State = {\n- activeTab: 'HOME',\n- };\n-\n- onClickHome = () => {\n- this.setState({ activeTab: 'HOME' });\n- };\n+function ChatTabs() {\n+ let backgroundTitle = 'BACKGROUND';\n+ const unreadBackgroundCountVal = useSelector(unreadBackgroundCount);\n+ if (unreadBackgroundCountVal) {\n+ backgroundTitle += ` (${unreadBackgroundCountVal})`;\n+ }\n- onClickBackground = () => {\n- this.setState({ activeTab: 'BACKGROUND' });\n- };\n+ const [activeTab, setActiveTab] = React.useState('HOME');\n+ const onClickHome = React.useCallback(() => setActiveTab('HOME'), []);\n+ const onClickBackground = React.useCallback(\n+ () => setActiveTab('BACKGROUND'),\n+ [],\n+ );\n- render() {\n- const { activeTab } = this.state;\nconst threadList =\nactiveTab === 'HOME' ? <ChatThreadHome /> : <ChatThreadBackground />;\n- let backgroundTitle = 'BACKGROUND';\n- if (this.props.unreadBackgroundCount) {\n- backgroundTitle += ` (${this.props.unreadBackgroundCount})`;\n- }\n-\nreturn (\n<div className={css.container}>\n<div className={css.tabs}>\n<ChatThreadTab\ntitle=\"HOME\"\n- tabIsActive={this.state.activeTab === 'HOME'}\n- onClick={this.onClickHome}\n+ tabIsActive={activeTab === 'HOME'}\n+ onClick={onClickHome}\n/>\n<ChatThreadTab\ntitle={backgroundTitle}\n- tabIsActive={this.state.activeTab === 'BACKGROUND'}\n- onClick={this.onClickBackground}\n+ tabIsActive={activeTab === 'BACKGROUND'}\n+ onClick={onClickBackground}\n/>\n</div>\n<div className={css.threadList}>{threadList}</div>\n</div>\n);\n}\n-}\n-export default connect((state: AppState) => ({\n- unreadBackgroundCount: unreadBackgroundCount(state),\n-}))(ChatTabs);\n+export default ChatTabs;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Convert ChatTabs to Hook
Test Plan: Flow
Reviewers: KatPo, palys-swm
Reviewed By: KatPo
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D472 |
129,191 | 12.11.2020 16:18:50 | -3,600 | dc0874d5fdbdb2a6c3a7d8e3dc4f24f705d8c2a8 | [server] Send a message when friend request is sent or accepted
Test Plan: I've sent a friend request and a message was created and successfully displayed. The same for accepting a request.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/relationship-updaters.js",
"new_path": "server/src/updaters/relationship-updaters.js",
"diff": "import invariant from 'invariant';\nimport { sortIDs } from 'lib/shared/relationship-utils';\n+import { messageTypes } from 'lib/types/message-types';\nimport {\ntype RelationshipRequest,\ntype RelationshipErrors,\n@@ -15,7 +16,10 @@ import { threadTypes } from 'lib/types/thread-types';\nimport { updateTypes, type UpdateData } from 'lib/types/update-types';\nimport { cartesianProduct } from 'lib/utils/array';\nimport { ServerError } from 'lib/utils/errors';\n+import { promiseAll } from 'lib/utils/promises';\n+import _mapValues from 'lodash/fp/mapValues';\n+import createMessages from '../creators/message-creator';\nimport createThread from '../creators/thread-creator';\nimport { createUpdates } from '../creators/update-creator';\nimport { dbQuery, SQL } from '../database/database';\n@@ -57,7 +61,7 @@ async function updateRelationships(\n// reported to the caller and can be repeated - there should be only\n// one PERSONAL thread per a pair of users and we can safely call it\n// repeatedly.\n- await createPersonalThreads(viewer, request);\n+ const threadIDPerUser = await createPersonalThreads(viewer, request);\nconst {\nuserRelationshipOperations,\nerrors: friendRequestErrors,\n@@ -67,6 +71,8 @@ async function updateRelationships(\nconst undirectedInsertRows = [];\nconst directedInsertRows = [];\nconst directedDeleteIDs = [];\n+ const messageDatas = [];\n+ const now = Date.now();\nfor (const userID in userRelationshipOperations) {\nconst operations = userRelationshipOperations[userID];\nconst ids = sortIDs(viewer.userID, userID);\n@@ -82,9 +88,25 @@ async function updateRelationships(\nconst [user1, user2] = ids;\nconst status = undirectedStatus.FRIEND;\nundirectedInsertRows.push({ user1, user2, status });\n+ messageDatas.push({\n+ type: messageTypes.UPDATE_RELATIONSHIP,\n+ threadID: threadIDPerUser[userID],\n+ creatorID: viewer.userID,\n+ targetID: userID,\n+ time: now,\n+ operation: 'request_accepted',\n+ });\n} else if (operation === 'pending_friend') {\nconst status = directedStatus.PENDING_FRIEND;\ndirectedInsertRows.push([viewer.userID, userID, status]);\n+ messageDatas.push({\n+ type: messageTypes.UPDATE_RELATIONSHIP,\n+ threadID: threadIDPerUser[userID],\n+ creatorID: viewer.userID,\n+ targetID: userID,\n+ time: now,\n+ operation: 'request_sent',\n+ });\n} else if (operation === 'know_of') {\nconst [user1, user2] = ids;\nconst status = undirectedStatus.KNOW_OF;\n@@ -114,6 +136,9 @@ async function updateRelationships(\n`;\npromises.push(dbQuery(directedDeleteQuery));\n}\n+ if (messageDatas.length > 0) {\n+ promises.push(createMessages(viewer, messageDatas, 'broadcast'));\n+ }\nawait Promise.all(promises);\n} else if (action === relationshipActions.UNFRIEND) {\n@@ -238,19 +263,23 @@ async function createPersonalThreads(\n`but we tried to do that for ${request.action}`,\n);\n- const threadCreationPromises = request.userIDs.map((id) =>\n- createThread(\n+ const threadCreationPromises = {};\n+ for (const userID of request.userIDs) {\n+ threadCreationPromises[userID] = createThread(\nviewer,\n{\ntype: threadTypes.PERSONAL,\n- initialMemberIDs: [id],\n+ initialMemberIDs: [userID],\n},\ntrue,\n'broadcast',\n- ),\n);\n+ }\n- return await Promise.all(threadCreationPromises);\n+ const personalThreadPerUser = await promiseAll(threadCreationPromises);\n+ return _mapValues((newThread) => newThread.newThreadID)(\n+ personalThreadPerUser,\n+ );\n}\nexport {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Send a message when friend request is sent or accepted
Test Plan: I've sent a friend request and a message was created and successfully displayed. The same for accepting a request.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D396 |
129,183 | 08.12.2020 14:53:26 | -3,600 | bbb9ed92a1a684f0ad09c81ece8d4e3b76fef433 | [native] Replace possiblyPendingThreadInfoSelector with hooks
Summary: This needs to be done in order to have correct currentUser permissions in pending threads
Test Plan: Tested if input is removed when blocking users in pending threads, and that correct notices are displayed
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/thread-selectors.js",
"new_path": "lib/selectors/thread-selectors.js",
"diff": "// @flow\n-import invariant from 'invariant';\nimport _compact from 'lodash/fp/compact';\nimport _filter from 'lodash/fp/filter';\nimport _flow from 'lodash/fp/flow';\n@@ -24,7 +23,6 @@ import {\nthreadInChatList,\nthreadHasAdminRole,\nroleIsAdminRole,\n- getPendingPersonalThreadOtherUser,\n} from '../shared/thread-utils';\nimport type { EntryInfo } from '../types/entry-types';\nimport type { MessageStore, RawMessageInfo } from '../types/message-types';\n@@ -57,53 +55,6 @@ const threadInfoSelector: ThreadInfoSelectorType = createObjectSelector(\nthreadInfoFromRawThreadInfo,\n);\n-type ThreadSelectorType = (\n- possiblyPendingThread: ThreadInfo,\n-) => (state: BaseAppState<*>) => ?ThreadInfo;\n-const possiblyPendingThreadInfoSelector: ThreadSelectorType = (\n- possiblyPendingThread: ThreadInfo,\n-) =>\n- createSelector(\n- threadInfoSelector,\n- (state: BaseAppState<*>) => state.currentUserInfo?.id,\n- (threadInfos: { [id: string]: ThreadInfo }, currentUserID: ?string) => {\n- const threadInfoFromState = threadInfos[possiblyPendingThread.id];\n- if (threadInfoFromState) {\n- return threadInfoFromState;\n- }\n- if (possiblyPendingThread.type !== threadTypes.PERSONAL) {\n- return undefined;\n- }\n- if (!currentUserID) {\n- return possiblyPendingThread;\n- }\n-\n- const otherUserID = getPendingPersonalThreadOtherUser(\n- possiblyPendingThread,\n- );\n-\n- if (!otherUserID) {\n- return possiblyPendingThread;\n- }\n-\n- for (const threadID in threadInfos) {\n- const threadInfo = threadInfos[threadID];\n- if (threadInfo.type !== threadTypes.PERSONAL) {\n- continue;\n- }\n- invariant(\n- threadInfo.members.length === 2,\n- 'Personal thread should have exactly two members',\n- );\n- const members = new Set(threadInfo.members.map((member) => member.id));\n- if (members.has(currentUserID) && members.has(otherUserID)) {\n- return threadInfo;\n- }\n- }\n- return possiblyPendingThread;\n- },\n- );\n-\nconst canBeOnScreenThreadInfos: (\nstate: BaseAppState<*>,\n) => ThreadInfo[] = createSelector(\n@@ -375,6 +326,5 @@ export {\notherUsersButNoOtherAdmins,\nmostRecentReadThread,\nmostRecentReadThreadSelector,\n- possiblyPendingThreadInfoSelector,\nsidebarInfoSelector,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -409,18 +409,18 @@ function threadInfoFromRawThreadInfo(\n}\nfunction getCurrentUser(\n- rawThreadInfo: RawThreadInfo,\n+ threadInfo: RawThreadInfo | ThreadInfo,\nviewerID: ?string,\nuserInfos: UserInfos,\n): ThreadCurrentUserInfo {\n- if (!threadFrozenDueToBlock(rawThreadInfo, viewerID, userInfos)) {\n- return rawThreadInfo.currentUser;\n+ if (!threadFrozenDueToBlock(threadInfo, viewerID, userInfos)) {\n+ return threadInfo.currentUser;\n}\nreturn {\n- ...rawThreadInfo.currentUser,\n+ ...threadInfo.currentUser,\npermissions: {\n- ...rawThreadInfo.currentUser.permissions,\n+ ...threadInfo.currentUser.permissions,\n...disabledPermissions,\n},\n};\n@@ -625,6 +625,7 @@ export {\ngetPendingPersonalThreadOtherUser,\ngetSingleOtherUser,\ncreatePendingThreadItem,\n+ getCurrentUser,\nthreadFrozenDueToBlock,\nthreadFrozenDueToViewerBlock,\nrawThreadInfoFromServerThreadInfo,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -8,10 +8,15 @@ import {\ntype ChatMessageItem,\nmessageListData,\n} from 'lib/selectors/chat-selectors';\n-import { possiblyPendingThreadInfoSelector } from 'lib/selectors/thread-selectors';\n+import { threadInfoSelector } from 'lib/selectors/thread-selectors';\nimport { messageID } from 'lib/shared/message-utils';\n+import {\n+ getPendingPersonalThreadOtherUser,\n+ getCurrentUser,\n+ threadIsPersonalAndPending,\n+} from 'lib/shared/thread-utils';\nimport { messageTypes } from 'lib/types/message-types';\n-import type { ThreadInfo } from 'lib/types/thread-types';\n+import { type ThreadInfo, threadTypes } from 'lib/types/thread-types';\nimport ContentLoading from '../components/content-loading.react';\nimport NodeHeightMeasurer from '../components/node-height-measurer.react';\n@@ -36,7 +41,6 @@ import MessageList from './message-list.react';\nimport type { ChatMessageInfoItemWithHeight } from './message.react';\nimport { multimediaMessageContentSizes } from './multimedia-message.react';\nimport { dummyNodeForRobotextMessageHeightMeasurement } from './robotext-message.react';\n-\nexport type ChatMessageItemWithHeight =\n| {| itemType: 'loader' |}\n| ChatMessageInfoItemWithHeight;\n@@ -48,7 +52,7 @@ type BaseProps = {|\ntype Props = {|\n...BaseProps,\n// Redux state\n- +threadInfo: ?ThreadInfo,\n+ +threadInfo: ThreadInfo,\n+messageListData: $ReadOnlyArray<ChatMessageItem>,\n+composedMessageMaxWidth: number,\n+colors: Colors,\n@@ -67,14 +71,6 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n};\npendingListDataWithHeights: ?$ReadOnlyArray<ChatMessageItemWithHeight>;\n- static getThreadInfo(props: Props): ThreadInfo {\n- const { threadInfo } = props;\n- if (threadInfo) {\n- return threadInfo;\n- }\n- return props.route.params.threadInfo;\n- }\n-\nget frozen() {\nconst { overlayContext } = this.props;\ninvariant(\n@@ -85,12 +81,6 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props) {\n- const oldReduxThreadInfo = prevProps.threadInfo;\n- const newReduxThreadInfo = this.props.threadInfo;\n- if (newReduxThreadInfo && newReduxThreadInfo !== oldReduxThreadInfo) {\n- this.props.navigation.setParams({ threadInfo: newReduxThreadInfo });\n- }\n-\nconst oldListData = prevProps.messageListData;\nconst newListData = this.props.messageListData;\nif (!newListData && oldListData) {\n@@ -104,7 +94,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}\nrender() {\n- const threadInfo = MessageListContainer.getThreadInfo(this.props);\n+ const { threadInfo } = this.props;\nconst { listDataWithHeights } = this.state;\nlet messageList;\n@@ -182,7 +172,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}\nconst { messageInfo } = item;\n- const threadInfo = MessageListContainer.getThreadInfo(this.props);\n+ const { threadInfo } = this.props;\nif (\nmessageInfo.type === messageTypes.IMAGES ||\nmessageInfo.type === messageTypes.MULTIMEDIA\n@@ -272,10 +262,62 @@ const unboundStyles = {\nexport default React.memo<BaseProps>(function ConnectedMessageListContainer(\nprops: BaseProps,\n) {\n- const threadInfo = useSelector(\n- possiblyPendingThreadInfoSelector(props.route.params.threadInfo),\n+ const viewerID = useSelector(\n+ (state) => state.currentUserInfo && state.currentUserInfo.id,\n+ );\n+ const threadInfos = useSelector(threadInfoSelector);\n+ const userInfos = useSelector((state) => state.userStore.userInfos);\n+ const threadInfoRef = React.useRef(props.route.params.threadInfo);\n+ const originalThreadInfoRef = React.useRef(props.route.params.threadInfo);\n+ const originalThreadInfo = originalThreadInfoRef.current;\n+\n+ const latestThreadInfo = React.useMemo(() => {\n+ const threadInfoFromParams = originalThreadInfo;\n+ const threadInfoFromStore = threadInfos[threadInfoFromParams.id];\n+\n+ if (threadInfoFromStore) {\n+ return threadInfoFromStore;\n+ } else if (!viewerID || !threadIsPersonalAndPending(threadInfoFromParams)) {\n+ return undefined;\n+ }\n+\n+ const otherMemberID = getPendingPersonalThreadOtherUser(\n+ threadInfoFromParams,\n+ );\n+ for (const threadID in threadInfos) {\n+ const currentThreadInfo = threadInfos[threadID];\n+ if (currentThreadInfo.type !== threadTypes.PERSONAL) {\n+ continue;\n+ }\n+ invariant(\n+ currentThreadInfo.members.length === 2,\n+ 'Personal thread should have exactly two members',\n);\n- const threadID = threadInfo?.id ?? props.route.params.threadInfo.id;\n+ const members = new Set(\n+ currentThreadInfo.members.map((member) => member.id),\n+ );\n+ if (members.has(viewerID) && members.has(otherMemberID)) {\n+ return currentThreadInfo;\n+ }\n+ }\n+\n+ return {\n+ ...threadInfoFromParams,\n+ currentUser: getCurrentUser(threadInfoFromParams, viewerID, userInfos),\n+ };\n+ }, [threadInfos, userInfos, viewerID, originalThreadInfo]);\n+\n+ if (latestThreadInfo) {\n+ threadInfoRef.current = latestThreadInfo;\n+ }\n+\n+ const threadInfo = threadInfoRef.current;\n+ const { setParams } = props.navigation;\n+ React.useEffect(() => {\n+ setParams({ threadInfo });\n+ }, [setParams, threadInfo]);\n+\n+ const threadID = threadInfoRef.current.id;\nconst boundMessageListData = useSelector(messageListData(threadID));\nconst composedMessageMaxWidth = useSelector(composedMessageMaxWidthSelector);\nconst colors = useColors();\n@@ -287,7 +329,7 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\n<MessageListContext.Provider value={messageListContext}>\n<MessageListContainer\n{...props}\n- threadInfo={threadInfo}\n+ threadInfo={threadInfoRef.current}\nmessageListData={boundMessageListData}\ncomposedMessageMaxWidth={composedMessageMaxWidth}\ncolors={colors}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Replace possiblyPendingThreadInfoSelector with hooks
Summary: This needs to be done in order to have correct currentUser permissions in pending threads
Test Plan: Tested if input is removed when blocking users in pending threads, and that correct notices are displayed
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D492 |
129,183 | 09.12.2020 12:54:29 | -3,600 | 72c4b596fba739087efff084ab514b39642253e8 | [native] Use hook instead of connect functions and HOC in SaveSettingButton
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/save-setting-button.react.js",
"new_path": "native/chat/settings/save-setting-button.react.js",
"diff": "@@ -4,29 +4,21 @@ import * as React from 'react';\nimport { TouchableOpacity } from 'react-native';\nimport Icon from 'react-native-vector-icons/Ionicons';\n-import { connect } from 'lib/utils/redux-utils';\n-\n-import type { AppState } from '../../redux/redux-setup';\n-import { styleSelector } from '../../themes/colors';\n+import { useStyles } from '../../themes/colors';\ntype Props = {|\n- onPress: () => void,\n- // Redux state\n- styles: typeof styles,\n+ +onPress: () => void,\n|};\nfunction SaveSettingButton(props: Props) {\n+ const styles = useStyles(unboundStyles);\nreturn (\n- <TouchableOpacity onPress={props.onPress} style={props.styles.container}>\n- <Icon\n- name=\"md-checkbox-outline\"\n- size={24}\n- style={props.styles.editIcon}\n- />\n+ <TouchableOpacity onPress={props.onPress} style={styles.container}>\n+ <Icon name=\"md-checkbox-outline\" size={24} style={styles.editIcon} />\n</TouchableOpacity>\n);\n}\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nwidth: 26,\n},\n@@ -37,8 +29,5 @@ const styles = {\ntop: -3,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(SaveSettingButton);\n+export default SaveSettingButton;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in SaveSettingButton
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D493 |
129,183 | 09.12.2020 13:00:52 | -3,600 | 24f929c25998002fe190efaa02abd426ef65dd45 | [native] Use hook instead of connect functions and HOC in ThreadSettingsCategory
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-category.react.js",
"new_path": "native/chat/settings/thread-settings-category.react.js",
"diff": "@@ -4,34 +4,30 @@ import invariant from 'invariant';\nimport * as React from 'react';\nimport { View, Text, Platform } from 'react-native';\n-import { connect } from 'lib/utils/redux-utils';\n-\n-import type { AppState } from '../../redux/redux-setup';\n-import { styleSelector } from '../../themes/colors';\n+import { useStyles } from '../../themes/colors';\nexport type CategoryType = 'full' | 'outline' | 'unpadded';\ntype HeaderProps = {|\n- type: CategoryType,\n- title: string,\n- // Redux state\n- styles: typeof styles,\n+ +type: CategoryType,\n+ +title: string,\n|};\nfunction ThreadSettingsCategoryHeader(props: HeaderProps) {\n+ const styles = useStyles(unboundStyles);\nlet contentStyle, paddingStyle;\nif (props.type === 'full') {\n- contentStyle = props.styles.fullHeader;\n- paddingStyle = props.styles.fullHeaderPadding;\n+ contentStyle = styles.fullHeader;\n+ paddingStyle = styles.fullHeaderPadding;\n} else if (props.type === 'outline') {\n// nothing\n} else if (props.type === 'unpadded') {\n- contentStyle = props.styles.fullHeader;\n+ contentStyle = styles.fullHeader;\n} else {\ninvariant(false, 'invalid ThreadSettingsCategory type');\n}\nreturn (\n<View>\n- <View style={[props.styles.header, contentStyle]}>\n- <Text style={props.styles.title}>{props.title.toUpperCase()}</Text>\n+ <View style={[styles.header, contentStyle]}>\n+ <Text style={styles.title}>{props.title.toUpperCase()}</Text>\n</View>\n<View style={paddingStyle} />\n</View>\n@@ -39,26 +35,25 @@ function ThreadSettingsCategoryHeader(props: HeaderProps) {\n}\ntype FooterProps = {|\n- type: CategoryType,\n- // Redux state\n- styles: typeof styles,\n+ +type: CategoryType,\n|};\nfunction ThreadSettingsCategoryFooter(props: FooterProps) {\n+ const styles = useStyles(unboundStyles);\nlet contentStyle, paddingStyle;\nif (props.type === 'full') {\n- contentStyle = props.styles.fullFooter;\n- paddingStyle = props.styles.fullFooterPadding;\n+ contentStyle = styles.fullFooter;\n+ paddingStyle = styles.fullFooterPadding;\n} else if (props.type === 'outline') {\n// nothing\n} else if (props.type === 'unpadded') {\n- contentStyle = props.styles.fullFooter;\n+ contentStyle = styles.fullFooter;\n} else {\ninvariant(false, 'invalid ThreadSettingsCategory type');\n}\nreturn (\n<View>\n<View style={paddingStyle} />\n- <View style={[props.styles.footer, contentStyle]} />\n+ <View style={[styles.footer, contentStyle]} />\n</View>\n);\n}\n@@ -67,7 +62,7 @@ const paddingHeight = Platform.select({\nandroid: 6.5,\ndefault: 6,\n});\n-const styles = {\n+const unboundStyles = {\nfooter: {\nmarginBottom: 16,\n},\n@@ -99,17 +94,5 @@ const styles = {\npaddingLeft: 24,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-\n-const WrappedThreadSettingsCategoryHeader = connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(ThreadSettingsCategoryHeader);\n-const WrappedThreadSettingsCategoryFooter = connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(ThreadSettingsCategoryFooter);\n-\n-export {\n- WrappedThreadSettingsCategoryHeader as ThreadSettingsCategoryHeader,\n- WrappedThreadSettingsCategoryFooter as ThreadSettingsCategoryFooter,\n-};\n+export { ThreadSettingsCategoryHeader, ThreadSettingsCategoryFooter };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in ThreadSettingsCategory
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D494 |
129,183 | 09.12.2020 13:06:00 | -3,600 | 2ad84a1d7253535300c6ac7fedecb74ffc4de4c6 | [native] Use hook instead of connect functions and HOC in ThreadSettingsListAction
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-list-action.react.js",
"new_path": "native/chat/settings/thread-settings-list-action.react.js",
"diff": "@@ -5,21 +5,18 @@ import { View, Text, Platform } from 'react-native';\nimport type { IoniconsGlyphs } from 'react-native-vector-icons/Ionicons';\nimport Icon from 'react-native-vector-icons/Ionicons';\n-import { connect } from 'lib/utils/redux-utils';\n-\nimport Button from '../../components/button.react';\n-import type { AppState } from '../../redux/redux-setup';\n-import { styleSelector } from '../../themes/colors';\n+import { useStyles } from '../../themes/colors';\nimport type { ViewStyle, TextStyle } from '../../types/styles';\ntype ListActionProps = {|\n- onPress: () => void,\n- text: string,\n- iconName: IoniconsGlyphs,\n- iconSize: number,\n- iconStyle?: TextStyle,\n- buttonStyle?: ViewStyle,\n- styles: typeof styles,\n+ +onPress: () => void,\n+ +text: string,\n+ +iconName: IoniconsGlyphs,\n+ +iconSize: number,\n+ +iconStyle?: TextStyle,\n+ +buttonStyle?: ViewStyle,\n+ +styles: typeof unboundStyles,\n|};\nfunction ThreadSettingsListAction(props: ListActionProps) {\nreturn (\n@@ -37,22 +34,21 @@ function ThreadSettingsListAction(props: ListActionProps) {\n}\ntype SeeMoreProps = {|\n- onPress: () => void,\n- // Redux state\n- styles: typeof styles,\n+ +onPress: () => void,\n|};\nfunction ThreadSettingsSeeMore(props: SeeMoreProps) {\n+ const styles = useStyles(unboundStyles);\nreturn (\n- <View style={props.styles.seeMoreRow}>\n- <View style={props.styles.seeMoreContents}>\n+ <View style={styles.seeMoreRow}>\n+ <View style={styles.seeMoreContents}>\n<ThreadSettingsListAction\nonPress={props.onPress}\ntext=\"See more...\"\niconName=\"ios-more\"\niconSize={36}\n- iconStyle={props.styles.seeMoreIcon}\n- buttonStyle={props.styles.seeMoreButton}\n- styles={props.styles}\n+ iconStyle={styles.seeMoreIcon}\n+ buttonStyle={styles.seeMoreButton}\n+ styles={styles}\n/>\n</View>\n</View>\n@@ -60,48 +56,46 @@ function ThreadSettingsSeeMore(props: SeeMoreProps) {\n}\ntype AddMemberProps = {|\n- onPress: () => void,\n- // Redux state\n- styles: typeof styles,\n+ +onPress: () => void,\n|};\nfunction ThreadSettingsAddMember(props: AddMemberProps) {\n+ const styles = useStyles(unboundStyles);\nreturn (\n- <View style={props.styles.addItemRow}>\n+ <View style={styles.addItemRow}>\n<ThreadSettingsListAction\nonPress={props.onPress}\ntext=\"Add users\"\niconName=\"md-add\"\n- iconStyle={props.styles.addIcon}\n+ iconStyle={styles.addIcon}\niconSize={20}\n- buttonStyle={props.styles.addMemberButton}\n- styles={props.styles}\n+ buttonStyle={styles.addMemberButton}\n+ styles={styles}\n/>\n</View>\n);\n}\ntype AddChildThreadProps = {|\n- onPress: () => void,\n- // Redux state\n- styles: typeof styles,\n+ +onPress: () => void,\n|};\nfunction ThreadSettingsAddSubthread(props: AddChildThreadProps) {\n+ const styles = useStyles(unboundStyles);\nreturn (\n- <View style={props.styles.addItemRow}>\n+ <View style={styles.addItemRow}>\n<ThreadSettingsListAction\nonPress={props.onPress}\ntext=\"Add subthread\"\niconName=\"md-add\"\n- iconStyle={props.styles.addIcon}\n+ iconStyle={styles.addIcon}\niconSize={20}\n- buttonStyle={props.styles.addSubthreadButton}\n- styles={props.styles}\n+ buttonStyle={styles.addSubthreadButton}\n+ styles={styles}\n/>\n</View>\n);\n}\n-const styles = {\n+const unboundStyles = {\naddSubthreadButton: {\npaddingTop: Platform.OS === 'ios' ? 4 : 1,\n},\n@@ -150,22 +144,9 @@ const styles = {\nfontStyle: 'italic',\n},\n};\n-const stylesSelector = styleSelector(styles);\n-\n-const WrappedThreadSettingsSeeMore = connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(ThreadSettingsSeeMore);\n-\n-const WrappedThreadSettingsAddMember = connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(ThreadSettingsAddMember);\n-\n-const WrappedThreadSettingsAddSubthread = connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(ThreadSettingsAddSubthread);\nexport {\n- WrappedThreadSettingsSeeMore as ThreadSettingsSeeMore,\n- WrappedThreadSettingsAddMember as ThreadSettingsAddMember,\n- WrappedThreadSettingsAddSubthread as ThreadSettingsAddSubthread,\n+ ThreadSettingsSeeMore,\n+ ThreadSettingsAddMember,\n+ ThreadSettingsAddSubthread,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in ThreadSettingsListAction
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D495 |
129,183 | 09.12.2020 13:10:53 | -3,600 | 77efdf52be5cf70b8ea190fb0c98730c9e123346 | [native] Use hook instead of connect functions and HOC in PencilIcon
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/components/pencil-icon.react.js",
"new_path": "native/components/pencil-icon.react.js",
"diff": "@@ -4,20 +4,14 @@ import * as React from 'react';\nimport { Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n-import { connect } from 'lib/utils/redux-utils';\n+import { useStyles } from '../themes/colors';\n-import type { AppState } from '../redux/redux-setup';\n-import { styleSelector } from '../themes/colors';\n-\n-type Props = {|\n- // Redux state\n- styles: typeof styles,\n-|};\n-function PencilIcon(props: Props) {\n- return <Icon name=\"pencil\" size={16} style={props.styles.editIcon} />;\n+function PencilIcon() {\n+ const styles = useStyles(unboundStyles);\n+ return <Icon name=\"pencil\" size={16} style={styles.editIcon} />;\n}\n-const styles = {\n+const unboundStyles = {\neditIcon: {\ncolor: 'link',\nlineHeight: 20,\n@@ -25,8 +19,5 @@ const styles = {\ntextAlign: 'right',\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(PencilIcon);\n+export default PencilIcon;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in PencilIcon
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D496 |
129,183 | 09.12.2020 13:20:37 | -3,600 | 1c6314702d9058dd489ed848621f74b084e06a47 | [native] Convert BuildInfo to Hook
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/more/build-info.react.js",
"new_path": "native/more/build-info.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { View, Text, ScrollView } from 'react-native';\n-import { connect } from 'lib/utils/redux-utils';\n-\nimport { persistConfig, codeVersion } from '../redux/persist';\n-import type { AppState } from '../redux/redux-setup';\n-import { styleSelector } from '../themes/colors';\n-\n-type Props = {|\n- // Redux state\n- styles: typeof styles,\n-|};\n-class BuildInfo extends React.PureComponent<Props> {\n- static propTypes = {\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- };\n+import { useStyles } from '../themes/colors';\n- render() {\n+function BuildInfo() {\n+ const styles = useStyles(unboundStyles);\nreturn (\n<ScrollView\n- contentContainerStyle={this.props.styles.scrollViewContentContainer}\n- style={this.props.styles.scrollView}\n+ contentContainerStyle={styles.scrollViewContentContainer}\n+ style={styles.scrollView}\n>\n- <View style={this.props.styles.section}>\n- <View style={this.props.styles.row}>\n- <Text style={this.props.styles.label}>Release</Text>\n- <Text style={this.props.styles.releaseText}>ALPHA</Text>\n+ <View style={styles.section}>\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Release</Text>\n+ <Text style={styles.releaseText}>ALPHA</Text>\n</View>\n- <View style={this.props.styles.row}>\n- <Text style={this.props.styles.label}>Code version</Text>\n- <Text style={this.props.styles.text}>{codeVersion}</Text>\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Code version</Text>\n+ <Text style={styles.text}>{codeVersion}</Text>\n</View>\n- <View style={this.props.styles.row}>\n- <Text style={this.props.styles.label}>State version</Text>\n- <Text style={this.props.styles.text}>{persistConfig.version}</Text>\n+ <View style={styles.row}>\n+ <Text style={styles.label}>State version</Text>\n+ <Text style={styles.text}>{persistConfig.version}</Text>\n</View>\n</View>\n- <View style={this.props.styles.section}>\n- <View style={this.props.styles.row}>\n- <Text style={this.props.styles.thanksText}>\n+ <View style={styles.section}>\n+ <View style={styles.row}>\n+ <Text style={styles.thanksText}>\nThank you for helping to test the alpha!\n</Text>\n</View>\n@@ -49,9 +37,8 @@ class BuildInfo extends React.PureComponent<Props> {\n</ScrollView>\n);\n}\n-}\n-const styles = {\n+const unboundStyles = {\nlabel: {\ncolor: 'panelForegroundTertiaryLabel',\nfontSize: 16,\n@@ -92,8 +79,5 @@ const styles = {\ntextAlign: 'center',\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(BuildInfo);\n+export default BuildInfo;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Convert BuildInfo to Hook
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D497 |
129,183 | 09.12.2020 14:12:20 | -3,600 | 95c9b8d499055b15e57e3cceda7d4022073be839 | [native] Remove unused RelationshipListAddButton
Summary: When removing relationshipUpdateModal, I forgot to delete this since it's never used anymore
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "DELETE",
"old_path": "native/more/relationship-list-add-button.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import * as React from 'react';\n-import Icon from 'react-native-vector-icons/Ionicons';\n-\n-import { connect } from 'lib/utils/redux-utils';\n-\n-import Button from '../components/button.react';\n-import type { AppState } from '../redux/redux-setup';\n-import { colorsSelector, type Colors } from '../themes/colors';\n-\n-type ListActionProps = {|\n- onPress: () => void,\n- // Redux state\n- colors: Colors,\n-|};\n-function RelationshipListAddButton(props: ListActionProps) {\n- const { link: linkColor } = props.colors;\n-\n- return (\n- <Button onPress={props.onPress} androidBorderlessRipple={true}>\n- <Icon\n- name=\"md-person-add\"\n- size={26}\n- color={linkColor}\n- style={styles.icon}\n- />\n- </Button>\n- );\n-}\n-\n-const styles = {\n- icon: {\n- paddingHorizontal: 15,\n- },\n-};\n-\n-export default connect((state: AppState) => ({\n- colors: colorsSelector(state),\n-}))(RelationshipListAddButton);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Remove unused RelationshipListAddButton
Summary: When removing relationshipUpdateModal, I forgot to delete this since it's never used anymore
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D498 |
129,187 | 14.12.2020 19:18:21 | 18,000 | 0f1b8689ce09786f09ec88484ee379a1c7013462 | [native] Convert DisconnectedBarVisibilityHandler to Hook
Test Plan: Flow
Reviewers: palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/navigation/disconnected-bar-visibility-handler.react.js",
"new_path": "native/navigation/disconnected-bar-visibility-handler.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\n+import { useDispatch } from 'react-redux';\n-import {\n- type ConnectionStatus,\n- connectionStatusPropType,\n- updateDisconnectedBarActionType,\n-} from 'lib/types/socket-types';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import { updateDisconnectedBarActionType } from 'lib/types/socket-types';\n-import type { AppState } from '../redux/redux-setup';\n-import {\n- type ConnectivityInfo,\n- connectivityInfoPropType,\n-} from '../types/connectivity';\n+import { useSelector } from '../redux/redux-utils';\n-type Props = {|\n- // Redux state\n- showDisconnectedBar: boolean,\n- connectionStatus: ConnectionStatus,\n- someRequestIsLate: boolean,\n- connectivity: ConnectivityInfo,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n-|};\n-class DisconnectedBarVisibilityHandler extends React.PureComponent<Props> {\n- static propTypes = {\n- showDisconnectedBar: PropTypes.bool.isRequired,\n- connectionStatus: connectionStatusPropType.isRequired,\n- someRequestIsLate: PropTypes.bool.isRequired,\n- connectivity: connectivityInfoPropType.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\n- networkActive = true;\n-\n- get disconnected() {\n- return this.props.showDisconnectedBar;\n- }\n-\n- setDisconnected(disconnected: boolean) {\n- if (this.disconnected === disconnected) {\n+function DisconnectedBarVisibilityHandler() {\n+ const dispatch = useDispatch();\n+ const disconnected = useSelector(\n+ (state) => state.connection.showDisconnectedBar,\n+ );\n+ const setDisconnected = React.useCallback(\n+ (newDisconnected: boolean) => {\n+ if (newDisconnected === disconnected) {\nreturn;\n}\n- this.props.dispatchActionPayload(updateDisconnectedBarActionType, {\n- visible: disconnected,\n+ dispatch({\n+ type: updateDisconnectedBarActionType,\n+ payload: { visible: newDisconnected },\n});\n- }\n-\n- componentDidMount() {\n- this.handleConnectionChange();\n- }\n+ },\n+ [disconnected, dispatch],\n+ );\n- handleConnectionChange() {\n- this.networkActive = this.props.connectivity.connected;\n- if (!this.networkActive) {\n- this.setDisconnected(true);\n- }\n+ const networkActiveRef = React.useRef(true);\n+ const networkConnected = useSelector((state) => state.connectivity.connected);\n+ React.useEffect(() => {\n+ networkActiveRef.current = networkConnected;\n+ if (!networkConnected) {\n+ setDisconnected(true);\n}\n+ }, [setDisconnected, networkConnected]);\n- componentDidUpdate(prevProps: Props) {\n- const { connected } = this.props.connectivity;\n- if (connected !== prevProps.connectivity.connected) {\n- this.handleConnectionChange();\n- }\n+ const prevConnectionStatusRef = React.useRef();\n+ const connectionStatus = useSelector((state) => state.connection.status);\n+ const someRequestIsLate = useSelector(\n+ (state) => state.connection.lateResponses.length !== 0,\n+ );\n+ React.useEffect(() => {\n+ const prevConnectionStatus = prevConnectionStatusRef.current;\n+ prevConnectionStatusRef.current = connectionStatus;\n- const { connectionStatus: status, someRequestIsLate } = this.props;\n- if (status === 'connected' && prevProps.connectionStatus !== 'connected') {\n+ if (\n+ connectionStatus === 'connected' &&\n+ prevConnectionStatus !== 'connected'\n+ ) {\n// Sometimes NetInfo misses the network coming back online for some\n// reason. But if the socket reconnects, the network must be up\n- this.networkActive = true;\n- this.setDisconnected(false);\n- } else if (!this.networkActive || someRequestIsLate) {\n- this.setDisconnected(true);\n- } else if (status === 'reconnecting' || status === 'forcedDisconnecting') {\n- this.setDisconnected(true);\n- } else if (status === 'connected') {\n- this.setDisconnected(false);\n- }\n+ networkActiveRef.current = true;\n+ setDisconnected(false);\n+ } else if (!networkActiveRef.current || someRequestIsLate) {\n+ setDisconnected(true);\n+ } else if (\n+ connectionStatus === 'reconnecting' ||\n+ connectionStatus === 'forcedDisconnecting'\n+ ) {\n+ setDisconnected(true);\n+ } else if (connectionStatus === 'connected') {\n+ setDisconnected(false);\n}\n+ }, [connectionStatus, someRequestIsLate, setDisconnected]);\n- render() {\nreturn null;\n}\n-}\n-export default connect(\n- (state: AppState) => ({\n- showDisconnectedBar: state.connection.showDisconnectedBar,\n- connectionStatus: state.connection.status,\n- someRequestIsLate: state.connection.lateResponses.length !== 0,\n- connectivity: state.connectivity,\n- }),\n- null,\n- true,\n-)(DisconnectedBarVisibilityHandler);\n+export default DisconnectedBarVisibilityHandler;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Convert DisconnectedBarVisibilityHandler to Hook
Test Plan: Flow
Reviewers: palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D513 |
129,183 | 10.12.2020 15:20:32 | -3,600 | 73f9dc936daf21ab465a799955950ebc646df183 | [native] Display buttons to change relationship in personal threads
Test Plan: Checked if buttons are displayed correctly, made sure pressing them changes relationship
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/relationship-utils.js",
"new_path": "lib/shared/relationship-utils.js",
"diff": "// @flow\n+import {\n+ type RelationshipButton,\n+ userRelationshipStatus,\n+ relationshipButtons,\n+} from '../types/relationship-types';\n+import type { UserInfo } from '../types/user-types';\n+\nfunction sortIDs(firstId: string, secondId: string): string[] {\nreturn [Number(firstId), Number(secondId)]\n.sort((a, b) => a - b)\n.map((num) => num.toString());\n}\n-export { sortIDs };\n+function getAvailableRelationshipButtons(\n+ userInfo: UserInfo,\n+): RelationshipButton[] {\n+ const relationship = userInfo.relationshipStatus;\n+\n+ if (relationship === userRelationshipStatus.FRIEND) {\n+ return [relationshipButtons.UNFRIEND, relationshipButtons.BLOCK];\n+ } else if (relationship === userRelationshipStatus.BLOCKED_VIEWER) {\n+ return [relationshipButtons.BLOCK];\n+ } else if (\n+ relationship === userRelationshipStatus.BOTH_BLOCKED ||\n+ relationship === userRelationshipStatus.BLOCKED_BY_VIEWER\n+ ) {\n+ return [relationshipButtons.UNBLOCK];\n+ } else if (relationship === userRelationshipStatus.REQUEST_RECEIVED) {\n+ return [\n+ relationshipButtons.ACCEPT,\n+ relationshipButtons.REJECT,\n+ relationshipButtons.BLOCK,\n+ ];\n+ } else if (relationship === userRelationshipStatus.REQUEST_SENT) {\n+ return [relationshipButtons.WITHDRAW, relationshipButtons.BLOCK];\n+ } else {\n+ return [relationshipButtons.FRIEND, relationshipButtons.BLOCK];\n+ }\n+}\n+\n+export { sortIDs, getAvailableRelationshipButtons };\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/relationship-types.js",
"new_path": "lib/types/relationship-types.js",
"diff": "@@ -36,6 +36,17 @@ export const relationshipActionsList: $ReadOnlyArray<RelationshipAction> = value\nrelationshipActions,\n);\n+export const relationshipButtons = Object.freeze({\n+ FRIEND: 'friend',\n+ UNFRIEND: 'unfriend',\n+ BLOCK: 'block',\n+ UNBLOCK: 'unblock',\n+ ACCEPT: 'accept',\n+ WITHDRAW: 'withdraw',\n+ REJECT: 'reject',\n+});\n+export type RelationshipButton = $Values<typeof relationshipButtons>;\n+\nexport type RelationshipRequest = {|\naction: RelationshipAction,\nuserIDs: $ReadOnlyArray<string>,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/settings/thread-settings-edit-relationship.react.js",
"diff": "+// @flow\n+\n+import invariant from 'invariant';\n+import * as React from 'react';\n+import { Alert, Text, View } from 'react-native';\n+\n+import {\n+ updateRelationships as serverUpdateRelationships,\n+ updateRelationshipsActionTypes,\n+} from 'lib/actions/relationship-actions';\n+import { getSingleOtherUser } from 'lib/shared/thread-utils';\n+import {\n+ type RelationshipAction,\n+ type RelationshipButton,\n+ relationshipButtons,\n+ relationshipActions,\n+} from 'lib/types/relationship-types';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import {\n+ useDispatchActionPromise,\n+ useServerCall,\n+} from 'lib/utils/action-utils';\n+\n+import Button from '../../components/button.react';\n+import { useSelector } from '../../redux/redux-utils';\n+import { useStyles, useColors } from '../../themes/colors';\n+import type { ViewStyle } from '../../types/styles';\n+\n+type Props = {|\n+ +threadInfo: ThreadInfo,\n+ +buttonStyle: ViewStyle,\n+ +relationshipButton: RelationshipButton,\n+|};\n+\n+export default React.memo<Props>(function ThreadSettingsEditRelationship(\n+ props: Props,\n+) {\n+ const otherUserInfo = useSelector((state) => {\n+ const currentUserID = state.currentUserInfo?.id;\n+ const otherUserID = getSingleOtherUser(props.threadInfo, currentUserID);\n+ invariant(otherUserID, 'Other user should be specified');\n+\n+ const { userInfos } = state.userStore;\n+ return userInfos[otherUserID];\n+ });\n+ invariant(otherUserInfo, 'Other user info should be specified');\n+\n+ const callUpdateRelationships = useServerCall(serverUpdateRelationships);\n+ const updateRelationship = React.useCallback(\n+ async (action: RelationshipAction) => {\n+ try {\n+ return await callUpdateRelationships({\n+ action,\n+ userIDs: [otherUserInfo.id],\n+ });\n+ } catch (e) {\n+ Alert.alert('Unknown error', 'Uhh... try again?', [{ text: 'OK' }], {\n+ cancelable: true,\n+ });\n+ throw e;\n+ }\n+ },\n+ [callUpdateRelationships, otherUserInfo],\n+ );\n+\n+ const { relationshipButton } = props;\n+ const relationshipAction = React.useMemo(() => {\n+ if (relationshipButton === relationshipButtons.BLOCK) {\n+ return relationshipActions.BLOCK;\n+ } else if (\n+ relationshipButton === relationshipButtons.FRIEND ||\n+ relationshipButton === relationshipButtons.ACCEPT\n+ ) {\n+ return relationshipActions.FRIEND;\n+ } else if (\n+ relationshipButton === relationshipButtons.UNFRIEND ||\n+ relationshipButton === relationshipButtons.REJECT ||\n+ relationshipButton === relationshipButtons.WITHDRAW\n+ ) {\n+ return relationshipActions.UNFRIEND;\n+ } else if (relationshipButton === relationshipButtons.UNBLOCK) {\n+ return relationshipActions.UNBLOCK;\n+ }\n+ invariant(false, 'relationshipButton conditions should be exhaustive');\n+ }, [relationshipButton]);\n+\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const onButtonPress = React.useCallback(() => {\n+ dispatchActionPromise(\n+ updateRelationshipsActionTypes,\n+ updateRelationship(relationshipAction),\n+ );\n+ }, [dispatchActionPromise, relationshipAction, updateRelationship]);\n+\n+ const colors = useColors();\n+ const { panelIosHighlightUnderlay } = colors;\n+\n+ const styles = useStyles(unboundStyles);\n+ const otherUserInfoUsername = otherUserInfo.username;\n+ invariant(otherUserInfoUsername, 'Other user username should be specified');\n+\n+ let relationshipButtonText;\n+ if (relationshipButton === relationshipButtons.BLOCK) {\n+ relationshipButtonText = `Block ${otherUserInfoUsername}`;\n+ } else if (relationshipButton === relationshipButtons.FRIEND) {\n+ relationshipButtonText = `Add ${otherUserInfoUsername} to friends`;\n+ } else if (relationshipButton === relationshipButtons.UNFRIEND) {\n+ relationshipButtonText = `Unfriend ${otherUserInfoUsername}`;\n+ } else if (relationshipButton === relationshipButtons.UNBLOCK) {\n+ relationshipButtonText = `Unblock ${otherUserInfoUsername}`;\n+ } else if (relationshipButton === relationshipButtons.ACCEPT) {\n+ relationshipButtonText = `Accept friend request from ${otherUserInfoUsername}`;\n+ } else if (relationshipButton === relationshipButtons.REJECT) {\n+ relationshipButtonText = `Reject friend request from ${otherUserInfoUsername}`;\n+ } else if (relationshipButton === relationshipButtons.WITHDRAW) {\n+ relationshipButtonText = `Withdraw request to friend ${otherUserInfoUsername}`;\n+ }\n+\n+ return (\n+ <View style={styles.container}>\n+ <Button\n+ onPress={onButtonPress}\n+ style={[styles.button, props.buttonStyle]}\n+ iosFormat=\"highlight\"\n+ iosHighlightUnderlayColor={panelIosHighlightUnderlay}\n+ >\n+ <Text style={styles.text}>{relationshipButtonText}</Text>\n+ </Button>\n+ </View>\n+ );\n+});\n+\n+const unboundStyles = {\n+ button: {\n+ flexDirection: 'row',\n+ paddingHorizontal: 12,\n+ paddingVertical: 10,\n+ },\n+ container: {\n+ backgroundColor: 'panelForeground',\n+ paddingHorizontal: 12,\n+ },\n+ text: {\n+ color: 'redText',\n+ flex: 1,\n+ fontSize: 16,\n+ },\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -17,18 +17,22 @@ import {\nchildThreadInfos,\n} from 'lib/selectors/thread-selectors';\nimport { relativeMemberInfoSelectorForMembersOfThread } from 'lib/selectors/user-selectors';\n+import { getAvailableRelationshipButtons } from 'lib/shared/relationship-utils';\nimport {\nthreadHasPermission,\nviewerIsMember,\nthreadInChatList,\n+ getSingleOtherUser,\n} from 'lib/shared/thread-utils';\nimport threadWatcher from 'lib/shared/thread-watcher';\n+import type { RelationshipButton } from 'lib/types/relationship-types';\nimport {\ntype ThreadInfo,\ntype RelativeMemberInfo,\nthreadPermissions,\nthreadTypes,\n} from 'lib/types/thread-types';\n+import type { UserInfos } from 'lib/types/user-types';\nimport {\ntype KeyboardState,\n@@ -63,6 +67,7 @@ import ThreadSettingsChildThread from './thread-settings-child-thread.react';\nimport ThreadSettingsColor from './thread-settings-color.react';\nimport ThreadSettingsDeleteThread from './thread-settings-delete-thread.react';\nimport ThreadSettingsDescription from './thread-settings-description.react';\n+import ThreadSettingsEditRelationship from './thread-settings-edit-relationship.react';\nimport ThreadSettingsHomeNotifs from './thread-settings-home-notifs.react';\nimport ThreadSettingsLeaveThread from './thread-settings-leave-thread.react';\nimport {\n@@ -185,6 +190,14 @@ type ChatSettingsItem =\n+threadInfo: ThreadInfo,\n+navigate: ThreadSettingsNavigate,\n+buttonStyle: ViewStyle,\n+ |}\n+ | {|\n+ +itemType: 'editRelationship',\n+ +key: string,\n+ +threadInfo: ThreadInfo,\n+ +navigate: ThreadSettingsNavigate,\n+ +buttonStyle: ViewStyle,\n+ +relationshipButton: RelationshipButton,\n|};\ntype BaseProps = {|\n@@ -194,6 +207,8 @@ type BaseProps = {|\ntype Props = {|\n...BaseProps,\n// Redux state\n+ +userInfos: UserInfos,\n+ +viewerID: ?string,\n+threadInfo: ?ThreadInfo,\n+threadMembers: $ReadOnlyArray<RelativeMemberInfo>,\n+childThreadInfos: ?$ReadOnlyArray<ThreadInfo>,\n@@ -652,10 +667,14 @@ class ThreadSettings extends React.PureComponent<Props, State> {\nThreadSettings.getThreadInfo(propsAndState),\n(propsAndState: PropsAndState) => propsAndState.navigation.navigate,\n(propsAndState: PropsAndState) => propsAndState.styles,\n+ (propsAndState: PropsAndState) => propsAndState.userInfos,\n+ (propsAndState: PropsAndState) => propsAndState.viewerID,\n(\nthreadInfo: ThreadInfo,\nnavigate: ThreadSettingsNavigate,\nstyles: typeof unboundStyles,\n+ userInfos: UserInfos,\n+ viewerID: ?string,\n) => {\nconst buttons = [];\n@@ -701,6 +720,26 @@ class ThreadSettings extends React.PureComponent<Props, State> {\n});\n}\n+ const threadIsPersonal = threadInfo.type === threadTypes.PERSONAL;\n+ if (threadIsPersonal && viewerID) {\n+ const otherMemberID = getSingleOtherUser(threadInfo, viewerID);\n+ invariant(otherMemberID, 'Other user should be specified');\n+ const otherUserInfo = userInfos[otherMemberID];\n+ const availableRelationshipActions = getAvailableRelationshipButtons(\n+ otherUserInfo,\n+ );\n+\n+ for (const action of availableRelationshipActions) {\n+ buttons.push({\n+ itemType: 'editRelationship',\n+ key: action,\n+ threadInfo,\n+ navigate,\n+ relationshipButton: action,\n+ });\n+ }\n+ }\n+\nconst listData: ChatSettingsItem[] = [];\nif (buttons.length === 0) {\nreturn listData;\n@@ -713,6 +752,16 @@ class ThreadSettings extends React.PureComponent<Props, State> {\ncategoryType: 'unpadded',\n});\nfor (let i = 0; i < buttons.length; i++) {\n+ // Necessary for Flow...\n+ if (buttons[i].itemType === 'editRelationship') {\n+ listData.push({\n+ ...buttons[i],\n+ buttonStyle: [\n+ i === 0 ? null : styles.nonTopButton,\n+ i === buttons.length - 1 ? styles.lastButton : null,\n+ ],\n+ });\n+ } else {\nlistData.push({\n...buttons[i],\nbuttonStyle: [\n@@ -721,6 +770,7 @@ class ThreadSettings extends React.PureComponent<Props, State> {\n],\n});\n}\n+ }\nlistData.push({\nitemType: 'footer',\nkey: 'actionsFooter',\n@@ -913,6 +963,14 @@ class ThreadSettings extends React.PureComponent<Props, State> {\nbuttonStyle={item.buttonStyle}\n/>\n);\n+ } else if (item.itemType === 'editRelationship') {\n+ return (\n+ <ThreadSettingsEditRelationship\n+ threadInfo={item.threadInfo}\n+ relationshipButton={item.relationshipButton}\n+ buttonStyle={item.buttonStyle}\n+ />\n+ );\n} else {\ninvariant(false, `unexpected ThreadSettings item type ${item.itemType}`);\n}\n@@ -1040,6 +1098,10 @@ const somethingIsSaving = (\nexport default React.memo<BaseProps>(function ConnectedThreadSettings(\nprops: BaseProps,\n) {\n+ const userInfos = useSelector((state) => state.userStore.userInfos);\n+ const viewerID = useSelector(\n+ (state) => state.currentUserInfo && state.currentUserInfo.id,\n+ );\nconst threadID = props.route.params.threadInfo.id;\nconst threadInfo = useSelector(\n(state) => threadInfoSelector(state)[threadID],\n@@ -1060,6 +1122,8 @@ export default React.memo<BaseProps>(function ConnectedThreadSettings(\nreturn (\n<ThreadSettings\n{...props}\n+ userInfos={userInfos}\n+ viewerID={viewerID}\nthreadInfo={threadInfo}\nthreadMembers={threadMembers}\nchildThreadInfos={boundChildThreadInfos}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Display buttons to change relationship in personal threads
Test Plan: Checked if buttons are displayed correctly, made sure pressing them changes relationship
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D499 |
129,183 | 17.12.2020 14:41:07 | -3,600 | 5d0a6b1591cf9fae6f182176d563bb284b9e493d | [native] Use hook instead of connect functions and HOC in CalendarInputBar
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar-input-bar.react.js",
"new_path": "native/calendar/calendar-input-bar.react.js",
"diff": "import * as React from 'react';\nimport { View, Text } from 'react-native';\n-import { connect } from 'lib/utils/redux-utils';\n-\nimport Button from '../components/button.react';\n-import type { AppState } from '../redux/redux-setup';\n-import { styleSelector } from '../themes/colors';\n+import { useStyles } from '../themes/colors';\ntype Props = {|\n- onSave: () => void,\n- disabled: boolean,\n- // Redux state\n- styles: typeof styles,\n+ +onSave: () => void,\n+ +disabled: boolean,\n|};\nfunction CalendarInputBar(props: Props) {\n- const inactiveStyle = props.disabled\n- ? props.styles.inactiveContainer\n- : undefined;\n+ const styles = useStyles(unboundStyles);\n+ const inactiveStyle = props.disabled ? styles.inactiveContainer : undefined;\nreturn (\n<View\n- style={[props.styles.container, inactiveStyle]}\n+ style={[styles.container, inactiveStyle]}\npointerEvents={props.disabled ? 'none' : 'auto'}\n>\n<Button onPress={props.onSave} iosActiveOpacity={0.5}>\n- <Text style={props.styles.saveButtonText}>Save</Text>\n+ <Text style={styles.saveButtonText}>Save</Text>\n</Button>\n</View>\n);\n}\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nalignItems: 'flex-end',\nbackgroundColor: 'listInputBar',\n@@ -47,8 +41,5 @@ const styles = {\npadding: 8,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-export default connect((state: AppState) => ({\n- styles: stylesSelector(state),\n-}))(CalendarInputBar);\n+export default CalendarInputBar;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in CalendarInputBar
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D518 |
129,183 | 17.12.2020 15:11:48 | -3,600 | 324fa7fd7298faae8de904f7fa71b93f88ad37d5 | [native] Use hook instead of connect functions and HOC in DeleteAccount
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/more/delete-account.react.js",
"new_path": "native/more/delete-account.react.js",
"diff": "// @flow\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\nText,\n@@ -19,56 +18,40 @@ import {\nimport { preRequestUserStateSelector } from 'lib/selectors/account-selectors';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport type { LogOutResult } from 'lib/types/account-types';\n-import { loadingStatusPropType } from 'lib/types/loading-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n-import {\n- type PreRequestUserState,\n- preRequestUserStatePropType,\n-} from 'lib/types/session-types';\n+import type { PreRequestUserState } from 'lib/types/session-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport { deleteNativeCredentialsFor } from '../account/native-credentials';\nimport Button from '../components/button.react';\n-import type { AppState } from '../redux/redux-setup';\n-import {\n- type Colors,\n- colorsPropType,\n- colorsSelector,\n- styleSelector,\n-} from '../themes/colors';\n-import { type GlobalTheme, globalThemePropType } from '../types/themes';\n+import { useSelector } from '../redux/redux-utils';\n+import { type Colors, useColors, useStyles } from '../themes/colors';\n+import type { GlobalTheme } from '../types/themes';\ntype Props = {|\n// Redux state\n- loadingStatus: LoadingStatus,\n- username: ?string,\n- preRequestUserState: PreRequestUserState,\n- activeTheme: ?GlobalTheme,\n- colors: Colors,\n- styles: typeof styles,\n+ +loadingStatus: LoadingStatus,\n+ +username: ?string,\n+ +preRequestUserState: PreRequestUserState,\n+ +activeTheme: ?GlobalTheme,\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- deleteAccount: (\n+ +deleteAccount: (\npassword: string,\npreRequestUserState: PreRequestUserState,\n) => Promise<LogOutResult>,\n|};\ntype State = {|\n- password: string,\n+ +password: string,\n|};\nclass DeleteAccount extends React.PureComponent<Props, State> {\n- static propTypes = {\n- loadingStatus: loadingStatusPropType.isRequired,\n- username: PropTypes.string,\n- preRequestUserState: preRequestUserStatePropType.isRequired,\n- activeTheme: globalThemePropType,\n- colors: colorsPropType.isRequired,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- deleteAccount: PropTypes.func.isRequired,\n- };\nstate: State = {\npassword: '',\n};\n@@ -191,7 +174,7 @@ class DeleteAccount extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\ndeleteButton: {\nbackgroundColor: 'redButton',\nborderRadius: 5,\n@@ -247,23 +230,37 @@ const styles = {\ntextAlign: 'center',\n},\n};\n-const stylesSelector = styleSelector(styles);\nconst loadingStatusSelector = createLoadingStatusSelector(\ndeleteAccountActionTypes,\n);\n-export default connect(\n- (state: AppState) => ({\n- loadingStatus: loadingStatusSelector(state),\n- username:\n- state.currentUserInfo && !state.currentUserInfo.anonymous\n- ? state.currentUserInfo.username\n- : undefined,\n- preRequestUserState: preRequestUserStateSelector(state),\n- activeTheme: state.globalThemeInfo.activeTheme,\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- }),\n- { deleteAccount },\n-)(DeleteAccount);\n+export default React.memo<{ ... }>(function ConnectedDeleteAccount() {\n+ const loadingStatus = useSelector(loadingStatusSelector);\n+ const username = useSelector((state) => {\n+ if (state.currentUserInfo && !state.currentUserInfo.anonymous) {\n+ return state.currentUserInfo.username;\n+ }\n+ return undefined;\n+ });\n+ const preRequestUserState = useSelector(preRequestUserStateSelector);\n+ const activeTheme = useSelector((state) => state.globalThemeInfo.activeTheme);\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callDeleteAccount = useServerCall(deleteAccount);\n+\n+ return (\n+ <DeleteAccount\n+ loadingStatus={loadingStatus}\n+ username={username}\n+ preRequestUserState={preRequestUserState}\n+ activeTheme={activeTheme}\n+ colors={colors}\n+ styles={styles}\n+ dispatchActionPromise={dispatchActionPromise}\n+ deleteAccount={callDeleteAccount}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in DeleteAccount
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D519 |
129,183 | 17.12.2020 15:31:21 | -3,600 | 7c50a42566da693bf6b65ed8ddd0ecfdabfa10e3 | [native] Use hook instead of connect functions and HOC in Crash
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/crash.react.js",
"new_path": "native/crash.react.js",
"diff": "import Clipboard from '@react-native-community/clipboard';\nimport invariant from 'invariant';\nimport _shuffle from 'lodash/fp/shuffle';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\nView,\n@@ -26,55 +25,44 @@ import {\ntype ReportCreationResponse,\nreportTypes,\n} from 'lib/types/report-types';\n-import {\n- type PreRequestUserState,\n- preRequestUserStatePropType,\n-} from 'lib/types/session-types';\n+import type { PreRequestUserState } from 'lib/types/session-types';\nimport { actionLogger } from 'lib/utils/action-logger';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ type DispatchActionPromise,\n+ useServerCall,\n+ useDispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport { sanitizeAction, sanitizeState } from 'lib/utils/sanitization';\nimport sleep from 'lib/utils/sleep';\nimport Button from './components/button.react';\nimport ConnectedStatusBar from './connected-status-bar.react';\nimport { persistConfig, codeVersion } from './redux/persist';\n-import type { AppState } from './redux/redux-setup';\n+import { useSelector } from './redux/redux-utils';\nimport { wipeAndExit } from './utils/crash-utils';\nconst errorTitles = ['Oh no!!', 'Womp womp womp...'];\n-type Props = {\n- errorData: $ReadOnlyArray<ErrorData>,\n+type BaseProps = {|\n+ +errorData: $ReadOnlyArray<ErrorData>,\n+|};\n+type Props = {|\n+ ...BaseProps,\n// Redux state\n- preRequestUserState: PreRequestUserState,\n+ +preRequestUserState: PreRequestUserState,\n// Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n+ +dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- sendReport: (\n+ +sendReport: (\nrequest: ClientReportCreationRequest,\n) => Promise<ReportCreationResponse>,\n- logOut: (preRequestUserState: PreRequestUserState) => Promise<LogOutResult>,\n-};\n+ +logOut: (preRequestUserState: PreRequestUserState) => Promise<LogOutResult>,\n+|};\ntype State = {|\n- errorReportID: ?string,\n- doneWaiting: boolean,\n+ +errorReportID: ?string,\n+ +doneWaiting: boolean,\n|};\nclass Crash extends React.PureComponent<Props, State> {\n- static propTypes = {\n- errorData: PropTypes.arrayOf(\n- PropTypes.shape({\n- error: PropTypes.object.isRequired,\n- info: PropTypes.shape({\n- componentStack: PropTypes.string.isRequired,\n- }),\n- }),\n- ).isRequired,\n- preRequestUserState: preRequestUserStatePropType.isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- sendReport: PropTypes.func.isRequired,\n- logOut: PropTypes.func.isRequired,\n- };\nerrorTitle = _shuffle(errorTitles)[0];\nstate: State = {\nerrorReportID: null,\n@@ -260,9 +248,19 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect(\n- (state: AppState) => ({\n- preRequestUserState: preRequestUserStateSelector(state),\n- }),\n- { sendReport, logOut },\n-)(Crash);\n+export default React.memo<BaseProps>(function ConnectedCrash(props: BaseProps) {\n+ const preRequestUserState = useSelector(preRequestUserStateSelector);\n+\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callSendReport = useServerCall(sendReport);\n+ const callLogOut = useServerCall(logOut);\n+ return (\n+ <Crash\n+ {...props}\n+ preRequestUserState={preRequestUserState}\n+ dispatchActionPromise={dispatchActionPromise}\n+ sendReport={callSendReport}\n+ logOut={callLogOut}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in Crash
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D520 |
129,183 | 14.12.2020 12:18:32 | -3,600 | b76238b16dd4a27f3d32bc88d4e67de52914f30d | [web] Display modal on see more sidebars click
Summary: Part two of creating modal with more sidebars
Test Plan: Flow, check if modal is displayed after clicking on button
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-tabs.react.js",
"new_path": "web/chat/chat-tabs.react.js",
"diff": "@@ -10,7 +10,10 @@ import ChatThreadBackground from './chat-thread-background.react';\nimport ChatThreadHome from './chat-thread-home.react';\nimport ChatThreadTab from './chat-thread-tab.react';\n-function ChatTabs() {\n+type Props = {|\n+ +setModal: (modal: ?React.Node) => void,\n+|};\n+function ChatTabs(props: Props) {\nlet backgroundTitle = 'BACKGROUND';\nconst unreadBackgroundCountVal = useSelector(unreadBackgroundCount);\nif (unreadBackgroundCountVal) {\n@@ -25,7 +28,11 @@ function ChatTabs() {\n);\nconst threadList =\n- activeTab === 'HOME' ? <ChatThreadHome /> : <ChatThreadBackground />;\n+ activeTab === 'HOME' ? (\n+ <ChatThreadHome setModal={props.setModal} />\n+ ) : (\n+ <ChatThreadBackground setModal={props.setModal} />\n+ );\nreturn (\n<div className={css.container}>\n<div className={css.tabs}>\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-thread-background.react.js",
"new_path": "web/chat/chat-thread-background.react.js",
"diff": "@@ -10,10 +10,14 @@ import {\nimport css from './chat-tabs.css';\nimport ChatThreadList from './chat-thread-list.react';\n-export default function ChatThreadBackground() {\n+type Props = {|\n+ +setModal: (modal: ?React.Node) => void,\n+|};\n+export default function ChatThreadBackground(props: Props) {\nreturn (\n<ChatThreadList\nfilterThreads={threadInBackgroundChatList}\n+ setModal={props.setModal}\nemptyItem={EmptyItem}\n/>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-thread-home.react.js",
"new_path": "web/chat/chat-thread-home.react.js",
"diff": "@@ -6,6 +6,14 @@ import { threadInHomeChatList } from 'lib/shared/thread-utils';\nimport ChatThreadList from './chat-thread-list.react';\n-export default function ChatThreadHome() {\n- return <ChatThreadList filterThreads={threadInHomeChatList} />;\n+type Props = {|\n+ +setModal: (modal: ?React.Node) => void,\n+|};\n+export default function ChatThreadHome(props: Props) {\n+ return (\n+ <ChatThreadList\n+ filterThreads={threadInHomeChatList}\n+ setModal={props.setModal}\n+ />\n+ );\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": "@@ -19,9 +19,10 @@ import MessagePreview from './message-preview.react';\ntype Props = {|\n+item: ChatThreadItem,\n+ +setModal: (modal: ?React.Node) => void,\n|};\nfunction ChatThreadListItem(props: Props) {\n- const { item } = props;\n+ const { item, setModal } = props;\nconst threadID = item.threadInfo.id;\nconst onClick = useOnClickThread(threadID);\n@@ -77,6 +78,7 @@ function ChatThreadListItem(props: Props) {\nreturn (\n<ChatThreadListSeeMoreSidebars\nunread={sidebarItem.unread}\n+ setModal={setModal}\nkey=\"seeMore\"\n/>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-thread-list-see-more-sidebars.react.js",
"new_path": "web/chat/chat-thread-list-see-more-sidebars.react.js",
"diff": "@@ -4,15 +4,21 @@ import classNames from 'classnames';\nimport * as React from 'react';\nimport DotsThreeHorizontal from 'react-entypo-icons/lib/entypo/DotsThreeHorizontal';\n+import SidebarListModal from '../modals/chat/sidebar-list-modal.react';\nimport css from './chat-thread-list.css';\ntype Props = {|\n+unread: boolean,\n+ +setModal: (modal: ?React.Node) => void,\n|};\nfunction ChatThreadListSeeMoreSidebars(props: Props) {\n- const { unread } = props;\n+ const { unread, setModal } = props;\n+ const onClick = React.useCallback(\n+ () => setModal(<SidebarListModal setModal={setModal} />),\n+ [setModal],\n+ );\nreturn (\n- <div className={classNames(css.thread, css.sidebar)}>\n+ <div className={classNames(css.thread, css.sidebar)} onClick={onClick}>\n<a className={css.threadButton}>\n<div className={css.threadRow}>\n<DotsThreeHorizontal className={css.sidebarIcon} />\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-thread-list.react.js",
"new_path": "web/chat/chat-thread-list.react.js",
"diff": "@@ -10,23 +10,28 @@ import ChatThreadListItem from './chat-thread-list-item.react';\ntype Props = {|\n+filterThreads: (threadItem: ThreadInfo) => boolean,\n+ +setModal: (modal: ?React.Node) => void,\n+emptyItem?: React.ComponentType<{||}>,\n|};\nfunction ChatThreadList(props: Props) {\n- const { filterThreads, emptyItem } = props;\n+ const { filterThreads, setModal, emptyItem } = props;\nconst chatListData = useSelector(webChatListData);\nconst listData: React.Node[] = React.useMemo(() => {\nconst threads = chatListData\n.filter((item) => filterThreads(item.threadInfo))\n.map((item) => (\n- <ChatThreadListItem item={item} key={item.threadInfo.id} />\n+ <ChatThreadListItem\n+ item={item}\n+ key={item.threadInfo.id}\n+ setModal={setModal}\n+ />\n));\nif (threads.length === 0 && emptyItem) {\nconst EmptyItem = emptyItem;\nthreads.push(<EmptyItem />);\n}\nreturn threads;\n- }, [chatListData, filterThreads, emptyItem]);\n+ }, [chatListData, emptyItem, filterThreads, setModal]);\nreturn <div>{listData}</div>;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat.react.js",
"new_path": "web/chat/chat.react.js",
"diff": "@@ -11,7 +11,7 @@ type Props = {|\nfunction Chat(props: Props) {\nreturn (\n<>\n- <ChatTabs />\n+ <ChatTabs setModal={props.setModal} />\n<ChatMessageList setModal={props.setModal} />\n</>\n);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "web/modals/chat/sidebar-list-modal.react.js",
"diff": "+// @flow\n+\n+import * as React from 'react';\n+\n+import css from '../../style.css';\n+import Modal from '../modal.react';\n+\n+type Props = {|\n+ +setModal: (modal: ?React.Node) => void,\n+|};\n+function SidebarsListModal(props: Props) {\n+ const { setModal } = props;\n+\n+ const clearModal = React.useCallback(() => {\n+ setModal(null);\n+ }, [setModal]);\n+\n+ return (\n+ <Modal name=\"Sidebars\" onClose={clearModal}>\n+ <div className={css['modal-body']}>\n+ <p>Sidebars will be displayed here</p>\n+ </div>\n+ </Modal>\n+ );\n+}\n+\n+export default SidebarsListModal;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Display modal on see more sidebars click
Summary: Part two of creating modal with more sidebars
Test Plan: Flow, check if modal is displayed after clicking on button
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D505 |
129,183 | 14.12.2020 14:44:28 | -3,600 | 4b4b4a3d926926d6007f8263273db926726d97cf | [web] Display more sidebars in modal
Summary: Last step of creating new modal: display sidebars inside
Test Plan: Checked if sidebars are displayed correctly, if clicking on them hides modal and changes active thread
Reviewers: ashoat, palys-swm
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": "@@ -77,6 +77,7 @@ function ChatThreadListItem(props: Props) {\n} else {\nreturn (\n<ChatThreadListSeeMoreSidebars\n+ threadInfo={item.threadInfo}\nunread={sidebarItem.unread}\nsetModal={setModal}\nkey=\"seeMore\"\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-thread-list-see-more-sidebars.react.js",
"new_path": "web/chat/chat-thread-list-see-more-sidebars.react.js",
"diff": "@@ -4,18 +4,24 @@ import classNames from 'classnames';\nimport * as React from 'react';\nimport DotsThreeHorizontal from 'react-entypo-icons/lib/entypo/DotsThreeHorizontal';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+\nimport SidebarListModal from '../modals/chat/sidebar-list-modal.react';\nimport css from './chat-thread-list.css';\ntype Props = {|\n+ +threadInfo: ThreadInfo,\n+unread: boolean,\n+setModal: (modal: ?React.Node) => void,\n|};\nfunction ChatThreadListSeeMoreSidebars(props: Props) {\n- const { unread, setModal } = props;\n+ const { unread, setModal, threadInfo } = props;\nconst onClick = React.useCallback(\n- () => setModal(<SidebarListModal setModal={setModal} />),\n- [setModal],\n+ () =>\n+ setModal(\n+ <SidebarListModal setModal={setModal} threadInfo={threadInfo} />,\n+ ),\n+ [setModal, threadInfo],\n);\nreturn (\n<div className={classNames(css.thread, css.sidebar)} onClick={onClick}>\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-thread-list.css",
"new_path": "web/chat/chat-thread-list.css",
"diff": "@@ -133,3 +133,8 @@ div.sidebar .menu > button svg {\n.menuContent button:hover {\nbackground-color: #DDDDDD;\n}\n+\n+ul.list {\n+ margin: 5px 3px 10px 0px;\n+ overflow: auto;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/chat/sidebar-list-modal.react.js",
"new_path": "web/modals/chat/sidebar-list-modal.react.js",
"diff": "// @flow\n+import classNames from 'classnames';\nimport * as React from 'react';\n-import css from '../../style.css';\n+import { sidebarInfoSelector } from 'lib/selectors/thread-selectors';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+\n+import chatThreadListCSS from '../../chat/chat-thread-list.css';\n+import SidebarItem from '../../chat/sidebar-item.react';\n+import { useSelector } from '../../redux/redux-utils';\n+import globalCSS from '../../style.css';\nimport Modal from '../modal.react';\ntype Props = {|\n+setModal: (modal: ?React.Node) => void,\n+ +threadInfo: ThreadInfo,\n|};\nfunction SidebarsListModal(props: Props) {\n- const { setModal } = props;\n+ const { setModal, threadInfo } = props;\nconst clearModal = React.useCallback(() => {\nsetModal(null);\n}, [setModal]);\n+ const sidebarInfos = useSelector(\n+ (state) => sidebarInfoSelector(state)[threadInfo.id] ?? [],\n+ );\n+\n+ const sidebars = React.useMemo(\n+ () =>\n+ sidebarInfos.map((item) => (\n+ <div\n+ className={classNames(\n+ chatThreadListCSS.thread,\n+ chatThreadListCSS.sidebar,\n+ )}\n+ key={item.threadInfo.id}\n+ onClick={clearModal}\n+ >\n+ <SidebarItem sidebarInfo={item} />\n+ </div>\n+ )),\n+ [clearModal, sidebarInfos],\n+ );\n+\nreturn (\n- <Modal name=\"Sidebars\" onClose={clearModal}>\n- <div className={css['modal-body']}>\n- <p>Sidebars will be displayed here</p>\n+ <Modal name=\"Sidebars\" onClose={clearModal} fixedHeight={false}>\n+ <div\n+ className={classNames(\n+ globalCSS['modal-body'],\n+ globalCSS['resized-modal-body'],\n+ )}\n+ >\n+ <ul className={chatThreadListCSS.list}>{sidebars}</ul>\n</div>\n</Modal>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/history/history.css",
"new_path": "web/modals/history/history.css",
"diff": "div.modalBody {\nposition: relative;\n- height: 240px;\n+ min-height: 240px;\noverflow: hidden;\npadding: 6px 6px;\nwidth: 100%;\n"
},
{
"change_type": "MODIFY",
"old_path": "web/style.css",
"new_path": "web/style.css",
"diff": "@@ -240,12 +240,18 @@ div.modal-overlay {\nposition: fixed;\nleft: 0;\ntop: 0;\n+ bottom: 0;\nz-index: 4;\nwidth: 100%;\n- height: 100%;\nbackground-color: rgba(0,0,0,0.4);\n+ display: flex;\n+ flex-direction: column;\n+ align-items: center;\noverflow: auto;\n}\n+div.resizable-modal-overlay {\n+ min-height: 60px;\n+}\ndiv.small-modal-overlay {\npadding-top: 100px;\n}\n@@ -255,10 +261,11 @@ div.large-modal-overlay {\ndiv.modal-container {\nbackground-image: url(../images/background.png);\nbackground-size: 3000px 2000px;\n- background-attachment: fixed;\n- margin: auto;\nmax-width: 330px;\nborder-radius: 15px;\n+ display: flex;\n+ min-height: 0;\n+ max-height: 500px;\n}\ndiv.large-modal-container {\nmax-width: 500px;\n@@ -267,8 +274,18 @@ div.modal {\nposition: relative;\nbox-shadow: 0 4px 20px rgba(0, 0, 0, .3),\n0 0 0 1px rgba(0, 0, 0, .1);\n- background-color: rgba(255,255,255,0.71);\n+ background-color: rgba(255,255,255,0.61);\nborder-radius: 15px;\n+ flex: 1;\n+ display: flex;\n+ flex-direction: column;\n+ width: 330px;\n+}\n+div.large-modal-container div.modal {\n+ width: 500px;\n+}\n+div.fixed-height-modal {\n+ height: 100%;\n}\nspan.modal-close {\nfloat: right;\n@@ -295,6 +312,12 @@ div.modal-body {\nbackground-color: white;\nborder-bottom-left-radius: 15px;\nborder-bottom-right-radius: 15px;\n+ flex: 1;\n+ display: flex;\n+ flex-direction: column;\n+}\n+div.resized-modal-body {\n+ min-height: 250px;\n}\ndiv.modal-body p {\npadding: 1px 3px 4px 3px;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Display more sidebars in modal
Summary: Last step of creating new modal: display sidebars inside
Test Plan: Checked if sidebars are displayed correctly, if clicking on them hides modal and changes active thread
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D506 |
129,183 | 15.12.2020 14:59:12 | -3,600 | fe1debc16d56778bf12ba658d0b49e6550d32a6d | [web] Add searching to sidebarListModal
Test Plan: Check if input looks and works good
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-thread-list.css",
"new_path": "web/chat/chat-thread-list.css",
"diff": "@@ -138,3 +138,44 @@ ul.list {\nmargin: 5px 3px 10px 0px;\noverflow: auto;\n}\n+\n+div.search {\n+ display: flex;\n+ background-color: #DDDDDD;\n+ border-radius: 5px;\n+ padding: 3px 5px;\n+ align-items: center;\n+}\n+svg.searchVector {\n+ fill: #AAAAAA;\n+ height: 22px;\n+ width: 22px;\n+ padding: 0 3px;\n+ margin-left: 8px;\n+}\n+div.search > input {\n+ color: black;\n+ padding: 0;\n+ border: none;\n+ background-color: #DDDDDD;\n+ font-family: 'Open Sans', sans-serif;\n+ font-weight: 600;\n+ font-size: 15px;\n+ flex-grow: 1;\n+ margin-left: 3px;\n+}\n+div.search > input:focus {\n+ outline: none;\n+}\n+svg.clearQuery {\n+ font-size: 15px;\n+ padding-bottom: 1px;\n+ padding-right: 2px;\n+ color: #AAAAAA;\n+}\n+svg.clearQuery:hover {\n+ font-size: 15px;\n+ padding-bottom: 1px;\n+ padding-right: 2px;\n+ color: white;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/chat/sidebar-list-modal.react.js",
"new_path": "web/modals/chat/sidebar-list-modal.react.js",
"diff": "// @flow\n+import { faTimesCircle } from '@fortawesome/free-solid-svg-icons';\n+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport classNames from 'classnames';\nimport * as React from 'react';\nimport { sidebarInfoSelector } from 'lib/selectors/thread-selectors';\n+import SearchIndex from 'lib/shared/search-index';\n+import { threadSearchText } from 'lib/shared/thread-utils';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport chatThreadListCSS from '../../chat/chat-thread-list.css';\nimport SidebarItem from '../../chat/sidebar-item.react';\nimport { useSelector } from '../../redux/redux-utils';\nimport globalCSS from '../../style.css';\n+import { MagnifyingGlass } from '../../vectors.react';\nimport Modal from '../modal.react';\ntype Props = {|\n@@ -18,6 +23,10 @@ type Props = {|\n|};\nfunction SidebarsListModal(props: Props) {\nconst { setModal, threadInfo } = props;\n+ const [searchState, setSearchState] = React.useState({\n+ text: '',\n+ results: new Set<string>(),\n+ });\nconst clearModal = React.useCallback(() => {\nsetModal(null);\n@@ -26,10 +35,20 @@ function SidebarsListModal(props: Props) {\nconst sidebarInfos = useSelector(\n(state) => sidebarInfoSelector(state)[threadInfo.id] ?? [],\n);\n+ const userInfos = useSelector((state) => state.userStore.userInfos);\n+\n+ const listData = React.useMemo(() => {\n+ if (!searchState.text) {\n+ return sidebarInfos;\n+ }\n+ return sidebarInfos.filter((sidebarInfo) =>\n+ searchState.results.has(sidebarInfo.threadInfo.id),\n+ );\n+ }, [sidebarInfos, searchState]);\nconst sidebars = React.useMemo(\n() =>\n- sidebarInfos.map((item) => (\n+ listData.map((item) => (\n<div\nclassName={classNames(\nchatThreadListCSS.thread,\n@@ -41,8 +60,58 @@ function SidebarsListModal(props: Props) {\n<SidebarItem sidebarInfo={item} />\n</div>\n)),\n- [clearModal, sidebarInfos],\n+ [clearModal, listData],\n+ );\n+\n+ const searchIndex = React.useMemo(() => {\n+ const index = new SearchIndex();\n+ for (const sidebarInfo of sidebarInfos) {\n+ const threadInfoFromSidebarInfo = sidebarInfo.threadInfo;\n+ index.addEntry(\n+ threadInfoFromSidebarInfo.id,\n+ threadSearchText(threadInfoFromSidebarInfo, userInfos),\n+ );\n+ }\n+ return index;\n+ }, [sidebarInfos, userInfos]);\n+\n+ React.useEffect(() => {\n+ setSearchState((curState) => ({\n+ ...curState,\n+ results: new Set(searchIndex.getSearchResults(curState.text)),\n+ }));\n+ }, [searchIndex]);\n+\n+ const onChangeSearchText = React.useCallback(\n+ (event: SyntheticEvent<HTMLInputElement>) => {\n+ const searchText = event.currentTarget.value;\n+ setSearchState({\n+ text: searchText,\n+ results: new Set(searchIndex.getSearchResults(searchText)),\n+ });\n+ },\n+ [searchIndex],\n+ );\n+\n+ const clearQuery = React.useCallback(\n+ (event: SyntheticEvent<HTMLAnchorElement>) => {\n+ event.preventDefault();\n+ setSearchState({ text: '', results: [] });\n+ },\n+ [],\n+ );\n+\n+ let clearQueryButton = null;\n+ if (searchState.text) {\n+ clearQueryButton = (\n+ <a href=\"#\" onClick={clearQuery}>\n+ <FontAwesomeIcon\n+ icon={faTimesCircle}\n+ className={chatThreadListCSS.clearQuery}\n+ />\n+ </a>\n);\n+ }\nreturn (\n<Modal name=\"Sidebars\" onClose={clearModal} fixedHeight={false}>\n@@ -52,6 +121,18 @@ function SidebarsListModal(props: Props) {\nglobalCSS['resized-modal-body'],\n)}\n>\n+ <div>\n+ <div className={chatThreadListCSS.search}>\n+ <MagnifyingGlass className={chatThreadListCSS.searchVector} />\n+ <input\n+ type=\"text\"\n+ placeholder=\"Search sidebars\"\n+ value={searchState.text}\n+ onChange={onChangeSearchText}\n+ />\n+ {clearQueryButton}\n+ </div>\n+ </div>\n<ul className={chatThreadListCSS.list}>{sidebars}</ul>\n</div>\n</Modal>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Add searching to sidebarListModal
Test Plan: Check if input looks and works good
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D516 |
129,191 | 21.12.2020 12:17:39 | -3,600 | b480a683d8a8e54d88669f19f95971039c32281f | [server] Update personal threads creation script to handle role = -1
Test Plan: Create a thread with two friends, remove one and verify that the thread doesn't get updated.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/create-personal-threads.js",
"new_path": "server/src/scripts/create-personal-threads.js",
"diff": "@@ -48,6 +48,8 @@ async function markThreadsAsPersonal() {\nAND t.id != ${bots.squadbot.staffThreadID}\nAND m3.user IS NULL\nAND r2.id IS NULL\n+ AND m1.role != -1\n+ AND m2.role != -1\nGROUP BY m1.user, m2.user\n) T\nINNER JOIN roles r ON r.thread = T.id\n@@ -59,6 +61,8 @@ async function markThreadsAsPersonal() {\nWHERE t.type = ${threadTypes.PERSONAL}\nAND m1.user = user1\nAND m2.user = user2\n+ AND m1.role != -1\n+ AND m2.role != -1\n)\n`;\nconst [result] = await dbQuery(findThreadsToUpdate);\n@@ -113,6 +117,8 @@ async function createPersonalThreadsForFriends() {\nWHERE t.type = ${threadTypes.PERSONAL}\nAND m1.user = r.user1\nAND m2.user = r.user2\n+ AND m1.role != -1\n+ AND m2.role != -1\n)\n`;\nconst [result] = await dbQuery(usersQuery);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Update personal threads creation script to handle role = -1
Test Plan: Create a thread with two friends, remove one and verify that the thread doesn't get updated.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D533 |
129,191 | 21.12.2020 14:15:13 | -3,600 | 5b14481d685ef6a2fbb93c16ccfa3772bc2c1ee8 | [server] Handle personal threads with removed user
Test Plan: Create a personal thread with removed user. Open pending thread with this user and send a message or friend request and verify that a personal thread was created.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/creators/thread-creator.js",
"new_path": "server/src/creators/thread-creator.js",
"diff": "@@ -190,6 +190,8 @@ async function createThread(\nINNER JOIN memberships m2\nON m2.thread = t.id AND m2.user = ${otherMemberID}\nWHERE t.type = ${threadTypes.PERSONAL}\n+ AND m1.role != -1\n+ AND m2.role != -1\n)\n`;\nconst [result] = await dbQuery(query);\n@@ -203,6 +205,8 @@ async function createThread(\nINNER JOIN memberships m2\nON m2.thread = t.id AND m2.user = ${otherMemberID}\nWHERE t.type = ${threadTypes.PERSONAL}\n+ AND m1.role != -1\n+ AND m2.role != -1\n`;\nconst deleteRoles = SQL`\nDELETE FROM roles\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/relationship-updaters.js",
"new_path": "server/src/updaters/relationship-updaters.js",
"diff": "@@ -272,6 +272,8 @@ async function createPersonalThreads(\nINNER JOIN memberships m2\nON m2.thread = t.id AND m2.user IN (${request.userIDs})\nWHERE t.type = ${threadTypes.PERSONAL}\n+ AND m1.role != -1\n+ AND m2.role != -1\n`;\nconst [personalThreadsResult] = await dbQuery(personalThreadsQuery);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Handle personal threads with removed user
Test Plan: Create a personal thread with removed user. Open pending thread with this user and send a message or friend request and verify that a personal thread was created.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D535 |
129,183 | 21.12.2020 16:00:12 | -3,600 | 9aadfaba6b6979e6d4fb0bb5d8da63bc6ca1e2f4 | [native] Fix background tab not showing empty item
Test Plan: Check if empty item is showing correctly like before
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -221,7 +221,6 @@ class ChatThreadList extends React.PureComponent<Props, State> {\nusersSearchResults: $ReadOnlyArray<GlobalAccountUserInfo>,\n): Item[] => {\nconst chatItems = [];\n- chatItems.push({ type: 'search', searchText });\nif (!searchText) {\nchatItems.push(\n@@ -257,7 +256,7 @@ class ChatThreadList extends React.PureComponent<Props, State> {\nchatItems.push({ type: 'empty', emptyItem });\n}\n- return chatItems;\n+ return [{ type: 'search', searchText }, ...chatItems];\n},\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix background tab not showing empty item
Test Plan: Check if empty item is showing correctly like before
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D537 |
129,183 | 18.12.2020 13:17:10 | -3,600 | 9ad3f86c16f54469a3ea33a2e446a7e367b771ff | [native] Use hook instead of connect functions and HOC in UserListUser
Test Plan: Flow
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/components/user-list-user.react.js",
"new_path": "native/components/user-list-user.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { Text, Platform, Alert } from 'react-native';\n-import { type UserListItem, userListItemPropType } from 'lib/types/user-types';\n-import { connect } from 'lib/utils/redux-utils';\n+import type { UserListItem } from 'lib/types/user-types';\n-import type { AppState } from '../redux/redux-setup';\n-import {\n- type Colors,\n- colorsPropType,\n- colorsSelector,\n- styleSelector,\n-} from '../themes/colors';\n+import { type Colors, useColors, useStyles } from '../themes/colors';\nimport type { TextStyle } from '../types/styles';\nimport Button from './button.react';\nimport { SingleLine } from './single-line.react';\n@@ -24,23 +16,18 @@ const getUserListItemHeight = (item: UserListItem) => {\nreturn Platform.OS === 'ios' ? 31.5 : 33.5;\n};\n+type BaseProps = {|\n+ +userInfo: UserListItem,\n+ +onSelect: (userID: string) => void,\n+ +textStyle?: TextStyle,\n+|};\ntype Props = {|\n- userInfo: UserListItem,\n- onSelect: (userID: string) => void,\n- textStyle?: TextStyle,\n+ ...BaseProps,\n// Redux state\n- colors: Colors,\n- styles: typeof styles,\n+ +colors: Colors,\n+ +styles: typeof unboundStyles,\n|};\nclass UserListUser extends React.PureComponent<Props> {\n- static propTypes = {\n- userInfo: userListItemPropType.isRequired,\n- onSelect: PropTypes.func.isRequired,\n- textStyle: Text.propTypes.style,\n- colors: colorsPropType.isRequired,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- };\n-\nrender() {\nconst { userInfo } = this.props;\nlet notice = null;\n@@ -77,7 +64,7 @@ class UserListUser extends React.PureComponent<Props> {\n};\n}\n-const styles = {\n+const unboundStyles = {\nbutton: {\nalignItems: 'center',\nflexDirection: 'row',\n@@ -95,11 +82,13 @@ const styles = {\npaddingVertical: 6,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-const WrappedUserListUser = connect((state: AppState) => ({\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n-}))(UserListUser);\n+const ConnectedUserListUser = React.memo<BaseProps>(\n+ function ConnectedUserListUser(props: BaseProps) {\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ return <UserListUser {...props} colors={colors} styles={styles} />;\n+ },\n+);\n-export { WrappedUserListUser as UserListUser, getUserListItemHeight };\n+export { ConnectedUserListUser as UserListUser, getUserListItemHeight };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hook instead of connect functions and HOC in UserListUser
Test Plan: Flow
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D527 |
129,183 | 18.12.2020 14:00:28 | -3,600 | 008f861b3f84004037ba9c8189db5368088a1512 | [server] Allow only parent thread members to be added to a sidebar
Test Plan: Checked if for sidebars adding user not in parent thread results in error, but it's still allowed for rest of threads
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": "@@ -119,14 +119,22 @@ async function createThread(\ninvariant(initialMemberIDs, 'should be set');\nfor (const initialMemberID of initialMemberIDs) {\nconst initialMember = fetchInitialMembers[initialMemberID];\n- if (!initialMember && shouldCreateRelationships) {\n+ if (\n+ !initialMember &&\n+ shouldCreateRelationships &&\n+ (threadType !== threadTypes.SIDEBAR ||\n+ parentThreadMembers?.includes(initialMemberID))\n+ ) {\nviewerNeedsRelationshipsWith.push(initialMemberID);\ncontinue;\n} else if (!initialMember) {\nthrow new ServerError('invalid_credentials');\n}\nconst { relationshipStatus } = initialMember;\n- if (relationshipStatus === userRelationshipStatus.FRIEND) {\n+ if (\n+ relationshipStatus === userRelationshipStatus.FRIEND &&\n+ threadType !== threadTypes.SIDEBAR\n+ ) {\ncontinue;\n} else if (\nrelationshipStatus === userRelationshipStatus.BLOCKED_BY_VIEWER ||\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-updaters.js",
"new_path": "server/src/updaters/thread-updaters.js",
"diff": "@@ -466,8 +466,10 @@ async function updateThread(\nthrow new ServerError('invalid_credentials');\n}\nconst { relationshipStatus } = fetchNewMembers[newMemberID];\n-\n- if (relationshipStatus === userRelationshipStatus.FRIEND) {\n+ if (\n+ relationshipStatus === userRelationshipStatus.FRIEND &&\n+ nextThreadType !== threadTypes.SIDEBAR\n+ ) {\ncontinue;\n} else if (\nparentThreadMembers &&\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Allow only parent thread members to be added to a sidebar
Test Plan: Checked if for sidebars adding user not in parent thread results in error, but it's still allowed for rest of threads
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D529 |
129,183 | 21.12.2020 14:38:29 | -3,600 | 9fad9090d96868b8d15d6f17782ea844e4365154 | Do not show sidebars inline if not active in 3 days
Test Plan: Check if correct sidebars are displayed inline, check if button to show more sidebars has correct text. Tested both on web and native
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/chat-selectors.js",
"new_path": "lib/selectors/chat-selectors.js",
"diff": "@@ -38,6 +38,7 @@ import {\n} from '../types/thread-types';\nimport { userInfoPropType } from '../types/user-types';\nimport type { UserInfo } from '../types/user-types';\n+import { threeDays } from '../utils/date-utils';\nimport { threadInfoSelector, sidebarInfoSelector } from './thread-selectors';\ntype SidebarItem =\n@@ -48,6 +49,7 @@ type SidebarItem =\n| {|\n+type: 'seeMore',\n+unread: boolean,\n+ +showingSidebarsInline: boolean,\n|};\nexport type ChatThreadItem = {|\n@@ -78,6 +80,7 @@ const chatThreadItemPropType = PropTypes.exact({\nPropTypes.exact({\ntype: PropTypes.oneOf(['seeMore']).isRequired,\nunread: PropTypes.bool.isRequired,\n+ showingSidebarsInline: PropTypes.bool.isRequired,\n}),\n]),\n).isRequired,\n@@ -149,6 +152,7 @@ function createChatThreadItem(\n(sidebar) => sidebar.threadInfo.currentUser.unread,\n).length;\nlet numReadSidebarsToShow = maxReadSidebars - numUnreadSidebars;\n+ const threeDaysAgo = Date.now() - threeDays;\nconst sidebarItems = [];\nfor (const sidebar of allSidebarItems) {\n@@ -156,7 +160,10 @@ function createChatThreadItem(\nbreak;\n} else if (sidebar.threadInfo.currentUser.unread) {\nsidebarItems.push(sidebar);\n- } else if (numReadSidebarsToShow > 0) {\n+ } else if (\n+ sidebar.lastUpdatedTime > threeDaysAgo &&\n+ numReadSidebarsToShow > 0\n+ ) {\nsidebarItems.push(sidebar);\nnumReadSidebarsToShow--;\n}\n@@ -166,6 +173,7 @@ function createChatThreadItem(\nsidebarItems.push({\ntype: 'seeMore',\nunread: numUnreadSidebars > maxUnreadSidebars,\n+ showingSidebarsInline: sidebarItems.length !== 0,\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/date-utils.js",
"new_path": "lib/utils/date-utils.js",
"diff": "@@ -140,6 +140,8 @@ function currentDateInTimeZone(timeZone: ?string): Date {\nreturn changeTimeZone(new Date(), timeZone);\n}\n+const threeDays = millisecondsInDay * 3;\n+\nexport {\ngetDate,\npadMonthOrDay,\n@@ -154,4 +156,5 @@ export {\nlongAbsoluteDate,\nthisMonthDates,\ncurrentDateInTimeZone,\n+ threeDays,\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": "@@ -71,6 +71,7 @@ function ChatThreadListItem({\n<ChatThreadListSeeMoreSidebars\nthreadInfo={data.threadInfo}\nunread={sidebarItem.unread}\n+ showingSidebarsInline={sidebarItem.showingSidebarsInline}\nonPress={onPressSeeMoreSidebars}\nkey=\"seeMore\"\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list-see-more-sidebars.react.js",
"new_path": "native/chat/chat-thread-list-see-more-sidebars.react.js",
"diff": "@@ -12,10 +12,11 @@ import { useColors, useStyles } from '../themes/colors';\ntype Props = {|\n+threadInfo: ThreadInfo,\n+unread: boolean,\n+ +showingSidebarsInline: boolean,\n+onPress: (threadInfo: ThreadInfo) => void,\n|};\nfunction ChatThreadListSeeMoreSidebars(props: Props) {\n- const { onPress, threadInfo } = props;\n+ const { onPress, threadInfo, unread, showingSidebarsInline } = props;\nconst onPressButton = React.useCallback(() => onPress(threadInfo), [\nonPress,\nthreadInfo,\n@@ -23,7 +24,8 @@ function ChatThreadListSeeMoreSidebars(props: Props) {\nconst colors = useColors();\nconst styles = useStyles(unboundStyles);\n- const unreadStyle = props.unread ? styles.unread : null;\n+ const unreadStyle = unread ? styles.unread : null;\n+ const buttonText = showingSidebarsInline ? 'See more...' : 'See sidebars...';\nreturn (\n<Button\niosFormat=\"highlight\"\n@@ -33,7 +35,7 @@ function ChatThreadListSeeMoreSidebars(props: Props) {\nonPress={onPressButton}\n>\n<Icon name=\"ios-more\" size={28} style={styles.icon} />\n- <Text style={[styles.text, unreadStyle]}>See more...</Text>\n+ <Text style={[styles.text, unreadStyle]}>{buttonText}</Text>\n</Button>\n);\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": "@@ -79,6 +79,7 @@ function ChatThreadListItem(props: Props) {\n<ChatThreadListSeeMoreSidebars\nthreadInfo={item.threadInfo}\nunread={sidebarItem.unread}\n+ showingSidebarsInline={sidebarItem.showingSidebarsInline}\nsetModal={setModal}\nkey=\"seeMore\"\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-thread-list-see-more-sidebars.react.js",
"new_path": "web/chat/chat-thread-list-see-more-sidebars.react.js",
"diff": "@@ -12,10 +12,11 @@ import css from './chat-thread-list.css';\ntype Props = {|\n+threadInfo: ThreadInfo,\n+unread: boolean,\n+ +showingSidebarsInline: boolean,\n+setModal: (modal: ?React.Node) => void,\n|};\nfunction ChatThreadListSeeMoreSidebars(props: Props) {\n- const { unread, setModal, threadInfo } = props;\n+ const { unread, showingSidebarsInline, setModal, threadInfo } = props;\nconst onClick = React.useCallback(\n() =>\nsetModal(\n@@ -23,6 +24,7 @@ function ChatThreadListSeeMoreSidebars(props: Props) {\n),\n[setModal, threadInfo],\n);\n+ const buttonText = showingSidebarsInline ? 'See more...' : 'See sidebars...';\nreturn (\n<div className={classNames(css.thread, css.sidebar)} onClick={onClick}>\n<a className={css.threadButton}>\n@@ -34,7 +36,7 @@ function ChatThreadListSeeMoreSidebars(props: Props) {\nunread ? css.unread : null,\n])}\n>\n- See more...\n+ {buttonText}\n</div>\n</div>\n</a>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Do not show sidebars inline if not active in 3 days
Test Plan: Check if correct sidebars are displayed inline, check if button to show more sidebars has correct text. Tested both on web and native
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D536 |
129,183 | 22.12.2020 10:07:30 | -3,600 | 9dea2b514da1a39e2b668da55b1fa19301376279 | [native] Add button to reject friend request in relationship list
Test Plan: Make sure button in displayed correctly, checked if updating relationship by pressing accept/reject buttons works correctly
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/more/relationship-list-item.react.js",
"new_path": "native/more/relationship-list-item.react.js",
"diff": "@@ -18,6 +18,7 @@ import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport {\ntype RelationshipRequest,\n+ type RelationshipAction,\nuserRelationshipStatus,\nrelationshipActions,\n} from 'lib/types/relationship-types';\n@@ -124,12 +125,23 @@ class RelationshipListItem extends React.PureComponent<Props> {\ncanEditFriendRequest\n) {\neditButton = (\n+ <View style={this.props.styles.buttonContainer}>\n<TouchableOpacity\n- onPress={this.onPressUpdateFriendship}\n+ onPress={this.onPressFriendUser}\nstyle={this.props.styles.editButton}\n>\n<Text style={this.props.styles.blueAction}>Accept</Text>\n</TouchableOpacity>\n+ <TouchableOpacity\n+ onPress={this.onPressUnfriendUser}\n+ style={[\n+ this.props.styles.editButton,\n+ this.props.styles.editButtonWithMargin,\n+ ]}\n+ >\n+ <Text style={this.props.styles.redAction}>Reject</Text>\n+ </TouchableOpacity>\n+ </View>\n);\n} else if (\nuserInfo.relationshipStatus === userRelationshipStatus.REQUEST_SENT &&\n@@ -137,7 +149,7 @@ class RelationshipListItem extends React.PureComponent<Props> {\n) {\neditButton = (\n<TouchableOpacity\n- onPress={this.onPressUpdateFriendship}\n+ onPress={this.onPressUnfriendUser}\nstyle={this.props.styles.editButton}\n>\n<Text style={this.props.styles.redAction}>Cancel request</Text>\n@@ -222,35 +234,26 @@ class RelationshipListItem extends React.PureComponent<Props> {\n// We need to set onLayout in order to allow .measure() to be on the ref\nonLayout = () => {};\n- onPressUpdateFriendship = () => {\n+ onPressFriendUser = () => {\n+ this.onPressUpdateFriendship(relationshipActions.FRIEND);\n+ };\n+\n+ onPressUnfriendUser = () => {\n+ this.onPressUpdateFriendship(relationshipActions.UNFRIEND);\n+ };\n+\n+ onPressUpdateFriendship(action: RelationshipAction) {\nconst { id } = this.props.userInfo;\nconst customKeyName = `${updateRelationshipsActionTypes.started}:${id}`;\nthis.props.dispatchActionPromise(\nupdateRelationshipsActionTypes,\n- this.updateFriendship(),\n+ this.updateFriendship(action),\n{ customKeyName },\n);\n- };\n-\n- get updateFriendshipAction() {\n- const { userInfo } = this.props;\n- if (\n- userInfo.relationshipStatus === userRelationshipStatus.REQUEST_RECEIVED\n- ) {\n- return relationshipActions.FRIEND;\n- } else if (\n- userInfo.relationshipStatus === userRelationshipStatus.REQUEST_SENT\n- ) {\n- return relationshipActions.UNFRIEND;\n- } else {\n- return undefined;\n- }\n}\n- async updateFriendship() {\n+ async updateFriendship(action: RelationshipAction) {\ntry {\n- const action = this.updateFriendshipAction;\n- invariant(action, 'invalid relationshipAction');\nreturn await this.props.updateRelationships({\naction,\nuserIDs: [this.props.userInfo.id],\n@@ -282,6 +285,12 @@ const unboundStyles = {\nborderBottom: {\nborderBottomWidth: 1,\n},\n+ buttonContainer: {\n+ flexDirection: 'row',\n+ },\n+ editButtonWithMargin: {\n+ marginLeft: 15,\n+ },\nusername: {\ncolor: 'panelForegroundSecondaryLabel',\nflex: 1,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Add button to reject friend request in relationship list
Test Plan: Make sure button in displayed correctly, checked if updating relationship by pressing accept/reject buttons works correctly
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D539 |
129,187 | 20.12.2020 22:43:27 | 18,000 | f76ed75e895904613e37e0a9e7120b01262ddeb9 | [native] codeVersion -> 71 | [
{
"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 69\n- versionName \"0.0.69\"\n+ versionCode 71\n+ versionName \"0.0.71\"\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.69</string>\n+ <string>0.0.71</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>69</string>\n+ <string>71</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.69</string>\n+ <string>0.0.71</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>69</string>\n+ <string>71</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": "@@ -204,7 +204,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 69;\n+const codeVersion = 71;\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 -> 71 |
129,187 | 23.12.2020 13:52:09 | 18,000 | bc893451b73fc501b887d48338fc519e008d69dd | [native] codeVersion -> 72
This is an iOS-only release to address an issue identified in the v71 release (see D551). | [
{
"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 71\n- versionName \"0.0.71\"\n+ versionCode 72\n+ versionName \"0.0.72\"\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.71</string>\n+ <string>0.0.72</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>71</string>\n+ <string>72</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.71</string>\n+ <string>0.0.72</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>71</string>\n+ <string>72</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": "@@ -204,7 +204,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 71;\n+const codeVersion = 72;\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 -> 72
This is an iOS-only release to address an issue identified in the v71 release (see D551). |
129,191 | 17.12.2020 13:23:32 | -3,600 | 54627dbcce7718f00a24db172224989da4cdf69c | [native] Update pending thread name when changing members
Summary: We should update a pending thread when its members change
Test Plan: Search for a pending thread and check if the name is correct
Reviewers: ashoat
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": "@@ -16,13 +16,14 @@ import {\nimport { messageID } from 'lib/shared/message-utils';\nimport { getPotentialMemberItems } from 'lib/shared/search-utils';\nimport {\n+ createPendingThread,\ngetCurrentUser,\ngetPendingThreadKey,\nthreadHasAdminRole,\nthreadIsPending,\n} from 'lib/shared/thread-utils';\nimport { messageTypes } from 'lib/types/message-types';\n-import { type ThreadInfo } from 'lib/types/thread-types';\n+import { type ThreadInfo, threadTypes } from 'lib/types/thread-types';\nimport type { AccountUserInfo, UserListItem } from 'lib/types/user-types';\nimport ContentLoading from '../components/content-loading.react';\n@@ -374,7 +375,7 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\nreturn infos;\n}, [threadInfos]);\n- const latestThreadInfo = React.useMemo(() => {\n+ const latestThreadInfo = React.useMemo((): ?ThreadInfo => {\nconst threadInfoFromParams = originalThreadInfo;\nconst threadInfoFromStore = threadInfos[threadInfoFromParams.id];\n@@ -389,20 +390,31 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\n: threadInfoFromParams.members.map((member) => member.id);\nconst threadKey = getPendingThreadKey(pendingThreadMemberIDs);\n- return (\n- threadCandidates.get(threadKey) ?? {\n- ...threadInfoFromParams,\n- currentUser: getCurrentUser(threadInfoFromParams, viewerID, userInfos),\n+ if (threadCandidates.get(threadKey)) {\n+ return threadCandidates.get(threadKey);\n}\n- );\n+\n+ const updatedThread = props.route.params.searching\n+ ? createPendingThread(\n+ viewerID,\n+ userInfoInputArray.length === 1\n+ ? threadTypes.PERSONAL\n+ : threadTypes.CHAT_SECRET,\n+ userInfoInputArray,\n+ )\n+ : threadInfoFromParams;\n+ return {\n+ ...updatedThread,\n+ currentUser: getCurrentUser(updatedThread, viewerID, userInfos),\n+ };\n}, [\n+ originalThreadInfo,\nthreadInfos,\n- threadCandidates,\n- userInfos,\nviewerID,\n- originalThreadInfo,\n- userInfoInputArray,\nprops.route.params.searching,\n+ userInfoInputArray,\n+ threadCandidates,\n+ userInfos,\n]);\nif (latestThreadInfo) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Update pending thread name when changing members
Summary: We should update a pending thread when its members change
Test Plan: Search for a pending thread and check if the name is correct
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D524 |
129,191 | 17.12.2020 13:30:55 | -3,600 | 667fd85bce263acb2ef790282c485f0dbc1c1dff | [native] Block setting for all the pending threads
Summary: We should block settings for all the pending threads, not only personal
Test Plan: Check if settings can not be accessed from pending personal and pending thread
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-header-title.react.js",
"new_path": "native/chat/message-list-header-title.react.js",
"diff": "@@ -6,7 +6,7 @@ import * as React from 'react';\nimport { View, Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/Ionicons';\n-import { threadIsPersonalAndPending } from 'lib/shared/thread-utils';\n+import { threadIsPending } from 'lib/shared/thread-utils';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport { threadInfoPropType } from 'lib/types/thread-types';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -32,9 +32,7 @@ class MessageListHeaderTitle extends React.PureComponent<Props> {\nrender() {\nlet icon, fakeIcon;\n- const areSettingsDisabled = threadIsPersonalAndPending(\n- this.props.threadInfo,\n- );\n+ const areSettingsDisabled = threadIsPending(this.props.threadInfo.id);\nif (Platform.OS === 'ios' && !areSettingsDisabled) {\nicon = (\n<Icon\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Block setting for all the pending threads
Summary: We should block settings for all the pending threads, not only personal
Test Plan: Check if settings can not be accessed from pending personal and pending thread
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D525 |
129,191 | 17.12.2020 14:21:34 | -3,600 | b67b1326ad752e8b8c025592049119db005f656b | [native] Create real thread when a message is sent
Test Plan: Create a personal thread and a pending thread with multiple users
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -178,20 +178,15 @@ function threadIsPersonalAndPending(threadInfo: ?(ThreadInfo | RawThreadInfo)) {\n);\n}\n-function getPendingPersonalThreadOtherUser(\n- threadInfo: ThreadInfo | RawThreadInfo,\n-) {\n- invariant(\n- threadIsPersonalAndPending(threadInfo),\n- 'Thread should be personal and pending',\n- );\n+function getPendingThreadOtherUsers(threadInfo: ThreadInfo | RawThreadInfo) {\n+ invariant(threadIsPending(threadInfo.id), 'Thread should be pending');\n- const otherUserID = threadInfo.id.split('/')[1];\n+ const otherUserIDs = threadInfo.id.split('/')[1];\ninvariant(\n- otherUserID,\n- 'Pending thread should contain other member id in its id',\n+ otherUserIDs,\n+ 'Pending thread should contain other members id in its id',\n);\n- return otherUserID;\n+ return otherUserIDs.split('+');\n}\nfunction getSingleOtherUser(\n@@ -305,6 +300,12 @@ function createPendingThreadItem(\n};\n}\n+function pendingThreadType(numberOfOtherMembers: number) {\n+ return numberOfOtherMembers === 1\n+ ? threadTypes.PERSONAL\n+ : threadTypes.CHAT_SECRET;\n+}\n+\ntype RawThreadInfoOptions = {|\n+includeVisibilityRules?: ?boolean,\n+filterMemberList?: ?boolean,\n@@ -655,11 +656,12 @@ export {\nthreadIsGroupChat,\nthreadIsPending,\nthreadIsPersonalAndPending,\n- getPendingPersonalThreadOtherUser,\n+ getPendingThreadOtherUsers,\ngetSingleOtherUser,\ngetPendingThreadKey,\ncreatePendingThread,\ncreatePendingThreadItem,\n+ pendingThreadType,\ngetCurrentUser,\nthreadFrozenDueToBlock,\nthreadFrozenDueToViewerBlock,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-input-bar.react.js",
"new_path": "native/chat/chat-input-bar.react.js",
"diff": "@@ -32,10 +32,11 @@ import { trimMessage } from 'lib/shared/message-utils';\nimport {\nthreadHasPermission,\nviewerIsMember,\n- threadIsPersonalAndPending,\nthreadFrozenDueToViewerBlock,\nthreadActualMembers,\n- getPendingPersonalThreadOtherUser,\n+ threadIsPending,\n+ getPendingThreadOtherUsers,\n+ pendingThreadType,\n} from 'lib/shared/thread-utils';\nimport type { CalendarQuery } from 'lib/types/entry-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\n@@ -48,7 +49,6 @@ import {\nthreadPermissions,\ntype ClientThreadJoinRequest,\ntype ThreadJoinPayload,\n- threadTypes,\ntype NewThreadRequest,\ntype NewThreadResult,\n} from 'lib/types/thread-types';\n@@ -616,15 +616,15 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nreturn this.newThreadID;\n}\nconst { threadInfo } = this.props;\n- if (!threadIsPersonalAndPending(threadInfo)) {\n+ if (!threadIsPending(threadInfo.id)) {\nreturn threadInfo.id;\n}\n- const otherMemberID = getPendingPersonalThreadOtherUser(threadInfo);\n+ const otherMemberIDs = getPendingThreadOtherUsers(threadInfo);\ntry {\nconst resultPromise = this.props.newThread({\n- type: threadTypes.PERSONAL,\n- initialMemberIDs: [otherMemberID],\n+ type: pendingThreadType(otherMemberIDs.length),\n+ initialMemberIDs: otherMemberIDs,\ncolor: threadInfo.color,\n});\nthis.props.dispatchActionPromise(newThreadActionTypes, resultPromise);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -19,11 +19,12 @@ import {\ncreatePendingThread,\ngetCurrentUser,\ngetPendingThreadKey,\n+ pendingThreadType,\nthreadHasAdminRole,\nthreadIsPending,\n} from 'lib/shared/thread-utils';\nimport { messageTypes } from 'lib/types/message-types';\n-import { type ThreadInfo, threadTypes } from 'lib/types/thread-types';\n+import { type ThreadInfo } from 'lib/types/thread-types';\nimport type { AccountUserInfo, UserListItem } from 'lib/types/user-types';\nimport ContentLoading from '../components/content-loading.react';\n@@ -397,9 +398,7 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\nconst updatedThread = props.route.params.searching\n? createPendingThread(\nviewerID,\n- userInfoInputArray.length === 1\n- ? threadTypes.PERSONAL\n- : threadTypes.CHAT_SECRET,\n+ pendingThreadType(userInfoInputArray.length),\nuserInfoInputArray,\n)\n: threadInfoFromParams;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Create real thread when a message is sent
Test Plan: Create a personal thread and a pending thread with multiple users
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D526 |
129,191 | 23.12.2020 13:57:47 | -3,600 | f91b6a194c19a771ba05c4822a363a6f56e60100 | [native] Create message list thread search component
Test Plan: Flow, check is the functionality remained the same
Reviewers: ashoat
Subscribers: Adrian, zrebcu411, KatPo | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "import invariant from 'invariant';\nimport * as React from 'react';\n-import { Text, View } from 'react-native';\n+import { View } from 'react-native';\nimport {\ntype ChatMessageItem,\n@@ -29,8 +29,6 @@ import type { AccountUserInfo, UserListItem } from 'lib/types/user-types';\nimport ContentLoading from '../components/content-loading.react';\nimport NodeHeightMeasurer from '../components/node-height-measurer.react';\n-import TagInput from '../components/tag-input.react';\n-import UserList from '../components/user-list.react';\nimport { type InputState, InputStateContext } from '../input/input-state';\nimport {\nOverlayContext,\n@@ -44,6 +42,7 @@ import { chatMessageItemKey } from './chat-list.react';\nimport type { ChatNavigationProp } from './chat.react';\nimport { composedMessageMaxWidthSelector } from './composed-message-width';\nimport { dummyNodeForTextMessageHeightMeasurement } from './inner-text-message.react';\n+import MessageListThreadSearch from './message-list-thread-search.react';\nimport {\nMessageListContext,\nuseMessageListContext,\n@@ -56,12 +55,6 @@ export type ChatMessageItemWithHeight =\n| {| itemType: 'loader' |}\n| ChatMessageInfoItemWithHeight;\n-const inputProps = {\n- placeholder: 'username',\n- autoFocus: true,\n- returnKeyType: 'go',\n-};\n-\ntype BaseProps = {|\n+navigation: ChatNavigationProp<'MessageList'>,\n+route: NavigationRoute<'MessageList'>,\n@@ -116,82 +109,27 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}\n}\n- tagDataLabelExtractor = (userInfo: AccountUserInfo) => userInfo.username;\n-\n- onUserSelect = (userID: string) => {\n- for (const existingUserInfo of this.props.userInfoInputArray) {\n- if (userID === existingUserInfo.id) {\n- return;\n- }\n- }\n- const userInfoInputArray = [\n- ...this.props.userInfoInputArray,\n- this.props.otherUserInfos[userID],\n- ];\n- this.props.updateUsernameInput('');\n- this.props.updateTagInput(userInfoInputArray);\n- };\n-\nrender() {\n- const {\n- threadInfo,\n- styles,\n- userInfoInputArray,\n- usernameInputText,\n- userSearchResults,\n- } = this.props;\n+ const { threadInfo, styles } = this.props;\nconst { listDataWithHeights } = this.state;\nconst { searching } = this.props.route.params;\n- const showMessageList = !searching || userInfoInputArray.length > 0;\n-\nlet searchComponent = null;\nif (searching) {\n- const isSearchResultVisible =\n- (userInfoInputArray.length === 0 || usernameInputText.length > 0) &&\n- userSearchResults.length > 0;\n-\n- let separator = null;\n- let userList = null;\n- if (isSearchResultVisible) {\n- userList = (\n- <View style={styles.userList}>\n- <UserList\n- userInfos={userSearchResults}\n- onSelect={this.onUserSelect}\n- />\n- </View>\n- );\n- separator = <View style={styles.separator} />;\n- }\n-\n- const userSelectionHeightStyle = showMessageList\n- ? styles.userSelectionLimitedHeight\n- : null;\n-\nsearchComponent = (\n- <>\n- <View style={[styles.userSelection, userSelectionHeightStyle]}>\n- <View style={styles.tagInputContainer}>\n- <Text style={styles.tagInputLabel}>To: </Text>\n- <View style={styles.tagInput}>\n- <TagInput\n- value={userInfoInputArray}\n- onChange={this.props.updateTagInput}\n- text={usernameInputText}\n- onChangeText={this.props.updateUsernameInput}\n- labelExtractor={this.tagDataLabelExtractor}\n- inputProps={inputProps}\n+ <MessageListThreadSearch\n+ usernameInputText={this.props.usernameInputText}\n+ updateUsernameInput={this.props.updateUsernameInput}\n+ userInfoInputArray={this.props.userInfoInputArray}\n+ updateTagInput={this.props.updateTagInput}\n+ otherUserInfos={this.props.otherUserInfos}\n+ userSearchResults={this.props.userSearchResults}\n/>\n- </View>\n- </View>\n- {userList}\n- </View>\n- {separator}\n- </>\n);\n}\n+ const showMessageList =\n+ !searching || this.props.userInfoInputArray.length > 0;\nlet threadContent = null;\nif (showMessageList) {\nlet messageList;\n@@ -362,40 +300,9 @@ const unboundStyles = {\nbackgroundColor: 'listBackground',\nflex: 1,\n},\n- userSelection: {\n- backgroundColor: 'panelBackground',\n- },\n- userSelectionLimitedHeight: {\n- maxHeight: 500,\n- },\nthreadContent: {\nflex: 1,\n},\n- tagInputLabel: {\n- color: 'modalForegroundSecondaryLabel',\n- fontSize: 16,\n- paddingLeft: 12,\n- },\n- tagInputContainer: {\n- alignItems: 'center',\n- backgroundColor: 'modalForeground',\n- borderBottomWidth: 1,\n- borderColor: 'modalForegroundBorder',\n- flexDirection: 'row',\n- paddingVertical: 6,\n- },\n- tagInput: {\n- flex: 1,\n- },\n- userList: {\n- backgroundColor: 'modalBackground',\n- paddingLeft: 35,\n- paddingRight: 12,\n- },\n- separator: {\n- height: 1,\n- backgroundColor: 'modalForegroundBorder',\n- },\n};\nexport default React.memo<BaseProps>(function ConnectedMessageListContainer(\n@@ -438,6 +345,7 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\nprops.route.params.threadInfo,\n);\n+ const { searching } = props.route.params;\nconst inputState = React.useContext(InputStateContext);\nconst hideSearch = React.useCallback(() => {\nsetOriginalThreadInfo(threadInfoRef.current);\n@@ -446,12 +354,12 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\n});\n}, [props.navigation]);\nReact.useEffect(() => {\n- if (!props.route.params.searching) {\n+ if (!searching) {\nreturn;\n}\ninputState?.registerSendCallback(hideSearch);\nreturn () => inputState?.unregisterSendCallback(hideSearch);\n- }, [hideSearch, inputState, props.route.params.searching]);\n+ }, [hideSearch, inputState, searching]);\nconst threadCandidates = React.useMemo(() => {\nconst infos = new Map<string, ThreadInfo>();\n@@ -480,7 +388,7 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\nreturn undefined;\n}\n- const pendingThreadMemberIDs = props.route.params.searching\n+ const pendingThreadMemberIDs = searching\n? [...userInfoInputArray.map((user) => user.id), viewerID]\n: threadInfoFromParams.members.map((member) => member.id);\nconst threadKey = getPendingThreadKey(pendingThreadMemberIDs);\n@@ -489,7 +397,7 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\nreturn threadCandidates.get(threadKey);\n}\n- const updatedThread = props.route.params.searching\n+ const updatedThread = searching\n? createPendingThread(\nviewerID,\npendingThreadType(userInfoInputArray.length),\n@@ -504,7 +412,7 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\noriginalThreadInfo,\nthreadInfos,\nviewerID,\n- props.route.params.searching,\n+ searching,\nuserInfoInputArray,\nthreadCandidates,\nuserInfos,\n@@ -524,14 +432,8 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\nconst boundMessageListData = useSelector(messageListDataSelector(threadID));\nconst messageListData = React.useMemo(\n() =>\n- props.route.params.searching && userInfoInputArray.length === 0\n- ? []\n- : boundMessageListData,\n- [\n- boundMessageListData,\n- props.route.params.searching,\n- userInfoInputArray.length,\n- ],\n+ searching && userInfoInputArray.length === 0 ? [] : boundMessageListData,\n+ [boundMessageListData, searching, userInfoInputArray.length],\n);\nconst composedMessageMaxWidth = useSelector(composedMessageMaxWidthSelector);\nconst colors = useColors();\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/message-list-thread-search.react.js",
"diff": "+// @flow\n+\n+import * as React from 'react';\n+import { Text, View } from 'react-native';\n+\n+import type { AccountUserInfo, UserListItem } from 'lib/types/user-types';\n+\n+import TagInput from '../components/tag-input.react';\n+import UserList from '../components/user-list.react';\n+import { useStyles } from '../themes/colors';\n+\n+type Props = {|\n+ +usernameInputText: string,\n+ +updateUsernameInput: (text: string) => void,\n+ +userInfoInputArray: $ReadOnlyArray<AccountUserInfo>,\n+ +updateTagInput: (items: $ReadOnlyArray<AccountUserInfo>) => void,\n+ +otherUserInfos: { [id: string]: AccountUserInfo },\n+ +userSearchResults: $ReadOnlyArray<UserListItem>,\n+|};\n+\n+const inputProps = {\n+ placeholder: 'username',\n+ autoFocus: true,\n+ returnKeyType: 'go',\n+};\n+\n+export default React.memo<Props>(function MessageListThreadSearch({\n+ usernameInputText,\n+ updateUsernameInput,\n+ userInfoInputArray,\n+ updateTagInput,\n+ otherUserInfos,\n+ userSearchResults,\n+}) {\n+ const styles = useStyles(unboundStyles);\n+\n+ const onUserSelect = React.useCallback(\n+ (userID: string) => {\n+ for (const existingUserInfo of userInfoInputArray) {\n+ if (userID === existingUserInfo.id) {\n+ return;\n+ }\n+ }\n+ const newUserInfoInputArray = [\n+ ...userInfoInputArray,\n+ otherUserInfos[userID],\n+ ];\n+ updateUsernameInput('');\n+ updateTagInput(newUserInfoInputArray);\n+ },\n+ [otherUserInfos, updateTagInput, updateUsernameInput, userInfoInputArray],\n+ );\n+\n+ const tagDataLabelExtractor = React.useCallback(\n+ (userInfo: AccountUserInfo) => userInfo.username,\n+ [],\n+ );\n+\n+ const isSearchResultVisible =\n+ (userInfoInputArray.length === 0 || usernameInputText.length > 0) &&\n+ userSearchResults.length > 0;\n+\n+ let separator = null;\n+ let userList = null;\n+ if (isSearchResultVisible) {\n+ userList = (\n+ <View style={styles.userList}>\n+ <UserList userInfos={userSearchResults} onSelect={onUserSelect} />\n+ </View>\n+ );\n+ separator = <View style={styles.separator} />;\n+ }\n+\n+ const showMessageList = userInfoInputArray.length > 0;\n+ const userSelectionHeightStyle = showMessageList\n+ ? styles.userSelectionLimitedHeight\n+ : null;\n+ return (\n+ <>\n+ <View style={[styles.userSelection, userSelectionHeightStyle]}>\n+ <View style={styles.tagInputContainer}>\n+ <Text style={styles.tagInputLabel}>To: </Text>\n+ <View style={styles.tagInput}>\n+ <TagInput\n+ value={userInfoInputArray}\n+ onChange={updateTagInput}\n+ text={usernameInputText}\n+ onChangeText={updateUsernameInput}\n+ labelExtractor={tagDataLabelExtractor}\n+ inputProps={inputProps}\n+ />\n+ </View>\n+ </View>\n+ {userList}\n+ </View>\n+ {separator}\n+ </>\n+ );\n+});\n+\n+const unboundStyles = {\n+ userSelection: {\n+ backgroundColor: 'panelBackground',\n+ },\n+ userSelectionLimitedHeight: {\n+ maxHeight: 500,\n+ },\n+ tagInputLabel: {\n+ color: 'modalForegroundSecondaryLabel',\n+ fontSize: 16,\n+ paddingLeft: 12,\n+ },\n+ tagInputContainer: {\n+ alignItems: 'center',\n+ backgroundColor: 'modalForeground',\n+ borderBottomWidth: 1,\n+ borderColor: 'modalForegroundBorder',\n+ flexDirection: 'row',\n+ paddingVertical: 6,\n+ },\n+ tagInput: {\n+ flex: 1,\n+ },\n+ userList: {\n+ backgroundColor: 'modalBackground',\n+ paddingLeft: 35,\n+ paddingRight: 12,\n+ },\n+ separator: {\n+ height: 1,\n+ backgroundColor: 'modalForegroundBorder',\n+ },\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Create message list thread search component
Test Plan: Flow, check is the functionality remained the same
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: Adrian, zrebcu411, KatPo
Differential Revision: https://phabricator.ashoat.com/D547 |
129,191 | 28.12.2020 12:31:14 | -3,600 | 6083a10fb278e8a20d2c98bc686f7f708178c647 | [native] Hide settings button on Android for pending threads
Test Plan: When pending thread is open, the button should not be visible. For a real thread, the button should still appear
Reviewers: ashoat
Subscribers: Adrian, zrebcu411, KatPo | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -19,6 +19,8 @@ import invariant from 'invariant';\nimport * as React from 'react';\nimport { Platform, View } from 'react-native';\n+import { threadIsPending } from 'lib/shared/thread-utils';\n+\nimport KeyboardAvoidingView from '../components/keyboard-avoiding-view.react';\nimport { InputStateContext } from '../input/input-state';\nimport HeaderBackButton from '../navigation/header-back-button.react';\n@@ -180,7 +182,7 @@ const messageListOptions = ({ navigation, route }) => ({\nflex: 1,\n},\nheaderRight:\n- Platform.OS === 'android'\n+ Platform.OS === 'android' && !threadIsPending(route.params.threadInfo.id)\n? // This is a render prop, not a component\n// eslint-disable-next-line react/display-name\n() => (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Hide settings button on Android for pending threads
Test Plan: When pending thread is open, the button should not be visible. For a real thread, the button should still appear
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: Adrian, zrebcu411, KatPo
Differential Revision: https://phabricator.ashoat.com/D562 |
129,187 | 24.12.2020 15:35:02 | 18,000 | 3f8f49563f6949b4f28ea5e08c7c5c86162df0c0 | [native] Convert EditPassword data-binding to hook
Test Plan: Flow
Reviewers: palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/more/edit-password.react.js",
"new_path": "native/more/edit-password.react.js",
"diff": "import { CommonActions } from '@react-navigation/native';\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\nText,\n@@ -19,55 +18,46 @@ import {\n} from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport type { ChangeUserSettingsResult } from 'lib/types/account-types';\n-import { loadingStatusPropType } from 'lib/types/loading-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { AccountUpdate } from 'lib/types/user-types';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ useServerCall,\n+ useDispatchActionPromise,\n+ type DispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport { setNativeCredentials } from '../account/native-credentials';\nimport Button from '../components/button.react';\n-import type { AppState } from '../redux/redux-setup';\n-import {\n- type Colors,\n- colorsPropType,\n- colorsSelector,\n- styleSelector,\n-} from '../themes/colors';\n-import { type GlobalTheme, globalThemePropType } from '../types/themes';\n+import type { NavigationRoute } from '../navigation/route-names';\n+import { useSelector } from '../redux/redux-utils';\n+import { type Colors, useColors, useStyles } from '../themes/colors';\n+import type { GlobalTheme } from '../types/themes';\nimport type { MoreNavigationProp } from './more.react';\n-type Props = {\n- navigation: MoreNavigationProp<'EditPassword'>,\n+type BaseProps = {|\n+ +navigation: MoreNavigationProp<'EditPassword'>,\n+ +route: NavigationRoute<'EditPassword'>,\n+|};\n+type Props = {|\n+ ...BaseProps,\n// Redux state\n- loadingStatus: LoadingStatus,\n- activeTheme: ?GlobalTheme,\n- colors: Colors,\n- styles: typeof styles,\n+ +loadingStatus: LoadingStatus,\n+ +activeTheme: ?GlobalTheme,\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- changeUserSettings: (\n+ +changeUserSettings: (\naccountUpdate: AccountUpdate,\n) => Promise<ChangeUserSettingsResult>,\n-};\n+|};\ntype State = {|\n- currentPassword: string,\n- newPassword: string,\n- confirmPassword: string,\n+ +currentPassword: string,\n+ +newPassword: string,\n+ +confirmPassword: string,\n|};\nclass EditPassword extends React.PureComponent<Props, State> {\n- static propTypes = {\n- navigation: PropTypes.shape({\n- dispatch: PropTypes.func.isRequired,\n- }).isRequired,\n- loadingStatus: loadingStatusPropType.isRequired,\n- activeTheme: globalThemePropType,\n- colors: colorsPropType.isRequired,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- changeUserSettings: PropTypes.func.isRequired,\n- };\nstate: State = {\ncurrentPassword: '',\nnewPassword: '',\n@@ -286,7 +276,7 @@ class EditPassword extends React.PureComponent<Props, State> {\n};\n}\n-const styles = {\n+const unboundStyles = {\nheader: {\ncolor: 'panelBackgroundLabel',\nfontSize: 12,\n@@ -341,18 +331,31 @@ const styles = {\npaddingVertical: 3,\n},\n};\n-const stylesSelector = styleSelector(styles);\nconst loadingStatusSelector = createLoadingStatusSelector(\nchangeUserSettingsActionTypes,\n);\n-export default connect(\n- (state: AppState) => ({\n- loadingStatus: loadingStatusSelector(state),\n- activeTheme: state.globalThemeInfo.activeTheme,\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n- }),\n- { changeUserSettings },\n-)(EditPassword);\n+export default React.memo<BaseProps>(function ConnectedEditPassword(\n+ props: BaseProps,\n+) {\n+ const loadingStatus = useSelector(loadingStatusSelector);\n+ const activeTheme = useSelector((state) => state.globalThemeInfo.activeTheme);\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+\n+ const dispatchActionPromise = useDispatchActionPromise();\n+ const callChangeUserSettings = useServerCall(changeUserSettings);\n+\n+ return (\n+ <EditPassword\n+ {...props}\n+ loadingStatus={loadingStatus}\n+ activeTheme={activeTheme}\n+ colors={colors}\n+ styles={styles}\n+ dispatchActionPromise={dispatchActionPromise}\n+ changeUserSettings={callChangeUserSettings}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Convert EditPassword data-binding to hook
Test Plan: Flow
Reviewers: palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D555 |
129,187 | 24.12.2020 16:34:41 | 18,000 | f3c2e8525679720dff1c8cdbc1570d56b4ffe924 | [native] Convert ThemeHandler to hook
Test Plan: Flow
Reviewers: palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/themes/theme-handler.react.js",
"new_path": "native/themes/theme-handler.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\ninitialMode as initialSystemTheme,\neventEmitter as systemThemeEventEmitter,\n} from 'react-native-dark-mode';\n-\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import { connect } from 'lib/utils/redux-utils';\n+import { useDispatch } from 'react-redux';\nimport { updateThemeInfoActionType } from '../redux/action-types';\n-import type { AppState } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\nimport {\ntype GlobalTheme,\ntype GlobalThemeInfo,\n- globalThemeInfoPropType,\nosCanTheme,\n} from '../types/themes';\n-type Props = {|\n- // Redux state\n- globalThemeInfo: GlobalThemeInfo,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n-|};\n-class ThemeHandler extends React.PureComponent<Props> {\n- static propTypes = {\n- globalThemeInfo: globalThemeInfoPropType.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n+function ThemeHandler() {\n+ const globalThemeInfo = useSelector((state) => state.globalThemeInfo);\n+ const dispatch = useDispatch();\n+ const updateSystemTheme = React.useCallback(\n+ (colorScheme: GlobalTheme) => {\n+ if (globalThemeInfo.systemTheme === colorScheme) {\n+ return;\n+ }\n+\n+ const updateObject: $Shape<GlobalThemeInfo> = {\n+ systemTheme: colorScheme,\n};\n+ if (globalThemeInfo.preference === 'system') {\n+ updateObject.activeTheme = colorScheme;\n+ }\n- componentDidMount() {\n+ dispatch({\n+ type: updateThemeInfoActionType,\n+ updateObject,\n+ });\n+ },\n+ [globalThemeInfo, dispatch],\n+ );\n+\n+ React.useEffect(() => {\nif (!osCanTheme) {\n- return;\n+ return undefined;\n}\nsystemThemeEventEmitter.addListener(\n'currentModeChanged',\n- this.updateSystemTheme,\n+ updateSystemTheme,\n);\n- this.updateSystemTheme(initialSystemTheme);\n- }\n-\n- componentWillUnmount() {\n- if (!osCanTheme) {\n- return;\n- }\n+ return () => {\nsystemThemeEventEmitter.removeListener(\n'currentModeChanged',\n- this.updateSystemTheme,\n+ updateSystemTheme,\n);\n- }\n-\n- updateSystemTheme = (colorScheme: GlobalTheme) => {\n- if (this.props.globalThemeInfo.systemTheme === colorScheme) {\n- return;\n- }\n-\n- const updateObject: $Shape<GlobalThemeInfo> = { systemTheme: colorScheme };\n- if (this.props.globalThemeInfo.preference === 'system') {\n- updateObject.activeTheme = colorScheme;\n- }\n-\n- this.props.dispatchActionPayload(updateThemeInfoActionType, updateObject);\n};\n+ }, [updateSystemTheme]);\n+\n+ React.useEffect(\n+ () => updateSystemTheme(initialSystemTheme),\n+ // eslint-disable-next-line react-hooks/exhaustive-deps\n+ [],\n+ );\n- render() {\nreturn null;\n}\n-}\n-export default connect(\n- (state: AppState) => ({\n- globalThemeInfo: state.globalThemeInfo,\n- }),\n- null,\n- true,\n-)(ThemeHandler);\n+export default ThemeHandler;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Convert ThemeHandler to hook
Test Plan: Flow
Reviewers: palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D558 |
129,187 | 24.12.2020 22:07:54 | 18,000 | 9481589559286b04d911fd206adff2b0916c1714 | [native] Convert HeaderBackButton into Hook
Test Plan: Flow
Reviewers: palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/navigation/header-back-button.react.js",
"new_path": "native/navigation/header-back-button.react.js",
"diff": "import { HeaderBackButton as BaseHeaderBackButton } from '@react-navigation/stack';\nimport * as React from 'react';\n-import { connect } from 'lib/utils/redux-utils';\n+import { useColors } from '../themes/colors';\n-import type { AppState } from '../redux/redux-setup';\n-import type { Colors } from '../themes/colors';\n-import { colorsSelector } from '../themes/colors';\n-\n-type Props = {\n- ...React.ElementConfig<typeof BaseHeaderBackButton>,\n- // Redux state\n- colors: Colors,\n-};\n+type Props = React.ElementConfig<typeof BaseHeaderBackButton>;\nfunction HeaderBackButton(props: Props) {\n+ const { link: tintColor } = useColors();\nif (!props.canGoBack) {\nreturn null;\n}\n- const { colors, ...rest } = props;\n- const { link: tintColor } = colors;\n- return <BaseHeaderBackButton {...rest} tintColor={tintColor} />;\n+ return <BaseHeaderBackButton {...props} tintColor={tintColor} />;\n}\n-\n-export default connect((state: AppState) => ({\n- colors: colorsSelector(state),\n-}))(HeaderBackButton);\n+export default HeaderBackButton;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Convert HeaderBackButton into Hook
Test Plan: Flow
Reviewers: palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D560 |
129,187 | 28.12.2020 11:19:07 | 18,000 | f116325111cd0fc9dcb18be00a0c446236e54d3c | [native] codeVersion -> 73
This is an Android-only release to address an issue identified in the v72 release (see D562). | [
{
"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 72\n- versionName \"0.0.72\"\n+ versionCode 73\n+ versionName \"0.0.73\"\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.72</string>\n+ <string>0.0.73</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>72</string>\n+ <string>73</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.72</string>\n+ <string>0.0.73</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>72</string>\n+ <string>73</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": "@@ -204,7 +204,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 72;\n+const codeVersion = 73;\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 -> 73
This is an Android-only release to address an issue identified in the v72 release (see D562). |
129,191 | 23.12.2020 15:33:55 | -3,600 | ccda03ba0ebc34022487fb86d2b787152e6455ad | [native] Make thread creator buttons navigate to message list with searching param
Test Plan: Test if header button on iOS and floating action on Android navigate to message list with search component visible
Reviewers: ashoat
Subscribers: Adrian, zrebcu411, KatPo | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -16,7 +16,10 @@ import {\nimport { threadSearchIndex as threadSearchIndexSelector } from 'lib/selectors/nav-selectors';\nimport { usersWithPersonalThreadSelector } from 'lib/selectors/user-selectors';\nimport SearchIndex from 'lib/shared/search-index';\n-import { createPendingThreadItem } from 'lib/shared/thread-utils';\n+import {\n+ createPendingThread,\n+ createPendingThreadItem,\n+} from 'lib/shared/thread-utils';\nimport type { UserSearchResult } from 'lib/types/search-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport { threadTypes } from 'lib/types/thread-types';\n@@ -26,7 +29,6 @@ import { useServerCall } from 'lib/utils/action-utils';\nimport Search from '../components/search.react';\nimport type { TabNavigationProp } from '../navigation/app-navigator.react';\nimport {\n- ComposeThreadRouteName,\nMessageListRouteName,\nSidebarListModalRouteName,\nHomeChatThreadListRouteName,\n@@ -359,10 +361,19 @@ class ChatThreadList extends React.PureComponent<Props, State> {\n};\ncomposeThread = () => {\n+ if (this.props.viewerID) {\nthis.props.navigation.navigate({\n- name: ComposeThreadRouteName,\n- params: {},\n+ name: MessageListRouteName,\n+ params: {\n+ threadInfo: createPendingThread(\n+ this.props.viewerID,\n+ threadTypes.CHAT_SECRET,\n+ [],\n+ ),\n+ searching: true,\n+ },\n});\n+ }\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/compose-thread-button.react.js",
"new_path": "native/chat/compose-thread-button.react.js",
"diff": "@@ -5,18 +5,21 @@ import * as React from 'react';\nimport { StyleSheet } from 'react-native';\nimport Icon from 'react-native-vector-icons/MaterialCommunityIcons';\n+import { createPendingThread } from 'lib/shared/thread-utils';\n+import { threadTypes } from 'lib/types/thread-types';\nimport { connect } from 'lib/utils/redux-utils';\nimport Button from '../components/button.react';\n-import { ComposeThreadRouteName } from '../navigation/route-names';\n+import { MessageListRouteName } from '../navigation/route-names';\nimport type { AppState } from '../redux/redux-setup';\nimport { type Colors, colorsPropType, colorsSelector } from '../themes/colors';\nimport type { ChatNavigationProp } from './chat.react';\ntype Props = {|\n- navigate: $PropertyType<ChatNavigationProp<'ChatThreadList'>, 'navigate'>,\n+ +navigate: $PropertyType<ChatNavigationProp<'ChatThreadList'>, 'navigate'>,\n// Redux state\n- colors: Colors,\n+ +colors: Colors,\n+ +viewerID: ?string,\n|};\nclass ComposeThreadButton extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -39,10 +42,19 @@ class ComposeThreadButton extends React.PureComponent<Props> {\n}\nonPress = () => {\n+ if (this.props.viewerID) {\nthis.props.navigate({\n- name: ComposeThreadRouteName,\n- params: {},\n+ name: MessageListRouteName,\n+ params: {\n+ threadInfo: createPendingThread(\n+ this.props.viewerID,\n+ threadTypes.CHAT_SECRET,\n+ [],\n+ ),\n+ searching: true,\n+ },\n});\n+ }\n};\n}\n@@ -54,4 +66,5 @@ const styles = StyleSheet.create({\nexport default connect((state: AppState) => ({\ncolors: colorsSelector(state),\n+ viewerID: state.currentUserInfo && state.currentUserInfo.id,\n}))(ComposeThreadButton);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Make thread creator buttons navigate to message list with searching param
Test Plan: Test if header button on iOS and floating action on Android navigate to message list with search component visible
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: Adrian, zrebcu411, KatPo
Differential Revision: https://phabricator.ashoat.com/D550 |
129,191 | 24.12.2020 15:13:31 | -3,600 | e523589964e02cd183e75e80afe76b5df41c0204 | [native] Use hooks in compose thread button
Test Plan: Flow, check if the button works ok
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/compose-thread-button.react.js",
"new_path": "native/chat/compose-thread-button.react.js",
"diff": "// @flow\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { StyleSheet } from 'react-native';\nimport Icon from 'react-native-vector-icons/MaterialCommunityIcons';\nimport { createPendingThread } from 'lib/shared/thread-utils';\nimport { threadTypes } from 'lib/types/thread-types';\n-import { connect } from 'lib/utils/redux-utils';\nimport Button from '../components/button.react';\nimport { MessageListRouteName } from '../navigation/route-names';\n-import type { AppState } from '../redux/redux-setup';\n-import { type Colors, colorsPropType, colorsSelector } from '../themes/colors';\n+import { useSelector } from '../redux/redux-utils';\n+import { type Colors, useColors } from '../themes/colors';\nimport type { ChatNavigationProp } from './chat.react';\n-type Props = {|\n+type BaseProps = {|\n+navigate: $PropertyType<ChatNavigationProp<'ChatThreadList'>, 'navigate'>,\n- // Redux state\n+|};\n+type Props = {|\n+ ...BaseProps,\n+colors: Colors,\n+viewerID: ?string,\n|};\nclass ComposeThreadButton extends React.PureComponent<Props> {\n- static propTypes = {\n- navigate: PropTypes.func.isRequired,\n- colors: colorsPropType.isRequired,\n- };\n-\nrender() {\nconst { link: linkColor } = this.props.colors;\nreturn (\n@@ -64,7 +59,13 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect((state: AppState) => ({\n- colors: colorsSelector(state),\n- viewerID: state.currentUserInfo && state.currentUserInfo.id,\n-}))(ComposeThreadButton);\n+export default React.memo<BaseProps>(function ConnectedComposeThreadButton(\n+ props,\n+) {\n+ const colors = useColors();\n+ const viewerID = useSelector(\n+ (state) => state.currentUserInfo && state.currentUserInfo.id,\n+ );\n+\n+ return <ComposeThreadButton {...props} colors={colors} viewerID={viewerID} />;\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use hooks in compose thread button
Test Plan: Flow, check if the button works ok
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D554 |
129,191 | 31.12.2020 22:46:04 | 25,200 | 67bda27bd9b25b210096227dc5a205c9e8699f91 | [lib] Shim unsupported update relationship message
Test Plan: I removed min code version condition, sent a request and checked if the message was displayed correctly
Reviewers: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -732,6 +732,21 @@ function shimUnsupportedRawMessageInfos(\nrobotext: multimediaMessagePreview(shimmedRawMessageInfo),\nunsupportedMessageInfo: shimmedRawMessageInfo,\n};\n+ } else if (rawMessageInfo.type === messageTypes.UPDATE_RELATIONSHIP) {\n+ if (hasMinCodeVersion(platformDetails, 71)) {\n+ return rawMessageInfo;\n+ }\n+ const { id } = rawMessageInfo;\n+ invariant(id !== null && id !== undefined, 'id should be set on server');\n+ return {\n+ type: messageTypes.UNSUPPORTED,\n+ id,\n+ threadID: rawMessageInfo.threadID,\n+ creatorID: rawMessageInfo.creatorID,\n+ time: rawMessageInfo.time,\n+ robotext: 'performed a relationship action',\n+ unsupportedMessageInfo: rawMessageInfo,\n+ };\n}\nreturn rawMessageInfo;\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Shim unsupported update relationship message
Test Plan: I removed min code version condition, sent a request and checked if the message was displayed correctly
Reviewers: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D565 |
129,187 | 29.12.2020 01:09:28 | 18,000 | fbcd65535d2a4f400fb67423b7c36d813c2dc116 | [server] Script to rename user
Summary: This will change Atul's SquadCal username to `atul`
Test Plan: I ran the script with a test user in my local environment
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/rename-user.js",
"diff": "+// @flow\n+\n+import { updateTypes } from 'lib/types/update-types';\n+\n+import { createUpdates } from '../creators/update-creator';\n+import { dbQuery, SQL } from '../database/database';\n+import { fetchKnownUserInfos } from '../fetchers/user-fetchers';\n+import { createScriptViewer } from '../session/scripts';\n+import { main } from './utils';\n+\n+const userID = '518252';\n+const newUsername = 'atul';\n+\n+async function renameUser() {\n+ const [adjacentUsers] = await Promise.all([\n+ fetchKnownUserInfos(createScriptViewer(userID)),\n+ dbQuery(\n+ SQL`UPDATE users SET username = ${newUsername} WHERE id = ${userID}`,\n+ ),\n+ ]);\n+\n+ const updateDatas = [];\n+ const time = Date.now();\n+ updateDatas.push({\n+ type: updateTypes.UPDATE_CURRENT_USER,\n+ userID,\n+ time,\n+ });\n+ for (const adjacentUserID in adjacentUsers) {\n+ updateDatas.push({\n+ type: updateTypes.UPDATE_USER,\n+ userID: adjacentUserID,\n+ time,\n+ updatedUserID: userID,\n+ });\n+ }\n+ await createUpdates(updateDatas);\n+}\n+\n+main([renameUser]);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Script to rename user
Summary: This will change Atul's SquadCal username to `atul`
Test Plan: I ran the script with a test user in my local environment
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D563 |
129,183 | 22.12.2020 15:54:06 | -3,600 | 127950c99fe3cffd0296a9e8363aea33d999d75d | Add initialMessageID parameter when creating sidebar
Summary: First step of displaying message that started sidebar.
Test Plan: Make sure creating sidebars is possible only with new parameter, and all of the rest thread types do not have it
Reviewers: ashoat, KatPo
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -315,14 +315,24 @@ export type UpdateThreadRequest = {|\nchanges: ThreadChanges,\n|};\n-export type NewThreadRequest = {|\n- +type: ThreadType,\n+export type BaseNewThreadRequest = {|\n+name?: ?string,\n+description?: ?string,\n+color?: ?string,\n+parentThreadID?: ?string,\n+initialMemberIDs?: ?$ReadOnlyArray<string>,\n|};\n+export type NewThreadRequest =\n+ | {|\n+ +type: 3 | 4 | 6,\n+ ...BaseNewThreadRequest,\n+ |}\n+ | {|\n+ +type: 5,\n+ +initialMessageID: string,\n+ ...BaseNewThreadRequest,\n+ |};\n+\nexport type NewThreadResponse = {|\n+updatesResult: {|\n+newUpdates: $ReadOnlyArray<UpdateInfo>,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/compose-thread.react.js",
"new_path": "native/chat/compose-thread.react.js",
"diff": "@@ -371,13 +371,15 @@ class ComposeThread extends React.PureComponent<Props, State> {\nthis.setLinkButton(false);\ntry {\nconst threadTypeParam = this.props.route.params.threadType;\n- const threadType = threadTypeParam\n- ? threadTypeParam\n- : threadTypes.CHAT_SECRET;\n+ const threadType = threadTypeParam ?? threadTypes.CHAT_SECRET;\nconst initialMemberIDs = this.state.userInfoInputArray.map(\n(userInfo: AccountUserInfo) => userInfo.id,\n);\nconst parentThreadInfo = ComposeThread.getParentThreadInfo(this.props);\n+ invariant(\n+ threadType !== 5,\n+ 'Creating sidebars from thread composer is not yet supported',\n+ );\nconst result = await this.props.newThread({\ntype: threadType,\nparentThreadID: parentThreadInfo ? parentThreadInfo.id : null,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/thread-responders.js",
"new_path": "server/src/responders/thread-responders.js",
"diff": "@@ -14,8 +14,9 @@ import {\ntype NewThreadResponse,\ntype ServerThreadJoinRequest,\ntype ThreadJoinResult,\n- assertThreadType,\n+ threadTypes,\n} from 'lib/types/thread-types';\n+import { values } from 'lib/utils/objects';\nimport createThread from '../creators/thread-creator';\nimport { deleteThread } from '../deleters/thread-deleters';\n@@ -101,7 +102,7 @@ async function threadLeaveResponder(\nconst updateThreadRequestInputValidator = tShape({\nthreadID: t.String,\nchanges: tShape({\n- type: t.maybe(tNumEnum(assertThreadType)),\n+ type: t.maybe(tNumEnum(values(threadTypes))),\nname: t.maybe(t.String),\ndescription: t.maybe(t.String),\ncolor: t.maybe(tColor),\n@@ -120,14 +121,28 @@ async function threadUpdateResponder(\nreturn await updateThread(viewer, request);\n}\n-const newThreadRequestInputValidator = tShape({\n- type: tNumEnum(assertThreadType),\n+const threadRequestValidationShape = {\nname: t.maybe(t.String),\ndescription: t.maybe(t.String),\ncolor: t.maybe(tColor),\nparentThreadID: t.maybe(t.String),\ninitialMemberIDs: t.maybe(t.list(t.String)),\n-});\n+};\n+const newThreadRequestInputValidator = t.union([\n+ tShape({\n+ type: tNumEnum([threadTypes.SIDEBAR]),\n+ initialMessageID: t.String,\n+ ...threadRequestValidationShape,\n+ }),\n+ tShape({\n+ type: tNumEnum([\n+ threadTypes.CHAT_NESTED_OPEN,\n+ threadTypes.CHAT_SECRET,\n+ threadTypes.PERSONAL,\n+ ]),\n+ ...threadRequestValidationShape,\n+ }),\n+]);\nasync function threadCreationResponder(\nviewer: Viewer,\ninput: any,\n@@ -163,4 +178,5 @@ export {\nthreadUpdateResponder,\nthreadCreationResponder,\nthreadJoinResponder,\n+ newThreadRequestInputValidator,\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/responders/thread-responders.test.js",
"diff": "+// @flow\n+\n+import { threadTypes } from 'lib/types/thread-types';\n+\n+import { newThreadRequestInputValidator } from './thread-responders';\n+\n+describe('Thread responders', () => {\n+ describe('New thread request validator', () => {\n+ const requestWithoutMessageID = {\n+ name: 'name',\n+ description: 'description',\n+ color: 'aaaaaa',\n+ parentThreadID: 'parentID',\n+ initialMemberIDs: [],\n+ };\n+ const requestWithMessageID = {\n+ ...requestWithoutMessageID,\n+ initialMessageID: 'messageID',\n+ };\n+\n+ it('Should require initialMessageID of a sidebar', () => {\n+ expect(\n+ newThreadRequestInputValidator.is({\n+ type: threadTypes.SIDEBAR,\n+ ...requestWithoutMessageID,\n+ }),\n+ ).toBe(false);\n+\n+ expect(\n+ newThreadRequestInputValidator.is({\n+ type: threadTypes.SIDEBAR,\n+ ...requestWithMessageID,\n+ }),\n+ ).toBe(true);\n+ });\n+\n+ it('Should not require initialMessageID of not a sidebar', () => {\n+ expect(\n+ newThreadRequestInputValidator.is({\n+ type: threadTypes.CHAT_SECRET,\n+ ...requestWithoutMessageID,\n+ }),\n+ ).toBe(true);\n+\n+ expect(\n+ newThreadRequestInputValidator.is({\n+ type: threadTypes.CHAT_SECRET,\n+ ...requestWithMessageID,\n+ }),\n+ ).toBe(false);\n+ });\n+ });\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/utils/validation-utils.js",
"new_path": "server/src/utils/validation-utils.js",
"diff": "@@ -23,14 +23,14 @@ function tRegex(regex: RegExp) {\nreturn t.refinement(t.String, (val) => regex.test(val));\n}\n-function tNumEnum(assertFunc: (input: number) => *) {\n+function tNumEnum(nums: $ReadOnlyArray<number>) {\nreturn t.refinement(t.Number, (input: number) => {\n- try {\n- assertFunc(input);\n+ for (const num of nums) {\n+ if (input === num) {\nreturn true;\n- } catch (e) {\n- return false;\n}\n+ }\n+ return false;\n});\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/utils/validation-utils.test.js",
"diff": "+// @flow\n+\n+import { threadTypes } from 'lib/types/thread-types';\n+import { values } from 'lib/utils/objects';\n+\n+import { tNumEnum } from './validation-utils';\n+\n+describe('Validation utils', () => {\n+ describe('tNumEnum validator', () => {\n+ it('Should discard when accepted set is empty', () => {\n+ expect(tNumEnum([]).is(1)).toBe(false);\n+ });\n+\n+ it('Should accept when array contains number', () => {\n+ expect(tNumEnum([1, 2, 3]).is(2)).toBe(true);\n+ });\n+\n+ it('Should discard when array does not contain number', () => {\n+ expect(tNumEnum([1, 2, 3]).is(4)).toBe(false);\n+ });\n+\n+ it('Should accept when value is a part of enum', () => {\n+ expect(tNumEnum(values(threadTypes)).is(threadTypes.SIDEBAR)).toBe(true);\n+ });\n+\n+ it('Should discard when value is not a part of enum', () => {\n+ expect(tNumEnum(values(threadTypes)).is(123)).toBe(false);\n+ });\n+ });\n+});\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": "@@ -253,6 +253,10 @@ class NewThreadModal extends React.PureComponent<Props, State> {\nasync newThreadAction(threadType: ThreadType) {\nconst name = this.state.name.trim();\ntry {\n+ invariant(\n+ threadType !== 5,\n+ 'Creating sidebars from modal is not yet supported',\n+ );\nconst response = await this.props.newThread({\ntype: threadType,\nname,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add initialMessageID parameter when creating sidebar
Summary: First step of displaying message that started sidebar.
Test Plan: Make sure creating sidebars is possible only with new parameter, and all of the rest thread types do not have it
Reviewers: ashoat, KatPo
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D541 |
129,183 | 23.12.2020 14:21:24 | -3,600 | cbe6b3ed8a6ab81af96a8d9fc69bb8017f3ca314 | [server] Create function to fetch message info for id
Test Plan: Check if returned message info looks good, also tested together with next diff
Reviewers: ashoat, KatPo
Subscribers: zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/message-fetchers.js",
"new_path": "server/src/fetchers/message-fetchers.js",
"diff": "@@ -675,6 +675,32 @@ async function fetchMessageInfoForEntryAction(\nreturn rawMessageInfoFromRows(result, viewer);\n}\n+async function fetchMessageInfoByID(\n+ viewer: Viewer,\n+ messageID: string,\n+): Promise<?RawMessageInfo> {\n+ if (!viewer.hasSessionInfo) {\n+ return null;\n+ }\n+\n+ const query = SQL`\n+ SELECT m.id, m.thread AS threadID, m.content, m.time, m.type, m.creation,\n+ m.user AS creatorID, up.id AS uploadID, up.type AS uploadType,\n+ up.secret AS uploadSecret, up.extra AS uploadExtra\n+ FROM messages m\n+ LEFT JOIN uploads up\n+ ON m.type IN (${[messageTypes.IMAGES, messageTypes.MULTIMEDIA]})\n+ AND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\n+ WHERE m.id = ${messageID}\n+ `;\n+\n+ const [result] = await dbQuery(query);\n+ if (result.length === 0) {\n+ return null;\n+ }\n+ return rawMessageInfoFromRows(result, viewer);\n+}\n+\nexport {\nfetchCollapsableNotifs,\nfetchMessageInfos,\n@@ -682,4 +708,5 @@ export {\ngetMessageFetchResultFromRedisMessages,\nfetchMessageInfoForLocalID,\nfetchMessageInfoForEntryAction,\n+ fetchMessageInfoByID,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Create function to fetch message info for id
Test Plan: Check if returned message info looks good, also tested together with next diff
Reviewers: ashoat, KatPo
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D548 |
129,187 | 03.01.2021 16:29:57 | 25,200 | 094a3926531311454bc793352a56053d4d89cf90 | [native] Fix dispatch call in ThemeHandler
Summary: I broke this in D558 :(
Test Plan: Make sure that status bar displays with dark text if OS is in light moded when booting a freshly installed native client
Reviewers: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/themes/theme-handler.react.js",
"new_path": "native/themes/theme-handler.react.js",
"diff": "@@ -35,7 +35,7 @@ function ThemeHandler() {\ndispatch({\ntype: updateThemeInfoActionType,\n- updateObject,\n+ payload: updateObject,\n});\n},\n[globalThemeInfo, dispatch],\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix dispatch call in ThemeHandler
Summary: I broke this in D558 :(
Test Plan: Make sure that status bar displays with dark text if OS is in light moded when booting a freshly installed native client
Reviewers: palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D566 |
129,187 | 03.01.2021 17:19:32 | 25,200 | 386906cb15106e06f2ac5536ffafceb339b879e1 | [native] Convert MediaGalleryKeyboard data-binding to hook
Test Plan: Flow
Reviewers: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/media/media-gallery-keyboard.react.js",
"new_path": "native/media/media-gallery-keyboard.react.js",
"diff": "import * as MediaLibrary from 'expo-media-library';\nimport invariant from 'invariant';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport {\nView,\n@@ -18,20 +17,11 @@ import { Provider } from 'react-redux';\nimport { extensionFromFilename } from 'lib/media/file-utils';\nimport type { MediaLibrarySelection } from 'lib/types/media-types';\n-import { connect } from 'lib/utils/redux-utils';\n-import {\n- type DimensionsInfo,\n- dimensionsInfoPropType,\n-} from '../redux/dimensions-updater.react';\n-import type { AppState } from '../redux/redux-setup';\n+import type { DimensionsInfo } from '../redux/dimensions-updater.react';\nimport { store } from '../redux/redux-setup';\n-import {\n- type Colors,\n- colorsPropType,\n- colorsSelector,\n- styleSelector,\n-} from '../themes/colors';\n+import { useSelector } from '../redux/redux-utils';\n+import { type Colors, useColors, useStyles } from '../themes/colors';\nimport type { ViewToken, LayoutEvent } from '../types/react-native';\nimport type { ViewStyle } from '../types/styles';\nimport { getCompatibleMediaURI } from './identifier-utils';\n@@ -46,28 +36,22 @@ const animationSpec = {\ntype Props = {|\n// Redux state\n- dimensions: DimensionsInfo,\n- foreground: boolean,\n- colors: Colors,\n- styles: typeof styles,\n+ +dimensions: DimensionsInfo,\n+ +foreground: boolean,\n+ +colors: Colors,\n+ +styles: typeof unboundStyles,\n|};\ntype State = {|\n- selections: ?$ReadOnlyArray<MediaLibrarySelection>,\n- error: ?string,\n- containerHeight: ?number,\n+ +selections: ?$ReadOnlyArray<MediaLibrarySelection>,\n+ +error: ?string,\n+ +containerHeight: ?number,\n// null means end reached; undefined means no fetch yet\n- cursor: ?string,\n- queuedMediaURIs: ?Set<string>,\n- focusedMediaURI: ?string,\n- dimensions: DimensionsInfo,\n+ +cursor: ?string,\n+ +queuedMediaURIs: ?Set<string>,\n+ +focusedMediaURI: ?string,\n+ +dimensions: DimensionsInfo,\n|};\nclass MediaGalleryKeyboard extends React.PureComponent<Props, State> {\n- static propTypes = {\n- dimensions: dimensionsInfoPropType.isRequired,\n- foreground: PropTypes.bool.isRequired,\n- colors: colorsPropType.isRequired,\n- styles: PropTypes.objectOf(PropTypes.object).isRequired,\n- };\nmounted = false;\nfetchingPhotos = false;\nflatList: ?FlatList<MediaLibrarySelection>;\n@@ -511,7 +495,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nconst mediaGalleryKeyboardName = 'MediaGalleryKeyboard';\n-const styles = {\n+const unboundStyles = {\ncontainer: {\nalignItems: 'center',\nbackgroundColor: 'listBackground',\n@@ -539,19 +523,26 @@ const styles = {\nwidth: 2,\n},\n};\n-const stylesSelector = styleSelector(styles);\n-const ReduxConnectedMediaGalleryKeyboard = connect((state: AppState) => ({\n- dimensions: state.dimensions,\n- foreground: state.foreground,\n- colors: colorsSelector(state),\n- styles: stylesSelector(state),\n-}))(MediaGalleryKeyboard);\n+function ConnectedMediaGalleryKeyboard() {\n+ const dimensions = useSelector((state) => state.dimensions);\n+ const foreground = useSelector((state) => state.foreground);\n+ const colors = useColors();\n+ const styles = useStyles(unboundStyles);\n+ return (\n+ <MediaGalleryKeyboard\n+ dimensions={dimensions}\n+ foreground={foreground}\n+ colors={colors}\n+ styles={styles}\n+ />\n+ );\n+}\nfunction ReduxMediaGalleryKeyboard() {\nreturn (\n<Provider store={store}>\n- <ReduxConnectedMediaGalleryKeyboard />\n+ <ConnectedMediaGalleryKeyboard />\n</Provider>\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Convert MediaGalleryKeyboard data-binding to hook
Test Plan: Flow
Reviewers: palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D567 |
129,187 | 03.01.2021 19:16:35 | 25,200 | 352db962590d7b2e55bf9644e18fe191113a74c6 | [client] Use thread color for send icon
Test Plan: Make sure it looks right on web and native
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-input-bar.react.js",
"new_path": "native/chat/chat-input-bar.react.js",
"diff": "@@ -512,6 +512,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n</Animated.View>\n</TouchableOpacity>\n);\n+ const threadColor = `#${this.props.threadInfo.color}`;\nreturn (\n<TouchableWithoutFeedback onPress={this.dismissKeyboard}>\n<View style={this.props.styles.inputContainer}>\n@@ -567,7 +568,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nname=\"md-send\"\nsize={25}\nstyle={this.props.styles.sendIcon}\n- color={this.props.colors.greenButton}\n+ color={threadColor}\n/>\n</TouchableOpacity>\n</Animated.View>\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-input-bar.react.js",
"new_path": "web/chat/chat-input-bar.react.js",
"diff": "@@ -214,6 +214,7 @@ class ChatInputBar extends React.PureComponent<Props> {\nlet content;\nif (threadHasPermission(this.props.threadInfo, threadPermissions.VOICED)) {\n+ const sendIconStyle = { color: `#${this.props.threadInfo.color}` };\ncontent = (\n<div className={css.inputBarTextInput}>\n<textarea\n@@ -236,7 +237,11 @@ class ChatInputBar extends React.PureComponent<Props> {\n<FontAwesomeIcon icon={faFileImage} />\n</a>\n<a className={css.send} onClick={this.onSend}>\n- <FontAwesomeIcon icon={faChevronRight} className={css.sendButton} />\n+ <FontAwesomeIcon\n+ icon={faChevronRight}\n+ className={css.sendButton}\n+ style={sendIconStyle}\n+ />\nSend\n</a>\n</div>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [client] Use thread color for send icon
Test Plan: Make sure it looks right on web and native
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D569 |
129,187 | 06.01.2021 12:58:36 | 18,000 | 2bf7fb6bb621609b701af8006fbfe9542f1aa0f2 | [native] codeVersion -> 74 | [
{
"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 73\n- versionName \"0.0.73\"\n+ versionCode 74\n+ versionName \"0.0.74\"\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.73</string>\n+ <string>0.0.74</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>73</string>\n+ <string>74</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.73</string>\n+ <string>0.0.74</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>73</string>\n+ <string>74</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": "@@ -204,7 +204,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 73;\n+const codeVersion = 74;\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 -> 74 |
129,183 | 04.01.2021 12:28:34 | -3,600 | 12e6af346b6f924cbb1cd7041893336ef5725312 | [native] Do not show sidebars below matching top-level threads in the search results
Test Plan: Check if matching top-level threads are displayed without sidebars below when search text is not empty
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -238,9 +238,9 @@ class ChatThreadList extends React.PureComponent<Props, State> {\ncontinue;\n}\nif (item.threadInfo.type === threadTypes.PERSONAL) {\n- personalThreads.push(item);\n+ personalThreads.push({ ...item, sidebars: [] });\n} else {\n- nonPersonalThreads.push(item);\n+ nonPersonalThreads.push({ ...item, sidebars: [] });\n}\n}\nchatItems.push(...personalThreads, ...nonPersonalThreads);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Do not show sidebars below matching top-level threads in the search results
Test Plan: Check if matching top-level threads are displayed without sidebars below when search text is not empty
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D571 |
129,187 | 07.01.2021 18:53:15 | 18,000 | 7f12502479bcf1d8b14a9bccf386da5fb5bedf23 | Remove calendar header | [
{
"change_type": "MODIFY",
"old_path": "web/calendar/calendar.css",
"new_path": "web/calendar/calendar.css",
"diff": "@@ -51,19 +51,6 @@ table.calendar > thead > tr > th {\nfont-size: 14px;\n}\ntextarea.entryText {\n- background: none;\n- width: 100%;\n- outline: none;\n- border: none;\n- resize: none;\n- overflow: auto;\n- overflow-y: hidden;\n- padding-right: 15px;\n- box-sizing: border-box;\n- font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\",\n- \"Oxygen\", \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\",\n- \"Helvetica Neue\", sans-serif;\n- font-size: 11px;\n}\ntable.calendar td.day {\nborder: 1px solid transparent;\n"
},
{
"change_type": "MODIFY",
"old_path": "web/calendar/calendar.react.js",
"new_path": "web/calendar/calendar.react.js",
"diff": "@@ -215,17 +215,7 @@ class Calendar extends React.PureComponent<Props, State> {\n</h2>\n</div>\n<table className={css.calendar}>\n- <thead>\n- <tr>\n- <th>Sunday</th>\n- <th>Monday</th>\n- <th>Tuesday</th>\n- <th>Wednesday</th>\n- <th>Thursday</th>\n- <th>Friday</th>\n- <th>Saturday</th>\n- </tr>\n- </thead>\n+ <thead></thead>\n<tbody>{rows}</tbody>\n</table>\n</div>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Remove calendar header |
129,187 | 07.01.2021 18:54:09 | 18,000 | cebcc8d027dd1967525b8effea9ad3e6ea1d5317 | Rewrite calendar header from scratch | [
{
"change_type": "MODIFY",
"old_path": "web/calendar/calendar.css",
"new_path": "web/calendar/calendar.css",
"diff": "@@ -51,6 +51,19 @@ table.calendar > thead > tr > th {\nfont-size: 14px;\n}\ntextarea.entryText {\n+ box-sizing: border-box;\n+ font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\",\n+ \"Oxygen\", \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\",\n+ \"Helvetica Neue\", sans-serif;\n+ font-size: 11px;\n+ width: 100%;\n+ background: none;\n+ border: none;\n+ outline: none;\n+ resize: none;\n+ overflow: auto;\n+ overflow-y: hidden;\n+ padding-right: 15px;\n}\ntable.calendar td.day {\nborder: 1px solid transparent;\n"
},
{
"change_type": "MODIFY",
"old_path": "web/calendar/calendar.react.js",
"new_path": "web/calendar/calendar.react.js",
"diff": "@@ -215,7 +215,17 @@ class Calendar extends React.PureComponent<Props, State> {\n</h2>\n</div>\n<table className={css.calendar}>\n- <thead></thead>\n+ <thead>\n+ <tr>\n+ <th>Sunday</th>\n+ <th>Monday</th>\n+ <th>Tuesday</th>\n+ <th>Wednesday</th>\n+ <th>Thursday</th>\n+ <th>Friday</th>\n+ <th>Saturday</th>\n+ </tr>\n+ </thead>\n<tbody>{rows}</tbody>\n</table>\n</div>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Rewrite calendar header from scratch |
129,187 | 11.01.2021 11:55:23 | 28,800 | 379751c2bf470b50c48d96b639008c3d6ffd1786 | Update to Comm | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "-## SquadCal\n+## Comm\n-SquadCal is the working name of this open source messaging project. The goal is to create a chat app that:\n-1. Is oriented around social planning,\n-2. Can support large communities, and\n-3. Is end-to-end encrypted.\n+Comm is the working name of this open source messaging project.\n## Repo structure\n"
},
{
"change_type": "MODIFY",
"old_path": "server/bash/deploy.sh",
"new_path": "server/bash/deploy.sh",
"diff": "@@ -13,7 +13,7 @@ MAX_DISK_USAGE_KB=3145728 # 3 GiB\nDAEMON_USER=squadcal\n# Input to git clone\n-GIT_CLONE_PARAMS=https://github.com/Ashoat/squadcal.git\n+GIT_CLONE_PARAMS=https://github.com/CommE2E/comm.git\nset -e\n[[ `whoami` = root ]] || exec sudo su -c \"$0 $1\"\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update to Comm |
129,183 | 08.01.2021 14:20:46 | -3,600 | c70e96c4c087b739b9d423abf073aa1268ca787c | [web] Check if thread has VOICED permission to show reply tooltip
Test Plan: Check if reply tooltip is not displayed in threads without voiced permission
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "web/chat/text-message.react.js",
"new_path": "web/chat/text-message.react.js",
"diff": "@@ -6,9 +6,9 @@ import * as React from 'react';\nimport type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors';\nimport { onlyEmojiRegex } from 'lib/shared/emojis';\n-import { colorIsDark } from 'lib/shared/thread-utils';\n+import { colorIsDark, threadHasPermission } from 'lib/shared/thread-utils';\nimport { messageTypes } from 'lib/types/message-types';\n-import type { ThreadInfo } from 'lib/types/thread-types';\n+import { type ThreadInfo, threadPermissions } from 'lib/types/thread-types';\nimport Markdown from '../markdown/markdown.react';\nimport css from './chat-message-list.css';\n@@ -60,7 +60,10 @@ function TextMessage(props: Props) {\nconst messageListContext = React.useContext(MessageListContext);\ninvariant(messageListContext, 'DummyTextNode should have MessageListContext');\nconst rules = messageListContext.getTextMessageMarkdownRules(darkColor);\n-\n+ const canReply = threadHasPermission(\n+ props.threadInfo,\n+ threadPermissions.VOICED,\n+ );\nreturn (\n<ComposedMessage\nitem={props.item}\n@@ -68,7 +71,7 @@ function TextMessage(props: Props) {\nsendFailed={textMessageSendFailed(props.item)}\nsetMouseOverMessagePosition={props.setMouseOverMessagePosition}\nmouseOverMessagePosition={props.mouseOverMessagePosition}\n- canReply={true}\n+ canReply={canReply}\n>\n<div className={messageClassName} style={messageStyle}>\n<Markdown rules={rules}>{text}</Markdown>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Check if thread has VOICED permission to show reply tooltip
Test Plan: Check if reply tooltip is not displayed in threads without voiced permission
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D575 |
129,187 | 12.01.2021 10:19:39 | 28,800 | e2371b4ddbfe0fe58c8dd6aaa52397bb540fc320 | [server] Script to add staff members
Test Plan: Run the script with my `test` user
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/add-staff.js",
"diff": "+// @flow\n+\n+import bots from 'lib/facts/bots';\n+\n+import { createScriptViewer } from '../session/scripts';\n+import { updateThread } from '../updaters/thread-updaters';\n+import { main } from './utils';\n+\n+const newStaffIDs = ['518252'];\n+\n+async function addStaff() {\n+ await updateThread(createScriptViewer(bots.squadbot.userID), {\n+ threadID: bots.squadbot.staffThreadID,\n+ changes: {\n+ newMemberIDs: newStaffIDs,\n+ },\n+ });\n+}\n+\n+main([addStaff]);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Script to add staff members
Test Plan: Run the script with my `test` user
Reviewers: atul, palys-swm
Reviewed By: atul
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D581 |
129,187 | 12.01.2021 11:15:39 | 28,800 | ee35c241672fbab2168b30d4e26cf7caf3d424f0 | [lib] Add staff.json and use it in isStaff
Summary: Now `isStaff` returns true for all four of us
Test Plan: Make sure I can still download an error report
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/facts/staff.json",
"diff": "+[\"256\",\"518252\",\"311149\",\"379341\"]\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/user-utils.js",
"new_path": "lib/shared/user-utils.js",
"diff": "// @flow\n-import ashoat from '../facts/ashoat';\nimport bots from '../facts/bots';\n+import staff from '../facts/staff';\nimport type { RelativeMemberInfo } from '../types/thread-types';\nimport type { RelativeUserInfo } from '../types/user-types';\n@@ -16,7 +16,7 @@ function stringForUser(user: RelativeUserInfo | RelativeMemberInfo): string {\n}\nfunction isStaff(userID: string) {\n- if (userID === ashoat.id) {\n+ if (staff.includes(userID)) {\nreturn true;\n}\nfor (let key in bots) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Add staff.json and use it in isStaff
Summary: Now `isStaff` returns true for all four of us
Test Plan: Make sure I can still download an error report
Reviewers: atul, palys-swm
Reviewed By: atul
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D582 |
129,187 | 12.01.2021 11:25:22 | 28,800 | d66d164ad501a5967e9fc095edd12a17684ba229 | [server] Add CreateThreadOptions type for createThread
Summary: I think this makes the code more readable at `createThread` callsites.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/bots/squadbot.js",
"new_path": "server/src/bots/squadbot.js",
"diff": "@@ -16,7 +16,9 @@ async function createSquadbotThread(userID: string): Promise<string> {\ntype: threadTypes.PERSONAL,\ninitialMemberIDs: [userID],\n};\n- const result = await createThread(squadbotViewer, newThreadRequest, true);\n+ const result = await createThread(squadbotViewer, newThreadRequest, {\n+ forceAddMembers: true,\n+ });\nconst { newThreadID } = result;\ninvariant(\nnewThreadID,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/account-creator.js",
"new_path": "server/src/creators/account-creator.js",
"diff": "@@ -115,7 +115,7 @@ async function createAccount(\nname: request.username,\ndescription: 'your personal calendar',\n},\n- true,\n+ { forceAddMembers: true },\n),\ncreateThread(\nviewer,\n@@ -123,7 +123,7 @@ async function createAccount(\ntype: threadTypes.PERSONAL,\ninitialMemberIDs: [ashoat.id],\n},\n- true,\n+ { forceAddMembers: true },\n),\n]);\nconst ashoatThreadID = ashoatThreadResult.newThreadInfo\n"
},
{
"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 {\ngenerateRandomColor,\n} from 'lib/shared/thread-utils';\nimport { hasMinCodeVersion } from 'lib/shared/version-utils';\n+import type { Shape } from 'lib/types/core';\nimport { messageTypes } from 'lib/types/message-types';\nimport { userRelationshipStatus } from 'lib/types/relationship-types';\nimport {\n@@ -36,6 +37,11 @@ import createMessages from './message-creator';\nimport { createInitialRolesForNewThread } from './role-creator';\nimport type { UpdatesForCurrentSession } from './update-creator';\n+type CreateThreadOptions = Shape<{|\n+ +forceAddMembers: boolean,\n+ +updatesForCurrentSession: UpdatesForCurrentSession,\n+|}>;\n+\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@@ -45,13 +51,16 @@ import type { UpdatesForCurrentSession } from './update-creator';\nasync function createThread(\nviewer: Viewer,\nrequest: NewThreadRequest,\n- forceAddMembers?: boolean = false,\n- updatesForCurrentSession?: UpdatesForCurrentSession = 'return',\n+ options?: CreateThreadOptions,\n): Promise<NewThreadResponse> {\nif (!viewer.loggedIn) {\nthrow new ServerError('not_logged_in');\n}\n+ const forceAddMembers = options?.forceAddMembers ?? false;\n+ const updatesForCurrentSession =\n+ options?.updatesForCurrentSession ?? 'return';\n+\nconst threadType = request.type;\nconst shouldCreateRelationships =\nforceAddMembers || threadType === threadTypes.PERSONAL;\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/relationship-updaters.js",
"new_path": "server/src/updaters/relationship-updaters.js",
"diff": "@@ -293,8 +293,7 @@ async function createPersonalThreads(\ntype: threadTypes.PERSONAL,\ninitialMemberIDs: [userID],\n},\n- true,\n- 'broadcast',\n+ { forceAddMembers: true, updatesForCurrentSession: 'broadcast' },\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Add CreateThreadOptions type for createThread
Summary: I think this makes the code more readable at `createThread` callsites.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: atul
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D583 |
129,187 | 12.01.2021 15:43:08 | 28,800 | 48e6c28f548f4c041db40c3f9fb0f7e114e76700 | [native] Update default server URLs to use comm instead of squadcal
Summary: This fixes the `dev_environment.md` setup instructions.
Test Plan: Make sure that everything works on `http://localhost/comm/` after I update `server/facts/url.json` and `/private/etc/apache2/users/$USER.conf`
Reviewers: atul, subnub, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/utils/url-utils.js",
"new_path": "native/utils/url-utils.js",
"diff": "@@ -4,9 +4,9 @@ import invariant from 'invariant';\nimport { Platform } from 'react-native';\nconst productionServer = 'https://squadcal.org';\n-const localhostServer = 'http://localhost/squadcal';\n-const localhostServerFromAndroidEmulator = 'http://10.0.2.2/squadcal';\n-const natServer = 'http://192.168.1.4/squadcal';\n+const localhostServer = 'http://localhost/comm';\n+const localhostServerFromAndroidEmulator = 'http://10.0.2.2/comm';\n+const natServer = 'http://192.168.1.4/comm';\nfunction defaultURLPrefix() {\nif (!__DEV__) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Update default server URLs to use comm instead of squadcal
Summary: This fixes the `dev_environment.md` setup instructions.
Test Plan: Make sure that everything works on `http://localhost/comm/` after I update `server/facts/url.json` and `/private/etc/apache2/users/$USER.conf`
Reviewers: atul, subnub, palys-swm
Reviewed By: atul
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D584 |
129,184 | 12.01.2021 19:42:26 | 28,800 | f638da040f1a7bf45b840aba30a7f0ca0ab1fde9 | .flowconfig M1 hack
Summary: Hack to get flow to run on Apple M1 Macs. Details:
Test Plan: NA
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/.flowconfig",
"new_path": "lib/.flowconfig",
"diff": "[libs]\n[options]\n+sharedmemory.heap_size=3221225472\nesproposal.optional_chaining=enable\nesproposal.nullish_coalescing=enable\n"
},
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": "../node_modules/react-native/flow/\n[options]\n+sharedmemory.heap_size=3221225472\nemoji=true\nesproposal.optional_chaining=enable\n"
},
{
"change_type": "MODIFY",
"old_path": "server/.flowconfig",
"new_path": "server/.flowconfig",
"diff": "../lib/flow-typed\n[options]\n+sharedmemory.heap_size=3221225472\nmodule.file_ext=.js\nmodule.file_ext=.cjs\nmodule.file_ext=.json\n"
},
{
"change_type": "MODIFY",
"old_path": "web/.flowconfig",
"new_path": "web/.flowconfig",
"diff": "../lib/flow-typed\n[options]\n+sharedmemory.heap_size=3221225472\nmodule.name_mapper.extension='css' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'\nesproposal.optional_chaining=enable\nesproposal.nullish_coalescing=enable\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | .flowconfig M1 hack
Summary: Hack to get flow to run on Apple M1 Macs. Details: https://github.com/facebook/flow/issues/8538
Test Plan: NA
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub
Differential Revision: https://phabricator.ashoat.com/D588 |
129,184 | 12.01.2021 15:54:33 | 28,800 | ecfb48f1d12d836ebd51eb8e93018494a676a456 | added forceAddMembers option to updateThread() to support addStaff() script
Test Plan: Created test account, ran script, and verified account joined staff thread.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/add-staff.js",
"new_path": "server/src/scripts/add-staff.js",
"diff": "@@ -9,12 +9,18 @@ import { main } from './utils';\nconst newStaffIDs = ['518252'];\nasync function addStaff() {\n- await updateThread(createScriptViewer(bots.squadbot.userID), {\n+ await updateThread(\n+ createScriptViewer(bots.squadbot.userID),\n+ {\nthreadID: bots.squadbot.staffThreadID,\nchanges: {\nnewMemberIDs: newStaffIDs,\n},\n- });\n+ },\n+ {\n+ forceAddMembers: true,\n+ },\n+ );\n}\nmain([addStaff]);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-updaters.js",
"new_path": "server/src/updaters/thread-updaters.js",
"diff": "@@ -9,6 +9,7 @@ import {\nviewerIsMember,\n} from 'lib/shared/thread-utils';\nimport { hasMinCodeVersion } from 'lib/shared/version-utils';\n+import type { Shape } from 'lib/types/core';\nimport { messageTypes, defaultNumberPerThread } from 'lib/types/message-types';\nimport { userRelationshipStatus } from 'lib/types/relationship-types';\nimport {\n@@ -288,14 +289,19 @@ async function leaveThread(\n};\n}\n+type UpdateThreadOptions = Shape<{|\n+ +forceAddMembers: boolean,\n+|}>;\n+\nasync function updateThread(\nviewer: Viewer,\nrequest: UpdateThreadRequest,\n+ options?: UpdateThreadOptions,\n): Promise<ChangeThreadSettingsResult> {\nif (!viewer.loggedIn) {\nthrow new ServerError('not_logged_in');\n}\n-\n+ const forceAddMembers = options?.forceAddMembers ?? false;\nconst validationPromises = {};\nconst changedFields = {};\n@@ -461,9 +467,16 @@ async function updateThread(\nif (fetchNewMembers) {\ninvariant(newMemberIDs, 'should be set');\n- for (const newMemberID of newMemberIDs) {\n+ const newIDs = newMemberIDs; // for Flow\n+ for (const newMemberID of newIDs) {\nif (!fetchNewMembers[newMemberID]) {\n+ if (!forceAddMembers) {\nthrow new ServerError('invalid_credentials');\n+ } else if (nextThreadType === threadTypes.SIDEBAR) {\n+ throw new ServerError('invalid_thread_type');\n+ } else {\n+ continue;\n+ }\n}\nconst { relationshipStatus } = fetchNewMembers[newMemberID];\nif (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | added forceAddMembers option to updateThread() to support addStaff() script
Test Plan: Created test account, ran script, and verified account joined staff thread.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D585 |
129,184 | 12.01.2021 17:14:47 | 28,800 | f4b2795a15f59f2ed9f79e3e3691e73dae37c293 | imagePasted event emitter
Summary: textInputImagePasted() sends event with pasted image's file path to JS side
Test Plan: Successfully receiving events on JS side.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian | [
{
"change_type": "MODIFY",
"old_path": "patches/react-native+0.63.4.patch",
"new_path": "patches/react-native+0.63.4.patch",
"diff": "@@ -11,3 +11,65 @@ index 5dc03df..e526092 100644\n? (background, useForeground) =>\nuseForeground && TouchableNativeFeedback.canUseNativeForeground()\n? {nativeForegroundAndroid: background}\n+diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h\n+index 3e1839b..2df81fb 100644\n+--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h\n++++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h\n+@@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN\n+ - (void)textInputDidChange;\n+\n+ - (void)textInputDidChangeSelection;\n++- (void)textInputImagePasted;\n+\n+ @optional\n+\n+diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m\n+index aa69593..8366cf2 100644\n+--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m\n++++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m\n+@@ -19,6 +19,8 @@\n+ #import <React/RCTTextAttributes.h>\n+ #import <React/RCTTextSelection.h>\n+\n++#import <MobileCoreServices/MobileCoreServices.h>\n++\n+ @implementation RCTBaseTextInputView {\n+ __weak RCTBridge *_bridge;\n+ __weak RCTEventDispatcher *_eventDispatcher;\n+@@ -479,6 +481,36 @@ - (void)textInputDidChangeSelection\n+ });\n+ }\n+\n++- (void)textInputImagePasted\n++{\n++ NSFileManager *fileManager = [NSFileManager defaultManager];\n++ UIPasteboard *clipboard = [UIPasteboard generalPasteboard];\n++ NSData *imageData = [clipboard dataForPasteboardType:(NSString*)kUTTypeImage];\n++\n++ if (!imageData) {\n++ RCTLog(@\"Failed to get image from UIPasteboard.\");\n++ return;\n++ }\n++\n++ NSString *fileName = [@([imageData hash]) stringValue];\n++ NSString *fileDest = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];\n++\n++ if (![fileManager fileExistsAtPath:fileDest]) {\n++ BOOL fileWritten = [imageData writeToFile:fileDest atomically:true];\n++ if (!fileWritten) {\n++ RCTLog(@\"Failed to save image to temporary directory.\");\n++ return;\n++ }\n++ }\n++\n++ NSDictionary *eventBody = @{\n++ @\"fileName\": fileName,\n++ @\"filePath\": fileDest,\n++ };\n++\n++ [_eventDispatcher sendAppEventWithName:@\"imagePasted\" body:eventBody];\n++}\n++\n+ - (void)updateLocalData\n+ {\n+ [self enforceTextAttributesIfNeeded];\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | imagePasted event emitter
Summary: textInputImagePasted() sends event with pasted image's file path to JS side
Test Plan: Successfully receiving events on JS side.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian
Differential Revision: https://phabricator.ashoat.com/D586 |
129,187 | 13.01.2021 10:00:22 | 28,800 | c0cd09ee6bab8fc368fce9ebe60c6fc6601ccedc | [server] Script to add source message column to threads table
Test Plan: I ran it in my local environment
Reviewers: palys-swm, KatPo
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/add-source-message-column.js",
"diff": "+// @flow\n+\n+import { dbQuery, SQL } from '../database/database';\n+import { main } from './utils';\n+\n+async function deleteUnreadColumn() {\n+ await dbQuery(SQL`\n+ ALTER TABLE threads\n+ ADD source_message BIGINT(20) NULL DEFAULT NULL AFTER color\n+ `);\n+}\n+\n+main([deleteUnreadColumn]);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Script to add source message column to threads table
Test Plan: I ran it in my local environment
Reviewers: palys-swm, KatPo
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D592 |
129,187 | 13.01.2021 11:13:33 | 28,800 | b91aeadf0e1e0897d0a7464a717e0b7a9925ea12 | [server] Rename initialMessageID to sourceMessageID
Summary: I noticed this was named differently, so just renaming it for consistency.
Test Plan: Flow
Reviewers: KatPo, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -334,7 +334,7 @@ export type NewThreadRequest =\n|}\n| {|\n+type: 5,\n- +initialMessageID: string,\n+ +sourceMessageID: string,\n...BaseNewThreadRequest,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/thread-responders.js",
"new_path": "server/src/responders/thread-responders.js",
"diff": "@@ -131,7 +131,7 @@ const threadRequestValidationShape = {\nconst newThreadRequestInputValidator = t.union([\ntShape({\ntype: tNumEnum([threadTypes.SIDEBAR]),\n- initialMessageID: t.String,\n+ sourceMessageID: t.String,\n...threadRequestValidationShape,\n}),\ntShape({\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/thread-responders.test.js",
"new_path": "server/src/responders/thread-responders.test.js",
"diff": "@@ -15,10 +15,10 @@ describe('Thread responders', () => {\n};\nconst requestWithMessageID = {\n...requestWithoutMessageID,\n- initialMessageID: 'messageID',\n+ sourceMessageID: 'messageID',\n};\n- it('Should require initialMessageID of a sidebar', () => {\n+ it('Should require sourceMessageID of a sidebar', () => {\nexpect(\nnewThreadRequestInputValidator.is({\ntype: threadTypes.SIDEBAR,\n@@ -34,7 +34,7 @@ describe('Thread responders', () => {\n).toBe(true);\n});\n- it('Should not require initialMessageID of not a sidebar', () => {\n+ it('Should not require sourceMessageID of not a sidebar', () => {\nexpect(\nnewThreadRequestInputValidator.is({\ntype: threadTypes.CHAT_SECRET,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Rename initialMessageID to sourceMessageID
Summary: I noticed this was named differently, so just renaming it for consistency.
Test Plan: Flow
Reviewers: KatPo, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D594 |
129,187 | 13.01.2021 14:19:08 | 28,800 | 898c61e4816fc80cc3e9114e324c9adec6c36f61 | [server] Fix isSubthreadMember check in postMessageSend
Summary: Oops! We missed this spot when we introduced -1 as a possible value for the `role` column of `memberships`.
Test Plan: log the value on my server (very hard to test notifs locally)
Reviewers: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "server/src/creators/message-creator.js",
"new_path": "server/src/creators/message-creator.js",
"diff": "@@ -288,7 +288,7 @@ async function postMessageSend(\n// Subthread info will be the same for each subthread, so we only parse\n// it once\nfor (const subthread of subthreadPermissionsToCheck) {\n- const isSubthreadMember = !!row[`subthread${subthread}_role`];\n+ const isSubthreadMember = row[`subthread${subthread}_role`] > 0;\nconst permissions = row[`subthread${subthread}_permissions`];\nconst canSeeSubthread = permissionLookup(\npermissions,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Fix isSubthreadMember check in postMessageSend
Summary: Oops! We missed this spot when we introduced -1 as a possible value for the `role` column of `memberships`.
Test Plan: log the value on my server (very hard to test notifs locally)
Reviewers: palys-swm
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D596 |
129,187 | 13.01.2021 14:46:52 | 28,800 | 4cb6a710594e48d91657f8b5edc718bac967fc5e | [lib] Use 'sidebar' in notif text
Test Plan: Flow
Reviewers: palys-swm, KatPo
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/notif-utils.js",
"new_path": "lib/shared/notif-utils.js",
"diff": "@@ -10,13 +10,13 @@ import {\ntype MessageType,\nmessageTypes,\n} from '../types/message-types';\n-import type { ThreadInfo } from '../types/thread-types';\n+import type { ThreadInfo, ThreadType } from '../types/thread-types';\nimport type { RelativeUserInfo } from '../types/user-types';\nimport { prettyDate } from '../utils/date-utils';\nimport { values } from '../utils/objects';\nimport { pluralize } from '../utils/text-utils';\nimport { robotextForMessageInfo, robotextToRawString } from './message-utils';\n-import { threadIsGroupChat } from './thread-utils';\n+import { threadIsGroupChat, threadNoun } from './thread-utils';\nimport { stringForUser } from './user-utils';\ntype NotifTexts = {|\n@@ -50,12 +50,13 @@ function trimNotifText(text: string, maxLength: number): string {\nconst notifTextForSubthreadCreation = (\ncreator: RelativeUserInfo,\n+ threadType: ThreadType,\nparentThreadInfo: ThreadInfo,\nchildThreadName: ?string,\nchildThreadUIName: string,\n) => {\nconst prefix = stringForUser(creator);\n- let body = `created a new thread`;\n+ let body = `created a new ${threadNoun(threadType)}`;\nif (parentThreadInfo.name) {\nbody += ` in ${parentThreadInfo.name}`;\n}\n@@ -140,6 +141,7 @@ function fullNotifTextsForMessageInfo(\nif (parentThreadInfo) {\nreturn notifTextForSubthreadCreation(\nmessageInfo.creator,\n+ messageInfo.initialThreadState.type,\nparentThreadInfo,\nmessageInfo.initialThreadState.name,\nthreadInfo.uiName,\n@@ -195,6 +197,7 @@ function fullNotifTextsForMessageInfo(\n);\nreturn notifTextForSubthreadCreation(\nmessageInfo.creator,\n+ messageInfo.childThreadInfo.type,\nthreadInfo,\nmessageInfo.childThreadInfo.name,\nmessageInfo.childThreadInfo.uiName,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -641,6 +641,10 @@ const threadSearchText = (\nreturn searchTextArray.join(' ');\n};\n+function threadNoun(threadType: ThreadType) {\n+ return threadType === threadTypes.SIDEBAR ? 'sidebar' : 'thread';\n+}\n+\nexport {\ncolorIsDark,\ngenerateRandomColor,\n@@ -681,4 +685,5 @@ export {\npermissionsDisabledByBlock,\nemptyItemText,\nthreadSearchText,\n+ threadNoun,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use 'sidebar' in notif text
Test Plan: Flow
Reviewers: palys-swm, KatPo
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D597 |
129,187 | 13.01.2021 15:26:11 | 28,800 | 34a8148fdd0996a5a51ee215e50dcc1f99b34e7b | [lib] Fix robotext for CREATE_SUB_THREAD to handle sidebar
Summary: We use the string 'sidebar' instead of 'child thread' now. D573 handled `CREATE_THREAD` and `CREATE_SIDEBAR`, but not `CREATE_SUB_THREAD`.
Test Plan: Flow
Reviewers: palys-swm, KatPo
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -28,7 +28,7 @@ import {\nmessageTypes,\nmessageTruncationStatus,\n} from '../types/message-types';\n-import type { ThreadInfo } from '../types/thread-types';\n+import { type ThreadInfo, threadTypes } from '../types/thread-types';\nimport type { RelativeUserInfo, UserInfos } from '../types/user-types';\nimport { prettyDate } from '../utils/date-utils';\nimport { codeBlockRegex } from './markdown';\n@@ -119,15 +119,19 @@ function robotextForMessageInfo(\nreturn `${creator} added ${addedUsersString}`;\n} else if (messageInfo.type === messageTypes.CREATE_SUB_THREAD) {\nconst childName = messageInfo.childThreadInfo.name;\n+ const childNoun =\n+ messageInfo.childThreadInfo.type === threadTypes.SIDEBAR\n+ ? 'sidebar'\n+ : 'child thread';\nif (childName) {\nreturn (\n- `${creator} created a child thread` +\n+ `${creator} created a ${childNoun}` +\n` named \"<${encodeURI(childName)}|t${messageInfo.childThreadInfo.id}>\"`\n);\n} else {\nreturn (\n`${creator} created a ` +\n- `<child thread|t${messageInfo.childThreadInfo.id}>`\n+ `<${childNoun}|t${messageInfo.childThreadInfo.id}>`\n);\n}\n} else if (messageInfo.type === messageTypes.CHANGE_SETTINGS) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Fix robotext for CREATE_SUB_THREAD to handle sidebar
Summary: We use the string 'sidebar' instead of 'child thread' now. D573 handled `CREATE_THREAD` and `CREATE_SIDEBAR`, but not `CREATE_SUB_THREAD`.
Test Plan: Flow
Reviewers: palys-swm, KatPo
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D598 |
129,184 | 13.01.2021 16:56:21 | 28,800 | de1dc5dca7b9ed96f428b0e1a9ff3a2627527b64 | Types and additions to support photo_pasted
Test Plan: NA
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/types/media-types.js",
"new_path": "lib/types/media-types.js",
"diff": "@@ -270,7 +270,30 @@ export type PhotoCapture = {|\nretries: number,\n|};\n-export type NativeMediaSelection = MediaLibrarySelection | PhotoCapture;\n+export type PhotoPaste = {|\n+ +step: 'photo_paste',\n+ +dimensions: Dimensions,\n+ +filename: string,\n+ +uri: string,\n+ +selectTime: number, // ms timestamp\n+ +sendTime: number, // ms timestamp\n+ +retries: number,\n+|};\n+\n+const photoPasteSelectionPropType = PropTypes.exact({\n+ step: PropTypes.oneOf(['photo_paste']).isRequired,\n+ dimensions: dimensionsPropType.isRequired,\n+ filename: PropTypes.string.isRequired,\n+ uri: PropTypes.string.isRequired,\n+ selectTime: PropTypes.number.isRequired,\n+ sendTime: PropTypes.number.isRequired,\n+ retries: PropTypes.number.isRequired,\n+});\n+\n+export type NativeMediaSelection =\n+ | MediaLibrarySelection\n+ | PhotoCapture\n+ | PhotoPaste;\nexport type MediaMissionStep =\n| NativeMediaSelection\n@@ -545,6 +568,7 @@ export type MediaMission = {|\nexport const mediaMissionStepPropType = PropTypes.oneOfType([\nphotoLibrarySelectionPropType,\nvideoLibrarySelectionPropType,\n+ photoPasteSelectionPropType,\nPropTypes.shape({\nstep: PropTypes.oneOf(['photo_capture']).isRequired,\ntime: PropTypes.number.isRequired,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/input/input-state-container.react.js",
"new_path": "native/input/input-state-container.react.js",
"diff": "@@ -417,6 +417,14 @@ class InputStateContainer extends React.PureComponent<Props, State> {\ndimensions: selection.dimensions,\nlocalMediaSelection: selection,\n};\n+ } else if (selection.step === 'photo_paste') {\n+ return {\n+ id: localID,\n+ uri: selection.uri,\n+ type: 'photo',\n+ dimensions: selection.dimensions,\n+ localMediaSelection: selection,\n+ };\n} else if (selection.step === 'video_library') {\nreturn {\nid: localID,\n@@ -878,6 +886,8 @@ class InputStateContainer extends React.PureComponent<Props, State> {\nselection = { ...oldSelection, sendTime: now, retries };\n} else if (oldSelection.step === 'photo_library') {\nselection = { ...oldSelection, sendTime: now, retries };\n+ } else if (oldSelection.step === 'photo_paste') {\n+ selection = { ...oldSelection, sendTime: now, retries };\n} else {\nselection = { ...oldSelection, sendTime: now, retries };\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Types and additions to support photo_pasted
Test Plan: NA
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub
Differential Revision: https://phabricator.ashoat.com/D599 |
129,184 | 14.01.2021 10:04:17 | 28,800 | cfeff0069315e882d9c6fa275081efa248828b98 | Getting image dimensions from objc side
Summary: Getting image height and width from UIImage and sending it over in event. Also, adding allowImagePaste prop in TextInput.js
Test Plan: NA
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub | [
{
"change_type": "MODIFY",
"old_path": "patches/react-native+0.63.4.patch",
"new_path": "patches/react-native+0.63.4.patch",
"diff": "+diff --git a/node_modules/react-native/Libraries/Components/TextInput/TextInput.js b/node_modules/react-native/Libraries/Components/TextInput/TextInput.js\n+index b124944..ca0884a 100644\n+--- a/node_modules/react-native/Libraries/Components/TextInput/TextInput.js\n++++ b/node_modules/react-native/Libraries/Components/TextInput/TextInput.js\n+@@ -207,6 +207,13 @@ export type TextContentType =\n+ type PasswordRules = string;\n+\n+ type IOSProps = $ReadOnly<{|\n++ /**\n++ * If `true`, allows pasting of images.\n++ * The default value is false.\n++ * @platform ios\n++ */\n++ allowImagePaste?: ?boolean,\n++\n+ /**\n+ * If `false`, disables spell-check style (i.e. red underlines).\n+ * The default value is inherited from `autoCorrect`.\ndiff --git a/node_modules/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js b/node_modules/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js\nindex 5dc03df..e526092 100644\n--- a/node_modules/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js\n@@ -60,7 +78,7 @@ index 3e1839b..2df81fb 100644\n@optional\ndiff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m\n-index aa69593..8366cf2 100644\n+index aa69593..007c6b0 100644\n--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m\n+++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m\n@@ -72,7 +90,7 @@ index aa69593..8366cf2 100644\n@implementation RCTBaseTextInputView {\n__weak RCTBridge *_bridge;\n__weak RCTEventDispatcher *_eventDispatcher;\n-@@ -479,6 +481,36 @@ - (void)textInputDidChangeSelection\n+@@ -479,6 +481,39 @@ - (void)textInputDidChangeSelection\n});\n}\n@@ -81,6 +99,7 @@ index aa69593..8366cf2 100644\n+ NSFileManager *fileManager = [NSFileManager defaultManager];\n+ UIPasteboard *clipboard = [UIPasteboard generalPasteboard];\n+ NSData *imageData = [clipboard dataForPasteboardType:(NSString*)kUTTypeImage];\n++ UIImage *uiImage = [UIImage imageWithData:imageData];\n+\n+ if (!imageData) {\n+ RCTLog(@\"Failed to get image from UIPasteboard.\");\n@@ -101,6 +120,8 @@ index aa69593..8366cf2 100644\n+ NSDictionary *eventBody = @{\n+ @\"fileName\": fileName,\n+ @\"filePath\": fileDest,\n++ @\"height\": @(uiImage.size.height),\n++ @\"width\": @(uiImage.size.width),\n+ };\n+\n+ [_eventDispatcher sendAppEventWithName:@\"imagePasted\" body:eventBody];\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Getting image dimensions from objc side
Summary: Getting image height and width from UIImage and sending it over in event. Also, adding allowImagePaste prop in TextInput.js
Test Plan: NA
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub
Differential Revision: https://phabricator.ashoat.com/D608 |
129,183 | 14.01.2021 09:54:18 | -3,600 | e457238328747202534a1bf6501081072408e136 | [server] Convert source_message to string
Summary: ThreadInfo expects sourceMessageID to be a string
Test Plan: Checked if warnings are gone
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/thread-fetchers.js",
"new_path": "server/src/fetchers/thread-fetchers.js",
"diff": "@@ -53,7 +53,7 @@ async function fetchServerThreadInfos(\n: null,\nmembers: [],\nroles: {},\n- sourceMessageID: row.source_message,\n+ sourceMessageID: row.source_message?.toString(),\n};\n}\nconst role = row.role.toString();\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Convert source_message to string
Summary: ThreadInfo expects sourceMessageID to be a string
Test Plan: Checked if warnings are gone
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D600 |
129,187 | 14.01.2021 18:01:03 | 28,800 | 56d525d49034ced5a69b37d91215fcb65bccff4b | [lib] Include sourceMessageID in rawThreadInfoFromThreadInfo
Summary: We don't actually use this function anywhere... but if it's in our codebase, it should work correctly, in case somebody does eventually use it for something.
Test Plan: careful inspection :)
Reviewers: palys-swm, KatPo
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -507,7 +507,7 @@ function threadFrozenDueToViewerBlock(\n}\nfunction rawThreadInfoFromThreadInfo(threadInfo: ThreadInfo): RawThreadInfo {\n- return {\n+ const rawThreadInfo: RawThreadInfo = {\nid: threadInfo.id,\ntype: threadInfo.type,\nname: threadInfo.name,\n@@ -519,6 +519,11 @@ function rawThreadInfoFromThreadInfo(threadInfo: ThreadInfo): RawThreadInfo {\nroles: threadInfo.roles,\ncurrentUser: threadInfo.currentUser,\n};\n+ const { sourceMessageID } = threadInfo;\n+ if (sourceMessageID) {\n+ rawThreadInfo.sourceMessageID = sourceMessageID;\n+ }\n+ return rawThreadInfo;\n}\nconst threadTypeDescriptions = {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Include sourceMessageID in rawThreadInfoFromThreadInfo
Summary: We don't actually use this function anywhere... but if it's in our codebase, it should work correctly, in case somebody does eventually use it for something.
Test Plan: careful inspection :)
Reviewers: palys-swm, KatPo
Reviewed By: KatPo
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D611 |
129,191 | 11.01.2021 14:58:14 | -3,600 | 5da446f924b67fae83247f27c3cabf67e9a0a488 | [lib] Support other initial message types
Summary: All the types but SIDEBAR_SOURCE are supported
Test Plan: Created a new SIDEBAR SOURCE message in db, pointing to an image message. Verified that it was displayed correctly.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -544,8 +544,8 @@ function createMessageInfo(\nthreadInfos,\n);\ninvariant(\n- initialMessage && initialMessage.type === messageTypes.TEXT,\n- 'Sidebars can be created only from text messages',\n+ initialMessage && initialMessage.type !== messageTypes.SIDEBAR_SOURCE,\n+ 'Sidebars can not be created from SIDEBAR SOURCE',\n);\nreturn {\ntype: messageTypes.SIDEBAR_SOURCE,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/notif-utils.js",
"new_path": "lib/shared/notif-utils.js",
"diff": "@@ -448,23 +448,8 @@ function fullNotifTextsForMessageInfo(\nmessageInfo.type === messageTypes.SIDEBAR_SOURCE,\n'messageInfo should be messageTypes.SIDEBAR_SOURCE!',\n);\n- const textMessageInfo = messageInfo.initialMessage;\n- if (!textMessageInfo.name && !threadIsGroupChat(textMessageInfo)) {\n- return {\n- merged: `${threadInfo.uiName}: ${textMessageInfo.text}`,\n- body: textMessageInfo.text,\n- title: threadInfo.uiName,\n- };\n- } else {\n- const userString = stringForUser(textMessageInfo.creator);\n- const threadName = notifThreadName(threadInfo);\n- return {\n- merged: `${userString} to ${threadName}: ${textMessageInfo.text}`,\n- body: textMessageInfo.text,\n- title: threadInfo.uiName,\n- prefix: `${userString}:`,\n- };\n- }\n+ const initialMessageInfo = messageInfo.initialMessage;\n+ return fullNotifTextsForMessageInfo([initialMessageInfo], threadInfo);\n} else if (mostRecentType === messageTypes.CREATE_SIDEBAR) {\nconst messageInfo = assertSingleMessageInfo(messageInfos);\ninvariant(\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/message-types.js",
"new_path": "lib/types/message-types.js",
"diff": "@@ -251,7 +251,7 @@ export type SidebarSourceMessageData = {|\n+threadID: string,\n+creatorID: string,\n+time: number,\n- +initialMessage: RawTextMessageInfo,\n+ +initialMessage: RawComposableMessageInfo | RawRobotextMessageInfo,\n|};\nexport type CreateSidebarMessageData = {|\n+type: 18,\n@@ -568,7 +568,7 @@ export type SidebarSourceMessageInfo = {|\n+threadID: string,\n+creator: RelativeUserInfo,\n+time: number,\n- +initialMessage: TextMessageInfo,\n+ +initialMessage: ComposableMessageInfo | RobotextMessageInfo,\n|};\nexport type MessageInfo =\n@@ -576,7 +576,8 @@ export type MessageInfo =\n| RobotextMessageInfo\n| SidebarSourceMessageInfo;\n-export const textMessagePropType = PropTypes.shape({\n+const messageInfoPropTypes = [\n+ PropTypes.shape({\ntype: PropTypes.oneOf([messageTypes.TEXT]).isRequired,\nid: PropTypes.string,\nlocalID: PropTypes.string,\n@@ -584,10 +585,7 @@ export const textMessagePropType = PropTypes.shape({\ncreator: relativeUserInfoPropType.isRequired,\ntime: PropTypes.number.isRequired,\ntext: PropTypes.string.isRequired,\n-});\n-\n-export const messageInfoPropType = PropTypes.oneOfType([\n- textMessagePropType,\n+ }),\nPropTypes.shape({\ntype: PropTypes.oneOf([messageTypes.CREATE_THREAD]).isRequired,\nid: PropTypes.string.isRequired,\n@@ -734,14 +732,6 @@ export const messageInfoPropType = PropTypes.oneOfType([\ntime: PropTypes.number.isRequired,\noperation: PropTypes.oneOf(['request_sent', 'request_accepted']),\n}),\n- PropTypes.exact({\n- type: PropTypes.oneOf([messageTypes.SIDEBAR_SOURCE]).isRequired,\n- id: PropTypes.string.isRequired,\n- threadID: PropTypes.string.isRequired,\n- creator: relativeUserInfoPropType.isRequired,\n- time: PropTypes.number.isRequired,\n- initialMessage: textMessagePropType.isRequired,\n- }),\nPropTypes.exact({\ntype: PropTypes.oneOf([messageTypes.CREATE_SIDEBAR]).isRequired,\nid: PropTypes.string.isRequired,\n@@ -755,6 +745,18 @@ export const messageInfoPropType = PropTypes.oneOfType([\notherMembers: PropTypes.arrayOf(relativeUserInfoPropType).isRequired,\n}).isRequired,\n}),\n+];\n+\n+export const messageInfoPropType = PropTypes.oneOfType([\n+ ...messageInfoPropTypes,\n+ PropTypes.exact({\n+ type: PropTypes.oneOf([messageTypes.SIDEBAR_SOURCE]).isRequired,\n+ id: PropTypes.string.isRequired,\n+ threadID: PropTypes.string.isRequired,\n+ creator: relativeUserInfoPropType.isRequired,\n+ time: PropTypes.number.isRequired,\n+ initialMessage: PropTypes.oneOfType(messageInfoPropTypes).isRequired,\n+ }),\n]);\nexport type ThreadMessageInfo = {|\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Support other initial message types
Summary: All the types but SIDEBAR_SOURCE are supported
Test Plan: Created a new SIDEBAR SOURCE message in db, pointing to an image message. Verified that it was displayed correctly.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D577 |
129,191 | 12.01.2021 16:18:35 | -3,600 | ba14dafee9c9d15aac8ef22eceaff1fd8d9e3226 | [server] Fetch all the initial messages in one query
Test Plan: Verify that sidebar source messages cause only one additional query
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/message-fetchers.js",
"new_path": "server/src/fetchers/message-fetchers.js",
"diff": "@@ -121,8 +121,9 @@ async function fetchCollapsableNotifs(\n}\n}\n+ const derivedMessages = await fetchDerivedMessages(collapseResult);\nfor (const userRows of rowsByUser.values()) {\n- const messages = await parseMessageSQLResult(userRows);\n+ const messages = parseMessageSQLResult(userRows, derivedMessages);\nfor (const message of messages) {\nconst { rawMessageInfo, rows } = message;\nconst [row] = rows;\n@@ -150,10 +151,11 @@ type MessageSQLResult = $ReadOnlyArray<{|\nrawMessageInfo: RawMessageInfo,\nrows: $ReadOnlyArray<Object>,\n|}>;\n-async function parseMessageSQLResult(\n+function parseMessageSQLResult(\nrows: $ReadOnlyArray<Object>,\n+ derivedMessages: $ReadOnlyMap<string, RawMessageInfo>,\nviewer?: Viewer,\n-): Promise<MessageSQLResult> {\n+): MessageSQLResult {\nconst rowsByID = new Map();\nfor (let row of rows) {\nconst id = row.id.toString();\n@@ -167,7 +169,11 @@ async function parseMessageSQLResult(\nconst messages = [];\nfor (let messageRows of rowsByID.values()) {\n- const rawMessageInfo = await rawMessageInfoFromRows(messageRows, viewer);\n+ const rawMessageInfo = rawMessageInfoFromRows(\n+ messageRows,\n+ viewer,\n+ derivedMessages,\n+ );\nif (rawMessageInfo) {\nmessages.push({ rawMessageInfo, rows: messageRows });\n}\n@@ -195,10 +201,11 @@ function mostRecentRowType(rows: $ReadOnlyArray<Object>): MessageType {\nreturn assertMessageType(rows[0].type);\n}\n-async function rawMessageInfoFromRows(\n+function rawMessageInfoFromRows(\nrows: $ReadOnlyArray<Object>,\n- viewer?: ?Viewer,\n-): Promise<?RawMessageInfo> {\n+ viewer?: Viewer,\n+ derivedMessages: $ReadOnlyMap<string, RawMessageInfo>,\n+): ?RawMessageInfo {\nconst type = mostRecentRowType(rows);\nif (type === messageTypes.TEXT) {\nconst row = assertSingleRow(rows);\n@@ -380,10 +387,7 @@ async function rawMessageInfoFromRows(\n} else if (type === messageTypes.SIDEBAR_SOURCE) {\nconst row = assertSingleRow(rows);\nconst content = JSON.parse(row.content);\n- const initialMessage = await fetchMessageInfoByID(\n- viewer,\n- content.initialMessageID,\n- );\n+ const initialMessage = derivedMessages.get(content.initialMessageID);\nreturn {\ntype: messageTypes.SIDEBAR_SOURCE,\nid: row.id.toString(),\n@@ -454,8 +458,8 @@ async function fetchMessageInfos(\nWHERE y.number <= ${numberPerThread}\n`);\nconst [result] = await dbQuery(query);\n-\n- const messages = await parseMessageSQLResult(result, viewer);\n+ const derivedMessages = await fetchDerivedMessages(result, viewer);\n+ const messages = parseMessageSQLResult(result, derivedMessages, viewer);\nconst rawMessageInfos = [];\nconst threadToMessageCount = new Map();\n@@ -584,8 +588,8 @@ async function fetchMessageInfosSince(\nORDER BY m.thread, m.time DESC\n`);\nconst [result] = await dbQuery(query);\n-\n- const messages = await parseMessageSQLResult(result, viewer);\n+ const derivedMessages = await fetchDerivedMessages(result, viewer);\n+ const messages = parseMessageSQLResult(result, derivedMessages, viewer);\nconst rawMessageInfos = [];\nlet currentThreadID = null;\n@@ -674,7 +678,8 @@ async function fetchMessageInfoForLocalID(\nif (result.length === 0) {\nreturn null;\n}\n- return rawMessageInfoFromRows(result, viewer);\n+ const derivedMessages = await fetchDerivedMessages(result, viewer);\n+ return rawMessageInfoFromRows(result, viewer, derivedMessages);\n}\nconst entryIDExtractString = '$.entryID';\n@@ -704,13 +709,11 @@ async function fetchMessageInfoForEntryAction(\nif (result.length === 0) {\nreturn null;\n}\n- return rawMessageInfoFromRows(result, viewer);\n+ const derivedMessages = await fetchDerivedMessages(result, viewer);\n+ return rawMessageInfoFromRows(result, viewer, derivedMessages);\n}\n-async function fetchMessageInfoByID(\n- viewer?: ?Viewer,\n- messageID: string,\n-): Promise<?RawMessageInfo> {\n+async function fetchMessageRowsByIDs(messageIDs: $ReadOnlyArray<string>) {\nconst query = SQL`\nSELECT m.id, m.thread AS threadID, m.content, m.time, m.type, m.creation,\nm.user AS creatorID, up.id AS uploadID, up.type AS uploadType,\n@@ -719,14 +722,51 @@ async function fetchMessageInfoByID(\nLEFT JOIN uploads up\nON m.type IN (${[messageTypes.IMAGES, messageTypes.MULTIMEDIA]})\nAND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\n- WHERE m.id = ${messageID}\n+ WHERE m.id IN (${messageIDs})\n`;\n-\nconst [result] = await dbQuery(query);\n+ return result;\n+}\n+\n+async function fetchDerivedMessages(\n+ rows: $ReadOnlyArray<Object>,\n+ viewer?: Viewer,\n+): Promise<$ReadOnlyMap<string, RawMessageInfo>> {\n+ const requiredIDs = new Set<string>();\n+ for (const row of rows) {\n+ if (row.type === messageTypes.SIDEBAR_SOURCE) {\n+ const content = JSON.parse(row.content);\n+ requiredIDs.add(content.initialMessageID);\n+ }\n+ }\n+\n+ const messagesByID = new Map<string, RawMessageInfo>();\n+ if (requiredIDs.size === 0) {\n+ return messagesByID;\n+ }\n+\n+ const result = await fetchMessageRowsByIDs([...requiredIDs]);\n+ const messages = parseMessageSQLResult(result, new Map(), viewer);\n+\n+ for (const message of messages) {\n+ const { rawMessageInfo } = message;\n+ if (rawMessageInfo.id) {\n+ messagesByID.set(rawMessageInfo.id, rawMessageInfo);\n+ }\n+ }\n+ return messagesByID;\n+}\n+\n+async function fetchMessageInfoByID(\n+ viewer?: Viewer,\n+ messageID: string,\n+): Promise<?RawMessageInfo> {\n+ const result = await fetchMessageRowsByIDs([messageID]);\nif (result.length === 0) {\nreturn null;\n}\n- return rawMessageInfoFromRows(result, viewer);\n+ const derivedMessages = await fetchDerivedMessages(result, viewer);\n+ return rawMessageInfoFromRows(result, viewer, derivedMessages);\n}\nexport {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Fetch all the initial messages in one query
Test Plan: Verify that sidebar source messages cause only one additional query
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D589 |
129,191 | 14.01.2021 14:01:57 | -3,600 | c52234e0f99c43c1da3d39e4327498713e1c5244 | [lib] Use more precise types instead of invariant in newThreadRobotext
Test Plan: Flow
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -21,6 +21,8 @@ import {\nmessageTypes,\nmessageTruncationStatus,\n} from '../types/message-types';\n+import type { CreateSidebarMessageInfo } from '../types/message/create-sidebar';\n+import type { CreateThreadMessageInfo } from '../types/message/create-thread';\nimport type {\nImagesMessageData,\nImagesMessageInfo,\n@@ -89,12 +91,10 @@ function encodedThreadEntity(threadID: string, text: string): string {\nreturn `<${text}|t${threadID}>`;\n}\n-function newThreadRobotext(messageInfo: RobotextMessageInfo, creator: string) {\n- invariant(\n- messageInfo.type === messageTypes.CREATE_THREAD ||\n- messageInfo.type === messageTypes.CREATE_SIDEBAR,\n- `Expected CREATE_THREAD or CREATE_SIDEBAR message type, but received ${messageInfo.type}`,\n- );\n+function newThreadRobotext(\n+ messageInfo: CreateThreadMessageInfo | CreateSidebarMessageInfo,\n+ creator: string,\n+) {\nconst threadTypeText =\nmessageInfo.type === messageTypes.CREATE_SIDEBAR ? 'sidebar' : 'thread';\nlet text = `created ${encodedThreadEntity(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use more precise types instead of invariant in newThreadRobotext
Test Plan: Flow
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D604 |
129,191 | 14.01.2021 17:22:30 | -3,600 | e668ded930ea3d2e5f52738579f2f48682b39b7f | [lib] Update create sidebar robotext
Test Plan: Create a message in db and check if it was displayed correctly
Reviewers: ashoat
Subscribers: subnub, atul, Adrian, zrebcu411, KatPo | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -92,14 +92,12 @@ function encodedThreadEntity(threadID: string, text: string): string {\n}\nfunction newThreadRobotext(\n- messageInfo: CreateThreadMessageInfo | CreateSidebarMessageInfo,\n+ messageInfo: CreateThreadMessageInfo,\ncreator: string,\n) {\n- const threadTypeText =\n- messageInfo.type === messageTypes.CREATE_SIDEBAR ? 'sidebar' : 'thread';\nlet text = `created ${encodedThreadEntity(\nmessageInfo.threadID,\n- `this ${threadTypeText}`,\n+ `this thread`,\n)}`;\nconst parentThread = messageInfo.initialThreadState.parentThreadInfo;\nif (parentThread) {\n@@ -120,6 +118,24 @@ function newThreadRobotext(\nreturn `${creator} ${text}`;\n}\n+function newSidebarRobotext(\n+ messageInfo: CreateSidebarMessageInfo,\n+ creator: string,\n+) {\n+ let text = `started ${encodedThreadEntity(\n+ messageInfo.threadID,\n+ `this sidebar`,\n+ )}`;\n+ const users = messageInfo.initialThreadState.otherMembers.filter(\n+ (member) => member.id !== messageInfo.initialMessageAuthor.id,\n+ );\n+ if (users.length !== 0) {\n+ const initialUsersString = robotextForUsers(users);\n+ text += ` and added ${initialUsersString}`;\n+ }\n+ return `${creator} ${text}`;\n+}\n+\nfunction robotextForMessageInfo(\nmessageInfo: RobotextMessageInfo,\nthreadInfo: ThreadInfo,\n@@ -225,7 +241,7 @@ function robotextForMessageInfo(\n`of message with type ${messageInfo.type}`,\n);\n} else if (messageInfo.type === messageTypes.CREATE_SIDEBAR) {\n- return newThreadRobotext(messageInfo, creator);\n+ return newSidebarRobotext(messageInfo, creator);\n} else if (messageInfo.type === messageTypes.UNSUPPORTED) {\nreturn `${creator} ${messageInfo.robotext}`;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Update create sidebar robotext
Test Plan: Create a message in db and check if it was displayed correctly
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: subnub, atul, Adrian, zrebcu411, KatPo
Differential Revision: https://phabricator.ashoat.com/D607 |
129,187 | 15.01.2021 09:20:43 | 28,800 | 895b0326569d6f6110327b4e569557b261860859 | [web] Use hook for data-binding in App
Test Plan: Flow, run the website
Reviewers: palys-swm, subnub
Subscribers: KatPo, zrebcu411, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "web/app.react.js",
"new_path": "web/app.react.js",
"diff": "@@ -6,10 +6,10 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport classNames from 'classnames';\nimport invariant from 'invariant';\nimport _isEqual from 'lodash/fp/isEqual';\n-import PropTypes from 'prop-types';\nimport * as React from 'react';\nimport { DndProvider } from 'react-dnd';\nimport { HTML5Backend } from 'react-dnd-html5-backend';\n+import { useDispatch } from 'react-redux';\nimport {\nfetchEntriesActionTypes,\n@@ -25,14 +25,12 @@ import {\n} from 'lib/selectors/thread-selectors';\nimport { isLoggedIn } from 'lib/selectors/user-selectors';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport {\nverifyField,\ntype ServerVerificationResult,\n- serverVerificationResultPropType,\n} from 'lib/types/verify-types';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\nimport { registerConfig } from 'lib/utils/config';\n-import { connect } from 'lib/utils/redux-utils';\nimport AccountBar from './account-bar.react';\nimport Calendar from './calendar/calendar.react';\n@@ -42,12 +40,8 @@ import LoadingIndicator from './loading-indicator.react';\nimport ResetPasswordModal from './modals/account/reset-password-modal.react';\nimport VerificationModal from './modals/account/verification-modal.react';\nimport FocusHandler from './redux/focus-handler.react';\n-import {\n- type AppState,\n- type NavInfo,\n- navInfoPropType,\n- updateNavInfoActionType,\n-} from './redux/redux-setup';\n+import { type NavInfo, updateNavInfoActionType } from './redux/redux-setup';\n+import { useSelector } from './redux/redux-utils';\nimport VisibilityHandler from './redux/visibility-handler.react';\nimport history from './router-history';\nimport Splash from './splash/splash.react';\n@@ -73,40 +67,30 @@ registerConfig({\nplatformDetails: { platform: 'web' },\n});\n-type Props = {\n- location: {\n- pathname: string,\n+type BaseProps = {|\n+ +location: {\n+ +pathname: string,\n+ ...\n},\n+|};\n+type Props = {|\n+ ...BaseProps,\n// Redux state\n- navInfo: NavInfo,\n- serverVerificationResult: ?ServerVerificationResult,\n- entriesLoadingStatus: LoadingStatus,\n- loggedIn: boolean,\n- mostRecentReadThread: ?string,\n- activeThreadCurrentlyUnread: boolean,\n- viewerID: ?string,\n- unreadCount: number,\n+ +navInfo: NavInfo,\n+ +serverVerificationResult: ?ServerVerificationResult,\n+ +entriesLoadingStatus: LoadingStatus,\n+ +loggedIn: boolean,\n+ +mostRecentReadThread: ?string,\n+ +activeThreadCurrentlyUnread: boolean,\n+ +viewerID: ?string,\n+ +unreadCount: number,\n// Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n-};\n+ +dispatch: Dispatch,\n+|};\ntype State = {|\n- currentModal: ?React.Node,\n+ +currentModal: ?React.Node,\n|};\nclass App extends React.PureComponent<Props, State> {\n- static propTypes = {\n- location: PropTypes.shape({\n- pathname: PropTypes.string.isRequired,\n- }).isRequired,\n- navInfo: navInfoPropType.isRequired,\n- serverVerificationResult: serverVerificationResultPropType,\n- entriesLoadingStatus: PropTypes.string.isRequired,\n- loggedIn: PropTypes.bool.isRequired,\n- mostRecentReadThread: PropTypes.string,\n- activeThreadCurrentlyUnread: PropTypes.bool.isRequired,\n- viewerID: PropTypes.string,\n- unreadCount: PropTypes.number.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\nstate: State = {\ncurrentModal: null,\n};\n@@ -146,7 +130,10 @@ class App extends React.PureComponent<Props, State> {\nnavInfo: this.props.navInfo,\n});\nif (!_isEqual(newNavInfo)(this.props.navInfo)) {\n- this.props.dispatchActionPayload(updateNavInfoActionType, newNavInfo);\n+ this.props.dispatch({\n+ type: updateNavInfoActionType,\n+ payload: newNavInfo,\n+ });\n}\n} else if (!_isEqual(this.props.navInfo)(prevProps.navInfo)) {\nconst newURL = canonicalURLFromReduxState(\n@@ -309,18 +296,22 @@ class App extends React.PureComponent<Props, State> {\nonClickCalendar = (event: SyntheticEvent<HTMLAnchorElement>) => {\nevent.preventDefault();\n- this.props.dispatchActionPayload(updateNavInfoActionType, {\n- tab: 'calendar',\n+ this.props.dispatch({\n+ type: updateNavInfoActionType,\n+ payload: { tab: 'calendar' },\n});\n};\nonClickChat = (event: SyntheticEvent<HTMLAnchorElement>) => {\nevent.preventDefault();\n- this.props.dispatchActionPayload(updateNavInfoActionType, {\n+ this.props.dispatch({\n+ type: updateNavInfoActionType,\n+ payload: {\ntab: 'chat',\nactiveChatThreadID: this.props.activeThreadCurrentlyUnread\n? this.props.mostRecentReadThread\n: this.props.navInfo.activeChatThreadID,\n+ },\n});\n};\n}\n@@ -332,25 +323,53 @@ const updateCalendarQueryLoadingStatusSelector = createLoadingStatusSelector(\nupdateCalendarQueryActionTypes,\n);\n-export default connect(\n- (state: AppState) => {\n- const activeChatThreadID = state.navInfo.activeChatThreadID;\n- return {\n- navInfo: state.navInfo,\n- serverVerificationResult: state.serverVerificationResult,\n- entriesLoadingStatus: combineLoadingStatuses(\n- fetchEntriesLoadingStatusSelector(state),\n- updateCalendarQueryLoadingStatusSelector(state),\n- ),\n- loggedIn: isLoggedIn(state),\n- mostRecentReadThread: mostRecentReadThreadSelector(state),\n- activeThreadCurrentlyUnread:\n+export default React.memo<BaseProps>(function ConnectedApp(props: BaseProps) {\n+ const activeChatThreadID = useSelector(\n+ (state) => state.navInfo.activeChatThreadID,\n+ );\n+ const navInfo = useSelector((state) => state.navInfo);\n+ const serverVerificationResult = useSelector(\n+ (state) => state.serverVerificationResult,\n+ );\n+\n+ const fetchEntriesLoadingStatus = useSelector(\n+ fetchEntriesLoadingStatusSelector,\n+ );\n+ const updateCalendarQueryLoadingStatus = useSelector(\n+ updateCalendarQueryLoadingStatusSelector,\n+ );\n+ const entriesLoadingStatus = combineLoadingStatuses(\n+ fetchEntriesLoadingStatus,\n+ updateCalendarQueryLoadingStatus,\n+ );\n+\n+ const loggedIn = useSelector(isLoggedIn);\n+ const mostRecentReadThread = useSelector(mostRecentReadThreadSelector);\n+ const activeThreadCurrentlyUnread = useSelector(\n+ (state) =>\n!activeChatThreadID ||\n- state.threadStore.threadInfos[activeChatThreadID].currentUser.unread,\n- viewerID: state.currentUserInfo && state.currentUserInfo.id,\n- unreadCount: unreadCount(state),\n- };\n- },\n- null,\n- true,\n-)(App);\n+ !!state.threadStore.threadInfos[activeChatThreadID].currentUser.unread,\n+ );\n+\n+ const viewerID = useSelector(\n+ (state) => state.currentUserInfo && state.currentUserInfo.id,\n+ );\n+ const boundUnreadCount = useSelector(unreadCount);\n+\n+ const dispatch = useDispatch();\n+\n+ return (\n+ <App\n+ {...props}\n+ navInfo={navInfo}\n+ serverVerificationResult={serverVerificationResult}\n+ entriesLoadingStatus={entriesLoadingStatus}\n+ loggedIn={loggedIn}\n+ mostRecentReadThread={mostRecentReadThread}\n+ activeThreadCurrentlyUnread={activeThreadCurrentlyUnread}\n+ viewerID={viewerID}\n+ unreadCount={boundUnreadCount}\n+ dispatch={dispatch}\n+ />\n+ );\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Use hook for data-binding in App
Test Plan: Flow, run the website
Reviewers: palys-swm, subnub
Reviewed By: subnub
Subscribers: KatPo, zrebcu411, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D617 |
129,184 | 14.01.2021 13:35:48 | 28,800 | 4771f960ecd67ddc243d06682ab5f9733ef45a2d | Added PNG extension to appease EXImageLoader
Summary: Append PNG path extension to appease EXImageLoader. Note that our code ignores file extensions and looks at the magic numbers directly, and shouldn't be affected by this change.
Test Plan: NA
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub | [
{
"change_type": "MODIFY",
"old_path": "patches/react-native+0.63.4.patch",
"new_path": "patches/react-native+0.63.4.patch",
"diff": "@@ -78,7 +78,7 @@ index 3e1839b..2df81fb 100644\n@optional\ndiff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m\n-index aa69593..007c6b0 100644\n+index aa69593..d00bc93 100644\n--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m\n+++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m\n@@ -90,7 +90,7 @@ index aa69593..007c6b0 100644\n@implementation RCTBaseTextInputView {\n__weak RCTBridge *_bridge;\n__weak RCTEventDispatcher *_eventDispatcher;\n-@@ -479,6 +481,39 @@ - (void)textInputDidChangeSelection\n+@@ -479,6 +481,45 @@ - (void)textInputDidChangeSelection\n});\n}\n@@ -99,6 +99,7 @@ index aa69593..007c6b0 100644\n+ NSFileManager *fileManager = [NSFileManager defaultManager];\n+ UIPasteboard *clipboard = [UIPasteboard generalPasteboard];\n+ NSData *imageData = [clipboard dataForPasteboardType:(NSString*)kUTTypeImage];\n++\n+ UIImage *uiImage = [UIImage imageWithData:imageData];\n+\n+ if (!imageData) {\n@@ -107,7 +108,12 @@ index aa69593..007c6b0 100644\n+ }\n+\n+ NSString *fileName = [@([imageData hash]) stringValue];\n-+ NSString *fileDest = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];\n++ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];\n++\n++ // We add the PNG file extension because EXImageLoader fails without it.\n++ // Our code ignores file extensions and looks at magic numbers directly.\n++ NSURL *fileURL = [[tmpDirURL URLByAppendingPathComponent:fileName] URLByAppendingPathExtension:@\"png\"];\n++ NSString *fileDest = [fileURL path];\n+\n+ if (![fileManager fileExistsAtPath:fileDest]) {\n+ BOOL fileWritten = [imageData writeToFile:fileDest atomically:true];\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Added PNG extension to appease EXImageLoader
Summary: Append PNG path extension to appease EXImageLoader. Note that our code ignores file extensions and looks at the magic numbers directly, and shouldn't be affected by this change.
Test Plan: NA
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub
Differential Revision: https://phabricator.ashoat.com/D609 |
129,187 | 15.01.2021 12:32:13 | 28,800 | b112b1548fb7d2ffe9b7832bdb2e2e0bd5f4d9c7 | Require curly braces for conditional blocks
Summary: Simple ESLint rule to require curly braces. More details [here](https://eslint.org/docs/rules/curly).
Test Plan: I misformatted a file and checked to make sure the formatting was fixed
Reviewers: atul, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub | [
{
"change_type": "MODIFY",
"old_path": ".eslintrc.json",
"new_path": ".eslintrc.json",
"diff": "\"parser\": \"babel-eslint\",\n\"plugins\": [\"react\", \"react-hooks\", \"flowtype\", \"monorepo\", \"import\"],\n\"rules\": {\n+ \"curly\": \"error\",\n\"linebreak-style\": \"error\",\n\"semi\": \"error\",\n\"react-hooks/rules-of-hooks\": \"error\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Require curly braces for conditional blocks
Summary: Simple ESLint rule to require curly braces. More details [here](https://eslint.org/docs/rules/curly).
Test Plan: I misformatted a file and checked to make sure the formatting was fixed
Reviewers: atul, palys-swm
Reviewed By: atul
Subscribers: KatPo, zrebcu411, Adrian, subnub
Differential Revision: https://phabricator.ashoat.com/D619 |
129,191 | 15.01.2021 17:41:35 | -3,600 | ed62db69e20dddf9fc3ba9100a8e0bef3d70916a | [server] Create script which renames field in sidebar messages
Test Plan: Run the script and check if SIDEBAR_SOURCE and CREATE_SIDEBAR message were updated
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/rename-sidebar-message-fields.js",
"diff": "+// @flow\n+\n+import { messageTypes } from 'lib/types/message-types';\n+\n+import { dbQuery, SQL } from '../database/database';\n+import { main } from './utils';\n+\n+async function renameSidebarSource() {\n+ const query = SQL`\n+ UPDATE messages\n+ SET content = JSON_REMOVE(\n+ JSON_SET(content, '$.sourceMessageID',\n+ JSON_EXTRACT(content, '$.initialMessageID')\n+ ),\n+ '$.initialMessageID'\n+ )\n+ WHERE type = ${messageTypes.SIDEBAR_SOURCE}\n+ `;\n+ await dbQuery(query);\n+}\n+\n+async function renameCreateSidebar() {\n+ const query = SQL`\n+ UPDATE messages\n+ SET content = JSON_REMOVE(\n+ JSON_SET(content, '$.sourceMessageAuthorID',\n+ JSON_EXTRACT(content, '$.initialMessageAuthorID')\n+ ),\n+ '$.initialMessageAuthorID'\n+ )\n+ WHERE type = ${messageTypes.CREATE_SIDEBAR}\n+ `;\n+ await dbQuery(query);\n+}\n+\n+main([renameSidebarSource, renameCreateSidebar]);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Create script which renames field in sidebar messages
Test Plan: Run the script and check if SIDEBAR_SOURCE and CREATE_SIDEBAR message were updated
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D615 |
129,191 | 15.01.2021 17:44:22 | -3,600 | 40c937a343f47ede94d4e4f9fc7e0265a22b3860 | Rename initialMessage and initialMessageAuthor to sourceMessage and sourceMessageAuthor
Test Plan: Run the script from the previous diff and check if the message were displayed correctly. Flow.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/chat-selectors.js",
"new_path": "lib/selectors/chat-selectors.js",
"diff": "@@ -263,7 +263,7 @@ function createChatMessageItems(\nconst messageInfo = threadMessageInfos[i];\nconst originalMessageInfo =\nmessageInfo.type === messageTypes.SIDEBAR_SOURCE\n- ? messageInfo.initialMessage\n+ ? messageInfo.sourceMessage\n: messageInfo;\nlet startsConversation = true;\nlet startsCluster = true;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -127,7 +127,7 @@ function newSidebarRobotext(\n`this sidebar`,\n)}`;\nconst users = messageInfo.initialThreadState.otherMembers.filter(\n- (member) => member.id !== messageInfo.initialMessageAuthor.id,\n+ (member) => member.id !== messageInfo.sourceMessageAuthor.id,\n);\nif (users.length !== 0) {\nconst initialUsersString = robotextForUsers(users);\n@@ -557,14 +557,14 @@ function createMessageInfo(\noperation: rawMessageInfo.operation,\n};\n} else if (rawMessageInfo.type === messageTypes.SIDEBAR_SOURCE) {\n- const initialMessage = createMessageInfo(\n- rawMessageInfo.initialMessage,\n+ const sourceMessage = createMessageInfo(\n+ rawMessageInfo.sourceMessage,\nviewerID,\nuserInfos,\nthreadInfos,\n);\ninvariant(\n- initialMessage && initialMessage.type !== messageTypes.SIDEBAR_SOURCE,\n+ sourceMessage && sourceMessage.type !== messageTypes.SIDEBAR_SOURCE,\n'Sidebars can not be created from SIDEBAR SOURCE',\n);\nreturn {\n@@ -577,14 +577,13 @@ function createMessageInfo(\nisViewer: rawMessageInfo.creatorID === viewerID,\n},\ntime: rawMessageInfo.time,\n- initialMessage,\n+ sourceMessage,\n};\n} else if (rawMessageInfo.type === messageTypes.CREATE_SIDEBAR) {\nconst parentThreadInfo =\nthreadInfos[rawMessageInfo.initialThreadState.parentThreadID];\n- const initialMessageAuthor =\n- userInfos[rawMessageInfo.initialMessageAuthorID];\n- if (!initialMessageAuthor) {\n+ const sourceMessageAuthor = userInfos[rawMessageInfo.sourceMessageAuthorID];\n+ if (!sourceMessageAuthor) {\nreturn null;\n}\nreturn {\n@@ -597,10 +596,10 @@ function createMessageInfo(\nisViewer: rawMessageInfo.creatorID === viewerID,\n},\ntime: rawMessageInfo.time,\n- initialMessageAuthor: {\n- id: rawMessageInfo.initialMessageAuthorID,\n- username: initialMessageAuthor.username,\n- isViewer: rawMessageInfo.initialMessageAuthorID === viewerID,\n+ sourceMessageAuthor: {\n+ id: rawMessageInfo.sourceMessageAuthorID,\n+ username: sourceMessageAuthor.username,\n+ isViewer: rawMessageInfo.sourceMessageAuthorID === viewerID,\n},\ninitialThreadState: {\nname: rawMessageInfo.initialThreadState.name,\n@@ -852,7 +851,7 @@ function shimUnsupportedRawMessageInfos(\n// TODO determine min code version\nif (\nhasMinCodeVersion(platformDetails, 75) &&\n- rawMessageInfo.initialMessage\n+ rawMessageInfo.sourceMessage\n) {\nreturn rawMessageInfo;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/notif-utils.js",
"new_path": "lib/shared/notif-utils.js",
"diff": "@@ -448,8 +448,8 @@ function fullNotifTextsForMessageInfo(\nmessageInfo.type === messageTypes.SIDEBAR_SOURCE,\n'messageInfo should be messageTypes.SIDEBAR_SOURCE!',\n);\n- const initialMessageInfo = messageInfo.initialMessage;\n- return fullNotifTextsForMessageInfo([initialMessageInfo], threadInfo);\n+ const sourceMessageInfo = messageInfo.sourceMessage;\n+ return fullNotifTextsForMessageInfo([sourceMessageInfo], threadInfo);\n} else if (mostRecentType === messageTypes.CREATE_SIDEBAR) {\nconst messageInfo = assertSingleMessageInfo(messageInfos);\ninvariant(\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/message-types.js",
"new_path": "lib/types/message-types.js",
"diff": "@@ -199,7 +199,7 @@ export type SidebarSourceMessageData = {|\n+threadID: string,\n+creatorID: string,\n+time: number,\n- +initialMessage: RawComposableMessageInfo | RawRobotextMessageInfo,\n+ +sourceMessage: RawComposableMessageInfo | RawRobotextMessageInfo,\n|};\nexport type MessageData =\n| TextMessageData\n@@ -289,7 +289,7 @@ export type SidebarSourceMessageInfo = {|\n+threadID: string,\n+creator: RelativeUserInfo,\n+time: number,\n- +initialMessage: ComposableMessageInfo | RobotextMessageInfo,\n+ +sourceMessage: ComposableMessageInfo | RobotextMessageInfo,\n|};\nexport type MessageInfo =\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/message/create-sidebar.js",
"new_path": "lib/types/message/create-sidebar.js",
"diff": "@@ -8,7 +8,7 @@ export type CreateSidebarMessageData = {|\n+threadID: string,\n+creatorID: string,\n+time: number,\n- +initialMessageAuthorID: string,\n+ +sourceMessageAuthorID: string,\n+initialThreadState: {|\n+name: ?string,\n+parentThreadID: string,\n@@ -28,7 +28,7 @@ export type CreateSidebarMessageInfo = {|\n+threadID: string,\n+creator: RelativeUserInfo,\n+time: number,\n- +initialMessageAuthor: RelativeUserInfo,\n+ +sourceMessageAuthor: RelativeUserInfo,\n+initialThreadState: {|\n+name: ?string,\n+parentThreadInfo: ThreadInfo,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -217,7 +217,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nconst { messageInfo } = item;\ninvariant(\nmessageInfo.type !== messageTypes.SIDEBAR_SOURCE,\n- 'Sidebar source messages should be replaced by initialMessage before being measured',\n+ 'Sidebar source messages should be replaced by sourceMessage before being measured',\n);\nconst { threadInfo } = this.props;\nif (\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-preview.react.js",
"new_path": "native/chat/message-preview.react.js",
"diff": "@@ -26,7 +26,7 @@ class MessagePreview extends React.PureComponent<Props> {\nrender() {\nconst messageInfo: MessageInfo =\nthis.props.messageInfo.type === messageTypes.SIDEBAR_SOURCE\n- ? this.props.messageInfo.initialMessage\n+ ? this.props.messageInfo.sourceMessage\n: this.props.messageInfo;\nconst unreadStyle = this.props.threadInfo.currentUser.unread\n? this.props.styles.unread\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/message-creator.js",
"new_path": "server/src/creators/message-creator.js",
"diff": "@@ -167,12 +167,12 @@ async function createMessages(\n});\n} else if (messageData.type === messageTypes.SIDEBAR_SOURCE) {\ncontent = JSON.stringify({\n- initialMessageID: messageData.initialMessage.id,\n+ sourceMessageID: messageData.sourceMessage.id,\n});\n} else if (messageData.type === messageTypes.CREATE_SIDEBAR) {\ncontent = JSON.stringify({\n...messageData.initialThreadState,\n- initialMessageAuthorID: messageData.initialMessageAuthorID,\n+ sourceMessageAuthorID: messageData.sourceMessageAuthorID,\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/message-fetchers.js",
"new_path": "server/src/fetchers/message-fetchers.js",
"diff": "@@ -387,11 +387,11 @@ function rawMessageInfoFromRows(\n} else if (type === messageTypes.SIDEBAR_SOURCE) {\nconst row = assertSingleRow(rows);\nconst content = JSON.parse(row.content);\n- const initialMessage = derivedMessages.get(content.initialMessageID);\n- if (!initialMessage) {\n+ const sourceMessage = derivedMessages.get(content.sourceMessageID);\n+ if (!sourceMessage) {\nconsole.warn(\n`Message with id ${row.id} has a derived message ` +\n- `${content.initialMessageID} which is not present in the database`,\n+ `${content.sourceMessageID} which is not present in the database`,\n);\n}\nreturn {\n@@ -400,11 +400,11 @@ function rawMessageInfoFromRows(\nthreadID: row.threadID.toString(),\ntime: row.time,\ncreatorID: row.creatorID.toString(),\n- initialMessage,\n+ sourceMessage,\n};\n} else if (type === messageTypes.CREATE_SIDEBAR) {\nconst row = assertSingleRow(rows);\n- const { initialMessageAuthorID, ...initialThreadState } = JSON.parse(\n+ const { sourceMessageAuthorID, ...initialThreadState } = JSON.parse(\nrow.content,\n);\nreturn {\n@@ -413,7 +413,7 @@ function rawMessageInfoFromRows(\nthreadID: row.threadID.toString(),\ntime: row.time,\ncreatorID: row.creatorID.toString(),\n- initialMessageAuthorID,\n+ sourceMessageAuthorID,\ninitialThreadState,\n};\n} else {\n@@ -749,7 +749,7 @@ async function fetchDerivedMessages(\nfor (const row of rows) {\nif (row.type === messageTypes.SIDEBAR_SOURCE) {\nconst content = JSON.parse(row.content);\n- requiredIDs.add(content.initialMessageID);\n+ requiredIDs.add(content.sourceMessageID);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/message-preview.react.js",
"new_path": "web/chat/message-preview.react.js",
"diff": "@@ -21,7 +21,7 @@ class MessagePreview extends React.PureComponent<Props> {\nconst messageInfo =\nthis.props.messageInfo &&\n(this.props.messageInfo.type === messageTypes.SIDEBAR_SOURCE\n- ? this.props.messageInfo.initialMessage\n+ ? this.props.messageInfo.sourceMessage\n: this.props.messageInfo);\nif (!messageInfo) {\nreturn (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Rename initialMessage and initialMessageAuthor to sourceMessage and sourceMessageAuthor
Test Plan: Run the script from the previous diff and check if the message were displayed correctly. Flow.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D616 |
129,184 | 19.01.2021 01:56:19 | 28,800 | dcc276a468aaf29084c8cb19b7c9a05b89c737e0 | Prevent image url from being pasted into text input when pasting image from browser
Summary: Minor fix to bypass pasting of image url
Test Plan: Tried it on a couple of images before and after change.
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub | [
{
"change_type": "MODIFY",
"old_path": "patches/react-native+0.63.4.patch",
"new_path": "patches/react-native+0.63.4.patch",
"diff": "@@ -42,20 +42,25 @@ index 7e12add..6979293 100644\n@end\ndiff --git a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m\n-index 88d3183..4fe51ff 100644\n+index 88d3183..25d00e2 100644\n--- a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m\n+++ b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m\n-@@ -173,6 +173,9 @@ - (void)setSelectedTextRange:(UITextRange *)selectedTextRange notifyDelegate:(BO\n+@@ -173,8 +173,12 @@ - (void)setSelectedTextRange:(UITextRange *)selectedTextRange notifyDelegate:(BO\n- (void)paste:(id)sender\n{\n+- [super paste:sender];\n+- _textWasPasted = YES;\n+ if ([UIPasteboard generalPasteboard].hasImages && _allowImagePasteForThreadID) {\n+ [_textInputDelegate textInputImagePasted:_allowImagePasteForThreadID];\n++ } else {\n++ [super paste:sender];\n++ _textWasPasted = YES;\n+ }\n- [super paste:sender];\n- _textWasPasted = YES;\n}\n-@@ -261,6 +264,9 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender\n+\n+ - (void)setContentOffset:(CGPoint)contentOffset animated:(__unused BOOL)animated\n+@@ -261,6 +265,9 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender\nreturn NO;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Prevent image url from being pasted into text input when pasting image from browser
Summary: Minor fix to bypass pasting of image url
Test Plan: Tried it on a couple of images before and after change.
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub
Differential Revision: https://phabricator.ashoat.com/D628 |
129,191 | 15.01.2021 16:04:52 | -3,600 | 5a24fffb682edebb617a9857ab85f5f1fa37a139 | [lib] Update notification text
Test Plan: I haven't tested it: we should probably think about finding a way to test notifications on local
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/notif-utils.js",
"new_path": "lib/shared/notif-utils.js",
"diff": "@@ -11,7 +11,6 @@ import {\nmessageTypes,\n} from '../types/message-types';\nimport type { ThreadInfo, ThreadType } from '../types/thread-types';\n-import { threadTypes } from '../types/thread-types';\nimport type { RelativeUserInfo } from '../types/user-types';\nimport { prettyDate } from '../utils/date-utils';\nimport { values } from '../utils/objects';\n@@ -456,14 +455,22 @@ function fullNotifTextsForMessageInfo(\nmessageInfo.type === messageTypes.CREATE_SIDEBAR,\n'messageInfo should be messageTypes.CREATE_SIDEBAR!',\n);\n- const parentThreadInfo = messageInfo.initialThreadState.parentThreadInfo;\n- return notifTextForSubthreadCreation(\n- messageInfo.creator,\n- threadTypes.SIDEBAR,\n- parentThreadInfo,\n- messageInfo.initialThreadState.name,\n- threadInfo.uiName,\n- );\n+ const prefix = stringForUser(messageInfo.creator);\n+ const title = threadInfo.uiName;\n+ const sourceMessageAuthorPossessive = messageInfo.sourceMessageAuthor\n+ .isViewer\n+ ? 'your'\n+ : `${stringForUser(messageInfo.sourceMessageAuthor)}'s`;\n+ const body =\n+ `started a sidebar in response to ${sourceMessageAuthorPossessive} ` +\n+ `message \"${messageInfo.initialThreadState.name}\"`;\n+ const merged = `${prefix} ${body}`;\n+ return {\n+ merged,\n+ body,\n+ title,\n+ prefix,\n+ };\n} else {\ninvariant(false, `we're not aware of messageType ${mostRecentType}`);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Update notification text
Test Plan: I haven't tested it: we should probably think about finding a way to test notifications on local
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D614 |
129,191 | 20.01.2021 18:31:43 | -3,600 | 07d26f74fee8e4903831d7cdd41e6c604886d315 | [lib] Use message spec when shimming the message
Test Plan: Log out, log in, check sidebar source and create sidebar messages on version 74
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "import invariant from 'invariant';\nimport _maxBy from 'lodash/fp/maxBy';\n-import { shimUploadURI, multimediaMessagePreview } from '../media/media-utils';\n+import { multimediaMessagePreview } from '../media/media-utils';\nimport { userIDsToRelativeUserInfos } from '../selectors/user-selectors';\nimport type { PlatformDetails } from '../types/device-types';\n-import type { Media, Image, Video } from '../types/media-types';\n+import type { Media } from '../types/media-types';\nimport {\ntype MessageInfo,\ntype RawMessageInfo,\n@@ -34,7 +34,6 @@ import type { RelativeUserInfo, UserInfos } from '../types/user-types';\nimport { codeBlockRegex } from './markdown';\nimport { messageSpecs } from './messages/message-specs';\nimport { stringForUser } from './user-utils';\n-import { hasMinCodeVersion } from './version-utils';\n// Prefers localID\nfunction messageKey(messageInfo: MessageInfo | RawMessageInfo): string {\n@@ -232,148 +231,14 @@ function shimUnsupportedRawMessageInfos(\nreturn [...rawMessageInfos];\n}\nreturn rawMessageInfos.map((rawMessageInfo) => {\n- if (rawMessageInfo.type === messageTypes.IMAGES) {\n- const shimmedRawMessageInfo = shimMediaMessageInfo(\n- rawMessageInfo,\n- platformDetails,\n- );\n- if (hasMinCodeVersion(platformDetails, 30)) {\n- return shimmedRawMessageInfo;\n- }\n- const { id } = shimmedRawMessageInfo;\n- invariant(id !== null && id !== undefined, 'id should be set on server');\n- return {\n- type: messageTypes.UNSUPPORTED,\n- id,\n- threadID: shimmedRawMessageInfo.threadID,\n- creatorID: shimmedRawMessageInfo.creatorID,\n- time: shimmedRawMessageInfo.time,\n- robotext: multimediaMessagePreview(shimmedRawMessageInfo),\n- unsupportedMessageInfo: shimmedRawMessageInfo,\n- };\n- } else if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n- const shimmedRawMessageInfo = shimMediaMessageInfo(\n- rawMessageInfo,\n- platformDetails,\n- );\n- // TODO figure out first native codeVersion supporting video playback\n- if (hasMinCodeVersion(platformDetails, 62)) {\n- return shimmedRawMessageInfo;\n- }\n- const { id } = shimmedRawMessageInfo;\n- invariant(id !== null && id !== undefined, 'id should be set on server');\n- return {\n- type: messageTypes.UNSUPPORTED,\n- id,\n- threadID: shimmedRawMessageInfo.threadID,\n- creatorID: shimmedRawMessageInfo.creatorID,\n- time: shimmedRawMessageInfo.time,\n- robotext: multimediaMessagePreview(shimmedRawMessageInfo),\n- unsupportedMessageInfo: shimmedRawMessageInfo,\n- };\n- } else if (rawMessageInfo.type === messageTypes.UPDATE_RELATIONSHIP) {\n- if (hasMinCodeVersion(platformDetails, 71)) {\n- return rawMessageInfo;\n- }\n- const { id } = rawMessageInfo;\n- invariant(id !== null && id !== undefined, 'id should be set on server');\n- return {\n- type: messageTypes.UNSUPPORTED,\n- id,\n- threadID: rawMessageInfo.threadID,\n- creatorID: rawMessageInfo.creatorID,\n- time: rawMessageInfo.time,\n- robotext: 'performed a relationship action',\n- unsupportedMessageInfo: rawMessageInfo,\n- };\n- } else if (rawMessageInfo.type === messageTypes.SIDEBAR_SOURCE) {\n- // TODO determine min code version\n- if (\n- hasMinCodeVersion(platformDetails, 75) &&\n- rawMessageInfo.sourceMessage\n- ) {\n- return rawMessageInfo;\n- }\n- const { id } = rawMessageInfo;\n- invariant(id !== null && id !== undefined, 'id should be set on server');\n- return {\n- type: messageTypes.UNSUPPORTED,\n- id,\n- threadID: rawMessageInfo.threadID,\n- creatorID: rawMessageInfo.creatorID,\n- time: rawMessageInfo.time,\n- robotext: 'first message in sidebar',\n- unsupportedMessageInfo: rawMessageInfo,\n- };\n- } else if (rawMessageInfo.type === messageTypes.CREATE_SIDEBAR) {\n- // TODO determine min code version\n- if (hasMinCodeVersion(platformDetails, 75)) {\n- return rawMessageInfo;\n- }\n- const { id } = rawMessageInfo;\n- invariant(id !== null && id !== undefined, 'id should be set on server');\n- return {\n- type: messageTypes.UNSUPPORTED,\n- id,\n- threadID: rawMessageInfo.threadID,\n- creatorID: rawMessageInfo.creatorID,\n- time: rawMessageInfo.time,\n- robotext: 'created a sidebar',\n- unsupportedMessageInfo: rawMessageInfo,\n- };\n+ const { shimUnsupportedMessageInfo } = messageSpecs[rawMessageInfo.type];\n+ if (shimUnsupportedMessageInfo) {\n+ return shimUnsupportedMessageInfo(rawMessageInfo, platformDetails);\n}\nreturn rawMessageInfo;\n});\n}\n-function shimMediaMessageInfo(\n- rawMessageInfo: RawMultimediaMessageInfo,\n- platformDetails: ?PlatformDetails,\n-): RawMultimediaMessageInfo {\n- if (rawMessageInfo.type === messageTypes.IMAGES) {\n- let uriChanged = false;\n- const newMedia: Image[] = [];\n- for (let singleMedia of rawMessageInfo.media) {\n- const shimmedURI = shimUploadURI(singleMedia.uri, platformDetails);\n- if (shimmedURI === singleMedia.uri) {\n- newMedia.push(singleMedia);\n- } else {\n- newMedia.push(({ ...singleMedia, uri: shimmedURI }: Image));\n- uriChanged = true;\n- }\n- }\n- if (!uriChanged) {\n- return rawMessageInfo;\n- }\n- return ({\n- ...rawMessageInfo,\n- media: newMedia,\n- }: RawImagesMessageInfo);\n- } else {\n- let uriChanged = false;\n- const newMedia: Media[] = [];\n- for (let singleMedia of rawMessageInfo.media) {\n- const shimmedURI = shimUploadURI(singleMedia.uri, platformDetails);\n- if (shimmedURI === singleMedia.uri) {\n- newMedia.push(singleMedia);\n- } else if (singleMedia.type === 'photo') {\n- newMedia.push(({ ...singleMedia, uri: shimmedURI }: Image));\n- uriChanged = true;\n- } else {\n- newMedia.push(({ ...singleMedia, uri: shimmedURI }: Video));\n- uriChanged = true;\n- }\n- }\n- if (!uriChanged) {\n- return rawMessageInfo;\n- }\n- return ({\n- ...rawMessageInfo,\n- media: newMedia,\n- }: RawMediaMessageInfo);\n- }\n-}\n-\nfunction messagePreviewText(\nmessageInfo: PreviewableMessageInfo,\nthreadInfo: ThreadInfo,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sidebar-message-spec.js",
"new_path": "lib/shared/messages/create-sidebar-message-spec.js",
"diff": "// @flow\n+import invariant from 'invariant';\n+\nimport { messageTypes } from '../../types/message-types';\nimport type {\nCreateSidebarMessageData,\nCreateSidebarMessageInfo,\nRawCreateSidebarMessageInfo,\n} from '../../types/message/create-sidebar';\n+import { hasMinCodeVersion } from '../version-utils';\nimport type { MessageSpec } from './message-spec';\nexport const createSidebarMessageSpec: MessageSpec<\n@@ -85,4 +88,22 @@ export const createSidebarMessageSpec: MessageSpec<\n}\nreturn `${creator} ${text}`;\n},\n+\n+ shimUnsupportedMessageInfo(rawMessageInfo, platformDetails) {\n+ // TODO determine min code version\n+ if (hasMinCodeVersion(platformDetails, 75)) {\n+ return rawMessageInfo;\n+ }\n+ const { id } = rawMessageInfo;\n+ invariant(id !== null && id !== undefined, 'id should be set on server');\n+ return {\n+ type: messageTypes.UNSUPPORTED,\n+ id,\n+ threadID: rawMessageInfo.threadID,\n+ creatorID: rawMessageInfo.creatorID,\n+ time: rawMessageInfo.time,\n+ robotext: 'created a sidebar',\n+ unsupportedMessageInfo: rawMessageInfo,\n+ };\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/message-spec.js",
"new_path": "lib/shared/messages/message-spec.js",
"diff": "// @flow\n+import type { PlatformDetails } from '../../types/device-types';\nimport type { Media } from '../../types/media-types';\nimport type {\nMessageInfo,\n@@ -7,6 +8,7 @@ import type {\nRawMessageInfo,\nRawRobotextMessageInfo,\n} from '../../types/message-types';\n+import type { RawUnsupportedMessageInfo } from '../../types/message/unsupported';\nimport type { ThreadInfo } from '../../types/thread-types';\nimport type { RelativeUserInfo } from '../../types/user-types';\n@@ -45,4 +47,8 @@ export type MessageSpec<Data, RawInfo, Info> = {|\n+threadInfo: ThreadInfo,\n|},\n) => string,\n+ +shimUnsupportedMessageInfo?: (\n+ rawMessageInfo: RawInfo,\n+ platformDetails: ?PlatformDetails,\n+ ) => RawInfo | RawUnsupportedMessageInfo,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/multimedia-message-spec.js",
"new_path": "lib/shared/messages/multimedia-message-spec.js",
"diff": "import invariant from 'invariant';\n+import {\n+ multimediaMessagePreview,\n+ shimUploadURI,\n+} from '../../media/media-utils';\n+import type { PlatformDetails } from '../../types/device-types';\n+import type { Media, Video, Image } from '../../types/media-types';\n+import type { RawMultimediaMessageInfo } from '../../types/message-types';\nimport { messageTypes } from '../../types/message-types';\nimport type {\nImagesMessageData,\n@@ -14,6 +21,7 @@ import type {\nRawMediaMessageInfo,\n} from '../../types/message/media';\nimport { createMediaMessageInfo } from '../message-utils';\n+import { hasMinCodeVersion } from '../version-utils';\nimport type { MessageSpec } from './message-spec';\nexport const multimediaMessageSpec: MessageSpec<\n@@ -80,4 +88,95 @@ export const multimediaMessageSpec: MessageSpec<\nreturn ({ ...messageData, id }: RawMediaMessageInfo);\n}\n},\n+\n+ shimUnsupportedMessageInfo(rawMessageInfo, platformDetails) {\n+ if (rawMessageInfo.type === messageTypes.IMAGES) {\n+ const shimmedRawMessageInfo = shimMediaMessageInfo(\n+ rawMessageInfo,\n+ platformDetails,\n+ );\n+ if (hasMinCodeVersion(platformDetails, 30)) {\n+ return shimmedRawMessageInfo;\n+ }\n+ const { id } = shimmedRawMessageInfo;\n+ invariant(id !== null && id !== undefined, 'id should be set on server');\n+ return {\n+ type: messageTypes.UNSUPPORTED,\n+ id,\n+ threadID: shimmedRawMessageInfo.threadID,\n+ creatorID: shimmedRawMessageInfo.creatorID,\n+ time: shimmedRawMessageInfo.time,\n+ robotext: multimediaMessagePreview(shimmedRawMessageInfo),\n+ unsupportedMessageInfo: shimmedRawMessageInfo,\n+ };\n+ } else {\n+ const shimmedRawMessageInfo = shimMediaMessageInfo(\n+ rawMessageInfo,\n+ platformDetails,\n+ );\n+ // TODO figure out first native codeVersion supporting video playback\n+ if (hasMinCodeVersion(platformDetails, 62)) {\n+ return shimmedRawMessageInfo;\n+ }\n+ const { id } = shimmedRawMessageInfo;\n+ invariant(id !== null && id !== undefined, 'id should be set on server');\n+ return {\n+ type: messageTypes.UNSUPPORTED,\n+ id,\n+ threadID: shimmedRawMessageInfo.threadID,\n+ creatorID: shimmedRawMessageInfo.creatorID,\n+ time: shimmedRawMessageInfo.time,\n+ robotext: multimediaMessagePreview(shimmedRawMessageInfo),\n+ unsupportedMessageInfo: shimmedRawMessageInfo,\n+ };\n+ }\n+ },\n});\n+\n+function shimMediaMessageInfo(\n+ rawMessageInfo: RawMultimediaMessageInfo,\n+ platformDetails: ?PlatformDetails,\n+): RawMultimediaMessageInfo {\n+ if (rawMessageInfo.type === messageTypes.IMAGES) {\n+ let uriChanged = false;\n+ const newMedia: Image[] = [];\n+ for (const singleMedia of rawMessageInfo.media) {\n+ const shimmedURI = shimUploadURI(singleMedia.uri, platformDetails);\n+ if (shimmedURI === singleMedia.uri) {\n+ newMedia.push(singleMedia);\n+ } else {\n+ newMedia.push(({ ...singleMedia, uri: shimmedURI }: Image));\n+ uriChanged = true;\n+ }\n+ }\n+ if (!uriChanged) {\n+ return rawMessageInfo;\n+ }\n+ return ({\n+ ...rawMessageInfo,\n+ media: newMedia,\n+ }: RawImagesMessageInfo);\n+ } else {\n+ let uriChanged = false;\n+ const newMedia: Media[] = [];\n+ for (const singleMedia of rawMessageInfo.media) {\n+ const shimmedURI = shimUploadURI(singleMedia.uri, platformDetails);\n+ if (shimmedURI === singleMedia.uri) {\n+ newMedia.push(singleMedia);\n+ } else if (singleMedia.type === 'photo') {\n+ newMedia.push(({ ...singleMedia, uri: shimmedURI }: Image));\n+ uriChanged = true;\n+ } else {\n+ newMedia.push(({ ...singleMedia, uri: shimmedURI }: Video));\n+ uriChanged = true;\n+ }\n+ }\n+ if (!uriChanged) {\n+ return rawMessageInfo;\n+ }\n+ return ({\n+ ...rawMessageInfo,\n+ media: newMedia,\n+ }: RawMediaMessageInfo);\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/sidebar-source-message-spec.js",
"new_path": "lib/shared/messages/sidebar-source-message-spec.js",
"diff": "@@ -8,6 +8,7 @@ import type {\nSidebarSourceMessageInfo,\n} from '../../types/message-types';\nimport { messageTypes } from '../../types/message-types';\n+import { hasMinCodeVersion } from '../version-utils';\nimport type { MessageSpec } from './message-spec';\nexport const sidebarSourceMessageSpec: MessageSpec<\n@@ -70,4 +71,25 @@ export const sidebarSourceMessageSpec: MessageSpec<\nrawMessageInfoFromMessageData(messageData, id) {\nreturn { ...messageData, id };\n},\n+\n+ shimUnsupportedMessageInfo(rawMessageInfo, platformDetails) {\n+ // TODO determine min code version\n+ if (\n+ hasMinCodeVersion(platformDetails, 75) &&\n+ rawMessageInfo.sourceMessage\n+ ) {\n+ return rawMessageInfo;\n+ }\n+ const { id } = rawMessageInfo;\n+ invariant(id !== null && id !== undefined, 'id should be set on server');\n+ return {\n+ type: messageTypes.UNSUPPORTED,\n+ id,\n+ threadID: rawMessageInfo.threadID,\n+ creatorID: rawMessageInfo.creatorID,\n+ time: rawMessageInfo.time,\n+ robotext: 'first message in sidebar',\n+ unsupportedMessageInfo: rawMessageInfo,\n+ };\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/update-relationship-message-spec.js",
"new_path": "lib/shared/messages/update-relationship-message-spec.js",
"diff": "@@ -8,6 +8,7 @@ import type {\nUpdateRelationshipMessageData,\nUpdateRelationshipMessageInfo,\n} from '../../types/message/update-relationship';\n+import { hasMinCodeVersion } from '../version-utils';\nimport type { MessageSpec } from './message-spec';\nexport const updateRelationshipMessageSpec: MessageSpec<\n@@ -71,4 +72,21 @@ export const updateRelationshipMessageSpec: MessageSpec<\n`of message with type ${messageInfo.type}`,\n);\n},\n+\n+ shimUnsupportedMessageInfo(rawMessageInfo, platformDetails) {\n+ if (hasMinCodeVersion(platformDetails, 71)) {\n+ return rawMessageInfo;\n+ }\n+ const { id } = rawMessageInfo;\n+ invariant(id !== null && id !== undefined, 'id should be set on server');\n+ return {\n+ type: messageTypes.UNSUPPORTED,\n+ id,\n+ threadID: rawMessageInfo.threadID,\n+ creatorID: rawMessageInfo.creatorID,\n+ time: rawMessageInfo.time,\n+ robotext: 'performed a relationship action',\n+ unsupportedMessageInfo: rawMessageInfo,\n+ };\n+ },\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use message spec when shimming the message
Test Plan: Log out, log in, check sidebar source and create sidebar messages on version 74
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D638 |
129,184 | 20.01.2021 19:26:07 | 28,800 | 17e95734fd902cbdc6ba1074e541e32d0dda663e | update
Summary: Updated react-navigation/stack from 5.12.6 to 5.12.8 to resolve issue where keyboard was not being dismissed when modal was displayed
Test Plan: NA
Reviewers: ashoat, palys-swm
Subscribers: KatPo, zrebcu411, Adrian, subnub | [
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"@react-navigation/devtools\": \"^5.1.17\",\n\"@react-navigation/material-top-tabs\": \"^5.3.9\",\n\"@react-navigation/native\": \"^5.8.9\",\n- \"@react-navigation/stack\": \"^5.12.6\",\n+ \"@react-navigation/stack\": \"^5.12.8\",\n\"base-64\": \"^0.1.0\",\n\"expo-image-manipulator\": \"^8.4.0\",\n\"expo-media-library\": \"^10.0.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "yarn.lock",
"new_path": "yarn.lock",
"diff": "dependencies:\nnanoid \"^3.1.15\"\n-\"@react-navigation/stack@^5.12.6\":\n- version \"5.12.6\"\n- resolved \"https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.12.6.tgz#a6f2caf66da78ad2afa80f7a960c36db6b83bcff\"\n- integrity sha512-pf9AigAIVtCQuCpZAZqBux4kNqQwj98ngvd6JEryFrqTQ1CYsUH6jfpQE7SKyHggVRFSQVMf24aCgwtRixBvjw==\n+\"@react-navigation/stack@^5.12.8\":\n+ version \"5.13.0\"\n+ resolved \"https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.13.0.tgz#3c00848642a4a966f497822f02494273f4d4c621\"\n+ integrity sha512-UorckfT7p7D5BLMJgpi8lY6duSV6WSG/NwidxWQK06u5bO0Uwxgx9sINjJZbS5+ijVJy8bB8SbG/I+H2bgT4eA==\ndependencies:\ncolor \"^3.1.3\"\nreact-native-iphone-x-helper \"^1.3.0\"\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | update @react-navigation/stack
Summary: Updated react-navigation/stack from 5.12.6 to 5.12.8 to resolve issue where keyboard was not being dismissed when modal was displayed
Test Plan: NA
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, subnub
Differential Revision: https://phabricator.ashoat.com/D641 |
129,191 | 22.01.2021 12:51:16 | -3,600 | a2ac274e4fdc0d88e2df4ba482fcd8eef02d609b | [lib] Use message specs when creating notification collapse key
Test Plan: Flow. Again, testing notifs is hard.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/add-members-message-spec.js",
"new_path": "lib/shared/messages/add-members-message-spec.js",
"diff": "@@ -10,6 +10,7 @@ import type {\n} from '../../types/message/add-members';\nimport { values } from '../../utils/objects';\nimport type { MessageSpec } from './message-spec';\n+import { joinResult } from './utils';\nexport const addMembersMessageSpec: MessageSpec<\nAddMembersMessageData,\n@@ -87,4 +88,12 @@ export const addMembersMessageSpec: MessageSpec<\nbody: robotext,\n};\n},\n+\n+ notificationCollapseKey(rawMessageInfo) {\n+ return joinResult(\n+ rawMessageInfo.type,\n+ rawMessageInfo.threadID,\n+ rawMessageInfo.creatorID,\n+ );\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/change-role-message-spec.js",
"new_path": "lib/shared/messages/change-role-message-spec.js",
"diff": "@@ -10,6 +10,7 @@ import type {\n} from '../../types/message/change-role';\nimport { values } from '../../utils/objects';\nimport type { MessageSpec } from './message-spec';\n+import { joinResult } from './utils';\nexport const changeRoleMessageSpec: MessageSpec<\nChangeRoleMessageData,\n@@ -95,4 +96,13 @@ export const changeRoleMessageSpec: MessageSpec<\nbody: robotext,\n};\n},\n+\n+ notificationCollapseKey(rawMessageInfo) {\n+ return joinResult(\n+ rawMessageInfo.type,\n+ rawMessageInfo.threadID,\n+ rawMessageInfo.creatorID,\n+ rawMessageInfo.newRole,\n+ );\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/change-settings-message-spec.js",
"new_path": "lib/shared/messages/change-settings-message-spec.js",
"diff": "@@ -9,6 +9,7 @@ import type {\nRawChangeSettingsMessageInfo,\n} from '../../types/message/change-settings';\nimport type { MessageSpec } from './message-spec';\n+import { joinResult } from './utils';\nexport const changeSettingsMessageSpec: MessageSpec<\nChangeSettingsMessageData,\n@@ -81,4 +82,13 @@ export const changeSettingsMessageSpec: MessageSpec<\nbody,\n};\n},\n+\n+ notificationCollapseKey(rawMessageInfo) {\n+ return joinResult(\n+ rawMessageInfo.type,\n+ rawMessageInfo.threadID,\n+ rawMessageInfo.creatorID,\n+ rawMessageInfo.field,\n+ );\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-entry-message-spec.js",
"new_path": "lib/shared/messages/create-entry-message-spec.js",
"diff": "@@ -11,6 +11,7 @@ import type {\nimport { prettyDate } from '../../utils/date-utils';\nimport { stringForUser } from '../user-utils';\nimport type { MessageSpec } from './message-spec';\n+import { joinResult } from './utils';\nexport const createEntryMessageSpec: MessageSpec<\nCreateEntryMessageData,\n@@ -104,4 +105,8 @@ export const createEntryMessageSpec: MessageSpec<\nprefix,\n};\n},\n+\n+ notificationCollapseKey(rawMessageInfo) {\n+ return joinResult(rawMessageInfo.creatorID, rawMessageInfo.entryID);\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/edit-entry-message-spec.js",
"new_path": "lib/shared/messages/edit-entry-message-spec.js",
"diff": "@@ -11,6 +11,7 @@ import type {\nimport { prettyDate } from '../../utils/date-utils';\nimport { stringForUser } from '../user-utils';\nimport type { MessageSpec } from './message-spec';\n+import { joinResult } from './utils';\nexport const editEntryMessageSpec: MessageSpec<\nEditEntryMessageData,\n@@ -104,4 +105,8 @@ export const editEntryMessageSpec: MessageSpec<\nprefix,\n};\n},\n+\n+ notificationCollapseKey(rawMessageInfo) {\n+ return joinResult(rawMessageInfo.creatorID, rawMessageInfo.entryID);\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/join-thread-message-spec.js",
"new_path": "lib/shared/messages/join-thread-message-spec.js",
"diff": "@@ -12,6 +12,7 @@ import { values } from '../../utils/objects';\nimport { pluralize } from '../../utils/text-utils';\nimport { stringForUser } from '../user-utils';\nimport type { MessageSpec } from './message-spec';\n+import { joinResult } from './utils';\nexport const joinThreadMessageSpec: MessageSpec<\nJoinThreadMessageData,\n@@ -69,4 +70,8 @@ export const joinThreadMessageSpec: MessageSpec<\nbody,\n};\n},\n+\n+ notificationCollapseKey(rawMessageInfo) {\n+ return joinResult(rawMessageInfo.type, rawMessageInfo.threadID);\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/leave-thread-message-spec.js",
"new_path": "lib/shared/messages/leave-thread-message-spec.js",
"diff": "@@ -12,6 +12,7 @@ import { values } from '../../utils/objects';\nimport { pluralize } from '../../utils/text-utils';\nimport { stringForUser } from '../user-utils';\nimport type { MessageSpec } from './message-spec';\n+import { joinResult } from './utils';\nexport const leaveThreadMessageSpec: MessageSpec<\nLeaveThreadMessageData,\n@@ -69,4 +70,8 @@ export const leaveThreadMessageSpec: MessageSpec<\nbody,\n};\n},\n+\n+ notificationCollapseKey(rawMessageInfo) {\n+ return joinResult(rawMessageInfo.type, rawMessageInfo.threadID);\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/message-spec.js",
"new_path": "lib/shared/messages/message-spec.js",
"diff": "@@ -75,4 +75,5 @@ export type MessageSpec<Data, RawInfo, Info> = {|\n) => NotifTexts,\n|},\n) => NotifTexts,\n+ +notificationCollapseKey?: (rawMessageInfo: RawInfo) => ?string,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/multimedia-message-spec.js",
"new_path": "lib/shared/messages/multimedia-message-spec.js",
"diff": "@@ -26,6 +26,7 @@ import { threadIsGroupChat } from '../thread-utils';\nimport { stringForUser } from '../user-utils';\nimport { hasMinCodeVersion } from '../version-utils';\nimport type { MessageSpec } from './message-spec';\n+import { joinResult } from './utils';\nexport const multimediaMessageSpec: MessageSpec<\nMediaMessageData | ImagesMessageData,\n@@ -168,6 +169,15 @@ export const multimediaMessageSpec: MessageSpec<\nprefix: userString,\n};\n},\n+\n+ notificationCollapseKey(rawMessageInfo) {\n+ // We use the legacy constant here to collapse both types into one\n+ return joinResult(\n+ messageTypes.IMAGES,\n+ rawMessageInfo.threadID,\n+ rawMessageInfo.creatorID,\n+ );\n+ },\n});\nfunction shimMediaMessageInfo(\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/remove-members-message-spec.js",
"new_path": "lib/shared/messages/remove-members-message-spec.js",
"diff": "@@ -10,6 +10,7 @@ import type {\n} from '../../types/message/remove-members';\nimport { values } from '../../utils/objects';\nimport type { MessageSpec } from './message-spec';\n+import { joinResult } from './utils';\nexport const removeMembersMessageSpec: MessageSpec<\nRemoveMembersMessageData,\n@@ -87,4 +88,12 @@ export const removeMembersMessageSpec: MessageSpec<\nbody: robotext,\n};\n},\n+\n+ notificationCollapseKey(rawMessageInfo) {\n+ return joinResult(\n+ rawMessageInfo.type,\n+ rawMessageInfo.threadID,\n+ rawMessageInfo.creatorID,\n+ );\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/utils.js",
"new_path": "lib/shared/messages/utils.js",
"diff": "@@ -16,3 +16,6 @@ export function assertSingleMessageInfo(\n}\nreturn messageInfos[0];\n}\n+\n+export const joinResult = (...keys: $ReadOnlyArray<string | number>) =>\n+ keys.join('|');\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/notif-utils.js",
"new_path": "lib/shared/notif-utils.js",
"diff": "@@ -7,7 +7,6 @@ import {\ntype RawMessageInfo,\ntype RobotextMessageInfo,\ntype MessageType,\n- messageTypes,\n} from '../types/message-types';\nimport type { NotifTexts } from '../types/notif-types';\nimport type { ThreadInfo, ThreadType } from '../types/thread-types';\n@@ -111,56 +110,11 @@ function strippedRobotextForMessageInfo(\nreturn robotextToRawString(threadMadeExplicit);\n}\n-const joinResult = (...keys: (string | number)[]) => keys.join('|');\nfunction notifCollapseKeyForRawMessageInfo(\nrawMessageInfo: RawMessageInfo,\n): ?string {\n- if (\n- rawMessageInfo.type === messageTypes.ADD_MEMBERS ||\n- rawMessageInfo.type === messageTypes.REMOVE_MEMBERS\n- ) {\n- return joinResult(\n- rawMessageInfo.type,\n- rawMessageInfo.threadID,\n- rawMessageInfo.creatorID,\n- );\n- } else if (\n- rawMessageInfo.type === messageTypes.IMAGES ||\n- rawMessageInfo.type === messageTypes.MULTIMEDIA\n- ) {\n- // We use the legacy constant here to collapse both types into one\n- return joinResult(\n- messageTypes.IMAGES,\n- rawMessageInfo.threadID,\n- rawMessageInfo.creatorID,\n- );\n- } else if (rawMessageInfo.type === messageTypes.CHANGE_SETTINGS) {\n- return joinResult(\n- rawMessageInfo.type,\n- rawMessageInfo.threadID,\n- rawMessageInfo.creatorID,\n- rawMessageInfo.field,\n- );\n- } else if (rawMessageInfo.type === messageTypes.CHANGE_ROLE) {\n- return joinResult(\n- rawMessageInfo.type,\n- rawMessageInfo.threadID,\n- rawMessageInfo.creatorID,\n- rawMessageInfo.newRole,\n- );\n- } else if (\n- rawMessageInfo.type === messageTypes.JOIN_THREAD ||\n- rawMessageInfo.type === messageTypes.LEAVE_THREAD\n- ) {\n- return joinResult(rawMessageInfo.type, rawMessageInfo.threadID);\n- } else if (\n- rawMessageInfo.type === messageTypes.CREATE_ENTRY ||\n- rawMessageInfo.type === messageTypes.EDIT_ENTRY\n- ) {\n- return joinResult(rawMessageInfo.creatorID, rawMessageInfo.entryID);\n- } else {\n- return null;\n- }\n+ const messageSpec = messageSpecs[rawMessageInfo.type];\n+ return messageSpec.notificationCollapseKey?.(rawMessageInfo) ?? null;\n}\ntype Unmerged = $ReadOnly<{\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use message specs when creating notification collapse key
Test Plan: Flow. Again, testing notifs is hard.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D645 |
129,191 | 22.01.2021 15:38:44 | -3,600 | fef18b10d35f948547ce43ada672f553fa6afa2f | [lib] Use message specs to get a list of referenced users
Test Plan: Flow.
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/add-members-message-spec.js",
"new_path": "lib/shared/messages/add-members-message-spec.js",
"diff": "@@ -98,4 +98,8 @@ export const addMembersMessageSpec: MessageSpec<\n},\ngeneratesNotifs: false,\n+\n+ userIDs(rawMessageInfo) {\n+ return rawMessageInfo.addedUserIDs;\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sidebar-message-spec.js",
"new_path": "lib/shared/messages/create-sidebar-message-spec.js",
"diff": "@@ -134,4 +134,8 @@ export const createSidebarMessageSpec: MessageSpec<\n},\ngeneratesNotifs: true,\n+\n+ userIDs(rawMessageInfo) {\n+ return rawMessageInfo.initialThreadState.memberIDs;\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-thread-message-spec.js",
"new_path": "lib/shared/messages/create-thread-message-spec.js",
"diff": "@@ -118,4 +118,8 @@ export const createThreadMessageSpec: MessageSpec<\n},\ngeneratesNotifs: true,\n+\n+ userIDs(rawMessageInfo) {\n+ return rawMessageInfo.initialThreadState.memberIDs;\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/message-spec.js",
"new_path": "lib/shared/messages/message-spec.js",
"diff": "@@ -77,4 +77,5 @@ export type MessageSpec<Data, RawInfo, Info> = {|\n) => NotifTexts,\n+notificationCollapseKey?: (rawMessageInfo: RawInfo) => ?string,\n+generatesNotifs: boolean,\n+ +userIDs?: (rawMessageInfo: RawInfo) => $ReadOnlyArray<string>,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/remove-members-message-spec.js",
"new_path": "lib/shared/messages/remove-members-message-spec.js",
"diff": "@@ -98,4 +98,8 @@ export const removeMembersMessageSpec: MessageSpec<\n},\ngeneratesNotifs: false,\n+\n+ userIDs(rawMessageInfo) {\n+ return rawMessageInfo.removedUserIDs;\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/push/send.js",
"new_path": "server/src/push/send.js",
"diff": "@@ -13,6 +13,7 @@ import {\nsortMessageInfoList,\nshimUnsupportedRawMessageInfos,\n} from 'lib/shared/message-utils';\n+import { messageSpecs } from 'lib/shared/messages/message-specs';\nimport { notifTextsForMessageInfo } from 'lib/shared/notif-utils';\nimport {\nrawThreadInfoFromServerThreadInfo,\n@@ -405,22 +406,11 @@ async function fetchNotifUserInfos(\nconst addUserIDsFromMessageInfos = (rawMessageInfo: RawMessageInfo) => {\nmissingUserIDs.add(rawMessageInfo.creatorID);\n- if (rawMessageInfo.type === messageTypes.ADD_MEMBERS) {\n- for (const userID of rawMessageInfo.addedUserIDs) {\n+ const userIDs =\n+ messageSpecs[rawMessageInfo.type].userIDs?.(rawMessageInfo) ?? [];\n+ for (const userID of userIDs) {\nmissingUserIDs.add(userID);\n}\n- } else if (rawMessageInfo.type === messageTypes.REMOVE_MEMBERS) {\n- for (const userID of rawMessageInfo.removedUserIDs) {\n- missingUserIDs.add(userID);\n- }\n- } else if (\n- rawMessageInfo.type === messageTypes.CREATE_THREAD ||\n- rawMessageInfo.type === messageTypes.CREATE_SIDEBAR\n- ) {\n- for (const userID of rawMessageInfo.initialThreadState.memberIDs) {\n- missingUserIDs.add(userID);\n- }\n- }\n};\nfor (const userID in usersToCollapsableNotifInfo) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use message specs to get a list of referenced users
Test Plan: Flow.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D647 |
129,191 | 25.01.2021 12:10:40 | -3,600 | 40ca72d3408825e4949fc2c6aac47e606ef92c50 | [lib] Use rawMessageInfoFromMessageData in createMediaMessageInfo function
Test Plan: Flow. Log out, log in, check messages
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -304,23 +304,8 @@ function createMediaMessageInfo(\ninput: MediaMessageInfoCreationInput,\n): RawMultimediaMessageInfo {\nconst messageData = createMediaMessageData(input);\n- // This conditional is for Flow\n- let rawMessageInfo;\n- if (messageData.type === messageTypes.IMAGES) {\n- rawMessageInfo = ({\n- ...messageData,\n- type: messageTypes.IMAGES,\n- }: RawImagesMessageInfo);\n- } else {\n- rawMessageInfo = ({\n- ...messageData,\n- type: messageTypes.MULTIMEDIA,\n- }: RawMediaMessageInfo);\n- }\n- if (input.id) {\n- rawMessageInfo.id = input.id;\n- }\n- return rawMessageInfo;\n+ const messageSpec = messageSpecs[messageData.type];\n+ return messageSpec.rawMessageInfoFromMessageData(messageData, input.id);\n}\nfunction stripLocalIDs(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use rawMessageInfoFromMessageData in createMediaMessageInfo function
Test Plan: Flow. Log out, log in, check messages
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D651 |
129,191 | 25.01.2021 12:50:28 | -3,600 | 4d081fc7c92ef297042a07bcadeaf62aa56b1f31 | [lib] Remove message type switch from stripLocalIDs function
Test Plan: Created new text message and console logged the result of stripLocalIDs function
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -20,15 +20,10 @@ import {\ntype MessageStore,\nmessageTypes,\nmessageTruncationStatus,\n+ type RawComposableMessageInfo,\n} from '../types/message-types';\n-import type {\n- ImagesMessageData,\n- RawImagesMessageInfo,\n-} from '../types/message/images';\n-import type {\n- MediaMessageData,\n- RawMediaMessageInfo,\n-} from '../types/message/media';\n+import type { ImagesMessageData } from '../types/message/images';\n+import type { MediaMessageData } from '../types/message/media';\nimport { type ThreadInfo } from '../types/thread-types';\nimport type { RelativeUserInfo, UserInfos } from '../types/user-types';\nimport { codeBlockRegex } from './markdown';\n@@ -308,37 +303,24 @@ function createMediaMessageInfo(\nreturn messageSpec.rawMessageInfoFromMessageData(messageData, input.id);\n}\n+function stripLocalID(rawMessageInfo: RawComposableMessageInfo) {\n+ const { localID, ...rest } = rawMessageInfo;\n+ return rest;\n+}\n+\nfunction stripLocalIDs(\ninput: $ReadOnlyArray<RawMessageInfo>,\n): RawMessageInfo[] {\nconst output = [];\n- for (let rawMessageInfo of input) {\n- if (\n- rawMessageInfo.localID === null ||\n- rawMessageInfo.localID === undefined\n- ) {\n- output.push(rawMessageInfo);\n- continue;\n- }\n+ for (const rawMessageInfo of input) {\n+ if (rawMessageInfo.localID) {\ninvariant(\nrawMessageInfo.id,\n'serverID should be set if localID is being stripped',\n);\n- if (rawMessageInfo.type === messageTypes.TEXT) {\n- const { localID, ...rest } = rawMessageInfo;\n- output.push({ ...rest });\n- } else if (rawMessageInfo.type === messageTypes.IMAGES) {\n- const { localID, ...rest } = rawMessageInfo;\n- output.push(({ ...rest }: RawImagesMessageInfo));\n- } else if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n- const { localID, ...rest } = rawMessageInfo;\n- output.push(({ ...rest }: RawMediaMessageInfo));\n+ output.push(stripLocalID(rawMessageInfo));\n} else {\n- invariant(\n- false,\n- `message ${rawMessageInfo.id} of type ${rawMessageInfo.type} ` +\n- `unexpectedly has localID`,\n- );\n+ output.push(rawMessageInfo);\n}\n}\nreturn output;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Remove message type switch from stripLocalIDs function
Test Plan: Created new text message and console logged the result of stripLocalIDs function
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D652 |
129,183 | 14.01.2021 13:25:58 | -3,600 | e6d0fbbdafdebd45810b6bc386d8e52e748ff112 | Extract createPendingSidebar function
Summary: createPendingSidebar will be used in other tooltips
Test Plan: Flow, make sure creating sidebars from text messages still works
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -10,6 +10,7 @@ import {\nmakePermissionsBlob,\n} from '../permissions/thread-permissions';\nimport type { ChatThreadItem } from '../selectors/chat-selectors';\n+import type { TextMessageInfo } from '../types/message/text';\nimport { userRelationshipStatus } from '../types/relationship-types';\nimport {\ntype RawThreadInfo,\n@@ -302,6 +303,26 @@ function createPendingThreadItem(\n};\n}\n+function createPendingSidebar(\n+ messageInfo: TextMessageInfo,\n+ threadInfo: ThreadInfo,\n+ viewerID: string,\n+) {\n+ const { id, username } = messageInfo.creator;\n+ const { id: parentThreadID, color } = threadInfo;\n+\n+ invariant(username, 'username should be set in createPendingSidebar');\n+ const initialMemberUserInfo: GlobalAccountUserInfo = { id, username };\n+\n+ return createPendingThread(\n+ viewerID,\n+ threadTypes.SIDEBAR,\n+ [initialMemberUserInfo],\n+ parentThreadID,\n+ color,\n+ );\n+}\n+\nfunction pendingThreadType(numberOfOtherMembers: number) {\nreturn numberOfOtherMembers === 1\n? threadTypes.PERSONAL\n@@ -681,6 +702,7 @@ export {\ngetPendingThreadKey,\ncreatePendingThread,\ncreatePendingThreadItem,\n+ createPendingSidebar,\npendingThreadType,\ngetCurrentUser,\nthreadFrozenDueToBlock,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message-tooltip-modal.react.js",
"new_path": "native/chat/text-message-tooltip-modal.react.js",
"diff": "@@ -4,9 +4,7 @@ import Clipboard from '@react-native-community/clipboard';\nimport invariant from 'invariant';\nimport { createMessageReply } from 'lib/shared/message-utils';\n-import { createPendingThread } from 'lib/shared/thread-utils';\n-import { threadTypes } from 'lib/types/thread-types';\n-import type { GlobalAccountUserInfo } from 'lib/types/user-types';\n+import { createPendingSidebar } from 'lib/shared/thread-utils';\nimport type {\nDispatchFunctions,\nActionFunc,\n@@ -62,32 +60,13 @@ function onPressCreateSidebar(\nviewerID,\n'viewerID should be set in TextMessageTooltipModal.onPressCreateSidebar',\n);\n- createSidebar(route, navigation, viewerID);\n-}\n-\n-function createSidebar(\n- route: TooltipRoute<'TextMessageTooltipModal'>,\n- navigation: AppNavigationProp<'TextMessageTooltipModal'>,\n- viewerID: string,\n-) {\nconst { messageInfo, threadInfo } = route.params.item;\n- const { id, username } = messageInfo.creator;\n- const sourceMessageID = messageInfo.id;\n- const { id: parentThreadID, color } = threadInfo;\n-\n- invariant(\n- username,\n- 'username should be set in TextMessageTooltipModal.createSidebar',\n- );\n- const initialMemberUserInfo: GlobalAccountUserInfo = { id, username };\n-\n- const pendingSidebarInfo = createPendingThread(\n+ const pendingSidebarInfo = createPendingSidebar(\n+ messageInfo,\n+ threadInfo,\nviewerID,\n- threadTypes.SIDEBAR,\n- [initialMemberUserInfo],\n- parentThreadID,\n- color,\n);\n+ const sourceMessageID = messageInfo.id;\nnavigation.navigate({\nname: MessageListRouteName,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Extract createPendingSidebar function
Summary: createPendingSidebar will be used in other tooltips
Test Plan: Flow, make sure creating sidebars from text messages still works
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D601 |
129,183 | 14.01.2021 13:31:09 | -3,600 | 306ad4eb0427fd67715e279ddfe0d5dfee398ebf | Add option to create sidebar for multimedia message
Test Plan: Check if tooltip have new button, if sidebars are created with correct multimedia message as source and if the message is displayed correctly
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -10,6 +10,7 @@ import {\nmakePermissionsBlob,\n} from '../permissions/thread-permissions';\nimport type { ChatThreadItem } from '../selectors/chat-selectors';\n+import type { MultimediaMessageInfo } from '../types/message-types';\nimport type { TextMessageInfo } from '../types/message/text';\nimport { userRelationshipStatus } from '../types/relationship-types';\nimport {\n@@ -304,7 +305,7 @@ function createPendingThreadItem(\n}\nfunction createPendingSidebar(\n- messageInfo: TextMessageInfo,\n+ messageInfo: TextMessageInfo | MultimediaMessageInfo,\nthreadInfo: ThreadInfo,\nviewerID: string,\n) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message-multimedia.react.js",
"new_path": "native/chat/multimedia-message-multimedia.react.js",
"diff": "@@ -6,7 +6,9 @@ import { View, StyleSheet } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport { messageKey } from 'lib/shared/message-utils';\n+import { threadHasPermission } from 'lib/shared/thread-utils';\nimport { type MediaInfo } from 'lib/types/media-types';\n+import { threadPermissions } from 'lib/types/thread-types';\nimport { type PendingMultimediaUpload } from '../input/input-state';\nimport {\n@@ -205,6 +207,20 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n});\n};\n+ visibleEntryIDs() {\n+ const result = ['save'];\n+\n+ const canCreateSidebars = threadHasPermission(\n+ this.props.item.threadInfo,\n+ threadPermissions.CREATE_SIDEBARS,\n+ );\n+ if (canCreateSidebars) {\n+ result.push('sidebar');\n+ }\n+\n+ return result;\n+ }\n+\nonLongPress = () => {\nif (this.dismissKeyboardIfShowing()) {\nreturn;\n@@ -275,6 +291,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nverticalBounds,\nlocation,\nmargin,\n+ visibleEntryIDs: this.visibleEntryIDs(),\n},\n});\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-tooltip-modal.react.js",
"new_path": "native/chat/multimedia-tooltip-modal.react.js",
"diff": "// @flow\n+import invariant from 'invariant';\n+\n+import { createPendingSidebar } from 'lib/shared/thread-utils';\nimport type { MediaInfo } from 'lib/types/media-types';\n+import type {\n+ DispatchFunctions,\n+ ActionFunc,\n+ BoundServerCall,\n+} from 'lib/utils/action-utils';\n+import type { InputState } from '../input/input-state';\nimport { intentionalSaveMedia } from '../media/save-media';\n+import type { AppNavigationProp } from '../navigation/app-navigator.react';\n+import { MessageListRouteName } from '../navigation/route-names';\nimport {\ncreateTooltip,\ntooltipHeight,\n@@ -26,8 +37,41 @@ function onPressSave(route: TooltipRoute<'MultimediaTooltipModal'>) {\nreturn intentionalSaveMedia(uri, ids);\n}\n+function onPressCreateSidebar(\n+ route: TooltipRoute<'MultimediaTooltipModal'>,\n+ dispatchFunctions: DispatchFunctions,\n+ bindServerCall: (serverCall: ActionFunc) => BoundServerCall,\n+ inputState: ?InputState,\n+ navigation: AppNavigationProp<'MultimediaTooltipModal'>,\n+ viewerID: ?string,\n+) {\n+ invariant(\n+ viewerID,\n+ 'viewerID should be set in MultimediaTooltipModal.onPressCreateSidebar',\n+ );\n+ const { messageInfo, threadInfo } = route.params.item;\n+ const pendingSidebarInfo = createPendingSidebar(\n+ messageInfo,\n+ threadInfo,\n+ viewerID,\n+ );\n+ const initialMessageID = messageInfo.id;\n+\n+ navigation.navigate({\n+ name: MessageListRouteName,\n+ params: {\n+ threadInfo: pendingSidebarInfo,\n+ sidebarSourceMessageID: initialMessageID,\n+ },\n+ key: `${MessageListRouteName}${pendingSidebarInfo.id}`,\n+ });\n+}\n+\nconst spec = {\n- entries: [{ id: 'save', text: 'Save', onPress: onPressSave }],\n+ entries: [\n+ { id: 'save', text: 'Save', onPress: onPressSave },\n+ { id: 'sidebar', text: 'Create sidebar', onPress: onPressCreateSidebar },\n+ ],\n};\nconst MultimediaTooltipModal = createTooltip<'MultimediaTooltipModal'>(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add option to create sidebar for multimedia message
Test Plan: Check if tooltip have new button, if sidebars are created with correct multimedia message as source and if the message is displayed correctly
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D602 |
129,183 | 20.01.2021 12:18:58 | -3,600 | a8a5ccb4062dba530386e34521b35dbce257aaa0 | Use relationshipBlockedInEitherDirection function
Test Plan: Flow, make sure everything works as before
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -38,6 +38,7 @@ import type {\nUserInfos,\n} from '../types/user-types';\nimport { pluralize } from '../utils/text-utils';\n+import { relationshipBlockedInEitherDirection } from './relationship-utils';\nfunction colorIsDark(color: string) {\nreturn tinycolor(`#${color}`).isDark();\n@@ -518,9 +519,8 @@ function threadIsWithBlockedUserOnly(\n}\nreturn (\n- otherUserRelationshipStatus === userRelationshipStatus.BLOCKED_BY_VIEWER ||\n- otherUserRelationshipStatus === userRelationshipStatus.BLOCKED_VIEWER ||\n- otherUserRelationshipStatus === userRelationshipStatus.BOTH_BLOCKED\n+ !!otherUserRelationshipStatus &&\n+ relationshipBlockedInEitherDirection(otherUserRelationshipStatus)\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/thread-creator.js",
"new_path": "server/src/creators/thread-creator.js",
"diff": "import invariant from 'invariant';\n+import { relationshipBlockedInEitherDirection } from 'lib/shared/relationship-utils';\nimport {\ngeneratePendingThreadColor,\ngenerateRandomColor,\n@@ -147,9 +148,8 @@ async function createThread(\n) {\ncontinue;\n} else if (\n- relationshipStatus === userRelationshipStatus.BLOCKED_BY_VIEWER ||\n- relationshipStatus === userRelationshipStatus.BLOCKED_VIEWER ||\n- relationshipStatus === userRelationshipStatus.BOTH_BLOCKED\n+ relationshipStatus &&\n+ relationshipBlockedInEitherDirection(relationshipStatus)\n) {\nthrow new ServerError('invalid_credentials');\n} else if (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Use relationshipBlockedInEitherDirection function
Test Plan: Flow, make sure everything works as before
Reviewers: ashoat, palys-swm
Reviewed By: ashoat
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D633 |
129,191 | 25.01.2021 13:04:24 | -3,600 | b9202ead6d2e9695c66f5cbeab8d9ec5f2233652 | [lib] Use message spec when determining truncation status
Test Plan: Log out, log in, using console log check if the right truncation status is set for the messages
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-thread-message-spec.js",
"new_path": "lib/shared/messages/create-thread-message-spec.js",
"diff": "@@ -122,4 +122,6 @@ export const createThreadMessageSpec: MessageSpec<\nuserIDs(rawMessageInfo) {\nreturn rawMessageInfo.initialThreadState.memberIDs;\n},\n+\n+ startsThread: true,\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/message-spec.js",
"new_path": "lib/shared/messages/message-spec.js",
"diff": "@@ -78,4 +78,5 @@ export type MessageSpec<Data, RawInfo, Info> = {|\n+notificationCollapseKey?: (rawMessageInfo: RawInfo) => ?string,\n+generatesNotifs: boolean,\n+userIDs?: (rawMessageInfo: RawInfo) => $ReadOnlyArray<string>,\n+ +startsThread?: boolean,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/sidebar-source-message-spec.js",
"new_path": "lib/shared/messages/sidebar-source-message-spec.js",
"diff": "@@ -105,4 +105,6 @@ export const sidebarSourceMessageSpec: MessageSpec<\n},\ngeneratesNotifs: false,\n+\n+ startsThread: true,\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/message-fetchers.js",
"new_path": "server/src/fetchers/message-fetchers.js",
"diff": "@@ -279,7 +279,7 @@ async function fetchMessageInfos(\nconst rawMessageInfos = [];\nconst threadToMessageCount = new Map();\n- for (let message of messages) {\n+ for (const message of messages) {\nconst { rawMessageInfo } = message;\nrawMessageInfos.push(rawMessageInfo);\nconst { threadID } = rawMessageInfo;\n@@ -288,7 +288,7 @@ async function fetchMessageInfos(\nthreadToMessageCount.set(threadID, currentCount + 1);\n}\n- for (let [threadID, messageCount] of threadToMessageCount) {\n+ for (const [threadID, messageCount] of threadToMessageCount) {\n// If there are fewer messages returned than the max for a given thread,\n// then our result set includes all messages in the query range for that\n// thread\n@@ -298,20 +298,14 @@ async function fetchMessageInfos(\n: messageTruncationStatus.TRUNCATED;\n}\n- for (let rawMessageInfo of rawMessageInfos) {\n- if (\n- rawMessageInfo.type === messageTypes.CREATE_THREAD ||\n- rawMessageInfo.type === messageTypes.SIDEBAR_SOURCE\n- ) {\n- // If a CREATE_THREAD or SIDEBAR_SOURCE message for a given thread is in\n- // the result set, then our result set includes all messages in the query\n- // range for that thread\n+ for (const rawMessageInfo of rawMessageInfos) {\n+ if (messageSpecs[rawMessageInfo.type].startsThread) {\ntruncationStatuses[rawMessageInfo.threadID] =\nmessageTruncationStatus.EXHAUSTIVE;\n}\n}\n- for (let threadID in criteria.threadCursors) {\n+ for (const threadID in criteria.threadCursors) {\nconst truncationStatus = truncationStatuses[threadID];\nif (truncationStatus === null || truncationStatus === undefined) {\n// If nothing was returned for a thread that was explicitly queried for,\n@@ -410,7 +404,7 @@ async function fetchMessageInfosSince(\nconst rawMessageInfos = [];\nlet currentThreadID = null;\nlet numMessagesForCurrentThreadID = 0;\n- for (let message of messages) {\n+ for (const message of messages) {\nconst { rawMessageInfo } = message;\nconst { threadID } = rawMessageInfo;\nif (threadID !== currentThreadID) {\n@@ -421,12 +415,7 @@ async function fetchMessageInfosSince(\nnumMessagesForCurrentThreadID++;\n}\nif (numMessagesForCurrentThreadID <= maxNumberPerThread) {\n- if (\n- rawMessageInfo.type === messageTypes.CREATE_THREAD ||\n- rawMessageInfo.type === messageTypes.SIDEBAR_SOURCE\n- ) {\n- // If a CREATE_THREAD or SIDEBAR_SOURCE message is here, then we have\n- // all messages\n+ if (messageSpecs[rawMessageInfo.type].startsThread) {\ntruncationStatuses[threadID] = messageTruncationStatus.EXHAUSTIVE;\n}\nrawMessageInfos.push(rawMessageInfo);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use message spec when determining truncation status
Test Plan: Log out, log in, using console log check if the right truncation status is set for the messages
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D654 |
129,191 | 25.01.2021 14:19:56 | -3,600 | 15c74210f6cb41927dd27ec6bc52243b5605ea64 | [lib] Use message spec to return a list of thread ids
Test Plan: Console log in fetchInfos to check if thread id was added when creating a subthread
Reviewers: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sidebar-message-spec.js",
"new_path": "lib/shared/messages/create-sidebar-message-spec.js",
"diff": "@@ -138,4 +138,9 @@ export const createSidebarMessageSpec: MessageSpec<\nuserIDs(rawMessageInfo) {\nreturn rawMessageInfo.initialThreadState.memberIDs;\n},\n+\n+ threadIDs(rawMessageInfo) {\n+ const { parentThreadID } = rawMessageInfo.initialThreadState;\n+ return [parentThreadID];\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-sub-thread-message-spec.js",
"new_path": "lib/shared/messages/create-sub-thread-message-spec.js",
"diff": "@@ -92,4 +92,8 @@ export const createSubThreadMessageSpec: MessageSpec<\n},\ngeneratesNotifs: true,\n+\n+ threadIDs(rawMessageInfo) {\n+ return [rawMessageInfo.childThreadID];\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/create-thread-message-spec.js",
"new_path": "lib/shared/messages/create-thread-message-spec.js",
"diff": "@@ -124,4 +124,9 @@ export const createThreadMessageSpec: MessageSpec<\n},\nstartsThread: true,\n+\n+ threadIDs(rawMessageInfo) {\n+ const { parentThreadID } = rawMessageInfo.initialThreadState;\n+ return parentThreadID ? [parentThreadID] : [];\n+ },\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/messages/message-spec.js",
"new_path": "lib/shared/messages/message-spec.js",
"diff": "@@ -79,4 +79,5 @@ export type MessageSpec<Data, RawInfo, Info> = {|\n+generatesNotifs: boolean,\n+userIDs?: (rawMessageInfo: RawInfo) => $ReadOnlyArray<string>,\n+startsThread?: boolean,\n+ +threadIDs?: (rawMessageInfo: RawInfo) => $ReadOnlyArray<string>,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/push/send.js",
"new_path": "server/src/push/send.js",
"diff": "@@ -304,14 +304,11 @@ async function fetchInfos(pushInfo: PushInfo) {\nconst addThreadIDsFromMessageInfos = (rawMessageInfo: RawMessageInfo) => {\nconst threadID = rawMessageInfo.threadID;\nthreadIDs.add(threadID);\n- if (\n- (rawMessageInfo.type === messageTypes.CREATE_THREAD ||\n- rawMessageInfo.type === messageTypes.CREATE_SIDEBAR) &&\n- rawMessageInfo.initialThreadState.parentThreadID\n- ) {\n- threadIDs.add(rawMessageInfo.initialThreadState.parentThreadID);\n- } else if (rawMessageInfo.type === messageTypes.CREATE_SUB_THREAD) {\n- threadIDs.add(rawMessageInfo.childThreadID);\n+ const messageSpec = messageSpecs[rawMessageInfo.type];\n+ if (messageSpec.threadIDs) {\n+ for (const id of messageSpec.threadIDs(rawMessageInfo)) {\n+ threadIDs.add(id);\n+ }\n}\nif (\nrawMessageInfo.type === messageTypes.CHANGE_SETTINGS &&\n@@ -325,12 +322,12 @@ async function fetchInfos(pushInfo: PushInfo) {\n}\n}\n};\n- for (let userID in usersToCollapsableNotifInfo) {\n- for (let notifInfo of usersToCollapsableNotifInfo[userID]) {\n- for (let rawMessageInfo of notifInfo.existingMessageInfos) {\n+ for (const userID in usersToCollapsableNotifInfo) {\n+ for (const notifInfo of usersToCollapsableNotifInfo[userID]) {\n+ for (const rawMessageInfo of notifInfo.existingMessageInfos) {\naddThreadIDsFromMessageInfos(rawMessageInfo);\n}\n- for (let rawMessageInfo of notifInfo.newMessageInfos) {\n+ for (const rawMessageInfo of notifInfo.newMessageInfos) {\naddThreadIDsFromMessageInfos(rawMessageInfo);\n}\n}\n@@ -359,7 +356,7 @@ async function fetchInfos(pushInfo: PushInfo) {\nAND JSON_EXTRACT(content, \"$.name\") IS NOT NULL\nAND`;\nconst threadClauses = [];\n- for (let [threadID, messages] of threadWithChangedNamesToMessages) {\n+ for (const [threadID, messages] of threadWithChangedNamesToMessages) {\nthreadClauses.push(\nSQL`(thread = ${threadID} AND id NOT IN (${messages}))`,\n);\n@@ -377,7 +374,7 @@ async function fetchInfos(pushInfo: PushInfo) {\nconst serverThreadInfos = threadResult.threadInfos;\nif (oldNames) {\nconst [result] = oldNames;\n- for (let row of result) {\n+ for (const row of result) {\nconst threadID = row.thread.toString();\nserverThreadInfos[threadID].name = row.name;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use message spec to return a list of thread ids
Test Plan: Console log in fetchInfos to check if thread id was added when creating a subthread
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D655 |
129,187 | 26.01.2021 13:01:42 | 18,000 | f8775a40c9e5310396105a77a15c8b09b7a617b7 | [web] Fix minor typo in web SidebarListModal
Test Plan: Flow
Reviewers: KatPo, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "web/modals/chat/sidebar-list-modal.react.js",
"new_path": "web/modals/chat/sidebar-list-modal.react.js",
"diff": "@@ -21,7 +21,7 @@ type Props = {|\n+setModal: (modal: ?React.Node) => void,\n+threadInfo: ThreadInfo,\n|};\n-function SidebarsListModal(props: Props) {\n+function SidebarListModal(props: Props) {\nconst { setModal, threadInfo } = props;\nconst [searchState, setSearchState] = React.useState({\ntext: '',\n@@ -139,4 +139,4 @@ function SidebarsListModal(props: Props) {\n);\n}\n-export default SidebarsListModal;\n+export default SidebarListModal;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Fix minor typo in web SidebarListModal
Test Plan: Flow
Reviewers: KatPo, palys-swm
Reviewed By: KatPo
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D657 |
129,183 | 27.01.2021 08:54:48 | -3,600 | 598944f19e79ce1458f8cb09e9517551bd1aead9 | [lib] Create function to determine thread label from thread type
Test Plan: Flow, tested with next diffs
Reviewers: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -684,6 +684,21 @@ function threadNoun(threadType: ThreadType) {\nreturn threadType === threadTypes.SIDEBAR ? 'sidebar' : 'thread';\n}\n+function threadLabel(threadType: ThreadType) {\n+ if (threadType === threadTypes.CHAT_SECRET) {\n+ return 'Secret';\n+ } else if (threadType === threadTypes.PERSONAL) {\n+ return 'Personal';\n+ } else if (threadType === threadTypes.SIDEBAR) {\n+ return 'Sidebar';\n+ } else if (threadType === threadTypes.PRIVATE) {\n+ return 'Private';\n+ } else if (threadType === threadTypes.CHAT_NESTED_OPEN) {\n+ return 'Open';\n+ }\n+ invariant(false, `unexpected threadType ${threadType}`);\n+}\n+\nexport {\ncolorIsDark,\ngenerateRandomColor,\n@@ -726,4 +741,5 @@ export {\nemptyItemText,\nthreadSearchText,\nthreadNoun,\n+ threadLabel,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Create function to determine thread label from thread type
Test Plan: Flow, tested with next diffs
Reviewers: ashoat, palys-swm
Reviewed By: ashoat, palys-swm
Subscribers: zrebcu411, Adrian, atul, subnub
Differential Revision: https://phabricator.ashoat.com/D658 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.