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,184 | 04.06.2021 16:45:02 | 14,400 | bf662af826c7e0abbc08b06dcd9e71cb8a725d02 | [native] Use `pill` component in `thread-ancestors`
Test Plan: Continues to look/work as expected
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/components/thread-ancestors.react.js",
"new_path": "native/components/thread-ancestors.react.js",
"diff": "// @flow\nimport * as React from 'react';\n-import { Text, View, ScrollView } from 'react-native';\n+import { View, ScrollView } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome5';\nimport { memberHasAdminPowers } from 'lib/shared/thread-utils';\nimport { type ThreadInfo, type MemberInfo } from 'lib/types/thread-types';\nimport { useSelector } from '../redux/redux-utils';\n-import { useStyles } from '../themes/colors';\n+import { useStyles, useColors } from '../themes/colors';\n+import Pill from './pill.react';\ntype Props = {|\n+ancestorThreads: $ReadOnlyArray<ThreadInfo>,\n|};\n-function ThreadAncestors(props: Props) {\n+function ThreadAncestors(props: Props): React.Node {\nconst { ancestorThreads } = props;\nconst styles = useStyles(unboundStyles);\n+ const colors = useColors();\nconst userInfos = useSelector((state) => state.userStore.userInfos);\nconst parentAdmin: ?string = React.useMemo(() => {\n@@ -27,80 +29,64 @@ function ThreadAncestors(props: Props) {\n}\n}, [ancestorThreads, userInfos]);\n- const pathElements = [];\n- for (const [idx, threadInfo] of ancestorThreads.entries()) {\n- if (idx === ancestorThreads.length - 1) {\n- pathElements.push(\n- <View key={threadInfo.id} style={styles.pathItem}>\n- <Text style={styles.pathLabel}>{threadInfo.uiName}</Text>\n- </View>,\n+ const adminLabel: ?React.Node = React.useMemo(() => {\n+ if (!parentAdmin) {\n+ return undefined;\n+ }\n+ return (\n+ <Pill\n+ backgroundColor={colors.codeBackground}\n+ roundCorners={{ left: true, right: false }}\n+ label={parentAdmin}\n+ faIcon=\"cloud\"\n+ />\n);\n- } else {\n- pathElements.push(\n- <View key={threadInfo.id} style={styles.pathItem}>\n- <Text style={styles.pathLabel}>{threadInfo.uiName}</Text>\n+ }, [colors.codeBackground, parentAdmin]);\n+\n+ const rightArrow: React.Node = React.useMemo(\n+ () => (\n<Icon\nname=\"chevron-right\"\nsize={12}\ncolor=\"white\"\nstyle={styles.arrowIcon}\n/>\n- </View>,\n+ ),\n+ [styles.arrowIcon],\n);\n- }\n- }\n- let adminLabel;\n- if (parentAdmin) {\n- adminLabel = (\n- <View style={styles.adminBadge}>\n- <Icon name=\"cloud\" size={12} color=\"white\" style={styles.cloudIcon} />\n- <Text style={styles.adminName}>{parentAdmin}</Text>\n- </View>\n+ const pathElements = [];\n+ for (const [idx, threadInfo] of ancestorThreads.entries()) {\n+ const isLastThread = idx === ancestorThreads.length - 1;\n+ const backgroundColor = `#${threadInfo.color}`;\n+\n+ pathElements.push(\n+ <View key={threadInfo.id} style={styles.pathItem}>\n+ {idx === 0 ? adminLabel : null}\n+ <Pill\n+ backgroundColor={backgroundColor}\n+ roundCorners={{ left: !(idx === 0), right: true }}\n+ label={threadInfo.uiName}\n+ />\n+ {!isLastThread ? rightArrow : null}\n+ </View>,\n);\n}\n-\nreturn (\n<ScrollView horizontal={true}>\n- <View style={styles.pathItem}>\n- {adminLabel}\n- {pathElements}\n- </View>\n+ <View style={styles.pathItem}>{pathElements}</View>\n</ScrollView>\n);\n}\nconst unboundStyles = {\n- adminBadge: {\n- fontSize: 16,\n- flexDirection: 'row',\n- alignItems: 'center',\n- backgroundColor: 'codeBackground',\n- paddingHorizontal: 8,\n- paddingVertical: 4,\n- borderRadius: 8,\n- },\n- adminName: {\n- fontSize: 16,\n- fontWeight: 'bold',\n- color: 'panelForegroundLabel',\n- },\npathItem: {\nflexDirection: 'row',\nalignItems: 'center',\nheight: 40,\n},\n- pathLabel: {\n- fontSize: 16,\n- paddingLeft: 8,\n- fontWeight: 'bold',\n- color: 'panelForegroundSecondaryLabel',\n- },\n- cloudIcon: {\n- paddingRight: 8,\n- },\narrowIcon: {\n- paddingLeft: 8,\n+ paddingHorizontal: 8,\n},\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use `pill` component in `thread-ancestors`
Test Plan: Continues to look/work as expected
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1357 |
129,184 | 07.06.2021 13:45:12 | 14,400 | 4d1a496f847b1e65ed27854938bb2c25048a5410 | [native] Navigate to ancestor thread on tap in `thread-ancestors` component
Test Plan: Works and looks as expected
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/components/thread-ancestors.react.js",
"new_path": "native/components/thread-ancestors.react.js",
"diff": "// @flow\n+import { useNavigation } from '@react-navigation/native';\nimport * as React from 'react';\n-import { View, ScrollView } from 'react-native';\n+import { View, ScrollView, StyleSheet } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome5';\nimport { memberHasAdminPowers } from 'lib/shared/thread-utils';\nimport { type ThreadInfo, type MemberInfo } from 'lib/types/thread-types';\n+import { MessageListRouteName } from '../navigation/route-names';\nimport { useSelector } from '../redux/redux-utils';\n-import { useStyles, useColors } from '../themes/colors';\n+import { useColors } from '../themes/colors';\n+import Button from './button.react';\nimport Pill from './pill.react';\ntype Props = {|\n@@ -17,10 +20,21 @@ type Props = {|\nfunction ThreadAncestors(props: Props): React.Node {\nconst { ancestorThreads } = props;\n- const styles = useStyles(unboundStyles);\n+ const navigation = useNavigation();\nconst colors = useColors();\nconst userInfos = useSelector((state) => state.userStore.userInfos);\n+ const navigateToThread = React.useCallback(\n+ (threadInfo) => {\n+ navigation.navigate({\n+ name: MessageListRouteName,\n+ params: { threadInfo },\n+ key: `${MessageListRouteName}${threadInfo.id}`,\n+ });\n+ },\n+ [navigation],\n+ );\n+\nconst parentAdmin: ?string = React.useMemo(() => {\nfor (const member: MemberInfo of ancestorThreads[0].members) {\nif (memberHasAdminPowers(member)) {\n@@ -43,51 +57,51 @@ function ThreadAncestors(props: Props): React.Node {\n);\n}, [colors.codeBackground, parentAdmin]);\n- const rightArrow: React.Node = React.useMemo(\n- () => (\n- <Icon\n- name=\"chevron-right\"\n- size={12}\n- color=\"white\"\n- style={styles.arrowIcon}\n- />\n- ),\n- [styles.arrowIcon],\n- );\n-\n- const pathElements = [];\n+ const pathElements = React.useMemo(() => {\n+ const elements = [];\nfor (const [idx, threadInfo] of ancestorThreads.entries()) {\nconst isLastThread = idx === ancestorThreads.length - 1;\nconst backgroundColor = `#${threadInfo.color}`;\n- pathElements.push(\n+ elements.push(\n<View key={threadInfo.id} style={styles.pathItem}>\n+ <Button\n+ style={styles.row}\n+ onPress={() => navigateToThread(threadInfo)}\n+ >\n{idx === 0 ? adminLabel : null}\n<Pill\nbackgroundColor={backgroundColor}\nroundCorners={{ left: !(idx === 0), right: true }}\nlabel={threadInfo.uiName}\n/>\n+ </Button>\n{!isLastThread ? rightArrow : null}\n</View>,\n);\n}\n- return (\n- <ScrollView horizontal={true}>\n- <View style={styles.pathItem}>{pathElements}</View>\n- </ScrollView>\n- );\n+ return <View style={styles.pathItem}>{elements}</View>;\n+ }, [adminLabel, ancestorThreads, navigateToThread]);\n+\n+ return <ScrollView horizontal={true}>{pathElements}</ScrollView>;\n}\n-const unboundStyles = {\n+const styles = StyleSheet.create({\n+ arrowIcon: {\n+ paddingHorizontal: 8,\n+ },\npathItem: {\n- flexDirection: 'row',\nalignItems: 'center',\n+ flexDirection: 'row',\nheight: 40,\n},\n- arrowIcon: {\n- paddingHorizontal: 8,\n+ row: {\n+ flexDirection: 'row',\n},\n-};\n+});\n+\n+const rightArrow: React.Node = (\n+ <Icon name=\"chevron-right\" size={12} color=\"white\" style={styles.arrowIcon} />\n+);\nexport default ThreadAncestors;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Navigate to ancestor thread on tap in `thread-ancestors` component
Test Plan: Works and looks as expected
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1358 |
129,184 | 07.06.2021 14:59:39 | 14,400 | 074dfd4be8f1b2a0ce156d258c55330ac98ebc81 | [native] Use `pill` component in `thread-settings-parent`
Test Plan: Works and looks as expected
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-parent.react.js",
"new_path": "native/chat/settings/thread-settings-parent.react.js",
"diff": "import invariant from 'invariant';\nimport * as React from 'react';\n-import { Text, View, Platform } from 'react-native';\n+import { Text, View } from 'react-native';\nimport { type ThreadInfo } from 'lib/types/thread-types';\nimport Button from '../../components/button.react';\n-import { SingleLine } from '../../components/single-line.react';\n+import Pill from '../../components/pill.react';\nimport { MessageListRouteName } from '../../navigation/route-names';\nimport { useStyles } from '../../themes/colors';\nimport type { ThreadSettingsNavigate } from './thread-settings.react';\n@@ -26,18 +26,11 @@ class ThreadSettingsParent extends React.PureComponent<Props> {\nlet parent;\nif (this.props.parentThreadInfo) {\nparent = (\n- <Button\n- onPress={this.onPressParentThread}\n- style={this.props.styles.currentValue}\n- >\n- <SingleLine\n- style={[\n- this.props.styles.currentValueText,\n- this.props.styles.parentThreadLink,\n- ]}\n- >\n- {this.props.parentThreadInfo.uiName}\n- </SingleLine>\n+ <Button onPress={this.onPressParentThread}>\n+ <Pill\n+ label={this.props.parentThreadInfo.uiName}\n+ backgroundColor={`#${this.props.parentThreadInfo.color}`}\n+ />\n</Button>\n);\n} else if (this.props.threadInfo.parentThreadID) {\n@@ -91,8 +84,6 @@ class ThreadSettingsParent extends React.PureComponent<Props> {\nconst unboundStyles = {\ncurrentValue: {\nflex: 1,\n- paddingLeft: 4,\n- paddingTop: Platform.OS === 'ios' ? 5 : 4,\n},\ncurrentValueText: {\ncolor: 'panelForegroundSecondaryLabel',\n@@ -111,13 +102,11 @@ const unboundStyles = {\nfontStyle: 'italic',\npaddingLeft: 2,\n},\n- parentThreadLink: {\n- color: 'link',\n- },\nrow: {\nbackgroundColor: 'panelForeground',\nflexDirection: 'row',\npaddingHorizontal: 24,\n+ alignItems: 'center',\n},\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/pill.react.js",
"new_path": "native/components/pill.react.js",
"diff": "@@ -62,7 +62,9 @@ function Pill(props: Props): React.Node {\nreturn (\n<View style={combinedContainerStyles}>\n{icon}\n- <Text style={combinedTextStyles}>{props.label}</Text>\n+ <Text numberOfLines={1} style={combinedTextStyles}>\n+ {props.label}\n+ </Text>\n</View>\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use `pill` component in `thread-settings-parent`
Test Plan: Works and looks as expected
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1359 |
129,184 | 07.06.2021 21:29:23 | 14,400 | fa8c78668ec63b499170bc9583d938aef2d62cd9 | [native] Use `pill` component in `thread-settings-visibility`
Test Plan: Looks as expected
Reviewers: ashoat
Subscribers: KatPo, palys-swm, 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": "@@ -20,7 +20,7 @@ function ThreadSettingsVisibility(props: Props) {\n<Text style={styles.label}>Visibility</Text>\n<ThreadVisibility\nthreadType={props.threadInfo.type}\n- color={colors.panelForegroundSecondaryLabel}\n+ color={colors.codeBackground}\n/>\n</View>\n);\n@@ -37,6 +37,7 @@ const unboundStyles = {\nflexDirection: 'row',\npaddingHorizontal: 24,\npaddingVertical: 8,\n+ alignItems: 'center',\n},\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/pill.react.js",
"new_path": "native/components/pill.react.js",
"diff": "@@ -12,6 +12,7 @@ import { useStyles } from '../themes/colors';\ntype Props = {|\n+label: string,\n+backgroundColor: string,\n+ +icon?: React.Node,\n+faIcon?: FontAwesome5Glyphs,\n+roundCorners?: {| +left: boolean, +right: boolean |},\n|};\n@@ -47,7 +48,9 @@ function Pill(props: Props): React.Node {\n);\nconst icon = React.useMemo(() => {\n- if (props.faIcon) {\n+ if (props.icon) {\n+ return <View style={styles.icon}>{props.icon}</View>;\n+ } else if (props.faIcon) {\nreturn (\n<Icon\nname={props.faIcon}\n@@ -57,7 +60,8 @@ function Pill(props: Props): React.Node {\n/>\n);\n}\n- }, [props.faIcon, styles.icon, textColor]);\n+ return undefined;\n+ }, [props.faIcon, props.icon, styles.icon, textColor]);\nreturn (\n<View style={combinedContainerStyles}>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/thread-visibility.react.js",
"new_path": "native/components/thread-visibility.react.js",
"diff": "// @flow\nimport * as React from 'react';\n-import { View, Text, StyleSheet } from 'react-native';\n+import { View, StyleSheet } from 'react-native';\nimport { threadLabel } from 'lib/shared/thread-utils';\nimport type { ThreadType } from 'lib/types/thread-types';\n+import Pill from './pill.react';\nimport ThreadIcon from './thread-icon.react';\ntype Props = {|\n@@ -14,13 +15,15 @@ type Props = {|\n|};\nfunction ThreadVisibility(props: Props) {\nconst { threadType, color } = props;\n- const visLabelStyle = [styles.visibilityLabel, { color }];\nconst label = threadLabel(threadType);\n+ const icon = React.useMemo(\n+ () => <ThreadIcon threadType={threadType} color=\"white\" />,\n+ [threadType],\n+ );\nreturn (\n<View style={styles.container}>\n- <ThreadIcon threadType={threadType} color={color} />\n- <Text style={visLabelStyle}>{label}</Text>\n+ <Pill icon={icon} label={label} backgroundColor={color} />\n</View>\n);\n}\n@@ -30,11 +33,6 @@ const styles = StyleSheet.create({\nalignItems: 'center',\nflexDirection: 'row',\n},\n- visibilityLabel: {\n- fontSize: 16,\n- fontWeight: 'bold',\n- paddingLeft: 4,\n- },\n});\nexport default ThreadVisibility;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use `pill` component in `thread-settings-visibility`
Test Plan: Looks as expected
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1360 |
129,184 | 08.06.2021 15:56:51 | 14,400 | 60da102261d9a4789eb06d0a89f200196dce4ea1 | [native] Minor search bar margin tweak
Summary:
Minor increase to search bar `marginTop`
Before:
After:
Test Plan: Looks as expected, no functional change
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -578,7 +578,7 @@ const unboundStyles = {\nsearch: {\nmarginBottom: 8,\nmarginHorizontal: 12,\n- marginTop: Platform.OS === 'android' ? 10 : 8,\n+ marginTop: 12,\n},\ncancelSearchButton: {\nposition: 'absolute',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Minor search bar margin tweak
Summary:
Minor increase to search bar `marginTop`
Before: https://blob.sh/atul/padding8.png
After: https://blob.sh/atul/padding12.png
Test Plan: Looks as expected, no functional change
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1379 |
129,184 | 09.06.2021 16:08:12 | 14,400 | 2811eeda5db5d8bd4dec0ba1ea9cfa6818d3fa2a | [native] Minor `ThreadAncesters` tweaks
Summary:
Move `paddingHorizontal` from `container` to `contentContainer`
Hide horizontal scroll indicator
Test Plan: Looks and works as expected
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/components/thread-ancestors.react.js",
"new_path": "native/components/thread-ancestors.react.js",
"diff": "@@ -97,7 +97,13 @@ function ThreadAncestors(props: Props): React.Node {\nreturn (\n<View style={styles.container}>\n- <ScrollView horizontal={true}>{pathElements}</ScrollView>\n+ <ScrollView\n+ contentContainerStyle={styles.contentContainer}\n+ showsHorizontalScrollIndicator={false}\n+ horizontal={true}\n+ >\n+ {pathElements}\n+ </ScrollView>\n</View>\n);\n}\n@@ -110,6 +116,8 @@ const unboundStyles = {\ncontainer: {\nheight,\nbackgroundColor: 'panelSecondaryForeground',\n+ },\n+ contentContainer: {\npaddingHorizontal: 12,\n},\npathItem: {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Minor `ThreadAncesters` tweaks
Summary:
- Move `paddingHorizontal` from `container` to `contentContainer`
- Hide horizontal scroll indicator
Test Plan: Looks and works as expected
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1391 |
129,184 | 09.06.2021 16:39:11 | 14,400 | 8da14570de325463fa9c2625cd17cf801882ad52 | [native] Introduce `ThreadAncestorsLabel` component
Summary: Introduce `ThreadAncestorsLabel` which displays a non-interactive ancestor path that may be shortened with ellipsis if full path exceeds the given space.
Test Plan: Looks as expected when added to `ChatThreadListItem` (next diff)
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/components/thread-ancestors-label.react.js",
"diff": "+// @flow\n+\n+import * as React from 'react';\n+\n+import { ancestorThreadInfos } from 'lib/selectors/thread-selectors';\n+import { type ThreadInfo } from 'lib/types/thread-types';\n+\n+import { useSelector } from '../redux/redux-utils';\n+import { useStyles } from '../themes/colors';\n+import { SingleLine } from './single-line.react';\n+\n+type Props = {|\n+ +threadInfo: ThreadInfo,\n+|};\n+function ThreadAncestorsLabel(props: Props): React.Node {\n+ const { threadInfo } = props;\n+ const styles = useStyles(unboundStyles);\n+ const ancestorThreads: $ReadOnlyArray<ThreadInfo> = useSelector(\n+ ancestorThreadInfos(threadInfo.id),\n+ );\n+\n+ const ancestorPath: string = React.useMemo(() => {\n+ const path = ancestorThreads.map((each) => each.uiName);\n+ return path.slice(0, -1).join(' > ').concat(' > ');\n+ }, [ancestorThreads]);\n+\n+ return <SingleLine style={styles.pathText}>{ancestorPath}</SingleLine>;\n+}\n+\n+const unboundStyles = {\n+ pathText: {\n+ opacity: 0.8,\n+ fontSize: 12,\n+ paddingLeft: 10,\n+ paddingVertical: 2,\n+ color: 'listForegroundTertiaryLabel',\n+ },\n+};\n+\n+export default ThreadAncestorsLabel;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Introduce `ThreadAncestorsLabel` component
Summary: Introduce `ThreadAncestorsLabel` which displays a non-interactive ancestor path that may be shortened with ellipsis if full path exceeds the given space.
Test Plan: Looks as expected when added to `ChatThreadListItem` (next diff)
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1392 |
129,184 | 09.06.2021 16:50:03 | 14,400 | 73d4cf6f9f7295a32267972a4af1b2e2be600e7e | [native] Show `ThreadAncestorsLabel` in `ChatThreadListItem`
Test Plan: Looks and works as expected on both iOS Simulator and physical device
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list-item.react.js",
"new_path": "native/chat/chat-thread-list-item.react.js",
"diff": "@@ -11,6 +11,7 @@ import { shortAbsoluteDate } from 'lib/utils/date-utils';\nimport Button from '../components/button.react';\nimport ColorSplotch from '../components/color-splotch.react';\nimport { SingleLine } from '../components/single-line.react';\n+import ThreadAncestorsLabel from '../components/thread-ancestors-label.react';\nimport { useColors, useStyles } from '../themes/colors';\nimport ChatThreadListSeeMoreSidebars from './chat-thread-list-see-more-sidebars.react';\nimport ChatThreadListSidebar from './chat-thread-list-sidebar.react';\n@@ -86,6 +87,17 @@ function ChatThreadListItem({\nconst lastActivity = shortAbsoluteDate(data.lastUpdatedTime);\nconst unreadStyle = data.threadInfo.currentUser.unread ? styles.unread : null;\n+ const ancestorLabel = React.useMemo(() => {\n+ if (!data.threadInfo.parentThreadID) {\n+ return undefined;\n+ }\n+ return (\n+ <View style={styles.ancestorLabel}>\n+ <ThreadAncestorsLabel threadInfo={data.threadInfo} />\n+ </View>\n+ );\n+ }, [data.threadInfo, styles.ancestorLabel]);\n+\nreturn (\n<>\n<SwipeableThread\n@@ -102,6 +114,7 @@ function ChatThreadListItem({\niosActiveOpacity={0.85}\nstyle={styles.container}\n>\n+ {ancestorLabel}\n<View style={styles.row}>\n<SingleLine style={[styles.threadName, unreadStyle]}>\n{data.threadInfo.uiName}\n@@ -124,14 +137,16 @@ function ChatThreadListItem({\n}\nconst unboundStyles = {\n+ ancestorLabel: {\n+ paddingRight: 80,\n+ },\ncolorSplotch: {\nmarginLeft: 10,\nmarginTop: 2,\n},\ncontainer: {\n- height: 60,\n- paddingLeft: 10,\n- paddingRight: 10,\n+ height: 76,\n+ paddingHorizontal: 10,\npaddingTop: 5,\nbackgroundColor: 'listBackground',\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -331,7 +331,7 @@ class ChatThreadList extends React.PureComponent<Props, State> {\nreturn 123;\n}\n- return 60 + item.sidebars.length * 30;\n+ return 76 + item.sidebars.length * 30;\n}\nstatic heightOfItems(data: $ReadOnlyArray<Item>): number {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Show `ThreadAncestorsLabel` in `ChatThreadListItem`
Test Plan: Looks and works as expected on both iOS Simulator and physical device
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1393 |
129,187 | 09.06.2021 15:39:40 | 14,400 | 89dbd3256cddd207aef9b0e5905594f44c7006ea | Add ESLint rule to avoid unnecessary curly braces in JSX
Summary: Some context [here](https://phabricator.ashoat.com/D1360?id=4074#inline-7298).
Test Plan: `yarn eslint:fix`
Reviewers: atul
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": ".eslintrc.json",
"new_path": ".eslintrc.json",
"diff": "\"groups\": [[\"builtin\", \"external\"], \"internal\"]\n}\n],\n- \"prefer-const\": \"error\"\n+ \"prefer-const\": \"error\",\n+ \"react/jsx-curly-brace-presence\": [\n+ \"error\",\n+ { \"props\": \"never\", \"children\": \"ignore\" }\n+ ]\n},\n\"settings\": {\n\"react\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/video-playback-modal.react.js",
"new_path": "native/media/video-playback-modal.react.js",
"diff": "@@ -614,7 +614,7 @@ function VideoPlaybackModal(props: Props) {\n<Progress.Circle\nsize={80}\nindeterminate={true}\n- color={'white'}\n+ color=\"white\"\nstyle={styles.progressCircle}\n/>\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add ESLint rule to avoid unnecessary curly braces in JSX
Summary: Some context [here](https://phabricator.ashoat.com/D1360?id=4074#inline-7298).
Test Plan: `yarn eslint:fix`
Reviewers: atul
Reviewed By: atul
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1390 |
129,184 | 09.06.2021 20:41:38 | 14,400 | b15efb6a167afc77b707caabbaf0ce5ed4f9e6d7 | [native] Fix typo
Test Plan: continues to work as expected
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -34,7 +34,7 @@ import {\n} from 'lib/types/thread-types';\nimport type { UserInfos } from 'lib/types/user-types';\n-import ThreadAncesters from '../../components/thread-ancestors.react';\n+import ThreadAncestors from '../../components/thread-ancestors.react';\nimport {\ntype KeyboardState,\nKeyboardContext,\n@@ -818,7 +818,7 @@ class ThreadSettings extends React.PureComponent<Props, State> {\nrender() {\nlet threadAncestors;\nif (this.props.threadInfo) {\n- threadAncestors = <ThreadAncesters threadInfo={this.props.threadInfo} />;\n+ threadAncestors = <ThreadAncestors threadInfo={this.props.threadInfo} />;\n}\nreturn (\n<View\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix typo
Test Plan: continues to work as expected
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1394 |
129,190 | 09.06.2021 13:32:42 | -7,200 | b6949e4cd8cc61d77e8cb5ff8c8d7122cf208a59 | [native] Move draft for realized pending thread
Summary: When a thread gets realized, change the draft key from pending to realized so the draft's not gone
Test Plan: todo
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, palys-swm, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -1018,6 +1018,10 @@ function checkIfDefaultMembersAreVoiced(threadInfo: ThreadInfo) {\nreturn !!defaultRole.permissions[threadPermissions.VOICED];\n}\n+function draftKeyFromThreadID(threadID: string): string {\n+ return `${threadID}/message_composer`;\n+}\n+\nexport {\ncolorIsDark,\ngenerateRandomColor,\n@@ -1067,4 +1071,5 @@ export {\nuseCanCreateSidebarFromMessage,\nuseSidebarExistsOrCanBeCreated,\ncheckIfDefaultMembersAreVoiced,\n+ draftKeyFromThreadID,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-input-bar.react.js",
"new_path": "native/chat/chat-input-bar.react.js",
"diff": "@@ -32,6 +32,7 @@ import {\nthreadFrozenDueToViewerBlock,\nthreadActualMembers,\ncheckIfDefaultMembersAreVoiced,\n+ draftKeyFromThreadID,\n} from 'lib/shared/thread-utils';\nimport type { CalendarQuery } from 'lib/types/entry-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n@@ -99,9 +100,6 @@ const sendButtonAnimationConfig = {\neasing: Easing.inOut(Easing.ease),\n};\n-const draftKeyFromThreadID = (threadID: string) =>\n- `${threadID}/message_composer`;\n-\ntype BaseProps = {|\n+threadInfo: ThreadInfo,\n+navigation: ChatNavigationProp<'MessageList'>,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -49,6 +49,7 @@ import MessageListHeaderTitle from './message-list-header-title.react';\nimport MessageStorePruner from './message-store-pruner.react';\nimport DeleteThread from './settings/delete-thread.react';\nimport ThreadSettings from './settings/thread-settings.react';\n+import ThreadDraftUpdater from './thread-draft-updater.react';\nimport ThreadScreenPruner from './thread-screen-pruner.react';\nimport ThreadSettingsButton from './thread-settings-button.react';\n@@ -258,6 +259,7 @@ export default function ChatComponent() {\n</Chat.Navigator>\n<MessageStorePruner />\n<ThreadScreenPruner />\n+ <ThreadDraftUpdater />\n</KeyboardAvoidingView>\n</View>\n);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/thread-draft-updater.react.js",
"diff": "+// @flow\n+\n+import invariant from 'invariant';\n+import * as React from 'react';\n+\n+import { pendingToRealizedThreadIDsSelector } from 'lib/selectors/thread-selectors';\n+import { draftKeyFromThreadID } from 'lib/shared/thread-utils';\n+\n+import type { AppState } from '../redux/redux-setup';\n+import { useSelector } from '../redux/redux-utils';\n+\n+type Props = {||};\n+\n+const ThreadDraftUpdater: React.AbstractComponent<\n+ Props,\n+ mixed,\n+> = React.memo<Props>(() => {\n+ const pendingToRealizedThreadIDs = useSelector((state: AppState) =>\n+ pendingToRealizedThreadIDsSelector(state.threadStore.threadInfos),\n+ );\n+\n+ const cachedThreadIDsRef = React.useRef();\n+ if (!cachedThreadIDsRef.current) {\n+ const newCachedThreadIDs = new Set();\n+ for (const realizedThreadID of pendingToRealizedThreadIDs.values()) {\n+ newCachedThreadIDs.add(realizedThreadID);\n+ }\n+ cachedThreadIDsRef.current = newCachedThreadIDs;\n+ }\n+\n+ React.useEffect(() => {\n+ for (const [pendingThreadID, threadID] of pendingToRealizedThreadIDs) {\n+ const cachedThreadIDs = cachedThreadIDsRef.current;\n+ invariant(cachedThreadIDs, 'should be set');\n+ if (cachedThreadIDs.has(threadID)) {\n+ continue;\n+ }\n+ global.CommCoreModule.moveDraft(\n+ draftKeyFromThreadID(pendingThreadID),\n+ draftKeyFromThreadID(threadID),\n+ );\n+ cachedThreadIDs.add(threadID);\n+ }\n+ }, [pendingToRealizedThreadIDs]);\n+ return null;\n+});\n+ThreadDraftUpdater.displayName = 'ThreadDraftUpdater';\n+\n+export default ThreadDraftUpdater;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Move draft for realized pending thread
Summary: When a thread gets realized, change the draft key from pending to realized so the draft's not gone
Test Plan: todo
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, palys-swm, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1384 |
129,190 | 10.06.2021 14:25:47 | -7,200 | 3d5944a6b8cf3ba6830a332ac4fd5c48795a77f2 | [native] Consider only types of threads that can be pending
Summary: When using `pendingToRealizedThreadIDsSelector` we want to filter threads by their types and handle only those that can be pending
Test Plan: todo
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, palys-swm, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/thread-selectors.js",
"new_path": "lib/selectors/thread-selectors.js",
"diff": "@@ -25,6 +25,7 @@ import {\nroleIsAdminRole,\nthreadIsPending,\ngetPendingThreadID,\n+ threadTypeCanBePending,\n} from '../shared/thread-utils';\nimport type { EntryInfo } from '../types/entry-types';\nimport type { MessageStore, RawMessageInfo } from '../types/message-types';\n@@ -367,10 +368,13 @@ const pendingToRealizedThreadIDsSelector: (rawThreadInfos: {\n(rawThreadInfos: { +[id: string]: RawThreadInfo }) => {\nconst result = new Map();\nfor (const threadID in rawThreadInfos) {\n- if (threadIsPending(threadID)) {\n+ const rawThreadInfo = rawThreadInfos[threadID];\n+ if (\n+ !threadTypeCanBePending(rawThreadInfo.type) ||\n+ threadIsPending(threadID)\n+ ) {\ncontinue;\n}\n- const rawThreadInfo = rawThreadInfos[threadID];\nconst actualMemberIDs = rawThreadInfo.members\n.filter((member) => member.role)\n.map((member) => member.id);\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-utils.js",
"new_path": "lib/shared/thread-utils.js",
"diff": "@@ -1022,6 +1022,14 @@ function draftKeyFromThreadID(threadID: string): string {\nreturn `${threadID}/message_composer`;\n}\n+function threadTypeCanBePending(threadType: ThreadType): boolean {\n+ return (\n+ threadType === threadTypes.PERSONAL ||\n+ threadType === threadTypes.LOCAL ||\n+ threadType === threadTypes.SIDEBAR\n+ );\n+}\n+\nexport {\ncolorIsDark,\ngenerateRandomColor,\n@@ -1072,4 +1080,5 @@ export {\nuseSidebarExistsOrCanBeCreated,\ncheckIfDefaultMembersAreVoiced,\ndraftKeyFromThreadID,\n+ threadTypeCanBePending,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Consider only types of threads that can be pending
Summary: When using `pendingToRealizedThreadIDsSelector` we want to filter threads by their types and handle only those that can be pending
Test Plan: todo
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, palys-swm, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1396 |
129,187 | 05.06.2021 03:37:09 | 14,400 | 3117b102ff00409ccdd0b243277fee0711fee111 | [server] Throw ServerError if we can't determine the intendedRole in changeRole
Summary: This is a serious error and shouldn't result in a silent failure.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -105,9 +105,6 @@ async function changeRole(\ndbQuery(membershipQuery),\nchangeRoleThreadQuery(threadID, role),\n]);\n- if (!roleThreadResult) {\n- return null;\n- }\nconst roleInfo = new Map();\nfor (const row of membershipResult) {\n@@ -240,14 +237,14 @@ type RoleThreadResult = {|\nasync function changeRoleThreadQuery(\nthreadID: string,\nrole: string | -1 | 0 | null,\n-): Promise<?RoleThreadResult> {\n+): Promise<RoleThreadResult> {\nif (role === 0 || role === -1) {\nconst query = SQL`\nSELECT type, containing_thread_id FROM threads WHERE id = ${threadID}\n`;\nconst [result] = await dbQuery(query);\nif (result.length === 0) {\n- return null;\n+ throw new ServerError('internal_error');\n}\nconst row = result[0];\nreturn {\n@@ -265,7 +262,7 @@ async function changeRoleThreadQuery(\n`;\nconst [result] = await dbQuery(query);\nif (result.length === 0) {\n- return null;\n+ throw new ServerError('internal_error');\n}\nconst row = result[0];\nreturn {\n@@ -283,7 +280,7 @@ async function changeRoleThreadQuery(\n`;\nconst [result] = await dbQuery(query);\nif (result.length === 0) {\n- return null;\n+ throw new ServerError('internal_error');\n}\nconst row = result[0];\nreturn {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Throw ServerError if we can't determine the intendedRole in changeRole
Summary: This is a serious error and shouldn't result in a silent failure.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1349 |
129,187 | 05.06.2021 03:28:42 | 14,400 | 0f191408c582e93030058c2b511d708a13fed8bb | [server] Delete DEPRECATED_updateRoleAndPermissions
Summary: Since the previous diff removed the only two callsites, we can now remove this deprecated function.
Test Plan: Flow
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/role-updaters.js",
"new_path": "server/src/updaters/role-updaters.js",
"diff": "import invariant from 'invariant';\nimport _isEqual from 'lodash/fp/isEqual';\n-import type {\n- ThreadType,\n- ThreadRolePermissionsBlob,\n-} from 'lib/types/thread-types';\n+import type { ThreadType } from 'lib/types/thread-types';\nimport createIDs from '../creators/id-creator';\nimport { getRolePermissionBlobs } from '../creators/role-creator';\nimport { dbQuery, SQL } from '../database/database';\nimport { fetchRoles } from '../fetchers/role-fetchers';\nimport type { Viewer } from '../session/viewer';\n-import {\n- commitMembershipChangeset,\n- recalculateThreadPermissions,\n-} from './thread-permission-updaters';\nasync function updateRoles(\nviewer: Viewer,\n@@ -107,27 +100,4 @@ async function updateRoles(\nawait Promise.all(promises);\n}\n-// Best to avoid this function going forward...\n-// It was used in a couple scripts that were meant to convert between thread\n-// types, but those scripts didn't properly handle converting between threads\n-// with different numbers of roles.\n-async function DEPRECATED_updateRoleAndPermissions(\n- viewer: Viewer,\n- threadID: string,\n- threadType: ThreadType,\n- roleID: string,\n- rolePermissionsBlob: ThreadRolePermissionsBlob,\n-): Promise<void> {\n- const rolePermissionsString = JSON.stringify(rolePermissionsBlob);\n- const updatePermissions = SQL`\n- UPDATE roles\n- SET permissions = ${rolePermissionsString}\n- WHERE id = ${roleID}\n- `;\n- await dbQuery(updatePermissions);\n-\n- const changeset = await recalculateThreadPermissions(threadID, threadType);\n- return await commitMembershipChangeset(viewer, changeset);\n-}\n-\n-export { updateRoles, DEPRECATED_updateRoleAndPermissions };\n+export { updateRoles };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Delete DEPRECATED_updateRoleAndPermissions
Summary: Since the previous diff removed the only two callsites, we can now remove this deprecated function.
Test Plan: Flow
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1354 |
129,187 | 07.06.2021 15:12:02 | 14,400 | 4c360965df029546573ac1cdddd0f882dbdf76c3 | [server] Skip updates in changeRole if no change detected
Summary: We check this in the other permissions updaters, so I figured we might as well do it in `changeRole` as well.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -88,7 +88,7 @@ async function changeRole(\noptions?.setNewMembersToUnread && intent === 'join';\nconst membershipQuery = SQL`\n- SELECT user, role, permissions_for_children\n+ SELECT user, role, permissions, permissions_for_children\nFROM memberships\nWHERE thread = ${threadID}\n`;\n@@ -135,6 +135,7 @@ async function changeRole(\nconst userID = row.user.toString();\nexistingMembershipInfo.set(userID, {\noldRole: row.role.toString(),\n+ oldPermissions: row.permissions,\noldPermissionsForChildren: row.permissions_for_children,\n});\n}\n@@ -165,6 +166,7 @@ async function changeRole(\nrelationshipChangeset.setAllRelationshipsExist(existingMemberIDs);\nfor (const userID of userIDs) {\nlet oldRole;\n+ let oldPermissions = null;\nlet oldPermissionsForChildren = null;\nconst existingMembership = existingMembershipInfo.get(userID);\nif (existingMembership) {\n@@ -177,6 +179,7 @@ async function changeRole(\n// anything\ncontinue;\n}\n+ oldPermissions = existingMembership.oldPermissions;\noldPermissionsForChildren = existingMembership.oldPermissionsForChildren;\noldRole = existingMembership.oldRole;\n}\n@@ -217,6 +220,12 @@ async function changeRole(\nconst userLostMembership =\noldRole && Number(oldRole) > 0 && Number(newRole) <= 0;\n+ if (_isEqual(permissions)(oldPermissions) && oldRole === newRole) {\n+ // This thread and all of its descendants need no updates for this user,\n+ // since the corresponding memberships row is unchanged by this operation\n+ continue;\n+ }\n+\nif (permissions) {\nif (\n(intent === 'join' && Number(newRole) <= 0) ||\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Skip updates in changeRole if no change detected
Summary: We check this in the other permissions updaters, so I figured we might as well do it in `changeRole` as well.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1365 |
129,187 | 07.06.2021 16:25:15 | 14,400 | c3ab0cbcb222e4917d92bac1dcc4d4160a90befa | [server] Don't return threads without memberships rows in updateDescendantPermissions query
Summary: This should result in exactly the same behavior.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -370,7 +370,7 @@ async function updateDescendantPermissions(\nr.permissions AS role_permissions, m.permissions,\nm.permissions_for_children, m.role\nFROM threads t\n- LEFT JOIN memberships m ON m.thread = t.id\n+ INNER JOIN memberships m ON m.thread = t.id\nLEFT JOIN roles r ON r.id = m.role\nWHERE t.parent_thread_id = ${threadID}\n`;\n@@ -385,9 +385,6 @@ async function updateDescendantPermissions(\nuserInfos: new Map(),\n});\n}\n- if (!row.user) {\n- continue;\n- }\nconst childThreadInfo = childThreadInfos.get(childThreadID);\ninvariant(childThreadInfo, `value should exist for key ${childThreadID}`);\nconst userID = row.user.toString();\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Don't return threads without memberships rows in updateDescendantPermissions query
Summary: This should result in exactly the same behavior.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1367 |
129,187 | 07.06.2021 17:59:51 | 14,400 | 36c948b1744bb2485722e395910e8282df0a8d6a | [server] Pass thread depth into updateDescendantPermissions
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -128,6 +128,7 @@ async function changeRole(\nthreadType,\nhasContainingThreadID,\nrolePermissions: intendedRolePermissions,\n+ depth,\n} = roleThreadResult;\nconst existingMembershipInfo = new Map();\n@@ -275,6 +276,7 @@ async function changeRole(\nrelationshipChangeset: descendantRelationshipChangeset,\n} = await updateDescendantPermissions({\nthreadID,\n+ depth,\nchangesByUser: toUpdateDescendants,\n});\npushAll(membershipRows, descendantMembershipRows);\n@@ -289,6 +291,7 @@ type RoleThreadResult = {|\n+threadType: ThreadType,\n+hasContainingThreadID: boolean,\n+rolePermissions: ?ThreadRolePermissionsBlob,\n+ +depth: number,\n|};\nasync function changeRoleThreadQuery(\nthreadID: string,\n@@ -296,7 +299,9 @@ async function changeRoleThreadQuery(\n): Promise<RoleThreadResult> {\nif (role === 0 || role === -1) {\nconst query = SQL`\n- SELECT type, containing_thread_id FROM threads WHERE id = ${threadID}\n+ SELECT type, depth, containing_thread_id\n+ FROM threads\n+ WHERE id = ${threadID}\n`;\nconst [result] = await dbQuery(query);\nif (result.length === 0) {\n@@ -305,13 +310,14 @@ async function changeRoleThreadQuery(\nconst row = result[0];\nreturn {\nroleColumnValue: role.toString(),\n+ depth: row.depth,\nthreadType: assertThreadType(row.type),\nhasContainingThreadID: row.containing_thread_id !== null,\nrolePermissions: null,\n};\n} else if (role !== null) {\nconst query = SQL`\n- SELECT t.type, r.permissions, t.containing_thread_id\n+ SELECT t.type, t.depth, t.containing_thread_id, r.permissions\nFROM threads t\nINNER JOIN roles r ON r.thread = t.id AND r.id = ${role}\nWHERE t.id = ${threadID}\n@@ -323,13 +329,15 @@ async function changeRoleThreadQuery(\nconst row = result[0];\nreturn {\nroleColumnValue: role,\n+ depth: row.depth,\nthreadType: assertThreadType(row.type),\nhasContainingThreadID: row.containing_thread_id !== null,\nrolePermissions: row.permissions,\n};\n} else {\nconst query = SQL`\n- SELECT t.type, t.default_role, r.permissions, t.containing_thread_id\n+ SELECT t.type, t.depth, t.containing_thread_id, t.default_role,\n+ r.permissions\nFROM threads t\nINNER JOIN roles r ON r.thread = t.id AND r.id = t.default_role\nWHERE t.id = ${threadID}\n@@ -341,6 +349,7 @@ async function changeRoleThreadQuery(\nconst row = result[0];\nreturn {\nroleColumnValue: row.default_role.toString(),\n+ depth: row.depth,\nthreadType: assertThreadType(row.type),\nhasContainingThreadID: row.containing_thread_id !== null,\nrolePermissions: row.permissions,\n@@ -350,6 +359,7 @@ async function changeRoleThreadQuery(\ntype ChangedAncestor = {|\n+threadID: string,\n+ +depth: number,\n+changesByUser: Map<string, AncestorChanges>,\n|};\ntype AncestorChanges = {|\n@@ -363,7 +373,7 @@ async function updateDescendantPermissions(\nconst membershipRows = [];\nconst relationshipChangeset = new RelationshipChangeset();\nwhile (stack.length > 0) {\n- const { threadID, changesByUser } = stack.shift();\n+ const { threadID, depth, changesByUser } = stack.shift();\nconst query = SQL`\nSELECT t.id, m.user, t.type,\n@@ -478,6 +488,7 @@ async function updateDescendantPermissions(\nif (usersForNextLayer.size > 0) {\nstack.push({\nthreadID: childThreadID,\n+ depth: depth + 1,\nchangesByUser: usersForNextLayer,\n});\n}\n@@ -498,7 +509,7 @@ async function recalculateThreadPermissions(\nthreadID: string,\n): Promise<Changeset> {\nconst threadQuery = SQL`\n- SELECT type, containing_thread_id FROM threads WHERE id = ${threadID}\n+ SELECT type, depth, containing_thread_id FROM threads WHERE id = ${threadID}\n`;\nconst membershipQuery = SQL`\nSELECT m.user, m.role, m.permissions, m.permissions_for_children,\n@@ -529,8 +540,9 @@ async function recalculateThreadPermissions(\nif (threadResults.length !== 1) {\nthrow new ServerError('internal_error');\n}\n- const hasContainingThreadID = threadResults[0].containing_thread_id !== null;\nconst threadType = assertThreadType(threadResults[0].type);\n+ const depth = threadResults[0].depth;\n+ const hasContainingThreadID = threadResults[0].containing_thread_id !== null;\nconst membershipInfo: Map<\nstring,\n@@ -647,6 +659,7 @@ async function recalculateThreadPermissions(\nrelationshipChangeset: descendantRelationshipChangeset,\n} = await updateDescendantPermissions({\nthreadID,\n+ depth,\nchangesByUser: toUpdateDescendants,\n});\npushAll(membershipRows, descendantMembershipRows);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Pass thread depth into updateDescendantPermissions
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1368 |
129,187 | 07.06.2021 23:24:20 | 14,400 | c1aad9eca2c3db70ac311f33810daac116044533 | [server] Extract query logic of updateDescendantPermissions into new function
Summary: This diff introduces `fetchDescendantsForUpdate`. Extracting this will make a lot of sense in the context of future diffs.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -365,106 +365,88 @@ type ChangedAncestor = {|\ntype AncestorChanges = {|\n+permissionsFromParent: ?ThreadPermissionsBlob,\n|};\n-\nasync function updateDescendantPermissions(\ninitialChangedAncestor: ChangedAncestor,\n): Promise<Changeset> {\nconst stack = [initialChangedAncestor];\nconst membershipRows = [];\nconst relationshipChangeset = new RelationshipChangeset();\n+\nwhile (stack.length > 0) {\n- const { threadID, depth, changesByUser } = stack.shift();\n+ const ancestor = stack.shift();\n+ const descendants = await fetchDescendantsForUpdate(ancestor);\n+ for (const descendant of descendants) {\n+ const { threadID, threadType, depth, users } = descendant;\n- const query = SQL`\n- SELECT t.id, m.user, t.type,\n- r.permissions AS role_permissions, m.permissions,\n- m.permissions_for_children, m.role\n- FROM threads t\n- INNER JOIN memberships m ON m.thread = t.id\n- LEFT JOIN roles r ON r.id = m.role\n- WHERE t.parent_thread_id = ${threadID}\n- `;\n- const [result] = await dbQuery(query);\n+ const existingMemberIDs = [...users.keys()];\n+ relationshipChangeset.setAllRelationshipsExist(existingMemberIDs);\n- const childThreadInfos = new Map();\n- for (const row of result) {\n- const childThreadID = row.id.toString();\n- if (!childThreadInfos.has(childThreadID)) {\n- childThreadInfos.set(childThreadID, {\n- threadType: assertThreadType(row.type),\n- userInfos: new Map(),\n- });\n- }\n- const childThreadInfo = childThreadInfos.get(childThreadID);\n- invariant(childThreadInfo, `value should exist for key ${childThreadID}`);\n- const userID = row.user.toString();\n- childThreadInfo.userInfos.set(userID, {\n- role: row.role.toString(),\n- rolePermissions: row.role_permissions,\n- permissions: row.permissions,\n- permissionsForChildren: row.permissions_for_children,\n- });\n+ const usersForNextLayer = new Map();\n+ for (const [userID, user] of users) {\n+ const {\n+ curRole,\n+ curRolePermissions,\n+ nextPermissionsFromParent,\n+ potentiallyNeedsUpdate,\n+ } = user;\n+ const curPermissions = user.curPermissions ?? null;\n+ const curPermissionsForChildren =\n+ user.curPermissionsForChildren ?? null;\n+\n+ if (!potentiallyNeedsUpdate) {\n+ continue;\n}\n+ invariant(\n+ nextPermissionsFromParent,\n+ 'currently, an update to permissionsFromParent is the only reason ' +\n+ 'that potentiallyNeedsUpdate should be set',\n+ );\n- for (const [childThreadID, childThreadInfo] of childThreadInfos) {\n- const userInfos = childThreadInfo.userInfos;\n- const existingMemberIDs = [...userInfos.keys()];\n- relationshipChangeset.setAllRelationshipsExist(existingMemberIDs);\n- const usersForNextLayer = new Map();\n- for (const [userID, ancestorChanges] of changesByUser) {\n- const { permissionsFromParent } = ancestorChanges;\n-\n- const userInfo = userInfos.get(userID);\n- const oldRole = userInfo?.role;\n- const targetRole = oldRole ?? '0';\n- const rolePermissions = userInfo?.rolePermissions;\n- const oldPermissions = userInfo?.permissions;\n- const oldPermissionsForChildren = userInfo\n- ? userInfo.permissionsForChildren\n- : null;\n+ const targetRole = curRole ?? '0';\nconst permissions = makePermissionsBlob(\n- rolePermissions,\n- permissionsFromParent,\n- childThreadID,\n- childThreadInfo.threadType,\n+ curRolePermissions,\n+ nextPermissionsFromParent,\n+ threadID,\n+ threadType,\n);\n- if (_isEqual(permissions)(oldPermissions)) {\n- // This thread and all of its children need no updates, since its\n- // permissions are unchanged by this operation\n- continue;\n- }\nconst permissionsForChildren = makePermissionsForChildrenBlob(\npermissions,\n);\n-\nconst newRole = getRoleForPermissions(targetRole, permissions);\nconst userLostMembership =\n- oldRole && Number(oldRole) > 0 && Number(newRole) <= 0;\n+ curRole && Number(curRole) > 0 && Number(newRole) <= 0;\n+\n+ if (_isEqual(permissions)(curPermissions) && curRole === newRole) {\n+ // This thread and all of its descendants need no updates for this\n+ // user, since the corresponding memberships row is unchanged by this\n+ // operation\n+ continue;\n+ }\nif (permissions) {\nmembershipRows.push({\noperation: 'save',\nintent: 'none',\nuserID,\n- threadID: childThreadID,\n+ threadID,\nuserNeedsFullThreadDetails: false,\npermissions,\npermissionsForChildren,\nrole: newRole,\n- oldRole: oldRole ?? '-1',\n+ oldRole: curRole ?? '-1',\n});\n} else {\nmembershipRows.push({\noperation: 'delete',\nintent: 'none',\nuserID,\n- threadID: childThreadID,\n- oldRole: oldRole ?? '-1',\n+ threadID,\n+ oldRole: curRole ?? '-1',\n});\n}\n- if (permissions && !userInfo) {\n+ if (permissions && !curRole) {\n// If there was no membership row before, and we are creating one,\n// we'll need to make sure the new member has a relationship row with\n// each existing member. We assume whoever called us will handle\n@@ -478,7 +460,7 @@ async function updateDescendantPermissions(\nif (\nuserLostMembership ||\n- !_isEqual(permissionsForChildren)(oldPermissionsForChildren)\n+ !_isEqual(permissionsForChildren)(curPermissionsForChildren)\n) {\nusersForNextLayer.set(userID, {\npermissionsFromParent: permissionsForChildren,\n@@ -487,8 +469,8 @@ async function updateDescendantPermissions(\n}\nif (usersForNextLayer.size > 0) {\nstack.push({\n- threadID: childThreadID,\n- depth: depth + 1,\n+ threadID,\n+ depth,\nchangesByUser: usersForNextLayer,\n});\n}\n@@ -497,6 +479,76 @@ async function updateDescendantPermissions(\nreturn { membershipRows, relationshipChangeset };\n}\n+type DescendantUserInfo = $Shape<{|\n+ curRole?: string,\n+ curRolePermissions?: ?ThreadRolePermissionsBlob,\n+ curPermissions?: ?ThreadPermissionsBlob,\n+ curPermissionsForChildren?: ?ThreadPermissionsBlob,\n+ nextPermissionsFromParent?: ?ThreadPermissionsBlob,\n+ potentiallyNeedsUpdate?: boolean,\n+|}>;\n+type DescendantInfo = {|\n+ +threadID: string,\n+ +threadType: ThreadType,\n+ +depth: number,\n+ +users: Map<string, DescendantUserInfo>,\n+|};\n+async function fetchDescendantsForUpdate(\n+ ancestor: ChangedAncestor,\n+): Promise<DescendantInfo[]> {\n+ const { threadID, depth } = ancestor;\n+ const query = SQL`\n+ SELECT t.id, m.user, t.type,\n+ r.permissions AS role_permissions, m.permissions,\n+ m.permissions_for_children, m.role\n+ FROM threads t\n+ INNER JOIN memberships m ON m.thread = t.id\n+ LEFT JOIN roles r ON r.id = m.role\n+ WHERE t.parent_thread_id = ${threadID}\n+ `;\n+ const [result] = await dbQuery(query);\n+\n+ const descendantThreadInfos: Map<string, DescendantInfo> = new Map();\n+ for (const row of result) {\n+ const descendantThreadID = row.id.toString();\n+ if (!descendantThreadInfos.has(descendantThreadID)) {\n+ descendantThreadInfos.set(descendantThreadID, {\n+ threadID: descendantThreadID,\n+ threadType: assertThreadType(row.type),\n+ depth: depth + 1,\n+ users: new Map(),\n+ });\n+ }\n+ const descendantThreadInfo = descendantThreadInfos.get(descendantThreadID);\n+ invariant(\n+ descendantThreadInfo,\n+ `value should exist for key ${descendantThreadID}`,\n+ );\n+ const userID = row.user.toString();\n+ descendantThreadInfo.users.set(userID, {\n+ curRole: row.role.toString(),\n+ curRolePermissions: row.role_permissions,\n+ curPermissions: row.permissions,\n+ curPermissionsForChildren: row.permissions_for_children,\n+ });\n+ }\n+\n+ const { changesByUser } = ancestor;\n+ for (const [userID, changes] of changesByUser) {\n+ for (const descendantThreadInfo of descendantThreadInfos.values()) {\n+ let user = descendantThreadInfo.users.get(userID);\n+ if (!user) {\n+ user = {};\n+ descendantThreadInfo.users.set(userID, user);\n+ }\n+ user.nextPermissionsFromParent = changes.permissionsFromParent;\n+ user.potentiallyNeedsUpdate = true;\n+ }\n+ }\n+\n+ return [...descendantThreadInfos.values()];\n+}\n+\ntype RecalculatePermissionsMemberInfo = {|\nrole?: ?string,\npermissions?: ?ThreadPermissionsBlob,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Extract query logic of updateDescendantPermissions into new function
Summary: This diff introduces `fetchDescendantsForUpdate`. Extracting this will make a lot of sense in the context of future diffs.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1369 |
129,187 | 07.06.2021 23:30:20 | 14,400 | 9c2d0b1086b8d54639bad8d4849dde19a7d70304 | [server] Rename AncestorChanges.permissionsFromParent to permissionsForChildren
Summary: We'll be naming the properties from the context of the parent, not the child, going forward.
Test Plan: Flow
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -265,7 +265,7 @@ async function changeRole(\n!_isEqual(permissionsForChildren)(oldPermissionsForChildren)\n) {\ntoUpdateDescendants.set(userID, {\n- permissionsFromParent: permissionsForChildren,\n+ permissionsForChildren,\n});\n}\n}\n@@ -363,7 +363,7 @@ type ChangedAncestor = {|\n+changesByUser: Map<string, AncestorChanges>,\n|};\ntype AncestorChanges = {|\n- +permissionsFromParent: ?ThreadPermissionsBlob,\n+ +permissionsForChildren: ?ThreadPermissionsBlob,\n|};\nasync function updateDescendantPermissions(\ninitialChangedAncestor: ChangedAncestor,\n@@ -463,7 +463,7 @@ async function updateDescendantPermissions(\n!_isEqual(permissionsForChildren)(curPermissionsForChildren)\n) {\nusersForNextLayer.set(userID, {\n- permissionsFromParent: permissionsForChildren,\n+ permissionsForChildren,\n});\n}\n}\n@@ -541,7 +541,7 @@ async function fetchDescendantsForUpdate(\nuser = {};\ndescendantThreadInfo.users.set(userID, user);\n}\n- user.nextPermissionsFromParent = changes.permissionsFromParent;\n+ user.nextPermissionsFromParent = changes.permissionsForChildren;\nuser.potentiallyNeedsUpdate = true;\n}\n}\n@@ -700,7 +700,7 @@ async function recalculateThreadPermissions(\n!_isEqual(permissionsForChildren)(oldPermissionsForChildren)\n) {\ntoUpdateDescendants.set(userID, {\n- permissionsFromParent: permissionsForChildren,\n+ permissionsForChildren,\n});\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Rename AncestorChanges.permissionsFromParent to permissionsForChildren
Summary: We'll be naming the properties from the context of the parent, not the child, going forward.
Test Plan: Flow
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1370 |
129,187 | 07.06.2021 23:32:39 | 14,400 | 25fff13695f818cbc187eca1982c4adcfbef02b4 | [server] Pass userIsMember in to updateDescendantPermissions
Summary: It will be checked in a future diff, which will update the fetch query and handle the new results.
Test Plan: Flow
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -265,6 +265,7 @@ async function changeRole(\n!_isEqual(permissionsForChildren)(oldPermissionsForChildren)\n) {\ntoUpdateDescendants.set(userID, {\n+ userIsMember: Number(newRole) > 0,\npermissionsForChildren,\n});\n}\n@@ -363,6 +364,7 @@ type ChangedAncestor = {|\n+changesByUser: Map<string, AncestorChanges>,\n|};\ntype AncestorChanges = {|\n+ +userIsMember: boolean,\n+permissionsForChildren: ?ThreadPermissionsBlob,\n|};\nasync function updateDescendantPermissions(\n@@ -463,6 +465,7 @@ async function updateDescendantPermissions(\n!_isEqual(permissionsForChildren)(curPermissionsForChildren)\n) {\nusersForNextLayer.set(userID, {\n+ userIsMember: Number(newRole) > 0,\npermissionsForChildren,\n});\n}\n@@ -700,6 +703,7 @@ async function recalculateThreadPermissions(\n!_isEqual(permissionsForChildren)(oldPermissionsForChildren)\n) {\ntoUpdateDescendants.set(userID, {\n+ userIsMember: Number(newRole) > 0,\npermissionsForChildren,\n});\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Pass userIsMember in to updateDescendantPermissions
Summary: It will be checked in a future diff, which will update the fetch query and handle the new results.
Test Plan: Flow
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1371 |
129,187 | 08.06.2021 00:02:20 | 14,400 | 91a1eda42f3bfd4f98f31f8703f6c035e674e629 | [server] Update updateDescendantPermissions to consider containing thread membership
Summary: This was done for `changeRole` in D1350 and for `recalculateThreadPermissions` in D1351.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -388,6 +388,9 @@ async function updateDescendantPermissions(\nconst {\ncurRole,\ncurRolePermissions,\n+ curPermissionsFromParent,\n+ curMemberOfContainingThread,\n+ nextMemberOfContainingThread,\nnextPermissionsFromParent,\npotentiallyNeedsUpdate,\n} = user;\n@@ -398,17 +401,23 @@ async function updateDescendantPermissions(\nif (!potentiallyNeedsUpdate) {\ncontinue;\n}\n- invariant(\n- nextPermissionsFromParent,\n- 'currently, an update to permissionsFromParent is the only reason ' +\n- 'that potentiallyNeedsUpdate should be set',\n- );\n- const targetRole = curRole ?? '0';\n+ const permissionsFromParent =\n+ nextPermissionsFromParent === undefined\n+ ? curPermissionsFromParent\n+ : nextPermissionsFromParent;\n+ const memberOfContainingThread =\n+ nextMemberOfContainingThread === undefined\n+ ? curMemberOfContainingThread\n+ : nextMemberOfContainingThread;\n+ const targetRole = memberOfContainingThread && curRole ? curRole : '0';\n+ const rolePermissions = memberOfContainingThread\n+ ? curRolePermissions\n+ : null;\nconst permissions = makePermissionsBlob(\n- curRolePermissions,\n- nextPermissionsFromParent,\n+ rolePermissions,\n+ permissionsFromParent,\nthreadID,\nthreadType,\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Update updateDescendantPermissions to consider containing thread membership
Summary: This was done for `changeRole` in D1350 and for `recalculateThreadPermissions` in D1351.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1374 |
129,187 | 08.06.2021 00:16:43 | 14,400 | 340ca6d37a3372c05880748168d4515283066ef3 | [server] Support multiple ancestors in fetchDescendantsForUpdate
Summary: This optimization was hard to do in the past, but since I am going to rework `updateDescendantPermissions` to iterate by depth, it becomes trivial.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -376,7 +376,7 @@ async function updateDescendantPermissions(\nwhile (stack.length > 0) {\nconst ancestor = stack.shift();\n- const descendants = await fetchDescendantsForUpdate(ancestor);\n+ const descendants = await fetchDescendantsForUpdate([ancestor]);\nfor (const descendant of descendants) {\nconst { threadID, threadType, depth, users } = descendant;\n@@ -511,9 +511,9 @@ type DescendantInfo = {|\n+users: Map<string, DescendantUserInfo>,\n|};\nasync function fetchDescendantsForUpdate(\n- ancestor: ChangedAncestor,\n+ ancestors: $ReadOnlyArray<ChangedAncestor>,\n): Promise<DescendantInfo[]> {\n- const { threadID } = ancestor;\n+ const threadIDs = ancestors.map((ancestor) => ancestor.threadID);\nconst query = SQL`\nSELECT t.id, m.user, t.type, t.depth, t.parent_thread_id,\nt.containing_thread_id, r.permissions AS role_permissions, m.permissions,\n@@ -527,8 +527,8 @@ async function fetchDescendantsForUpdate(\nLEFT JOIN memberships cm\nON cm.thread = t.containing_thread_id AND cm.user = m.user\nLEFT JOIN roles r ON r.id = m.role\n- WHERE t.parent_thread_id = ${threadID}\n- OR t.containing_thread_id = ${threadID}\n+ WHERE t.parent_thread_id IN (${threadIDs})\n+ OR t.containing_thread_id IN (${threadIDs})\n`;\nconst [result] = await dbQuery(query);\n@@ -561,7 +561,8 @@ async function fetchDescendantsForUpdate(\n});\n}\n- const { changesByUser } = ancestor;\n+ for (const ancestor of ancestors) {\n+ const { threadID, changesByUser } = ancestor;\nfor (const [userID, changes] of changesByUser) {\nfor (const descendantThreadInfo of descendantThreadInfos.values()) {\nconst {\n@@ -569,16 +570,19 @@ async function fetchDescendantsForUpdate(\nparentThreadID,\ncontainingThreadID,\n} = descendantThreadInfo;\n+ if (threadID !== parentThreadID && threadID !== containingThreadID) {\n+ continue;\n+ }\nlet user = users.get(userID);\nif (!user) {\nuser = {};\nusers.set(userID, user);\n}\n- if (parentThreadID === threadID) {\n+ if (threadID === parentThreadID) {\nuser.nextPermissionsFromParent = changes.permissionsForChildren;\nuser.potentiallyNeedsUpdate = true;\n}\n- if (containingThreadID === threadID) {\n+ if (threadID === containingThreadID) {\nuser.nextMemberOfContainingThread = changes.userIsMember;\nif (!user.nextMemberOfContainingThread) {\nuser.potentiallyNeedsUpdate = true;\n@@ -586,6 +590,7 @@ async function fetchDescendantsForUpdate(\n}\n}\n}\n+ }\nreturn [...descendantThreadInfos.values()];\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Support multiple ancestors in fetchDescendantsForUpdate
Summary: This optimization was hard to do in the past, but since I am going to rework `updateDescendantPermissions` to iterate by depth, it becomes trivial.
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1375 |
129,187 | 08.06.2021 00:24:56 | 14,400 | 13d830007e91cc033a9a271b0ee236619fa0dceb | [server] Batch fetchDescendantsForUpdate fetches
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -510,10 +510,15 @@ type DescendantInfo = {|\n+depth: number,\n+users: Map<string, DescendantUserInfo>,\n|};\n+const fetchDescendantsBatchSize = 10;\nasync function fetchDescendantsForUpdate(\nancestors: $ReadOnlyArray<ChangedAncestor>,\n): Promise<DescendantInfo[]> {\nconst threadIDs = ancestors.map((ancestor) => ancestor.threadID);\n+\n+ const rows = [];\n+ while (threadIDs.length > 0) {\n+ const batch = threadIDs.splice(0, fetchDescendantsBatchSize);\nconst query = SQL`\nSELECT t.id, m.user, t.type, t.depth, t.parent_thread_id,\nt.containing_thread_id, r.permissions AS role_permissions, m.permissions,\n@@ -527,13 +532,15 @@ async function fetchDescendantsForUpdate(\nLEFT JOIN memberships cm\nON cm.thread = t.containing_thread_id AND cm.user = m.user\nLEFT JOIN roles r ON r.id = m.role\n- WHERE t.parent_thread_id IN (${threadIDs})\n- OR t.containing_thread_id IN (${threadIDs})\n+ WHERE t.parent_thread_id IN (${batch})\n+ OR t.containing_thread_id IN (${batch})\n`;\n- const [result] = await dbQuery(query);\n+ const [results] = await dbQuery(query);\n+ pushAll(rows, results);\n+ }\nconst descendantThreadInfos: Map<string, DescendantInfo> = new Map();\n- for (const row of result) {\n+ for (const row of rows) {\nconst descendantThreadID = row.id.toString();\nif (!descendantThreadInfos.has(descendantThreadID)) {\ndescendantThreadInfos.set(descendantThreadID, {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Batch fetchDescendantsForUpdate fetches
Test Plan: Will be tested in combination with following diffs
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1376 |
129,190 | 15.06.2021 14:46:55 | -7,200 | 303de37ea36ce30895d357a8d869e0660f581115 | [native] Apply core data provider
Summary: Apply core data provider introduced in D1121
Test Plan: todo
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, palys-swm, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-input-bar.react.js",
"new_path": "native/chat/chat-input-bar.react.js",
"diff": "@@ -54,6 +54,7 @@ import {\nimport Button from '../components/button.react';\nimport ClearableTextInput from '../components/clearable-text-input.react';\n+import { type UpdateDraft, type MoveDraft, useDrafts } from '../data/core-data';\nimport { type InputState, InputStateContext } from '../input/input-state';\nimport { getKeyboardHeight } from '../keyboard/keyboard';\nimport KeyboardInputHost from '../keyboard/keyboard-input-host.react';\n@@ -110,6 +111,8 @@ type Props = {|\n// Redux state\n+viewerID: ?string,\n+draft: string,\n+ +updateDraft: UpdateDraft,\n+ +moveDraft: MoveDraft,\n+joinThreadLoadingStatus: LoadingStatus,\n+threadCreationInProgress: boolean,\n+calendarQuery: () => CalendarQuery,\n@@ -301,18 +304,17 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props, prevState: State) {\n- const { draft } = this.props;\nif (\nthis.state.textEdited &&\nthis.state.text &&\nthis.props.threadInfo.id !== prevProps.threadInfo.id\n) {\n- global.CommCoreModule.moveDraft(\n+ this.props.moveDraft(\ndraftKeyFromThreadID(prevProps.threadInfo.id),\ndraftKeyFromThreadID(this.props.threadInfo.id),\n);\n- } else if (!this.state.textEdited && draft !== prevProps.draft) {\n- this.setState({ text: draft });\n+ } else if (!this.state.textEdited && this.props.draft !== prevProps.draft) {\n+ this.setState({ text: this.props.draft });\n}\nif (this.props.isActive && !prevProps.isActive) {\nthis.addReplyListener();\n@@ -582,7 +584,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n};\nsaveDraft = _throttle((text) => {\n- global.CommCoreModule.updateDraft({\n+ this.props.updateDraft({\nkey: draftKeyFromThreadID(this.props.threadInfo.id),\ntext,\n});\n@@ -810,14 +812,7 @@ export default React.memo<BaseProps>(function ConnectedChatInputBar(\n[props.threadInfo.id, navContext],\n);\n- const draftKey = draftKeyFromThreadID(props.threadInfo.id);\n- const [draft, setDraft] = React.useState('');\n- React.useEffect(() => {\n- (async () => {\n- const fetchedDraft = await global.CommCoreModule.getDraft(draftKey);\n- setDraft(fetchedDraft);\n- })();\n- }, [draftKey]);\n+ const { draft, updateDraft, moveDraft } = useDrafts(props.threadInfo.id);\nconst viewerID = useSelector(\n(state) => state.currentUserInfo && state.currentUserInfo.id,\n@@ -881,6 +876,8 @@ export default React.memo<BaseProps>(function ConnectedChatInputBar(\n{...props}\nviewerID={viewerID}\ndraft={draft}\n+ updateDraft={updateDraft}\n+ moveDraft={moveDraft}\njoinThreadLoadingStatus={joinThreadLoadingStatus}\nthreadCreationInProgress={threadCreationInProgress}\ncalendarQuery={calendarQuery}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/thread-draft-updater.react.js",
"new_path": "native/chat/thread-draft-updater.react.js",
"diff": "@@ -6,6 +6,7 @@ import * as React from 'react';\nimport { pendingToRealizedThreadIDsSelector } from 'lib/selectors/thread-selectors';\nimport { draftKeyFromThreadID } from 'lib/shared/thread-utils';\n+import { useDrafts } from '../data/core-data';\nimport type { AppState } from '../redux/redux-setup';\nimport { useSelector } from '../redux/redux-utils';\n@@ -18,6 +19,7 @@ const ThreadDraftUpdater: React.AbstractComponent<\nconst pendingToRealizedThreadIDs = useSelector((state: AppState) =>\npendingToRealizedThreadIDsSelector(state.threadStore.threadInfos),\n);\n+ const drafts = useDrafts();\nconst cachedThreadIDsRef = React.useRef();\nif (!cachedThreadIDsRef.current) {\n@@ -28,6 +30,7 @@ const ThreadDraftUpdater: React.AbstractComponent<\ncachedThreadIDsRef.current = newCachedThreadIDs;\n}\n+ const { moveDraft } = drafts;\nReact.useEffect(() => {\nfor (const [pendingThreadID, threadID] of pendingToRealizedThreadIDs) {\nconst cachedThreadIDs = cachedThreadIDsRef.current;\n@@ -35,13 +38,13 @@ const ThreadDraftUpdater: React.AbstractComponent<\nif (cachedThreadIDs.has(threadID)) {\ncontinue;\n}\n- global.CommCoreModule.moveDraft(\n+ moveDraft(\ndraftKeyFromThreadID(pendingThreadID),\ndraftKeyFromThreadID(threadID),\n);\ncachedThreadIDs.add(threadID);\n}\n- }, [pendingToRealizedThreadIDs]);\n+ }, [pendingToRealizedThreadIDs, moveDraft]);\nreturn null;\n});\nThreadDraftUpdater.displayName = 'ThreadDraftUpdater';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/data/core-data-provider.react.js",
"new_path": "native/data/core-data-provider.react.js",
"diff": "import './core-module-shim';\nimport * as React from 'react';\n-import {\n- type CoreDataDrafts,\n- defaultCoreData,\n- CoreDataContext,\n-} from './core-data';\n+import { type CoreData, defaultCoreData, CoreDataContext } from './core-data';\ntype Props = {|\n+children: React.Node,\n|};\nfunction CoreDataProvider(props: Props) {\nconst [draftCache, setDraftCache] = React.useState<\n- $PropertyType<CoreDataDrafts, 'data'>,\n+ $PropertyType<$PropertyType<CoreData, 'drafts'>, 'data'>,\n>(defaultCoreData.drafts.data);\nReact.useEffect(() => {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/data/core-data.js",
"new_path": "native/data/core-data.js",
"diff": "import './core-module-shim';\nimport * as React from 'react';\n-export type CoreDataDrafts = {|\n- +data: { +[key: string]: string },\n- +updateDraft: (draft: {|\n+import { draftKeyFromThreadID } from 'lib/shared/thread-utils';\n+\n+export type UpdateDraft = (draft: {|\n+key: string,\n+text: string,\n- |}) => Promise<boolean>,\n- +moveDraft: (prevKey: string, nextKey: string) => Promise<boolean>,\n-|};\n+|}) => Promise<boolean>;\n+\n+export type MoveDraft = (prevKey: string, nextKey: string) => Promise<boolean>;\nexport type CoreData = {|\n- +drafts: CoreDataDrafts,\n+ +drafts: {|\n+ +data: { +[key: string]: string },\n+ +updateDraft: UpdateDraft,\n+ +moveDraft: MoveDraft,\n+ |},\n|};\nconst defaultCoreData = Object.freeze({\n@@ -26,4 +30,18 @@ const defaultCoreData = Object.freeze({\nconst CoreDataContext = React.createContext<CoreData>(defaultCoreData);\n-export { defaultCoreData, CoreDataContext };\n+const useDrafts = (threadID: ?string) => {\n+ const coreData = React.useContext(CoreDataContext);\n+ return React.useMemo(\n+ () => ({\n+ draft: threadID\n+ ? coreData.drafts.data[draftKeyFromThreadID(threadID)] ?? ''\n+ : '',\n+ updateDraft: coreData.drafts.updateDraft,\n+ moveDraft: coreData.drafts.moveDraft,\n+ }),\n+ [coreData, threadID],\n+ );\n+};\n+\n+export { defaultCoreData, CoreDataContext, useDrafts };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/root.react.js",
"new_path": "native/root.react.js",
"diff": "@@ -19,6 +19,7 @@ import { PersistGate } from 'redux-persist/integration/react';\nimport { actionLogger } from 'lib/utils/action-logger';\nimport ConnectedStatusBar from './connected-status-bar.react';\n+import CoreDataProvider from './data/core-data-provider.react';\nimport ErrorBoundary from './error-boundary.react';\nimport InputStateContainer from './input/input-state-container.react';\nimport LifecycleHandler from './lifecycle/lifecycle-handler.react';\n@@ -245,6 +246,7 @@ function Root() {\n}\nreturn (\n<View style={styles.app}>\n+ <CoreDataProvider>\n<NavContext.Provider value={navContext}>\n<RootContext.Provider value={rootContext}>\n<InputStateContainer>\n@@ -257,6 +259,7 @@ function Root() {\n</InputStateContainer>\n</RootContext.Provider>\n</NavContext.Provider>\n+ </CoreDataProvider>\n</View>\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Apply core data provider
Summary: Apply core data provider introduced in D1121
Test Plan: todo
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, palys-swm, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1413 |
129,187 | 18.06.2021 12:29:14 | 14,400 | b5ce61dbc9857d5355b6ddc5b1404fd6d00717ba | [lib] Allow single-character usernames for soft launch
Test Plan: Copy-pasted into a JS REPL:
Reviewers: atul
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/account-utils.js",
"new_path": "lib/shared/account-utils.js",
"diff": "@@ -10,9 +10,9 @@ import type { PreRequestUserState } from '../types/session-types';\nimport type { CurrentUserInfo } from '../types/user-types';\nconst usernameMaxLength = 191;\n-const validUsernameRegexString = `^[a-zA-Z0-9][a-zA-Z0-9-_]{5,${\n- usernameMaxLength - 1\n-}}$`;\n+const usernameMinLength = 1;\n+const secondCharRange = `{${usernameMinLength - 1},${usernameMaxLength - 1}}`;\n+const validUsernameRegexString = `^[a-zA-Z0-9][a-zA-Z0-9-_]${secondCharRange}$`;\nconst validUsernameRegex = new RegExp(validUsernameRegexString);\n// usernames used to be less restrictive (eg single chars were allowed)\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Allow single-character usernames for soft launch
Test Plan: Copy-pasted into a JS REPL: https://www.dropbox.com/s/rayjbmws1g8vmg7/Screen%20Shot%202021-06-18%20at%2012.31.28%20PM.png?dl=0
Reviewers: atul
Reviewed By: atul
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1425 |
129,187 | 18.06.2021 12:26:02 | 14,400 | c0ac27617e448cb46b961925e74329b6ab64d97d | [server] Delete a user's reports when they delete their account
Test Plan: Ran the query
Reviewers: atul
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/deleters/account-deleters.js",
"new_path": "server/src/deleters/account-deleters.js",
"diff": "@@ -74,6 +74,10 @@ async function deleteAccount(\nFROM sessions s\nLEFT JOIN ids i ON i.id = s.id\nWHERE s.user = ${deletedUserID};\n+ DELETE r, i\n+ FROM reports r\n+ LEFT JOIN ids i ON i.id = r.id\n+ WHERE r.user = ${deletedUserID};\nDELETE FROM relationships_undirected WHERE user1 = ${deletedUserID};\nDELETE FROM relationships_undirected WHERE user2 = ${deletedUserID};\nDELETE FROM relationships_directed WHERE user1 = ${deletedUserID};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Delete a user's reports when they delete their account
Test Plan: Ran the query
Reviewers: atul
Reviewed By: atul
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1424 |
129,184 | 13.06.2021 16:37:14 | 14,400 | 6f712bc130718acddc2d73568d1344c61bb40696 | [native] Use `pill` component in `thread-settings-child-thread`
Summary:
Before:
After:
Test Plan: Continues to work as expected
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-child-thread.react.js",
"new_path": "native/chat/settings/thread-settings-child-thread.react.js",
"diff": "@@ -6,8 +6,7 @@ import { View, Platform } from 'react-native';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport Button from '../../components/button.react';\n-import ColorSplotch from '../../components/color-splotch.react';\n-import { SingleLine } from '../../components/single-line.react';\n+import Pill from '../../components/pill.react';\nimport ThreadIcon from '../../components/thread-icon.react';\nimport { MessageListRouteName } from '../../navigation/route-names';\nimport { useColors, useStyles } from '../../themes/colors';\n@@ -38,8 +37,10 @@ function ThreadSettingsChildThread(props: Props) {\n<View style={styles.container}>\n<Button onPress={onPress} style={[styles.button, firstItem, lastItem]}>\n<View style={styles.leftSide}>\n- <ColorSplotch color={threadInfo.color} />\n- <SingleLine style={styles.text}>{threadInfo.uiName}</SingleLine>\n+ <Pill\n+ backgroundColor={`#${threadInfo.color}`}\n+ label={threadInfo.uiName}\n+ />\n</View>\n<ThreadIcon\nthreadType={threadInfo.type}\n@@ -77,12 +78,6 @@ const unboundStyles = {\nflexDirection: 'row',\nalignItems: 'center',\n},\n- text: {\n- flex: 1,\n- color: 'link',\n- fontSize: 16,\n- paddingLeft: 8,\n- },\n};\nexport default ThreadSettingsChildThread;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use `pill` component in `thread-settings-child-thread`
Summary:
Before: https://blob.sh/atul/thread-settings-child-thread-before.png
After: https://blob.sh/atul/thread-settings-child-thread-after.png
Test Plan: Continues to work as expected
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1398 |
129,184 | 18.06.2021 17:41:03 | 14,400 | aee87e2dee30bd713758debf0ecb3515fd930197 | [refactor] Rename `sanitizeAction` to `sanitizeActionSecrets`
Summary: Simple rename in preparation for upcoming user data sanitization diff
Test Plan: NA
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -78,7 +78,7 @@ import { setNewSessionActionType } from '../utils/action-utils';\nimport { getConfig } from '../utils/config';\nimport { dateString } from '../utils/date-utils';\nimport { values } from '../utils/objects';\n-import { sanitizeAction } from '../utils/sanitization';\n+import { sanitizeActionSecrets } from '../utils/sanitization';\nfunction daysToEntriesFromEntryInfos(entryInfos: $ReadOnlyArray<RawEntryInfo>) {\nreturn _flow(\n@@ -675,7 +675,7 @@ function findInconsistencies(\ntype: reportTypes.ENTRY_INCONSISTENCY,\nplatformDetails: getConfig().platformDetails,\nbeforeAction: beforeStateCheck,\n- action: sanitizeAction(action),\n+ action: sanitizeActionSecrets(action),\ncalendarQuery,\npushResult: afterStateCheck,\nlastActions: actionLogger.interestingActionSummaries,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/thread-reducer.js",
"new_path": "lib/reducers/thread-reducer.js",
"diff": "@@ -50,7 +50,7 @@ import {\nimport { actionLogger } from '../utils/action-logger';\nimport { setNewSessionActionType } from '../utils/action-utils';\nimport { getConfig } from '../utils/config';\n-import { sanitizeAction } from '../utils/sanitization';\n+import { sanitizeActionSecrets } from '../utils/sanitization';\nfunction reduceThreadUpdates(\nthreadInfos: { [id: string]: RawThreadInfo },\n@@ -121,7 +121,7 @@ function findInconsistencies(\ntype: reportTypes.THREAD_INCONSISTENCY,\nplatformDetails: getConfig().platformDetails,\nbeforeAction: beforeStateCheck,\n- action: sanitizeAction(action),\n+ action: sanitizeActionSecrets(action),\npushResult: afterStateCheck,\nlastActions: actionLogger.interestingActionSummaries,\ntime: Date.now(),\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/user-reducer.js",
"new_path": "lib/reducers/user-reducer.js",
"diff": "@@ -38,7 +38,7 @@ import type {\nimport { actionLogger } from '../utils/action-logger';\nimport { setNewSessionActionType } from '../utils/action-utils';\nimport { getConfig } from '../utils/config';\n-import { sanitizeAction } from '../utils/sanitization';\n+import { sanitizeActionSecrets } from '../utils/sanitization';\nfunction reduceCurrentUserInfo(\nstate: ?CurrentUserInfo,\n@@ -122,7 +122,7 @@ function findInconsistencies(\n{\ntype: reportTypes.USER_INCONSISTENCY,\nplatformDetails: getConfig().platformDetails,\n- action: sanitizeAction(action),\n+ action: sanitizeActionSecrets(action),\nbeforeStateCheck,\nafterStateCheck,\nlastActions: actionLogger.interestingActionSummaries,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/action-logger.js",
"new_path": "lib/utils/action-logger.js",
"diff": "@@ -4,7 +4,7 @@ import inspect from 'util-inspect';\nimport { rehydrateActionType } from '../types/redux-types';\nimport type { ActionSummary } from '../types/report-types';\n-import { sanitizeAction } from './sanitization';\n+import { sanitizeActionSecrets } from './sanitization';\nconst uninterestingActionTypes = new Set(['Navigation/COMPLETE_TRANSITION']);\nconst maxActionSummaryLength = 500;\n@@ -38,7 +38,7 @@ class ActionLogger {\n}\nstatic getSummaryForAction(action: Object): string {\n- const sanitized = sanitizeAction(action);\n+ const sanitized = sanitizeActionSecrets(action);\nlet summary,\nlength,\ndepth = 3;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/sanitization.js",
"new_path": "lib/utils/sanitization.js",
"diff": "@@ -8,7 +8,7 @@ import type {\n} from '../types/redux-types';\nimport { setNewSessionActionType } from './action-utils';\n-function sanitizeAction(action: BaseAction): BaseAction {\n+function sanitizeActionSecrets(action: BaseAction): BaseAction {\nif (action.type === setNewSessionActionType) {\nconst { sessionChange } = action.payload;\nif (sessionChange.cookieInvalidated) {\n@@ -61,4 +61,4 @@ function sanitizeState(state: AppState): AppState {\nreturn state;\n}\n-export { sanitizeAction, sanitizeState };\n+export { sanitizeActionSecrets, sanitizeState };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/crash.react.js",
"new_path": "native/crash.react.js",
"diff": "@@ -32,7 +32,7 @@ import {\nuseServerCall,\nuseDispatchActionPromise,\n} from 'lib/utils/action-utils';\n-import { sanitizeAction, sanitizeState } from 'lib/utils/sanitization';\n+import { sanitizeActionSecrets, sanitizeState } from 'lib/utils/sanitization';\nimport sleep from 'lib/utils/sleep';\nimport Button from './components/button.react';\n@@ -161,7 +161,7 @@ class Crash extends React.PureComponent<Props, State> {\n})),\npreloadedState: sanitizeState(actionLogger.preloadedState),\ncurrentState: sanitizeState(actionLogger.currentState),\n- actions: actionLogger.actions.map(sanitizeAction),\n+ actions: actionLogger.actions.map(sanitizeActionSecrets),\n});\nthis.setState({\nerrorReportID: result.id,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/report-creator.js",
"new_path": "server/src/creators/report-creator.js",
"diff": "@@ -17,7 +17,7 @@ import {\nreportTypes,\n} from 'lib/types/report-types';\nimport { values } from 'lib/utils/objects';\n-import { sanitizeAction, sanitizeState } from 'lib/utils/sanitization';\n+import { sanitizeActionSecrets, sanitizeState } from 'lib/utils/sanitization';\nimport { dbQuery, SQL } from '../database/database';\nimport { fetchUsername } from '../fetchers/user-fetchers';\n@@ -57,7 +57,7 @@ async function createReport(\n...report,\npreloadedState: sanitizeState(report.preloadedState),\ncurrentState: sanitizeState(report.currentState),\n- actions: report.actions.map(sanitizeAction),\n+ actions: report.actions.map(sanitizeActionSecrets),\n};\n}\nconst row = [\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [refactor] Rename `sanitizeAction` to `sanitizeActionSecrets`
Summary: Simple rename in preparation for upcoming user data sanitization diff
Test Plan: NA
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1427 |
129,184 | 21.06.2021 22:18:39 | 14,400 | 62487814ee3babe099b8f7129c649d17c00d6272 | [native] Fix `thread-visibility` icon color
Summary: Change the `thread-visibility` icon color based on the background color
Test Plan: Looks as expected (https://blob.sh/atul/thread-visibility-icon-color.png)
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/components/thread-visibility.react.js",
"new_path": "native/components/thread-visibility.react.js",
"diff": "import * as React from 'react';\nimport { View, StyleSheet } from 'react-native';\n+import tinycolor from 'tinycolor2';\nimport { threadLabel } from 'lib/shared/thread-utils';\nimport type { ThreadType } from 'lib/types/thread-types';\n@@ -16,9 +17,15 @@ type Props = {|\nfunction ThreadVisibility(props: Props) {\nconst { threadType, color } = props;\nconst label = threadLabel(threadType);\n+\n+ const iconColor = React.useMemo(\n+ () => (tinycolor(color).isDark() ? 'white' : 'black'),\n+ [color],\n+ );\n+\nconst icon = React.useMemo(\n- () => <ThreadIcon threadType={threadType} color=\"white\" />,\n- [threadType],\n+ () => <ThreadIcon threadType={threadType} color={iconColor} />,\n+ [iconColor, threadType],\n);\nreturn (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix `thread-visibility` icon color
Summary: Change the `thread-visibility` icon color based on the background color
Test Plan: Looks as expected (https://blob.sh/atul/thread-visibility-icon-color.png)
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1435 |
129,184 | 21.06.2021 17:26:38 | 14,400 | 6e06ac376c82127819204fa684c38c1210e126fe | [lib] Factor out common functionality from `crash.react` and `report-creator` into `sanitizeReduxReport`
Test Plan: Continues to work as expected
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/sanitization.js",
"new_path": "lib/utils/sanitization.js",
"diff": "@@ -11,6 +11,12 @@ import type {\n} from '../types/redux-types';\nimport { setNewSessionActionType } from './action-utils';\n+export type ReduxCrashReport = {|\n+ +preloadedState: AppState,\n+ +currentState: AppState,\n+ +actions: $ReadOnlyArray<BaseAction>,\n+|};\n+\n// eg {\"email\":\"squad@bot.com\"} => {\"email\":\"[redacted]\"}\nconst keysWithStringsToBeRedacted = new Set([\n'source',\n@@ -119,6 +125,17 @@ function scrambleText(str: string): string {\nreturn arr.join('');\n}\n+function sanitizeReduxReport(reduxReport: ReduxCrashReport): ReduxCrashReport {\n+ const redact = generateSaltedRedactionFn();\n+ return {\n+ preloadedState: sanitizeState(reduxReport.preloadedState, redact),\n+ currentState: sanitizeState(reduxReport.currentState, redact),\n+ actions: reduxReport.actions.map((x) =>\n+ sanitizeAction(sanitizeActionSecrets(x), redact),\n+ ),\n+ };\n+}\n+\nconst MessageListRouteName = 'MessageList';\nconst ThreadSettingsRouteName = 'ThreadSettings';\n@@ -250,5 +267,5 @@ export {\nsanitizeActionSecrets,\nsanitizeAction,\nsanitizeState,\n- generateSaltedRedactionFn,\n+ sanitizeReduxReport,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/crash.react.js",
"new_path": "native/crash.react.js",
"diff": "@@ -33,10 +33,8 @@ import {\nuseDispatchActionPromise,\n} from 'lib/utils/action-utils';\nimport {\n- sanitizeActionSecrets,\n- sanitizeAction,\n- sanitizeState,\n- generateSaltedRedactionFn,\n+ sanitizeReduxReport,\n+ type ReduxCrashReport,\n} from 'lib/utils/sanitization';\nimport sleep from 'lib/utils/sleep';\n@@ -152,7 +150,11 @@ class Crash extends React.PureComponent<Props, State> {\n}\nasync sendReport() {\n- const redact = generateSaltedRedactionFn();\n+ const sanitizedReduxReport: ReduxCrashReport = sanitizeReduxReport({\n+ preloadedState: actionLogger.preloadedState,\n+ currentState: actionLogger.currentState,\n+ actions: actionLogger.actions,\n+ });\nconst result = await this.props.sendReport({\ntype: reportTypes.ERROR,\nplatformDetails: {\n@@ -165,11 +167,7 @@ class Crash extends React.PureComponent<Props, State> {\nstack: data.error.stack,\ncomponentStack: data.info && data.info.componentStack,\n})),\n- preloadedState: sanitizeState(actionLogger.preloadedState, redact),\n- currentState: sanitizeState(actionLogger.currentState, redact),\n- actions: actionLogger.actions.map((x) =>\n- sanitizeAction(sanitizeActionSecrets(x), redact),\n- ),\n+ ...sanitizedReduxReport,\n});\nthis.setState({\nerrorReportID: result.id,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/report-creator.js",
"new_path": "server/src/creators/report-creator.js",
"diff": "@@ -18,10 +18,8 @@ import {\n} from 'lib/types/report-types';\nimport { values } from 'lib/utils/objects';\nimport {\n- sanitizeActionSecrets,\n- sanitizeState,\n- sanitizeAction,\n- generateSaltedRedactionFn,\n+ sanitizeReduxReport,\n+ type ReduxCrashReport,\n} from 'lib/utils/sanitization';\nimport { dbQuery, SQL } from '../database/database';\n@@ -57,15 +55,15 @@ async function createReport(\n({ type, time, ...report } = request);\n} else {\n({ type, ...report } = request);\n- const redact = generateSaltedRedactionFn();\ntime = Date.now();\n+ const redactedReduxReport: ReduxCrashReport = sanitizeReduxReport({\n+ preloadedState: report.preloadedState,\n+ currentState: report.currentState,\n+ actions: report.actions,\n+ });\nreport = {\n...report,\n- preloadedState: sanitizeState(report.preloadedState, redact),\n- currentState: sanitizeState(report.currentState, redact),\n- actions: report.actions.map((x) =>\n- sanitizeAction(sanitizeActionSecrets(x), redact),\n- ),\n+ ...redactedReduxReport,\n};\n}\nconst row = [\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Factor out common functionality from `crash.react` and `report-creator` into `sanitizeReduxReport`
Test Plan: Continues to work as expected
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1433 |
129,184 | 21.06.2021 21:22:01 | 14,400 | 136f250d910aacea4d3961e11e0e85995194cf26 | [lib] Introduce `generateColorRedactionFn` and use in `sanitizeNavState` and `sanitizePII`
Test Plan: Triggered a couple of crashes and imported into Redux Dev Tools...the colors changed as expected and were consistent throughout.
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/sanitization.js",
"new_path": "lib/utils/sanitization.js",
"diff": "@@ -17,6 +17,11 @@ export type ReduxCrashReport = {|\n+actions: $ReadOnlyArray<BaseAction>,\n|};\n+export type RedactionHelpers = {|\n+ +redactString: (string) => string,\n+ +redactColor: (string) => string,\n+|};\n+\n// eg {\"email\":\"squad@bot.com\"} => {\"email\":\"[redacted]\"}\nconst keysWithStringsToBeRedacted = new Set([\n'source',\n@@ -108,6 +113,13 @@ function generateSaltedRedactionFn(): (string) => string {\n};\n}\n+function generateColorRedactionFn(): (string) => string {\n+ const salt = Math.random().toString(16);\n+ return (oldColor: string) => {\n+ return `${stringHash(oldColor.concat(salt)).toString(16).slice(0, 6)}`;\n+ };\n+}\n+\nfunction placeholderImageURI(): string {\nreturn 'https://comm.app/images/background.png';\n}\n@@ -126,12 +138,16 @@ function scrambleText(str: string): string {\n}\nfunction sanitizeReduxReport(reduxReport: ReduxCrashReport): ReduxCrashReport {\n- const redact = generateSaltedRedactionFn();\n+ const redactionHelpers: RedactionHelpers = {\n+ redactString: generateSaltedRedactionFn(),\n+ redactColor: generateColorRedactionFn(),\n+ };\n+\nreturn {\n- preloadedState: sanitizeState(reduxReport.preloadedState, redact),\n- currentState: sanitizeState(reduxReport.currentState, redact),\n+ preloadedState: sanitizeState(reduxReport.preloadedState, redactionHelpers),\n+ currentState: sanitizeState(reduxReport.currentState, redactionHelpers),\nactions: reduxReport.actions.map((x) =>\n- sanitizeAction(sanitizeActionSecrets(x), redact),\n+ sanitizeAction(sanitizeActionSecrets(x), redactionHelpers),\n),\n};\n}\n@@ -139,62 +155,70 @@ function sanitizeReduxReport(reduxReport: ReduxCrashReport): ReduxCrashReport {\nconst MessageListRouteName = 'MessageList';\nconst ThreadSettingsRouteName = 'ThreadSettings';\n-function sanitizeNavState(obj: Object, redact: (string) => string): void {\n+function sanitizeNavState(\n+ obj: Object,\n+ redactionHelpers: RedactionHelpers,\n+): void {\nfor (const k in obj) {\nif (k === 'params') {\n- sanitizePII(obj[k], redact);\n+ sanitizePII(obj[k], redactionHelpers);\n} else if (k === 'key' && obj[k].startsWith(MessageListRouteName)) {\n- obj[k] = `${MessageListRouteName}${redact(\n+ obj[k] = `${MessageListRouteName}${redactionHelpers.redactString(\nobj[k].substring(MessageListRouteName.length),\n)}`;\n} else if (k === 'key' && obj[k].startsWith(ThreadSettingsRouteName)) {\n- obj[k] = `${ThreadSettingsRouteName}${redact(\n+ obj[k] = `${ThreadSettingsRouteName}${redactionHelpers.redactString(\nobj[k].substring(ThreadSettingsRouteName.length),\n)}`;\n} else if (typeof obj[k] === 'object') {\n- sanitizeNavState(obj[k], redact);\n+ sanitizeNavState(obj[k], redactionHelpers);\n}\n}\n}\n-function sanitizePII(obj: Object, redact: (string) => string): void {\n+function sanitizePII(obj: Object, redactionHelpers: RedactionHelpers): void {\nfor (const k in obj) {\nif (k === 'navState') {\n- sanitizeNavState(obj[k], redact);\n+ sanitizeNavState(obj[k], redactionHelpers);\ncontinue;\n}\nif (keysWithObjectsWithKeysToBeRedacted.has(k)) {\nfor (const keyToBeRedacted in obj[k]) {\n- obj[k][redact(keyToBeRedacted)] = obj[k][keyToBeRedacted];\n+ obj[k][redactionHelpers.redactString(keyToBeRedacted)] =\n+ obj[k][keyToBeRedacted];\ndelete obj[k][keyToBeRedacted];\n}\n}\nif (keysWithObjectsWithArraysToBeRedacted.has(k)) {\nfor (const arrayToBeRedacted in obj[k]) {\n- obj[k][arrayToBeRedacted] = obj[k][arrayToBeRedacted].map(redact);\n+ obj[k][arrayToBeRedacted] = obj[k][arrayToBeRedacted].map(\n+ redactionHelpers.redactString,\n+ );\n}\n}\nif (keysWithStringsToBeRedacted.has(k) && typeof obj[k] === 'string') {\n- obj[k] = redact(obj[k]);\n+ obj[k] = redactionHelpers.redactString(obj[k]);\n} else if (k === 'key' && obj[k].startsWith(MessageListRouteName)) {\n- obj[k] = `${MessageListRouteName}${redact(\n+ obj[k] = `${MessageListRouteName}${redactionHelpers.redactString(\nobj[k].substring(MessageListRouteName.length),\n)}`;\n} else if (k === 'key' && obj[k].startsWith(ThreadSettingsRouteName)) {\n- obj[k] = `${ThreadSettingsRouteName}${redact(\n+ obj[k] = `${ThreadSettingsRouteName}${redactionHelpers.redactString(\nobj[k].substring(ThreadSettingsRouteName.length),\n)}`;\n+ } else if (k === 'color') {\n+ obj[k] = redactionHelpers.redactColor(obj[k]);\n} else if (keysWithStringsToBeScrambled.has(k)) {\nobj[k] = scrambleText(obj[k]);\n} else if (keysWithImageURIsToBeReplaced.has(k)) {\nobj[k] = placeholderImageURI();\n} else if (keysWithArraysToBeRedacted.has(k)) {\n- obj[k] = obj[k].map(redact);\n+ obj[k] = obj[k].map(redactionHelpers.redactString);\n} else if (typeof obj[k] === 'object') {\n- sanitizePII(obj[k], redact);\n+ sanitizePII(obj[k], redactionHelpers);\n}\n}\n}\n@@ -242,14 +266,17 @@ function sanitizeActionSecrets(action: BaseAction): BaseAction {\nfunction sanitizeAction(\naction: BaseAction,\n- redact: (string) => string,\n+ redactionHelpers: RedactionHelpers,\n): BaseAction {\nconst actionCopy = clone(action);\n- sanitizePII(actionCopy, redact);\n+ sanitizePII(actionCopy, redactionHelpers);\nreturn actionCopy;\n}\n-function sanitizeState(state: AppState, redact: (string) => string): AppState {\n+function sanitizeState(\n+ state: AppState,\n+ redactionHelpers: RedactionHelpers,\n+): AppState {\nif (state.cookie !== undefined && state.cookie !== null) {\nconst oldState: NativeAppState = state;\nstate = { ...oldState, cookie: null };\n@@ -259,7 +286,7 @@ function sanitizeState(state: AppState, redact: (string) => string): AppState {\nstate = { ...oldState, deviceToken: null };\n}\nconst stateCopy = clone(state);\n- sanitizePII(stateCopy, redact);\n+ sanitizePII(stateCopy, redactionHelpers);\nreturn stateCopy;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Introduce `generateColorRedactionFn` and use in `sanitizeNavState` and `sanitizePII`
Test Plan: Triggered a couple of crashes and imported into Redux Dev Tools...the colors changed as expected and were consistent throughout.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1434 |
129,184 | 22.06.2021 11:53:50 | 14,400 | 67eed3fa1c134a15d850282dfe258b742990cf38 | [lib] Pull out common `...RouteName` redaction functionality from `sanitizePII` and `sanitizeNavState`
Test Plan: Triggered crash from developer menu, imported crash report into Redux dev tools
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/sanitization.js",
"new_path": "lib/utils/sanitization.js",
"diff": "@@ -155,6 +155,22 @@ function sanitizeReduxReport(reduxReport: ReduxCrashReport): ReduxCrashReport {\nconst MessageListRouteName = 'MessageList';\nconst ThreadSettingsRouteName = 'ThreadSettings';\n+function potentiallyRedactReactNavigationKey(\n+ key: string,\n+ redactionFn: (string) => string,\n+): string {\n+ if (key.startsWith(MessageListRouteName)) {\n+ return `${MessageListRouteName}${redactionFn(\n+ key.substring(MessageListRouteName.length),\n+ )}`;\n+ } else if (key.startsWith(ThreadSettingsRouteName)) {\n+ return `${ThreadSettingsRouteName}${redactionFn(\n+ key.substring(ThreadSettingsRouteName.length),\n+ )}`;\n+ }\n+ return key;\n+}\n+\nfunction sanitizeNavState(\nobj: Object,\nredactionHelpers: RedactionHelpers,\n@@ -162,14 +178,11 @@ function sanitizeNavState(\nfor (const k in obj) {\nif (k === 'params') {\nsanitizePII(obj[k], redactionHelpers);\n- } else if (k === 'key' && obj[k].startsWith(MessageListRouteName)) {\n- obj[k] = `${MessageListRouteName}${redactionHelpers.redactString(\n- obj[k].substring(MessageListRouteName.length),\n- )}`;\n- } else if (k === 'key' && obj[k].startsWith(ThreadSettingsRouteName)) {\n- obj[k] = `${ThreadSettingsRouteName}${redactionHelpers.redactString(\n- obj[k].substring(ThreadSettingsRouteName.length),\n- )}`;\n+ } else if (k === 'key') {\n+ obj[k] = potentiallyRedactReactNavigationKey(\n+ obj[k],\n+ redactionHelpers.redactString,\n+ );\n} else if (typeof obj[k] === 'object') {\nsanitizeNavState(obj[k], redactionHelpers);\n}\n@@ -201,14 +214,11 @@ function sanitizePII(obj: Object, redactionHelpers: RedactionHelpers): void {\nif (keysWithStringsToBeRedacted.has(k) && typeof obj[k] === 'string') {\nobj[k] = redactionHelpers.redactString(obj[k]);\n- } else if (k === 'key' && obj[k].startsWith(MessageListRouteName)) {\n- obj[k] = `${MessageListRouteName}${redactionHelpers.redactString(\n- obj[k].substring(MessageListRouteName.length),\n- )}`;\n- } else if (k === 'key' && obj[k].startsWith(ThreadSettingsRouteName)) {\n- obj[k] = `${ThreadSettingsRouteName}${redactionHelpers.redactString(\n- obj[k].substring(ThreadSettingsRouteName.length),\n- )}`;\n+ } else if (k === 'key') {\n+ obj[k] = potentiallyRedactReactNavigationKey(\n+ obj[k],\n+ redactionHelpers.redactString,\n+ );\n} else if (k === 'color') {\nobj[k] = redactionHelpers.redactColor(obj[k]);\n} else if (keysWithStringsToBeScrambled.has(k)) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Pull out common `...RouteName` redaction functionality from `sanitizePII` and `sanitizeNavState`
Test Plan: Triggered crash from developer menu, imported crash report into Redux dev tools
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1439 |
129,187 | 23.06.2021 11:23:56 | 14,400 | 8cbc5c0895ec3fe3bc840cd22833b00522a08b8c | Update LICENSE
Reference Comm | [
{
"change_type": "MODIFY",
"old_path": "LICENSE",
"new_path": "LICENSE",
"diff": "-Copyright (c) 2016, Ashoat\n+Copyright (c) 2021, Comm Technologies, Inc.\nAll rights reserved.\nRedistribution and use in source and binary forms, with or without\n@@ -11,7 +11,7 @@ modification, are permitted provided that the following conditions are met:\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n-* Neither the name of squadcal nor the names of its\n+* Neither the name of Comm nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update LICENSE
Reference Comm |
129,187 | 22.06.2021 13:49:34 | 14,400 | 6ddf8e4f1977a2082d8ca7e9766f45a24f666fbb | [lib][native][web] Disable logging in with email
Summary: This is part of the [task](https://www.notion.so/commapp/Don-t-take-emails-during-signup-93e41f772b1349f2be8215896c0f31f8) to get rid of emails.
Test Plan: Flow, play around with log in
Reviewers: atul, palys-swm
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/types/account-types.js",
"new_path": "lib/types/account-types.js",
"diff": "@@ -94,13 +94,14 @@ export type LogInExtraInfo = {|\nexport type LogInInfo = {|\n...LogInExtraInfo,\n- +usernameOrEmail: string,\n+ +username: string,\n+password: string,\n+source?: ?LogInActionSource,\n|};\nexport type LogInRequest = {|\n- +usernameOrEmail: string,\n+ +usernameOrEmail?: ?string,\n+ +username?: ?string,\n+password: string,\n+calendarQuery?: ?CalendarQuery,\n+deviceTokenUpdateRequest?: ?DeviceTokenUpdateRequest,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/forgot-password-panel.react.js",
"new_path": "native/account/forgot-password-panel.react.js",
"diff": "@@ -23,10 +23,7 @@ import {\n} from 'lib/utils/action-utils';\nimport { useSelector } from '../redux/redux-utils';\n-import {\n- TextInput,\n- usernamePlaceholderSelector,\n-} from './modal-components.react';\n+import { TextInput } from './modal-components.react';\nimport { PanelButton, Panel } from './panel-components.react';\ntype BaseProps = {|\n@@ -38,7 +35,6 @@ type Props = {|\n...BaseProps,\n// Redux state\n+loadingStatus: LoadingStatus,\n- +usernamePlaceholder: string,\n// Redux dispatch functions\n+dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -62,7 +58,7 @@ class ForgotPasswordPanel extends React.PureComponent<Props, State> {\nstyle={styles.input}\nvalue={this.state.usernameOrEmailInputText}\nonChangeText={this.onChangeUsernameOrEmailInputText}\n- placeholder={this.props.usernamePlaceholder}\n+ placeholder=\"Username\"\nautoFocus={true}\nautoCorrect={false}\nautoCapitalize=\"none\"\n@@ -172,7 +168,6 @@ export default React.memo<BaseProps>(function ConnectedForgotPasswordPanel(\nprops: BaseProps,\n) {\nconst loadingStatus = useSelector(loadingStatusSelector);\n- const usernamePlaceholder = useSelector(usernamePlaceholderSelector);\nconst dispatchActionPromise = useDispatchActionPromise();\nconst callForgotPassword = useServerCall(forgotPassword);\n@@ -181,7 +176,6 @@ export default React.memo<BaseProps>(function ConnectedForgotPasswordPanel(\n<ForgotPasswordPanel\n{...props}\nloadingStatus={loadingStatus}\n- usernamePlaceholder={usernamePlaceholder}\ndispatchActionPromise={dispatchActionPromise}\nforgotPassword={callForgotPassword}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel-container.react.js",
"new_path": "native/account/log-in-panel-container.react.js",
"diff": "@@ -206,7 +206,7 @@ class BaseLogInPanelContainer extends React.PureComponent<Props, State> {\nnextLogInMode: 'log-in',\n});\ninvariant(this.logInPanel, 'ref should be set');\n- this.logInPanel.focusUsernameOrEmailInput();\n+ this.logInPanel.focusUsernameInput();\nthis.props.hideForgotPasswordLink.setValue(0);\nthis.panelTransitionTarget.setValue(modeNumbers['log-in']);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -8,10 +8,7 @@ import Icon from 'react-native-vector-icons/FontAwesome';\nimport { logInActionTypes, logIn } from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import {\n- oldValidUsernameRegex,\n- validEmailRegex,\n-} from 'lib/shared/account-utils';\n+import { oldValidUsernameRegex } from 'lib/shared/account-utils';\nimport type {\nLogInInfo,\nLogInExtraInfo,\n@@ -29,10 +26,7 @@ import { NavContext } from '../navigation/navigation-context';\nimport { useSelector } from '../redux/redux-utils';\nimport { nativeLogInExtraInfoSelector } from '../selectors/account-selectors';\nimport type { StateContainer } from '../utils/state-container';\n-import {\n- TextInput,\n- usernamePlaceholderSelector,\n-} from './modal-components.react';\n+import { TextInput } from './modal-components.react';\nimport {\nfetchNativeCredentials,\nsetNativeCredentials,\n@@ -40,7 +34,7 @@ import {\nimport { PanelButton, Panel } from './panel-components.react';\nexport type LogInState = {|\n- +usernameOrEmailInputText: ?string,\n+ +usernameInputText: ?string,\n+passwordInputText: ?string,\n|};\ntype BaseProps = {|\n@@ -54,14 +48,13 @@ type Props = {|\n// Redux state\n+loadingStatus: LoadingStatus,\n+logInExtraInfo: () => LogInExtraInfo,\n- +usernamePlaceholder: string,\n// Redux dispatch functions\n+dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n+logIn: (logInInfo: LogInInfo) => Promise<LogInResult>,\n|};\nclass LogInPanel extends React.PureComponent<Props> {\n- usernameOrEmailInput: ?TextInput;\n+ usernameInput: ?TextInput;\npasswordInput: ?TextInput;\ncomponentDidMount() {\n@@ -73,8 +66,8 @@ class LogInPanel extends React.PureComponent<Props> {\nthis.props.innerRef(null);\n}\n- get usernameOrEmailInputText(): string {\n- return this.props.logInState.state.usernameOrEmailInputText || '';\n+ get usernameInputText(): string {\n+ return this.props.logInState.state.usernameInputText || '';\n}\nget passwordInputText(): string {\n@@ -83,8 +76,8 @@ class LogInPanel extends React.PureComponent<Props> {\nasync attemptToFetchCredentials() {\nif (\n- this.props.logInState.state.usernameOrEmailInputText !== null &&\n- this.props.logInState.state.usernameOrEmailInputText !== undefined\n+ this.props.logInState.state.usernameInputText !== null &&\n+ this.props.logInState.state.usernameInputText !== undefined\n) {\nreturn;\n}\n@@ -93,13 +86,13 @@ class LogInPanel extends React.PureComponent<Props> {\nreturn;\n}\nif (\n- this.props.logInState.state.usernameOrEmailInputText !== null &&\n- this.props.logInState.state.usernameOrEmailInputText !== undefined\n+ this.props.logInState.state.usernameInputText !== null &&\n+ this.props.logInState.state.usernameInputText !== undefined\n) {\nreturn;\n}\nthis.props.logInState.setState({\n- usernameOrEmailInputText: credentials.username,\n+ usernameInputText: credentials.username,\npasswordInputText: credentials.password,\n});\n}\n@@ -111,10 +104,10 @@ class LogInPanel extends React.PureComponent<Props> {\n<Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n<TextInput\nstyle={styles.input}\n- value={this.usernameOrEmailInputText}\n- onChangeText={this.onChangeUsernameOrEmailInputText}\n- onKeyPress={this.onUsernameOrEmailKeyPress}\n- placeholder={this.props.usernamePlaceholder}\n+ value={this.usernameInputText}\n+ onChangeText={this.onChangeUsernameInputText}\n+ onKeyPress={this.onUsernameKeyPress}\n+ placeholder=\"Username\"\nautoFocus={Platform.OS !== 'ios'}\nautoCorrect={false}\nautoCapitalize=\"none\"\n@@ -125,7 +118,7 @@ class LogInPanel extends React.PureComponent<Props> {\nblurOnSubmit={false}\nonSubmitEditing={this.focusPasswordInput}\neditable={this.props.loadingStatus !== 'loading'}\n- ref={this.usernameOrEmailInputRef}\n+ ref={this.usernameInputRef}\n/>\n</View>\n<View>\n@@ -154,16 +147,16 @@ class LogInPanel extends React.PureComponent<Props> {\n);\n}\n- usernameOrEmailInputRef = (usernameOrEmailInput: ?TextInput) => {\n- this.usernameOrEmailInput = usernameOrEmailInput;\n- if (Platform.OS === 'ios' && usernameOrEmailInput) {\n- setTimeout(() => usernameOrEmailInput.focus());\n+ usernameInputRef = (usernameInput: ?TextInput) => {\n+ this.usernameInput = usernameInput;\n+ if (Platform.OS === 'ios' && usernameInput) {\n+ setTimeout(() => usernameInput.focus());\n}\n};\n- focusUsernameOrEmailInput = () => {\n- invariant(this.usernameOrEmailInput, 'ref should be set');\n- this.usernameOrEmailInput.focus();\n+ focusUsernameInput = () => {\n+ invariant(this.usernameInput, 'ref should be set');\n+ this.usernameInput.focus();\n};\npasswordInputRef = (passwordInput: ?TextInput) => {\n@@ -175,11 +168,11 @@ class LogInPanel extends React.PureComponent<Props> {\nthis.passwordInput.focus();\n};\n- onChangeUsernameOrEmailInputText = (text: string) => {\n- this.props.logInState.setState({ usernameOrEmailInputText: text });\n+ onChangeUsernameInputText = (text: string) => {\n+ this.props.logInState.setState({ usernameInputText: text });\n};\n- onUsernameOrEmailKeyPress = (\n+ onUsernameKeyPress = (\nevent: $ReadOnly<{ nativeEvent: $ReadOnly<{ key: string }> }>,\n) => {\nconst { key } = event.nativeEvent;\n@@ -199,14 +192,11 @@ class LogInPanel extends React.PureComponent<Props> {\nonSubmit = () => {\nthis.props.setActiveAlert(true);\n- if (\n- this.usernameOrEmailInputText.search(oldValidUsernameRegex) === -1 &&\n- this.usernameOrEmailInputText.search(validEmailRegex) === -1\n- ) {\n+ if (this.usernameInputText.search(oldValidUsernameRegex) === -1) {\nAlert.alert(\n'Invalid username',\n- 'Alphanumeric usernames or emails only',\n- [{ text: 'OK', onPress: this.onUsernameOrEmailAlertAcknowledged }],\n+ 'Alphanumeric usernames only',\n+ [{ text: 'OK', onPress: this.onUsernameAlertAcknowledged }],\n{ cancelable: false },\n);\nreturn;\n@@ -230,23 +220,20 @@ class LogInPanel extends React.PureComponent<Props> {\n);\n};\n- onUsernameOrEmailAlertAcknowledged = () => {\n+ onUsernameAlertAcknowledged = () => {\nthis.props.setActiveAlert(false);\nthis.props.logInState.setState(\n{\n- usernameOrEmailInputText: '',\n- },\n- () => {\n- invariant(this.usernameOrEmailInput, 'ref should exist');\n- this.usernameOrEmailInput.focus();\n+ usernameInputText: '',\n},\n+ this.focusUsernameInput,\n);\n};\nasync logInAction(extraInfo: LogInExtraInfo) {\ntry {\nconst result = await this.props.logIn({\n- usernameOrEmail: this.usernameOrEmailInputText,\n+ username: this.usernameInputText,\npassword: this.passwordInputText,\n...extraInfo,\n});\n@@ -261,7 +248,7 @@ class LogInPanel extends React.PureComponent<Props> {\nAlert.alert(\n'Invalid username',\n\"User doesn't exist\",\n- [{ text: 'OK', onPress: this.onUsernameOrEmailAlertAcknowledged }],\n+ [{ text: 'OK', onPress: this.onUsernameAlertAcknowledged }],\n{ cancelable: false },\n);\n} else if (e.message === 'invalid_credentials') {\n@@ -301,10 +288,7 @@ class LogInPanel extends React.PureComponent<Props> {\n{\npasswordInputText: '',\n},\n- () => {\n- invariant(this.passwordInput, 'passwordInput ref unset');\n- this.passwordInput.focus();\n- },\n+ this.focusPasswordInput,\n);\n};\n@@ -312,13 +296,10 @@ class LogInPanel extends React.PureComponent<Props> {\nthis.props.setActiveAlert(false);\nthis.props.logInState.setState(\n{\n- usernameOrEmailInputText: '',\n+ usernameInputText: '',\npasswordInputText: '',\n},\n- () => {\n- invariant(this.usernameOrEmailInput, 'ref should exist');\n- this.usernameOrEmailInput.focus();\n- },\n+ this.focusUsernameInput,\n);\n};\n@@ -346,7 +327,6 @@ export default React.memo<BaseProps>(function ConnectedLogInPanel(\nprops: BaseProps,\n) {\nconst loadingStatus = useSelector(loadingStatusSelector);\n- const usernamePlaceholder = useSelector(usernamePlaceholderSelector);\nconst navContext = React.useContext(NavContext);\nconst logInExtraInfo = useSelector((state) =>\n@@ -364,7 +344,6 @@ export default React.memo<BaseProps>(function ConnectedLogInPanel(\n{...props}\nloadingStatus={loadingStatus}\nlogInExtraInfo={logInExtraInfo}\n- usernamePlaceholder={usernamePlaceholder}\ndispatchActionPromise={dispatchActionPromise}\nlogIn={callLogIn}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -171,7 +171,7 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nmode: props.rehydrateConcluded ? 'prompt' : 'loading',\nlogInState: {\nstate: {\n- usernameOrEmailInputText: null,\n+ usernameInputText: null,\npasswordInputText: null,\n},\nsetState: setLogInState,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/modal-components.react.js",
"new_path": "native/account/modal-components.react.js",
"diff": "import invariant from 'invariant';\nimport * as React from 'react';\nimport { TextInput as BaseTextInput, View, StyleSheet } from 'react-native';\n-import { createSelector } from 'reselect';\n-\n-import type { AppState } from '../redux/redux-setup';\nclass TextInput extends React.PureComponent<*> {\ninnerTextInput: ?React.ElementRef<typeof BaseTextInput>;\n@@ -51,10 +48,4 @@ const styles = StyleSheet.create({\n},\n});\n-const usernamePlaceholderSelector: (state: AppState) => string = createSelector(\n- (state: AppState) => state.dimensions.width,\n- (windowWidth: number): string =>\n- windowWidth < 360 ? 'Username or email' : 'Username or email address',\n-);\n-\n-export { TextInput, usernamePlaceholderSelector };\n+export { TextInput };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/resolve-invalidated-cookie.js",
"new_path": "native/account/resolve-invalidated-cookie.js",
"diff": "@@ -28,10 +28,9 @@ async function resolveInvalidatedCookie(\nconst newCookie = await dispatchRecoveryAttempt(\nlogInActionTypes,\nlogIn(fetchJSON)({\n- usernameOrEmail: keychainCredentials.username,\n- password: keychainCredentials.password,\n- source,\n+ ...keychainCredentials,\n...extraInfo,\n+ source,\n}),\n{ calendarQuery },\n);\n@@ -49,10 +48,9 @@ async function resolveInvalidatedCookie(\nawait dispatchRecoveryAttempt(\nlogInActionTypes,\nlogIn(fetchJSON)({\n- usernameOrEmail: sharedWebCredentials.username,\n- password: sharedWebCredentials.password,\n- source,\n+ ...sharedWebCredentials,\n...extraInfo,\n+ source,\n}),\n{ calendarQuery },\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/user-responders.js",
"new_path": "server/src/responders/user-responders.js",
"diff": "@@ -175,7 +175,8 @@ async function accountCreationResponder(\n}\nconst logInRequestInputValidator = tShape({\n- usernameOrEmail: t.String,\n+ username: t.maybe(t.String),\n+ usernameOrEmail: t.maybe(t.String),\npassword: tPassword,\nwatchedIDs: t.list(t.String),\ncalendarQuery: t.maybe(entryQueryInputValidator),\n@@ -199,11 +200,14 @@ async function logInResponder(\ncalendarQuery,\n);\n}\n+ const username = request.username ?? request.usernameOrEmail;\n+ if (!username) {\n+ throw new ServerError('invalid_parameters');\n+ }\nconst userQuery = SQL`\nSELECT id, hash, username, email, email_verified\nFROM users\n- WHERE LCASE(username) = LCASE(${request.usernameOrEmail})\n- OR LCASE(email) = LCASE(${request.usernameOrEmail})\n+ WHERE LCASE(username) = LCASE(${username})\n`;\npromises.userQuery = dbQuery(userQuery);\nconst {\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/account/log-in-modal.react.js",
"new_path": "web/modals/account/log-in-modal.react.js",
"diff": "@@ -5,10 +5,7 @@ import * as React from 'react';\nimport { logInActionTypes, logIn } from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import {\n- oldValidUsernameRegex,\n- validEmailRegex,\n-} from 'lib/shared/account-utils';\n+import { oldValidUsernameRegex } from 'lib/shared/account-utils';\nimport type {\nLogInInfo,\nLogInExtraInfo,\n@@ -70,7 +67,7 @@ class LogInModal extends React.PureComponent<Props, State> {\n<div className={css['form-content']}>\n<input\ntype=\"text\"\n- placeholder=\"Username or email\"\n+ placeholder=\"Username\"\nvalue={this.state.usernameOrEmail}\nonChange={this.onChangeUsernameOrEmail}\nref={this.usernameOrEmailInputRef}\n@@ -141,14 +138,11 @@ class LogInModal extends React.PureComponent<Props, State> {\nonSubmit = (event: SyntheticEvent<HTMLInputElement>) => {\nevent.preventDefault();\n- if (\n- this.state.usernameOrEmail.search(oldValidUsernameRegex) === -1 &&\n- this.state.usernameOrEmail.search(validEmailRegex) === -1\n- ) {\n+ if (this.state.usernameOrEmail.search(oldValidUsernameRegex) === -1) {\nthis.setState(\n{\nusernameOrEmail: '',\n- errorMessage: 'alphanumeric usernames or emails only',\n+ errorMessage: 'alphanumeric usernames only',\n},\n() => {\ninvariant(\n@@ -173,7 +167,7 @@ class LogInModal extends React.PureComponent<Props, State> {\nasync logInAction(extraInfo: LogInExtraInfo) {\ntry {\nconst result = await this.props.logIn({\n- usernameOrEmail: this.state.usernameOrEmail,\n+ username: this.state.usernameOrEmail,\npassword: this.state.password,\n...extraInfo,\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/account/reset-password-modal.react.js",
"new_path": "web/modals/account/reset-password-modal.react.js",
"diff": "@@ -58,7 +58,7 @@ class ResetPasswordModal extends React.PureComponent<Props, State> {\n}\ncomponentDidMount() {\n- invariant(this.passwordInput, 'usernameOrEmail ref unset');\n+ invariant(this.passwordInput, 'passwordInput ref unset');\nthis.passwordInput.focus();\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib][native][web] Disable logging in with email
Summary: This is part of the [task](https://www.notion.so/commapp/Don-t-take-emails-during-signup-93e41f772b1349f2be8215896c0f31f8) to get rid of emails.
Test Plan: Flow, play around with log in
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1441 |
129,187 | 22.06.2021 14:10:41 | 14,400 | 07fd6db60b4159a7a954570beba51784565a2d8c | [native] Get rid of "forgot password" functionality
Summary: Also gets rid of `LogInPanelContainer`, which handled animating between `LogInPanel` and `ForgotPasswordPanel`, and as such is no longer necessary.
Test Plan: Flow, visual inspection
Reviewers: atul, palys-swm
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "DELETE",
"old_path": "native/account/forgot-password-panel.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import invariant from 'invariant';\n-import React from 'react';\n-import { StyleSheet, View, Alert, Keyboard } from 'react-native';\n-import Animated from 'react-native-reanimated';\n-import Icon from 'react-native-vector-icons/FontAwesome';\n-\n-import {\n- forgotPasswordActionTypes,\n- forgotPassword,\n-} from 'lib/actions/user-actions';\n-import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import {\n- oldValidUsernameRegex,\n- validEmailRegex,\n-} from 'lib/shared/account-utils';\n-import type { LoadingStatus } from 'lib/types/loading-types';\n-import {\n- type DispatchActionPromise,\n- useServerCall,\n- useDispatchActionPromise,\n-} from 'lib/utils/action-utils';\n-\n-import { useSelector } from '../redux/redux-utils';\n-import { TextInput } from './modal-components.react';\n-import { PanelButton, Panel } from './panel-components.react';\n-\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- // Redux dispatch functions\n- +dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- +forgotPassword: (usernameOrEmail: string) => Promise<void>,\n-|};\n-type State = {|\n- +usernameOrEmailInputText: string,\n-|};\n-class ForgotPasswordPanel extends React.PureComponent<Props, State> {\n- state: State = {\n- usernameOrEmailInputText: '',\n- };\n- usernameOrEmailInput: ?TextInput;\n-\n- render() {\n- return (\n- <Panel opacityValue={this.props.opacityValue}>\n- <View>\n- <Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n- <TextInput\n- style={styles.input}\n- value={this.state.usernameOrEmailInputText}\n- onChangeText={this.onChangeUsernameOrEmailInputText}\n- placeholder=\"Username\"\n- autoFocus={true}\n- autoCorrect={false}\n- autoCapitalize=\"none\"\n- keyboardType=\"ascii-capable\"\n- returnKeyType=\"go\"\n- blurOnSubmit={false}\n- onSubmitEditing={this.onSubmit}\n- editable={this.props.loadingStatus !== 'loading'}\n- ref={this.usernameOrEmailInputRef}\n- />\n- </View>\n- <PanelButton\n- text=\"RESET PASSWORD\"\n- loadingStatus={this.props.loadingStatus}\n- onSubmit={this.onSubmit}\n- />\n- </Panel>\n- );\n- }\n-\n- usernameOrEmailInputRef = (usernameOrEmailInput: ?TextInput) => {\n- this.usernameOrEmailInput = usernameOrEmailInput;\n- };\n-\n- onChangeUsernameOrEmailInputText = (text: string) => {\n- this.setState({ usernameOrEmailInputText: text });\n- };\n-\n- onSubmit = () => {\n- this.props.setActiveAlert(true);\n- if (\n- this.state.usernameOrEmailInputText.search(oldValidUsernameRegex) ===\n- -1 &&\n- this.state.usernameOrEmailInputText.search(validEmailRegex) === -1\n- ) {\n- Alert.alert(\n- 'Invalid username',\n- 'Alphanumeric usernames or emails only',\n- [{ text: 'OK', onPress: this.onUsernameOrEmailAlertAcknowledged }],\n- { cancelable: false },\n- );\n- return;\n- }\n-\n- Keyboard.dismiss();\n- this.props.dispatchActionPromise(\n- forgotPasswordActionTypes,\n- this.forgotPasswordAction(),\n- );\n- };\n-\n- onUsernameOrEmailAlertAcknowledged = () => {\n- this.props.setActiveAlert(false);\n- this.setState(\n- {\n- usernameOrEmailInputText: '',\n- },\n- () => {\n- invariant(this.usernameOrEmailInput, 'ref should exist');\n- this.usernameOrEmailInput.focus();\n- },\n- );\n- };\n-\n- async forgotPasswordAction() {\n- try {\n- await this.props.forgotPassword(this.state.usernameOrEmailInputText);\n- this.props.setActiveAlert(false);\n- this.props.onSuccess();\n- } catch (e) {\n- if (e.message === 'invalid_user') {\n- Alert.alert(\n- \"User doesn't exist\",\n- 'No user with that username or email exists',\n- [{ text: 'OK', onPress: this.onUsernameOrEmailAlertAcknowledged }],\n- { cancelable: false },\n- );\n- } else {\n- Alert.alert(\n- 'Unknown error',\n- 'Uhh... try again?',\n- [{ text: 'OK', onPress: this.onUsernameOrEmailAlertAcknowledged }],\n- { cancelable: false },\n- );\n- }\n- throw e;\n- }\n- }\n-}\n-\n-const styles = StyleSheet.create({\n- icon: {\n- bottom: 8,\n- left: 4,\n- position: 'absolute',\n- },\n- input: {\n- paddingLeft: 35,\n- },\n-});\n-\n-const loadingStatusSelector = createLoadingStatusSelector(\n- forgotPasswordActionTypes,\n-);\n-\n-export default React.memo<BaseProps>(function ConnectedForgotPasswordPanel(\n- props: BaseProps,\n-) {\n- const loadingStatus = useSelector(loadingStatusSelector);\n-\n- const dispatchActionPromise = useDispatchActionPromise();\n- const callForgotPassword = useServerCall(forgotPassword);\n-\n- return (\n- <ForgotPasswordPanel\n- {...props}\n- loadingStatus={loadingStatus}\n- dispatchActionPromise={dispatchActionPromise}\n- forgotPassword={callForgotPassword}\n- />\n- );\n-});\n"
},
{
"change_type": "DELETE",
"old_path": "native/account/log-in-panel-container.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import invariant from 'invariant';\n-import * as React from 'react';\n-import { View, Text, StyleSheet } from 'react-native';\n-import Animated from 'react-native-reanimated';\n-import Icon from 'react-native-vector-icons/FontAwesome';\n-\n-import sleep from 'lib/utils/sleep';\n-\n-import { useSelector } from '../redux/redux-utils';\n-import { runTiming } from '../utils/animation-utils';\n-import { type StateContainer } from '../utils/state-container';\n-import ForgotPasswordPanel from './forgot-password-panel.react';\n-import LogInPanel from './log-in-panel.react';\n-import type { InnerLogInPanel, LogInState } from './log-in-panel.react';\n-\n-type LogInMode = 'log-in' | 'forgot-password' | 'forgot-password-success';\n-const modeNumbers: { [LogInMode]: number } = {\n- 'log-in': 0,\n- 'forgot-password': 1,\n- 'forgot-password-success': 2,\n-};\n-\n-/* eslint-disable import/no-named-as-default-member */\n-const {\n- Value,\n- Clock,\n- block,\n- set,\n- call,\n- cond,\n- eq,\n- neq,\n- lessThan,\n- modulo,\n- stopClock,\n- interpolate,\n-} = Animated;\n-/* eslint-enable import/no-named-as-default-member */\n-\n-type BaseProps = {|\n- +setActiveAlert: (activeAlert: boolean) => void,\n- +opacityValue: Value,\n- +hideForgotPasswordLink: Value,\n- +logInState: StateContainer<LogInState>,\n-|};\n-type Props = {|\n- ...BaseProps,\n- +windowWidth: number,\n-|};\n-type State = {|\n- logInMode: LogInMode,\n- nextLogInMode: LogInMode,\n-|};\n-class BaseLogInPanelContainer extends React.PureComponent<Props, State> {\n- logInPanel: ?InnerLogInPanel = null;\n-\n- panelTransitionTarget: Value;\n- panelTransitionValue: Value;\n-\n- constructor(props: Props) {\n- super(props);\n- this.state = {\n- logInMode: 'log-in',\n- nextLogInMode: 'log-in',\n- };\n- this.panelTransitionTarget = new Value(modeNumbers['log-in']);\n- this.panelTransitionValue = this.panelTransition();\n- }\n-\n- proceedToNextMode = () => {\n- this.setState({ logInMode: this.state.nextLogInMode });\n- };\n-\n- panelTransition() {\n- const panelTransition = new Value(-1);\n- const prevPanelTransitionTarget = new Value(-1);\n- const clock = new Clock();\n- return block([\n- cond(lessThan(panelTransition, 0), [\n- set(panelTransition, this.panelTransitionTarget),\n- set(prevPanelTransitionTarget, this.panelTransitionTarget),\n- ]),\n- cond(neq(this.panelTransitionTarget, prevPanelTransitionTarget), [\n- stopClock(clock),\n- set(prevPanelTransitionTarget, this.panelTransitionTarget),\n- ]),\n- cond(\n- neq(panelTransition, this.panelTransitionTarget),\n- set(\n- panelTransition,\n- runTiming(clock, panelTransition, this.panelTransitionTarget),\n- ),\n- ),\n- cond(eq(modulo(panelTransition, 1), 0), call([], this.proceedToNextMode)),\n- panelTransition,\n- ]);\n- }\n-\n- render() {\n- const { windowWidth } = this.props;\n- const logInPanelDynamicStyle = {\n- left: interpolate(this.panelTransitionValue, {\n- inputRange: [0, 2],\n- outputRange: [0, windowWidth * -2],\n- }),\n- right: interpolate(this.panelTransitionValue, {\n- inputRange: [0, 2],\n- outputRange: [0, windowWidth * 2],\n- }),\n- };\n- const logInPanel = (\n- <Animated.View style={[styles.panel, logInPanelDynamicStyle]}>\n- <LogInPanel\n- setActiveAlert={this.props.setActiveAlert}\n- opacityValue={this.props.opacityValue}\n- innerRef={this.logInPanelRef}\n- logInState={this.props.logInState}\n- />\n- </Animated.View>\n- );\n- let forgotPasswordPanel = null;\n- if (\n- this.state.nextLogInMode !== 'log-in' ||\n- this.state.logInMode !== 'log-in'\n- ) {\n- const forgotPasswordPanelDynamicStyle = {\n- left: interpolate(this.panelTransitionValue, {\n- inputRange: [0, 2],\n- outputRange: [windowWidth, windowWidth * -1],\n- }),\n- right: interpolate(this.panelTransitionValue, {\n- inputRange: [0, 2],\n- outputRange: [windowWidth * -1, windowWidth],\n- }),\n- };\n- forgotPasswordPanel = (\n- <Animated.View style={[styles.panel, forgotPasswordPanelDynamicStyle]}>\n- <ForgotPasswordPanel\n- setActiveAlert={this.props.setActiveAlert}\n- opacityValue={this.props.opacityValue}\n- onSuccess={this.onForgotPasswordSuccess}\n- />\n- </Animated.View>\n- );\n- }\n- let forgotPasswordSuccess = null;\n- if (\n- this.state.nextLogInMode === 'forgot-password-success' ||\n- this.state.logInMode === 'forgot-password-success'\n- ) {\n- const forgotPasswordSuccessDynamicStyle = {\n- left: interpolate(this.panelTransitionValue, {\n- inputRange: [0, 2],\n- outputRange: [windowWidth * 2, 0],\n- }),\n- right: interpolate(this.panelTransitionValue, {\n- inputRange: [0, 2],\n- outputRange: [windowWidth * -2, 0],\n- }),\n- };\n- const successText =\n- \"Okay, we've sent that account an email. Check your inbox to \" +\n- 'complete the process.';\n- forgotPasswordSuccess = (\n- <Animated.View\n- style={[styles.panel, forgotPasswordSuccessDynamicStyle]}\n- >\n- <Icon\n- name=\"check-circle\"\n- size={48}\n- color=\"#88FF88DD\"\n- style={styles.forgotPasswordSuccessIcon}\n- />\n- <Text style={styles.forgotPasswordSuccessText}>{successText}</Text>\n- </Animated.View>\n- );\n- }\n- return (\n- <View>\n- {logInPanel}\n- {forgotPasswordPanel}\n- {forgotPasswordSuccess}\n- </View>\n- );\n- }\n-\n- logInPanelRef = (logInPanel: ?InnerLogInPanel) => {\n- this.logInPanel = logInPanel;\n- };\n-\n- onPressForgotPassword = () => {\n- this.props.hideForgotPasswordLink.setValue(1);\n- this.setState({ nextLogInMode: 'forgot-password' });\n- this.panelTransitionTarget.setValue(modeNumbers['forgot-password']);\n- };\n-\n- backFromLogInMode = () => {\n- if (this.state.nextLogInMode === 'log-in') {\n- return false;\n- }\n-\n- this.setState({\n- logInMode: this.state.nextLogInMode,\n- nextLogInMode: 'log-in',\n- });\n- invariant(this.logInPanel, 'ref should be set');\n- this.logInPanel.focusUsernameInput();\n-\n- this.props.hideForgotPasswordLink.setValue(0);\n- this.panelTransitionTarget.setValue(modeNumbers['log-in']);\n-\n- return true;\n- };\n-\n- onForgotPasswordSuccess = () => {\n- if (this.state.nextLogInMode === 'log-in') {\n- return;\n- }\n-\n- this.setState({ nextLogInMode: 'forgot-password-success' });\n- this.panelTransitionTarget.setValue(modeNumbers['forgot-password-success']);\n-\n- this.inCoupleSecondsNavigateToLogIn();\n- };\n-\n- async inCoupleSecondsNavigateToLogIn() {\n- await sleep(2350);\n- this.backFromLogInMode();\n- }\n-}\n-\n-const styles = StyleSheet.create({\n- forgotPasswordSuccessIcon: {\n- marginTop: 40,\n- textAlign: 'center',\n- },\n- forgotPasswordSuccessText: {\n- color: 'white',\n- fontSize: 18,\n- marginLeft: 20,\n- marginRight: 20,\n- marginTop: 10,\n- textAlign: 'center',\n- },\n- panel: {\n- left: 0,\n- position: 'absolute',\n- right: 0,\n- },\n-});\n-\n-const LogInPanelContainer = React.forwardRef<\n- BaseProps,\n- BaseLogInPanelContainer,\n->(function ForwardedConnectedLogInPanelContainer(\n- props: BaseProps,\n- ref: React.Ref<typeof BaseLogInPanelContainer>,\n-) {\n- const windowWidth = useSelector((state) => state.dimensions.width);\n- return (\n- <BaseLogInPanelContainer {...props} windowWidth={windowWidth} ref={ref} />\n- );\n-});\n-\n-export { LogInPanelContainer, BaseLogInPanelContainer };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -40,7 +40,6 @@ export type LogInState = {|\ntype BaseProps = {|\n+setActiveAlert: (activeAlert: boolean) => void,\n+opacityValue: Animated.Value,\n- +innerRef: (logInPanel: ?LogInPanel) => void,\n+logInState: StateContainer<LogInState>,\n|};\ntype Props = {|\n@@ -58,14 +57,9 @@ class LogInPanel extends React.PureComponent<Props> {\npasswordInput: ?TextInput;\ncomponentDidMount() {\n- this.props.innerRef(this);\nthis.attemptToFetchCredentials();\n}\n- componentWillUnmount() {\n- this.props.innerRef(null);\n- }\n-\nget usernameInputText(): string {\nreturn this.props.logInState.state.usernameInputText || '';\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "// @flow\n-import invariant from 'invariant';\nimport _isEqual from 'lodash/fp/isEqual';\nimport * as React from 'react';\nimport {\n@@ -56,10 +55,7 @@ import {\nsetStateForContainer,\n} from '../utils/state-container';\nimport { splashBackgroundURI } from './background-info';\n-import {\n- LogInPanelContainer,\n- BaseLogInPanelContainer,\n-} from './log-in-panel-container.react';\n+import LogInPanel from './log-in-panel.react';\nimport type { LogInState } from './log-in-panel.react';\nimport RegisterPanel from './register-panel.react';\nimport type { RegisterState } from './register-panel.react';\n@@ -130,18 +126,14 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nmounted = false;\nnextMode: LoggedOutMode = 'loading';\nactiveAlert = false;\n- logInPanelContainer: ?BaseLogInPanelContainer = null;\ncontentHeight: Value;\nkeyboardHeightValue = new Value(0);\nmodeValue: Value;\n- hideForgotPasswordLink = new Value(0);\nbuttonOpacity: Value;\npanelPaddingTopValue: Value;\n- footerPaddingTopValue: Value;\npanelOpacityValue: Value;\n- forgotPasswordLinkOpacityValue: Value;\nconstructor(props: Props) {\nsuper(props);\n@@ -195,9 +187,7 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nthis.buttonOpacity = new Value(props.rehydrateConcluded ? 1 : 0);\nthis.panelPaddingTopValue = this.panelPaddingTop();\n- this.footerPaddingTopValue = this.footerPaddingTop();\nthis.panelOpacityValue = this.panelOpacity();\n- this.forgotPasswordLinkOpacityValue = this.forgotPasswordLinkOpacity();\n}\nguardedSetState = (change: StateChange<State>, callback?: () => mixed) => {\n@@ -321,13 +311,6 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\n}\nhardwareBack = () => {\n- if (this.nextMode === 'log-in') {\n- invariant(this.logInPanelContainer, 'ref should be set');\n- const returnValue = this.logInPanelContainer.backFromLogInMode();\n- if (returnValue) {\n- return true;\n- }\n- }\nif (this.nextMode !== 'prompt') {\nthis.goBackToPrompt();\nreturn true;\n@@ -342,29 +325,18 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nconst registerPanelSize = 246;\n// On large enough devices, we want to properly center the panels on screen.\n- // But on smaller devices, this can lead to some issues:\n- // - We need enough space below the log-in panel to render the\n- // \"Forgot password?\" link\n- // - On Android, ratchetAlongWithKeyboardHeight won't adjust the panel's\n- // position when the keyboard size changes\n- // To address these issues, we artifically increase the panel sizes so that\n- // they get positioned a little higher than center on small devices.\n+ // But on smaller Android devices, this can lead to an issue, since on\n+ // Android, ratchetAlongWithKeyboardHeight won't adjust the panel's position\n+ // when the keyboard size changes. To avoid this issue, we artifically\n+ // increase the panel sizes so that they get positioned a little higher than\n+ // center on small devices.\nconst smallDeviceThreshold = 600;\n- const smallDeviceLogInContainerSize = 195;\nconst smallDeviceRegisterPanelSize = 261;\nconst containerSize = add(\nheaderHeight,\ncond(not(isPastPrompt(this.modeValue)), promptButtonsSize, 0),\n- cond(\n- eq(this.modeValue, modeNumbers['log-in']),\n- cond(\n- lessThan(this.contentHeight, smallDeviceThreshold),\n- smallDeviceLogInContainerSize,\n- logInContainerSize,\n- ),\n- 0,\n- ),\n+ cond(eq(this.modeValue, modeNumbers['log-in']), logInContainerSize, 0),\ncond(\neq(this.modeValue, modeNumbers['register']),\ncond(\n@@ -430,42 +402,6 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\n]);\n}\n- footerPaddingTop() {\n- const textHeight = Platform.OS === 'ios' ? 17 : 19;\n- const spacingAboveKeyboard = 15;\n- const potentialFooterPaddingTop = max(\n- sub(\n- this.contentHeight,\n- max(this.keyboardHeightValue, 0),\n- textHeight,\n- spacingAboveKeyboard,\n- ),\n- 0,\n- );\n-\n- const footerPaddingTop = new Value(-1);\n- const targetFooterPaddingTop = new Value(-1);\n- const clock = new Clock();\n- return block([\n- cond(lessThan(footerPaddingTop, 0), [\n- set(footerPaddingTop, potentialFooterPaddingTop),\n- set(targetFooterPaddingTop, potentialFooterPaddingTop),\n- ]),\n- ratchetAlongWithKeyboardHeight(this.keyboardHeightValue, [\n- stopClock(clock),\n- set(targetFooterPaddingTop, potentialFooterPaddingTop),\n- ]),\n- cond(\n- neq(footerPaddingTop, targetFooterPaddingTop),\n- set(\n- footerPaddingTop,\n- runTiming(clock, footerPaddingTop, targetFooterPaddingTop),\n- ),\n- ),\n- footerPaddingTop,\n- ]);\n- }\n-\npanelOpacity() {\nconst targetPanelOpacity = isPastPrompt(this.modeValue);\n@@ -498,46 +434,6 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\n]);\n}\n- forgotPasswordLinkOpacity() {\n- const targetForgotPasswordLinkOpacity = and(\n- eq(this.modeValue, modeNumbers['log-in']),\n- not(this.hideForgotPasswordLink),\n- );\n-\n- const forgotPasswordLinkOpacity = new Value(0);\n- const prevTargetForgotPasswordLinkOpacity = new Value(0);\n- const clock = new Clock();\n- return block([\n- cond(greaterOrEq(this.keyboardHeightValue, 0), [\n- cond(\n- neq(\n- targetForgotPasswordLinkOpacity,\n- prevTargetForgotPasswordLinkOpacity,\n- ),\n- [\n- stopClock(clock),\n- set(\n- prevTargetForgotPasswordLinkOpacity,\n- targetForgotPasswordLinkOpacity,\n- ),\n- ],\n- ),\n- cond(\n- neq(forgotPasswordLinkOpacity, targetForgotPasswordLinkOpacity),\n- set(\n- forgotPasswordLinkOpacity,\n- runTiming(\n- clock,\n- forgotPasswordLinkOpacity,\n- targetForgotPasswordLinkOpacity,\n- ),\n- ),\n- ),\n- ]),\n- forgotPasswordLinkOpacity,\n- ]);\n- }\n-\nkeyboardShow = (event: KeyboardEvent) => {\nif (_isEqual(event.startCoordinates)(event.endCoordinates)) {\nreturn;\n@@ -575,12 +471,10 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nlet buttons = null;\nif (this.state.mode === 'log-in') {\npanel = (\n- <LogInPanelContainer\n+ <LogInPanel\nsetActiveAlert={this.setActiveAlert}\nopacityValue={this.panelOpacityValue}\n- hideForgotPasswordLink={this.hideForgotPasswordLink}\nlogInState={this.state.logInState}\n- ref={this.logInPanelContainerRef}\n/>\n);\n} else if (this.state.mode === 'register') {\n@@ -621,26 +515,6 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\n);\n}\n- let forgotPasswordLink = null;\n- if (this.state.mode === 'log-in') {\n- const reanimatedStyle = {\n- top: this.footerPaddingTopValue,\n- opacity: this.forgotPasswordLinkOpacityValue,\n- };\n- forgotPasswordLink = (\n- <Animated.View\n- style={[styles.forgotPasswordTextContainer, reanimatedStyle]}\n- >\n- <TouchableOpacity\n- activeOpacity={0.6}\n- onPress={this.onPressForgotPassword}\n- >\n- <Text style={styles.forgotPasswordText}>Forgot password?</Text>\n- </TouchableOpacity>\n- </Animated.View>\n- );\n- }\n-\nconst windowWidth = this.props.dimensions.width;\nconst buttonStyle = {\nopacity: this.panelOpacityValue,\n@@ -674,19 +548,12 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\n<View style={styles.container}>\n{animatedContent}\n{buttons}\n- {forgotPasswordLink}\n</View>\n</SafeAreaView>\n</React.Fragment>\n);\n}\n- logInPanelContainerRef = (\n- logInPanelContainer: ?React.ElementRef<typeof LogInPanelContainer>,\n- ) => {\n- this.logInPanelContainer = logInPanelContainer;\n- };\n-\nonPressLogIn = () => {\nif (Platform.OS !== 'ios') {\n// For some strange reason, iOS's password management logic doesn't\n@@ -707,11 +574,6 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nthis.keyboardHeightValue.setValue(-1);\nthis.setMode('register');\n};\n-\n- onPressForgotPassword = () => {\n- invariant(this.logInPanelContainer, 'ref should be set');\n- this.logInPanelContainer.onPressForgotPassword();\n- };\n}\nconst styles = StyleSheet.create({\n@@ -751,14 +613,6 @@ const styles = StyleSheet.create({\nbackgroundColor: 'transparent',\nflex: 1,\n},\n- forgotPasswordText: {\n- color: '#8899FF',\n- },\n- forgotPasswordTextContainer: {\n- alignSelf: 'flex-end',\n- position: 'absolute',\n- right: 20,\n- },\nheader: {\ncolor: 'white',\nfontFamily: Platform.OS === 'ios' ? 'IBMPlexSans' : 'IBMPlexSans-Medium',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Get rid of "forgot password" functionality
Summary: Also gets rid of `LogInPanelContainer`, which handled animating between `LogInPanel` and `ForgotPasswordPanel`, and as such is no longer necessary.
Test Plan: Flow, visual inspection
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1442 |
129,187 | 22.06.2021 14:21:59 | 14,400 | 4d7efba01b75291964b3687d17492e57c3834d3f | [web] Get rid of "forgot password" functionality
Test Plan: Flow, visual inspection
Reviewers: palys-swm
Subscribers: KatPo, palys-swm, Adrian, atul | [
{
"change_type": "DELETE",
"old_path": "web/modals/account/forgot-password-modal.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import invariant from 'invariant';\n-import * as React from 'react';\n-\n-import {\n- forgotPasswordActionTypes,\n- forgotPassword,\n-} from 'lib/actions/user-actions';\n-import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import {\n- oldValidUsernameRegex,\n- validEmailRegex,\n-} from 'lib/shared/account-utils';\n-import {\n- type DispatchActionPromise,\n- useDispatchActionPromise,\n- useServerCall,\n-} from 'lib/utils/action-utils';\n-\n-import { useSelector } from '../../redux/redux-utils';\n-import css from '../../style.css';\n-import Modal from '../modal.react';\n-import PasswordResetEmailModal from './password-reset-email-modal.react';\n-\n-type BaseProps = {|\n- +setModal: (modal: ?React.Node) => void,\n-|};\n-type Props = {|\n- ...BaseProps,\n- +inputDisabled: boolean,\n- +dispatchActionPromise: DispatchActionPromise,\n- +forgotPassword: (usernameOrEmail: string) => Promise<void>,\n-|};\n-type State = {|\n- +usernameOrEmail: string,\n- +errorMessage: string,\n-|};\n-class ForgotPasswordModal extends React.PureComponent<Props, State> {\n- props: Props;\n- state: State;\n- usernameOrEmailInput: ?HTMLInputElement;\n-\n- constructor(props: Props) {\n- super(props);\n- this.state = {\n- usernameOrEmail: '',\n- errorMessage: '',\n- };\n- }\n-\n- componentDidMount() {\n- invariant(this.usernameOrEmailInput, 'usernameOrEmail ref unset');\n- this.usernameOrEmailInput.focus();\n- }\n-\n- render() {\n- return (\n- <Modal name=\"Reset password\" onClose={this.clearModal}>\n- <div className={css['modal-body']}>\n- <form method=\"POST\">\n- <div>\n- <div className={css['form-title']}>Username</div>\n- <div className={css['form-content']}>\n- <input\n- type=\"text\"\n- placeholder=\"Username or email\"\n- value={this.state.usernameOrEmail}\n- onChange={this.onChangeUsernameOrEmail}\n- ref={this.usernameOrEmailInputRef}\n- disabled={this.props.inputDisabled}\n- />\n- </div>\n- </div>\n- <div className={css['form-footer']}>\n- <input\n- type=\"submit\"\n- value=\"Reset\"\n- onClick={this.onSubmit}\n- disabled={this.props.inputDisabled}\n- />\n- <div className={css['modal-form-error']}>\n- {this.state.errorMessage}\n- </div>\n- </div>\n- </form>\n- </div>\n- </Modal>\n- );\n- }\n-\n- usernameOrEmailInputRef = (usernameOrEmailInput: ?HTMLInputElement) => {\n- this.usernameOrEmailInput = usernameOrEmailInput;\n- };\n-\n- onChangeUsernameOrEmail = (event: SyntheticEvent<HTMLInputElement>) => {\n- const target = event.target;\n- invariant(target instanceof HTMLInputElement, 'target not input');\n- this.setState({ usernameOrEmail: target.value });\n- };\n-\n- onSubmit = (event: SyntheticEvent<HTMLInputElement>) => {\n- event.preventDefault();\n-\n- if (\n- this.state.usernameOrEmail.search(oldValidUsernameRegex) === -1 &&\n- this.state.usernameOrEmail.search(validEmailRegex) === -1\n- ) {\n- this.setState(\n- {\n- usernameOrEmail: '',\n- errorMessage: 'alphanumeric usernames or emails only',\n- },\n- () => {\n- invariant(\n- this.usernameOrEmailInput,\n- 'usernameOrEmailInput ref unset',\n- );\n- this.usernameOrEmailInput.focus();\n- },\n- );\n- return;\n- }\n-\n- this.props.dispatchActionPromise(\n- forgotPasswordActionTypes,\n- this.forgotPasswordAction(),\n- );\n- };\n-\n- async forgotPasswordAction() {\n- try {\n- await this.props.forgotPassword(this.state.usernameOrEmail);\n- this.props.setModal(\n- <PasswordResetEmailModal onClose={this.clearModal} />,\n- );\n- } catch (e) {\n- this.setState(\n- {\n- usernameOrEmail: '',\n- errorMessage:\n- e.message === 'invalid_user'\n- ? \"user doesn't exist\"\n- : 'unknown error',\n- },\n- () => {\n- invariant(\n- this.usernameOrEmailInput,\n- 'usernameOrEmailInput ref unset',\n- );\n- this.usernameOrEmailInput.focus();\n- },\n- );\n- throw e;\n- }\n- }\n-\n- clearModal = () => {\n- this.props.setModal(null);\n- };\n-}\n-\n-const loadingStatusSelector = createLoadingStatusSelector(\n- forgotPasswordActionTypes,\n-);\n-\n-export default React.memo<BaseProps>(function ConnectedForgotPasswordModal(\n- props: BaseProps,\n-) {\n- const inputDisabled = useSelector(loadingStatusSelector) === 'loading';\n- const callForgotPassword = useServerCall(forgotPassword);\n- const dispatchActionPromise = useDispatchActionPromise();\n-\n- return (\n- <ForgotPasswordModal\n- {...props}\n- inputDisabled={inputDisabled}\n- forgotPassword={callForgotPassword}\n- dispatchActionPromise={dispatchActionPromise}\n- />\n- );\n-});\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/account/log-in-modal.react.js",
"new_path": "web/modals/account/log-in-modal.react.js",
"diff": "@@ -22,7 +22,6 @@ import { useSelector } from '../../redux/redux-utils';\nimport { webLogInExtraInfoSelector } from '../../selectors/account-selectors';\nimport css from '../../style.css';\nimport Modal from '../modal.react';\n-import ForgotPasswordModal from './forgot-password-modal.react';\ntype BaseProps = {|\n+setModal: (modal: ?React.Node) => void,\n@@ -86,11 +85,6 @@ class LogInModal extends React.PureComponent<Props, State> {\nref={this.passwordInputRef}\ndisabled={this.props.inputDisabled}\n/>\n- <div className={css['form-subtitle']}>\n- <a href=\"#\" onClick={this.onClickForgotPassword}>\n- Forgot password?\n- </a>\n- </div>\n</div>\n</div>\n<div className={css['form-footer']}>\n@@ -130,11 +124,6 @@ class LogInModal extends React.PureComponent<Props, State> {\nthis.setState({ password: target.value });\n};\n- onClickForgotPassword = (event: SyntheticEvent<HTMLAnchorElement>) => {\n- event.preventDefault();\n- this.props.setModal(<ForgotPasswordModal setModal={this.props.setModal} />);\n- };\n-\nonSubmit = (event: SyntheticEvent<HTMLInputElement>) => {\nevent.preventDefault();\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Get rid of "forgot password" functionality
Test Plan: Flow, visual inspection
Reviewers: palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, palys-swm, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1443 |
129,187 | 22.06.2021 14:24:07 | 14,400 | 47241ececafe70aa26637a06d8ef52f459f4e4a7 | [lib] Get rid of forgotPassword
Summary: Since none of the clients use this anymore, we can get rid of the Redux action. (The server endpoint is still there for old clients.)
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/user-actions.js",
"new_path": "lib/actions/user-actions.js",
"diff": "@@ -189,17 +189,6 @@ const resetPassword = (fetchJSON: FetchJSON) => async (\n};\n};\n-const forgotPasswordActionTypes = Object.freeze({\n- started: 'FORGOT_PASSWORD_STARTED',\n- success: 'FORGOT_PASSWORD_SUCCESS',\n- failed: 'FORGOT_PASSWORD_FAILED',\n-});\n-const forgotPassword = (fetchJSON: FetchJSON) => async (\n- usernameOrEmail: string,\n-): Promise<void> => {\n- await fetchJSON('send_password_reset_email', { usernameOrEmail });\n-};\n-\nconst changeUserSettingsActionTypes = Object.freeze({\nstarted: 'CHANGE_USER_SETTINGS_STARTED',\nsuccess: 'CHANGE_USER_SETTINGS_SUCCESS',\n@@ -294,8 +283,6 @@ export {\nlogIn,\nresetPasswordActionTypes,\nresetPassword,\n- forgotPasswordActionTypes,\n- forgotPassword,\nchangeUserSettingsActionTypes,\nchangeUserSettings,\nresendVerificationEmailActionTypes,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -271,22 +271,6 @@ export type BaseAction =\n+payload: LogInResult,\n+loadingInfo: LoadingInfo,\n|}\n- | {|\n- +type: 'FORGOT_PASSWORD_STARTED',\n- +payload?: void,\n- +loadingInfo: LoadingInfo,\n- |}\n- | {|\n- +type: 'FORGOT_PASSWORD_FAILED',\n- +error: true,\n- +payload: Error,\n- +loadingInfo: LoadingInfo,\n- |}\n- | {|\n- +type: 'FORGOT_PASSWORD_SUCCESS',\n- +payload?: void,\n- +loadingInfo: LoadingInfo,\n- |}\n| {|\n+type: 'CHANGE_USER_SETTINGS_STARTED',\n+payload?: void,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Get rid of forgotPassword
Summary: Since none of the clients use this anymore, we can get rid of the Redux action. (The server endpoint is still there for old clients.)
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1444 |
129,187 | 22.06.2021 15:15:21 | 14,400 | e9ad5a6df6389aeee54e8bd2be9ad77c632e9e36 | [web] Get rid of verification functionality
Summary: This was used for verifying emails and resetting passwords, but since both of those rely on emails (which we're getting rid of), we can remove this code.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/types/verify-types.js",
"new_path": "lib/types/verify-types.js",
"diff": "@@ -24,9 +24,6 @@ export type HandleVerificationCodeResult = {|\n+resetPasswordUsername?: string,\n|};\n-type FailedVerificationResult = {|\n- +success: false,\n-|};\ntype EmailServerVerificationResult = {|\n+success: true,\n+field: 0,\n@@ -39,6 +36,3 @@ type ResetPasswordServerVerificationResult = {|\nexport type ServerSuccessfulVerificationResult =\n| EmailServerVerificationResult\n| ResetPasswordServerVerificationResult;\n-export type ServerVerificationResult =\n- | FailedVerificationResult\n- | ServerSuccessfulVerificationResult;\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/website-responders.js",
"new_path": "server/src/responders/website-responders.js",
"diff": "@@ -21,7 +21,6 @@ import { defaultCalendarFilters } from 'lib/types/filter-types';\nimport { defaultNumberPerThread } from 'lib/types/message-types';\nimport { defaultConnectionInfo } from 'lib/types/socket-types';\nimport { threadPermissions } from 'lib/types/thread-types';\n-import type { ServerVerificationResult } from 'lib/types/verify-types';\nimport { currentDateInTimeZone } from 'lib/utils/date-utils';\nimport { ServerError } from 'lib/utils/errors';\nimport { promiseAll } from 'lib/utils/promises';\n@@ -37,7 +36,6 @@ import {\nfetchCurrentUserInfo,\nfetchKnownUserInfos,\n} from '../fetchers/user-fetchers';\n-import { handleCodeVerificationRequest } from '../models/verification';\nimport { setNewSession } from '../session/cookies';\nimport { Viewer } from '../session/viewer';\nimport { streamJSON, waitForStream } from '../utils/json-stream';\n@@ -144,10 +142,6 @@ async function websiteResponder(\n);\nconst entryInfoPromise = fetchEntryInfos(viewer, [calendarQuery]);\nconst currentUserInfoPromise = fetchCurrentUserInfo(viewer);\n- const serverVerificationResultPromise = handleVerificationRequest(\n- viewer,\n- initialNavInfo.verify,\n- );\nconst userInfoPromise = fetchKnownUserInfos(viewer);\nconst sessionIDPromise = (async () => {\n@@ -259,7 +253,6 @@ async function websiteResponder(\nnavInfo: navInfoPromise,\ncurrentUserInfo: currentUserInfoPromise,\nsessionID: sessionIDPromise,\n- serverVerificationResult: serverVerificationResultPromise,\nentryStore: entryStorePromise,\nthreadStore: threadStorePromise,\nuserStore: userStorePromise,\n@@ -336,21 +329,4 @@ async function websiteResponder(\n`);\n}\n-async function handleVerificationRequest(\n- viewer: Viewer,\n- code: ?string,\n-): Promise<?ServerVerificationResult> {\n- if (!code) {\n- return null;\n- }\n- try {\n- return await handleCodeVerificationRequest(viewer, code);\n- } catch (e) {\n- if (e instanceof ServerError && e.message === 'invalid_code') {\n- return { success: false };\n- }\n- throw e;\n- }\n-}\n-\nexport { websiteResponder };\n"
},
{
"change_type": "MODIFY",
"old_path": "web/app.react.js",
"new_path": "web/app.react.js",
"diff": "@@ -26,10 +26,6 @@ import {\nimport { isLoggedIn } from 'lib/selectors/user-selectors';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { Dispatch } from 'lib/types/redux-types';\n-import {\n- verifyField,\n- type ServerVerificationResult,\n-} from 'lib/types/verify-types';\nimport { registerConfig } from 'lib/utils/config';\nimport AccountBar from './account-bar.react';\n@@ -37,8 +33,6 @@ import Calendar from './calendar/calendar.react';\nimport Chat from './chat/chat.react';\nimport InputStateContainer from './input/input-state-container.react';\nimport LoadingIndicator from './loading-indicator.react';\n-import ResetPasswordModal from './modals/account/reset-password-modal.react';\n-import VerificationModal from './modals/account/verification-modal.react';\nimport FocusHandler from './redux/focus-handler.react';\nimport { useSelector } from './redux/redux-utils';\nimport VisibilityHandler from './redux/visibility-handler.react';\n@@ -78,7 +72,6 @@ type Props = {|\n...BaseProps,\n// Redux state\n+navInfo: NavInfo,\n- +serverVerificationResult: ?ServerVerificationResult,\n+entriesLoadingStatus: LoadingStatus,\n+loggedIn: boolean,\n+mostRecentReadThread: ?string,\n@@ -97,92 +90,44 @@ class App extends React.PureComponent<Props, State> {\n};\ncomponentDidMount() {\n- const { navInfo, serverVerificationResult } = this.props;\n- if (navInfo.verify && serverVerificationResult) {\n- if (serverVerificationResult.field === verifyField.RESET_PASSWORD) {\n- this.showResetPasswordModal();\n- } else {\n- this.setModal(\n- <VerificationModal onClose={this.clearVerificationModal} />,\n- );\n- }\n- }\n-\n- const newURL = canonicalURLFromReduxState(\n+ const {\nnavInfo,\n- this.props.location.pathname,\n- this.props.loggedIn,\n- );\n- if (this.props.location.pathname !== newURL) {\n+ location: { pathname },\n+ loggedIn,\n+ } = this.props;\n+ const newURL = canonicalURLFromReduxState(navInfo, pathname, loggedIn);\n+ if (pathname !== newURL) {\nhistory.replace(newURL);\n}\n}\ncomponentDidUpdate(prevProps: Props) {\n- if (!_isEqual(this.props.navInfo)(prevProps.navInfo)) {\n- const { navInfo, serverVerificationResult } = this.props;\n- if (\n- navInfo.verify &&\n- !prevProps.navInfo.verify &&\n- serverVerificationResult\n- ) {\n- if (serverVerificationResult.field === verifyField.RESET_PASSWORD) {\n- this.showResetPasswordModal();\n- } else {\n- this.setModal(\n- <VerificationModal onClose={this.clearVerificationModal} />,\n- );\n- }\n- } else if (!navInfo.verify && prevProps.navInfo.verify) {\n- this.clearModal();\n- }\n-\n- const newURL = canonicalURLFromReduxState(\n+ const {\nnavInfo,\n- this.props.location.pathname,\n- this.props.loggedIn,\n- );\n- if (newURL !== this.props.location.pathname) {\n+ location: { pathname },\n+ loggedIn,\n+ } = this.props;\n+ if (!_isEqual(navInfo)(prevProps.navInfo)) {\n+ const newURL = canonicalURLFromReduxState(navInfo, pathname, loggedIn);\n+ if (newURL !== pathname) {\nhistory.push(newURL);\n}\n- } else if (this.props.location.pathname !== prevProps.location.pathname) {\n- const newNavInfo = navInfoFromURL(this.props.location.pathname, {\n- navInfo: this.props.navInfo,\n- });\n- if (!_isEqual(newNavInfo)(this.props.navInfo)) {\n+ } else if (pathname !== prevProps.location.pathname) {\n+ const newNavInfo = navInfoFromURL(pathname, { navInfo });\n+ if (!_isEqual(newNavInfo)(navInfo)) {\nthis.props.dispatch({\ntype: updateNavInfoActionType,\npayload: newNavInfo,\n});\n}\n- } else if (this.props.loggedIn !== prevProps.loggedIn) {\n- const newURL = canonicalURLFromReduxState(\n- this.props.navInfo,\n- this.props.location.pathname,\n- this.props.loggedIn,\n- );\n- if (newURL !== this.props.location.pathname) {\n+ } else if (loggedIn !== prevProps.loggedIn) {\n+ const newURL = canonicalURLFromReduxState(navInfo, pathname, loggedIn);\n+ if (newURL !== pathname) {\nhistory.replace(newURL);\n}\n}\n}\n- showResetPasswordModal() {\n- const newURL = canonicalURLFromReduxState(\n- {\n- ...this.props.navInfo,\n- verify: null,\n- },\n- this.props.location.pathname,\n- this.props.loggedIn,\n- );\n- const onClose = () => history.push(newURL);\n- const onSuccess = () => history.replace(newURL);\n- this.setModal(\n- <ResetPasswordModal onClose={onClose} onSuccess={onSuccess} />,\n- );\n- }\n-\nrender() {\nlet content;\nif (this.props.loggedIn) {\n@@ -287,18 +232,6 @@ class App extends React.PureComponent<Props, State> {\nthis.setModal(null);\n}\n- clearVerificationModal = () => {\n- const navInfo = { ...this.props.navInfo, verify: null };\n- const newURL = canonicalURLFromReduxState(\n- navInfo,\n- this.props.location.pathname,\n- this.props.loggedIn,\n- );\n- if (newURL !== this.props.location.pathname) {\n- history.push(newURL);\n- }\n- };\n-\nonClickCalendar = (event: SyntheticEvent<HTMLAnchorElement>) => {\nevent.preventDefault();\nthis.props.dispatch({\n@@ -333,9 +266,6 @@ export default React.memo<BaseProps>(function ConnectedApp(props: BaseProps) {\n(state) => state.navInfo.activeChatThreadID,\n);\nconst navInfo = useSelector((state) => state.navInfo);\n- const serverVerificationResult = useSelector(\n- (state) => state.serverVerificationResult,\n- );\nconst fetchEntriesLoadingStatus = useSelector(\nfetchEntriesLoadingStatusSelector,\n@@ -371,7 +301,6 @@ export default React.memo<BaseProps>(function ConnectedApp(props: BaseProps) {\n<App\n{...props}\nnavInfo={navInfo}\n- serverVerificationResult={serverVerificationResult}\nentriesLoadingStatus={entriesLoadingStatus}\nloggedIn={loggedIn}\nmostRecentReadThread={mostRecentReadThread}\n"
},
{
"change_type": "DELETE",
"old_path": "web/modals/account/reset-password-modal.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import invariant from 'invariant';\n-import * as React from 'react';\n-\n-import {\n- resetPasswordActionTypes,\n- resetPassword,\n-} from 'lib/actions/user-actions';\n-import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import type {\n- UpdatePasswordInfo,\n- LogInExtraInfo,\n- LogInResult,\n- LogInStartingPayload,\n-} from 'lib/types/account-types';\n-import { verifyField } from 'lib/types/verify-types';\n-import {\n- type DispatchActionPromise,\n- useDispatchActionPromise,\n- useServerCall,\n-} from 'lib/utils/action-utils';\n-\n-import { useSelector } from '../../redux/redux-utils';\n-import { webLogInExtraInfoSelector } from '../../selectors/account-selectors';\n-import css from '../../style.css';\n-import Modal from '../modal.react';\n-\n-type BaseProps = {|\n- +onClose: () => void,\n- +onSuccess: () => void,\n-|};\n-type Props = {|\n- ...BaseProps,\n- +resetPasswordUsername: string,\n- +verifyCode: ?string,\n- +inputDisabled: boolean,\n- +logInExtraInfo: () => LogInExtraInfo,\n- +dispatchActionPromise: DispatchActionPromise,\n- +resetPassword: (info: UpdatePasswordInfo) => Promise<LogInResult>,\n-|};\n-type State = {|\n- +password: string,\n- +confirmPassword: string,\n- +errorMessage: string,\n-|};\n-\n-class ResetPasswordModal extends React.PureComponent<Props, State> {\n- passwordInput: ?HTMLInputElement;\n-\n- constructor(props: Props) {\n- super(props);\n- this.state = {\n- password: '',\n- confirmPassword: '',\n- errorMessage: '',\n- };\n- }\n-\n- componentDidMount() {\n- invariant(this.passwordInput, 'passwordInput ref unset');\n- this.passwordInput.focus();\n- }\n-\n- render() {\n- return (\n- <Modal name=\"Reset password\" onClose={this.props.onClose}>\n- <div className={css['modal-body']}>\n- <form method=\"POST\">\n- <div className={css['form-text']}>\n- <div className={css['form-title']}>Username</div>\n- <div className={css['form-content']}>\n- {this.props.resetPasswordUsername}\n- </div>\n- </div>\n- <div>\n- <div className={css['form-title']}>Password</div>\n- <div className={css['form-content']}>\n- <div>\n- <input\n- type=\"password\"\n- placeholder=\"Password\"\n- value={this.state.password}\n- onChange={this.onChangePassword}\n- ref={this.passwordInputRef}\n- disabled={this.props.inputDisabled}\n- />\n- </div>\n- <div>\n- <input\n- type=\"password\"\n- placeholder=\"Confirm password\"\n- value={this.state.confirmPassword}\n- onChange={this.onChangeConfirmPassword}\n- disabled={this.props.inputDisabled}\n- />\n- </div>\n- </div>\n- </div>\n- <div className={css['form-footer']}>\n- <input\n- type=\"submit\"\n- value=\"Update\"\n- onClick={this.onSubmit}\n- disabled={this.props.inputDisabled}\n- />\n- <div className={css['modal-form-error']}>\n- {this.state.errorMessage}\n- </div>\n- </div>\n- </form>\n- </div>\n- </Modal>\n- );\n- }\n-\n- passwordInputRef = (passwordInput: ?HTMLInputElement) => {\n- this.passwordInput = passwordInput;\n- };\n-\n- onChangePassword = (event: SyntheticEvent<HTMLInputElement>) => {\n- const target = event.target;\n- invariant(target instanceof HTMLInputElement, 'target not input');\n- this.setState({ password: target.value });\n- };\n-\n- onChangeConfirmPassword = (event: SyntheticEvent<HTMLInputElement>) => {\n- const target = event.target;\n- invariant(target instanceof HTMLInputElement, 'target not input');\n- this.setState({ confirmPassword: target.value });\n- };\n-\n- onSubmit = (event: SyntheticEvent<HTMLInputElement>) => {\n- event.preventDefault();\n-\n- if (this.state.password === '') {\n- this.setState(\n- {\n- password: '',\n- confirmPassword: '',\n- errorMessage: 'empty password',\n- },\n- () => {\n- invariant(this.passwordInput, 'passwordInput ref unset');\n- this.passwordInput.focus();\n- },\n- );\n- return;\n- }\n- if (this.state.password !== this.state.confirmPassword) {\n- this.setState(\n- {\n- password: '',\n- confirmPassword: '',\n- errorMessage: \"passwords don't match\",\n- },\n- () => {\n- invariant(this.passwordInput, 'passwordInput ref unset');\n- this.passwordInput.focus();\n- },\n- );\n- return;\n- }\n-\n- const extraInfo = this.props.logInExtraInfo();\n- this.props.dispatchActionPromise(\n- resetPasswordActionTypes,\n- this.resetPasswordAction(extraInfo),\n- undefined,\n- ({ calendarQuery: extraInfo.calendarQuery }: LogInStartingPayload),\n- );\n- };\n-\n- async resetPasswordAction(extraInfo: LogInExtraInfo) {\n- if (!this.props.verifyCode) {\n- return;\n- }\n- try {\n- const response = await this.props.resetPassword({\n- code: this.props.verifyCode,\n- password: this.state.password,\n- ...extraInfo,\n- });\n- this.props.onSuccess();\n- return response;\n- } catch (e) {\n- this.setState(\n- {\n- password: '',\n- confirmPassword: '',\n- errorMessage: 'unknown error',\n- },\n- () => {\n- invariant(this.passwordInput, 'passwordInput ref unset');\n- this.passwordInput.focus();\n- },\n- );\n- throw e;\n- }\n- }\n-}\n-\n-const loadingStatusSelector = createLoadingStatusSelector(\n- resetPasswordActionTypes,\n-);\n-\n-export default React.memo<BaseProps>(function ConnectedResetPasswordModal(\n- props: BaseProps,\n-) {\n- const resetPasswordUsername = useSelector(\n- (state) =>\n- state.serverVerificationResult &&\n- state.serverVerificationResult.success &&\n- state.serverVerificationResult.field === verifyField.RESET_PASSWORD &&\n- state.serverVerificationResult.username,\n- );\n- const verifyCode = useSelector((state) => state.navInfo.verify);\n- const inputDisabled = useSelector(\n- (state) => loadingStatusSelector(state) === 'loading',\n- );\n- const logInExtraInfo = useSelector(webLogInExtraInfoSelector);\n- const callResetPassword = useServerCall(resetPassword);\n- const dispatchActionPromise = useDispatchActionPromise();\n- invariant(resetPasswordUsername, 'should have reset password username');\n-\n- return (\n- <ResetPasswordModal\n- {...props}\n- resetPasswordUsername={resetPasswordUsername}\n- verifyCode={verifyCode}\n- inputDisabled={inputDisabled}\n- logInExtraInfo={logInExtraInfo}\n- resetPassword={callResetPassword}\n- dispatchActionPromise={dispatchActionPromise}\n- />\n- );\n-});\n"
},
{
"change_type": "DELETE",
"old_path": "web/modals/account/verification-modal.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import invariant from 'invariant';\n-import * as React from 'react';\n-\n-import {\n- type ServerVerificationResult,\n- verifyField,\n-} from 'lib/types/verify-types';\n-\n-import { useSelector } from '../../redux/redux-utils';\n-import css from '../../style.css';\n-import Modal from '../modal.react';\n-\n-type BaseProps = {|\n- +onClose: () => void,\n-|};\n-type Props = {|\n- ...BaseProps,\n- +serverVerificationResult: ?ServerVerificationResult,\n-|};\n-function VerificationModal(props: Props) {\n- const { onClose, serverVerificationResult } = props;\n- invariant(\n- serverVerificationResult,\n- 'VerificationModal needs a serverVerificationResult',\n- );\n-\n- const { success } = serverVerificationResult;\n- let message, title;\n- if (!success) {\n- title = 'Invalid code';\n- message = 'Sorry, but that code has expired or is invalid.';\n- } else if (success && serverVerificationResult.field === verifyField.EMAIL) {\n- title = 'Verified email';\n- message = 'Thanks for verifying your email address!';\n- }\n- invariant(\n- title && message,\n- \"VerificationModal can't handle serverVerificationResult \" +\n- JSON.stringify(serverVerificationResult),\n- );\n-\n- return (\n- <Modal name={title} onClose={onClose}>\n- <div className={css['modal-body']}>\n- <p>{message}</p>\n- </div>\n- </Modal>\n- );\n-}\n-\n-export default React.memo<BaseProps>(function ConnectedVerificationModal(\n- props: BaseProps,\n-) {\n- const serverVerificationResult = useSelector(\n- (state) => state.serverVerificationResult,\n- );\n-\n- return (\n- <VerificationModal\n- {...props}\n- serverVerificationResult={serverVerificationResult}\n- />\n- );\n-});\n"
},
{
"change_type": "MODIFY",
"old_path": "web/redux/redux-setup.js",
"new_path": "web/redux/redux-setup.js",
"diff": "@@ -21,7 +21,6 @@ import type { ClientReportCreationRequest } from 'lib/types/report-types';\nimport type { ConnectionInfo } from 'lib/types/socket-types';\nimport type { ThreadStore } from 'lib/types/thread-types';\nimport type { CurrentUserInfo, UserStore } from 'lib/types/user-types';\n-import type { ServerVerificationResult } from 'lib/types/verify-types';\nimport { setNewSessionActionType } from 'lib/utils/action-utils';\nimport { activeThreadSelector } from '../selectors/nav-selectors';\n@@ -35,7 +34,6 @@ export type AppState = {|\nnavInfo: NavInfo,\ncurrentUserInfo: ?CurrentUserInfo,\nsessionID: ?string,\n- serverVerificationResult: ?ServerVerificationResult,\nentryStore: EntryStore,\nthreadStore: ThreadStore,\nuserStore: UserStore,\n"
},
{
"change_type": "MODIFY",
"old_path": "web/types/nav-types.js",
"new_path": "web/types/nav-types.js",
"diff": "@@ -6,7 +6,6 @@ import type { ThreadInfo } from 'lib/types/thread-types';\nexport type NavInfo = {|\n...$Exact<BaseNavInfo>,\n+tab: 'calendar' | 'chat',\n- +verify: ?string,\n+activeChatThreadID: ?string,\n+pendingThread?: ThreadInfo,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "web/url-utils.js",
"new_path": "web/url-utils.js",
"diff": "@@ -61,10 +61,6 @@ function canonicalURLFromReduxState(\n}\n}\n- if (navInfo.verify) {\n- newURL += `verify/${navInfo.verify}/`;\n- }\n-\nreturn newURL;\n}\n@@ -106,7 +102,6 @@ function navInfoFromURL(\nstartDate: startDateForYearAndMonth(year, month),\nendDate: endDateForYearAndMonth(year, month),\nactiveChatThreadID,\n- verify: urlInfo.verify ? urlInfo.verify : null,\n};\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Get rid of verification functionality
Summary: This was used for verifying emails and resetting passwords, but since both of those rely on emails (which we're getting rid of), we can remove this code.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1445 |
129,187 | 22.06.2021 15:22:41 | 14,400 | 200554f89f3616ae704e90c68b364481ae048d55 | [native] Get rid of verification functionality
Summary: This was used for verifying emails and resetting passwords, but since both of those rely on emails (which we're getting rid of), we can remove this code.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "DELETE",
"old_path": "native/account/verification-modal.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import invariant from 'invariant';\n-import * as React from 'react';\n-import {\n- Image,\n- Text,\n- View,\n- StyleSheet,\n- ActivityIndicator,\n- Platform,\n- Keyboard,\n- TouchableHighlight,\n-} from 'react-native';\n-import Animated from 'react-native-reanimated';\n-import { SafeAreaView } from 'react-native-safe-area-context';\n-import Icon from 'react-native-vector-icons/FontAwesome';\n-\n-import {\n- handleVerificationCodeActionTypes,\n- handleVerificationCode,\n-} from 'lib/actions/user-actions';\n-import { registerFetchKey } from 'lib/reducers/loading-reducer';\n-import {\n- type VerifyField,\n- verifyField,\n- type HandleVerificationCodeResult,\n-} from 'lib/types/verify-types';\n-import {\n- useServerCall,\n- useDispatchActionPromise,\n- type DispatchActionPromise,\n-} from 'lib/utils/action-utils';\n-import sleep from 'lib/utils/sleep';\n-\n-import ConnectedStatusBar from '../connected-status-bar.react';\n-import type { KeyboardEvent } from '../keyboard/keyboard';\n-import {\n- addKeyboardShowListener,\n- addKeyboardDismissListener,\n- removeKeyboardListener,\n-} from '../keyboard/keyboard';\n-import { createIsForegroundSelector } from '../navigation/nav-selectors';\n-import { NavContext } from '../navigation/navigation-context';\n-import type { RootNavigationProp } from '../navigation/root-navigator.react';\n-import { VerificationModalRouteName } from '../navigation/route-names';\n-import type { NavigationRoute } from '../navigation/route-names';\n-import { useSelector } from '../redux/redux-utils';\n-import {\n- type DerivedDimensionsInfo,\n- derivedDimensionsInfoSelector,\n-} from '../selectors/dimensions-selectors';\n-import { splashStyleSelector } from '../splash';\n-import type { ImageStyle } from '../types/styles';\n-import {\n- runTiming,\n- ratchetAlongWithKeyboardHeight,\n-} from '../utils/animation-utils';\n-import { splashBackgroundURI } from './background-info';\n-import ResetPasswordPanel from './reset-password-panel.react';\n-\n-const safeAreaEdges = ['top', 'bottom'];\n-\n-/* eslint-disable import/no-named-as-default-member */\n-const {\n- Value,\n- Clock,\n- block,\n- set,\n- call,\n- cond,\n- not,\n- and,\n- eq,\n- neq,\n- lessThan,\n- greaterOrEq,\n- sub,\n- divide,\n- max,\n- stopClock,\n- clockRunning,\n-} = Animated;\n-/* eslint-enable import/no-named-as-default-member */\n-\n-export type VerificationModalParams = {|\n- +verifyCode: string,\n-|};\n-\n-type VerificationModalMode = 'simple-text' | 'reset-password';\n-const modeNumbers: { [VerificationModalMode]: number } = {\n- 'simple-text': 0,\n- 'reset-password': 1,\n-};\n-\n-type BaseProps = {|\n- +navigation: RootNavigationProp<'VerificationModal'>,\n- +route: NavigationRoute<'VerificationModal'>,\n-|};\n-type Props = {|\n- ...BaseProps,\n- // Navigation state\n- +isForeground: boolean,\n- // Redux state\n- +dimensions: DerivedDimensionsInfo,\n- +splashStyle: ImageStyle,\n- // Redux dispatch functions\n- +dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- +handleVerificationCode: (\n- code: string,\n- ) => Promise<HandleVerificationCodeResult>,\n-|};\n-type State = {|\n- +mode: VerificationModalMode,\n- +verifyField: ?VerifyField,\n- +errorMessage: ?string,\n- +resetPasswordUsername: ?string,\n-|};\n-class VerificationModal extends React.PureComponent<Props, State> {\n- keyboardShowListener: ?Object;\n- keyboardHideListener: ?Object;\n-\n- activeAlert = false;\n- nextMode: VerificationModalMode = 'simple-text';\n-\n- contentHeight: Value;\n- keyboardHeightValue = new Value(0);\n- modeValue: Value;\n-\n- paddingTopValue: Value;\n- resetPasswordPanelOpacityValue: Value;\n-\n- constructor(props: Props) {\n- super(props);\n- this.state = {\n- mode: 'simple-text',\n- verifyField: null,\n- errorMessage: null,\n- resetPasswordUsername: null,\n- };\n-\n- this.contentHeight = new Value(props.dimensions.safeAreaHeight);\n- this.modeValue = new Value(modeNumbers[this.nextMode]);\n-\n- this.paddingTopValue = this.paddingTop();\n- this.resetPasswordPanelOpacityValue = this.resetPasswordPanelOpacity();\n- }\n-\n- proceedToNextMode = () => {\n- this.setState({ mode: this.nextMode });\n- };\n-\n- paddingTop() {\n- const simpleTextHeight = 90;\n- const resetPasswordPanelHeight = 165;\n- const potentialPaddingTop = divide(\n- max(\n- sub(\n- this.contentHeight,\n- cond(\n- eq(this.modeValue, modeNumbers['simple-text']),\n- simpleTextHeight,\n- ),\n- cond(\n- eq(this.modeValue, modeNumbers['reset-password']),\n- resetPasswordPanelHeight,\n- ),\n- this.keyboardHeightValue,\n- ),\n- 0,\n- ),\n- 2,\n- );\n-\n- const paddingTop = new Value(-1);\n- const targetPaddingTop = new Value(-1);\n- const prevModeValue = new Value(modeNumbers[this.nextMode]);\n- const clock = new Clock();\n- const keyboardTimeoutClock = new Clock();\n- return block([\n- cond(lessThan(paddingTop, 0), [\n- set(paddingTop, potentialPaddingTop),\n- set(targetPaddingTop, potentialPaddingTop),\n- ]),\n- cond(\n- lessThan(this.keyboardHeightValue, 0),\n- [\n- runTiming(keyboardTimeoutClock, 0, 1, true, { duration: 500 }),\n- cond(\n- not(clockRunning(keyboardTimeoutClock)),\n- set(this.keyboardHeightValue, 0),\n- ),\n- ],\n- stopClock(keyboardTimeoutClock),\n- ),\n- cond(\n- and(\n- greaterOrEq(this.keyboardHeightValue, 0),\n- neq(prevModeValue, this.modeValue),\n- ),\n- [\n- stopClock(clock),\n- set(targetPaddingTop, potentialPaddingTop),\n- set(prevModeValue, this.modeValue),\n- ],\n- ),\n- ratchetAlongWithKeyboardHeight(this.keyboardHeightValue, [\n- stopClock(clock),\n- set(targetPaddingTop, potentialPaddingTop),\n- ]),\n- cond(\n- neq(paddingTop, targetPaddingTop),\n- set(paddingTop, runTiming(clock, paddingTop, targetPaddingTop)),\n- ),\n- paddingTop,\n- ]);\n- }\n-\n- resetPasswordPanelOpacity() {\n- const targetResetPasswordPanelOpacity = eq(\n- this.modeValue,\n- modeNumbers['reset-password'],\n- );\n-\n- const resetPasswordPanelOpacity = new Value(-1);\n- const prevResetPasswordPanelOpacity = new Value(-1);\n- const prevTargetResetPasswordPanelOpacity = new Value(-1);\n- const clock = new Clock();\n- return block([\n- cond(lessThan(resetPasswordPanelOpacity, 0), [\n- set(resetPasswordPanelOpacity, targetResetPasswordPanelOpacity),\n- set(prevResetPasswordPanelOpacity, targetResetPasswordPanelOpacity),\n- set(\n- prevTargetResetPasswordPanelOpacity,\n- targetResetPasswordPanelOpacity,\n- ),\n- ]),\n- cond(greaterOrEq(this.keyboardHeightValue, 0), [\n- cond(\n- neq(\n- targetResetPasswordPanelOpacity,\n- prevTargetResetPasswordPanelOpacity,\n- ),\n- [\n- stopClock(clock),\n- set(\n- prevTargetResetPasswordPanelOpacity,\n- targetResetPasswordPanelOpacity,\n- ),\n- ],\n- ),\n- cond(\n- neq(resetPasswordPanelOpacity, targetResetPasswordPanelOpacity),\n- set(\n- resetPasswordPanelOpacity,\n- runTiming(\n- clock,\n- resetPasswordPanelOpacity,\n- targetResetPasswordPanelOpacity,\n- ),\n- ),\n- ),\n- ]),\n- cond(\n- and(\n- eq(resetPasswordPanelOpacity, 0),\n- neq(prevResetPasswordPanelOpacity, 0),\n- ),\n- call([], this.proceedToNextMode),\n- ),\n- set(prevResetPasswordPanelOpacity, resetPasswordPanelOpacity),\n- resetPasswordPanelOpacity,\n- ]);\n- }\n-\n- componentDidMount() {\n- this.props.dispatchActionPromise(\n- handleVerificationCodeActionTypes,\n- this.handleVerificationCodeAction(),\n- );\n-\n- Keyboard.dismiss();\n-\n- if (this.props.isForeground) {\n- this.onForeground();\n- }\n- }\n-\n- componentDidUpdate(prevProps: Props, prevState: State) {\n- if (\n- this.state.verifyField === verifyField.EMAIL &&\n- prevState.verifyField !== verifyField.EMAIL\n- ) {\n- sleep(1500).then(this.dismiss);\n- }\n-\n- const prevCode = prevProps.route.params.verifyCode;\n- const code = this.props.route.params.verifyCode;\n- if (code !== prevCode) {\n- Keyboard.dismiss();\n- this.nextMode = 'simple-text';\n- this.modeValue.setValue(modeNumbers[this.nextMode]);\n- this.keyboardHeightValue.setValue(0);\n- this.setState({\n- mode: this.nextMode,\n- verifyField: null,\n- errorMessage: null,\n- resetPasswordUsername: null,\n- });\n- this.props.dispatchActionPromise(\n- handleVerificationCodeActionTypes,\n- this.handleVerificationCodeAction(),\n- );\n- }\n-\n- if (this.props.isForeground && !prevProps.isForeground) {\n- this.onForeground();\n- } else if (!this.props.isForeground && prevProps.isForeground) {\n- this.onBackground();\n- }\n-\n- const newContentHeight = this.props.dimensions.safeAreaHeight;\n- const oldContentHeight = prevProps.dimensions.safeAreaHeight;\n- if (newContentHeight !== oldContentHeight) {\n- this.contentHeight.setValue(newContentHeight);\n- }\n- }\n-\n- onForeground() {\n- this.keyboardShowListener = addKeyboardShowListener(this.keyboardShow);\n- this.keyboardHideListener = addKeyboardDismissListener(this.keyboardHide);\n- }\n-\n- onBackground() {\n- if (this.keyboardShowListener) {\n- removeKeyboardListener(this.keyboardShowListener);\n- this.keyboardShowListener = null;\n- }\n- if (this.keyboardHideListener) {\n- removeKeyboardListener(this.keyboardHideListener);\n- this.keyboardHideListener = null;\n- }\n- }\n-\n- dismiss = () => {\n- this.props.navigation.clearRootModals([this.props.route.key]);\n- };\n-\n- onResetPasswordSuccess = async () => {\n- this.nextMode = 'simple-text';\n- this.modeValue.setValue(modeNumbers[this.nextMode]);\n- this.keyboardHeightValue.setValue(0);\n-\n- Keyboard.dismiss();\n-\n- // Wait a couple seconds before letting the SUCCESS action propagate and\n- // clear VerificationModal\n- await sleep(1750);\n-\n- this.dismiss();\n- };\n-\n- async handleVerificationCodeAction() {\n- const code = this.props.route.params.verifyCode;\n- try {\n- const result = await this.props.handleVerificationCode(code);\n- if (result.verifyField === verifyField.EMAIL) {\n- this.setState({ verifyField: result.verifyField });\n- } else if (result.verifyField === verifyField.RESET_PASSWORD) {\n- this.nextMode = 'reset-password';\n- this.modeValue.setValue(modeNumbers[this.nextMode]);\n- this.keyboardHeightValue.setValue(-1);\n- this.setState({\n- verifyField: result.verifyField,\n- mode: 'reset-password',\n- resetPasswordUsername: result.resetPasswordUsername,\n- });\n- }\n- } catch (e) {\n- if (e.message === 'invalid_code') {\n- this.setState({ errorMessage: 'Invalid verification code' });\n- } else {\n- this.setState({ errorMessage: 'Unknown error occurred' });\n- }\n- throw e;\n- }\n- }\n-\n- keyboardShow = (event: KeyboardEvent) => {\n- const keyboardHeight = Platform.select({\n- // Android doesn't include the bottomInset in this height measurement\n- android: event.endCoordinates.height,\n- default: Math.max(\n- event.endCoordinates.height - this.props.dimensions.bottomInset,\n- 0,\n- ),\n- });\n- this.keyboardHeightValue.setValue(keyboardHeight);\n- };\n-\n- keyboardHide = () => {\n- if (!this.activeAlert) {\n- this.keyboardHeightValue.setValue(0);\n- }\n- };\n-\n- setActiveAlert = (activeAlert: boolean) => {\n- this.activeAlert = activeAlert;\n- };\n-\n- render() {\n- const statusBar = <ConnectedStatusBar barStyle=\"light-content\" />;\n- const background = (\n- <Image\n- source={{ uri: splashBackgroundURI }}\n- style={[styles.modalBackground, this.props.splashStyle]}\n- />\n- );\n- const closeButton = (\n- <TouchableHighlight\n- onPress={this.dismiss}\n- style={styles.closeButton}\n- underlayColor=\"#A0A0A0DD\"\n- >\n- <Icon\n- name=\"close\"\n- size={20}\n- color=\"white\"\n- style={styles.closeButtonIcon}\n- />\n- </TouchableHighlight>\n- );\n- let content;\n- if (this.state.mode === 'reset-password') {\n- const code = this.props.route.params.verifyCode;\n- invariant(this.state.resetPasswordUsername, 'should be set');\n- content = (\n- <ResetPasswordPanel\n- verifyCode={code}\n- username={this.state.resetPasswordUsername}\n- onSuccess={this.onResetPasswordSuccess}\n- setActiveAlert={this.setActiveAlert}\n- opacityValue={this.resetPasswordPanelOpacityValue}\n- />\n- );\n- } else if (this.state.errorMessage) {\n- content = (\n- <View style={styles.contentContainer}>\n- <Icon\n- name=\"exclamation\"\n- size={48}\n- color=\"#FF0000DD\"\n- style={styles.icon}\n- />\n- <Text style={styles.loadingText}>{this.state.errorMessage}</Text>\n- </View>\n- );\n- } else if (this.state.verifyField !== null) {\n- let message;\n- if (this.state.verifyField === verifyField.EMAIL) {\n- message = 'Thanks for verifying your email!';\n- } else {\n- message = 'Your password has been reset.';\n- }\n- content = (\n- <View style={styles.contentContainer}>\n- <Icon\n- name=\"check-circle\"\n- size={48}\n- color=\"#88FF88DD\"\n- style={styles.icon}\n- />\n- <Text style={styles.loadingText}>{message}</Text>\n- </View>\n- );\n- } else {\n- content = (\n- <View style={styles.contentContainer}>\n- <ActivityIndicator color=\"white\" size=\"large\" />\n- <Text style={styles.loadingText}>Verifying code...</Text>\n- </View>\n- );\n- }\n- const padding = { paddingTop: this.paddingTopValue };\n- const animatedContent = (\n- <Animated.View style={padding}>{content}</Animated.View>\n- );\n- return (\n- <React.Fragment>\n- {background}\n- <SafeAreaView style={styles.container} edges={safeAreaEdges}>\n- <View style={styles.container}>\n- {statusBar}\n- {animatedContent}\n- {closeButton}\n- </View>\n- </SafeAreaView>\n- </React.Fragment>\n- );\n- }\n-}\n-\n-const styles = StyleSheet.create({\n- closeButton: {\n- backgroundColor: '#D0D0D055',\n- borderRadius: 3,\n- height: 36,\n- position: 'absolute',\n- right: 15,\n- top: 15,\n- width: 36,\n- },\n- closeButtonIcon: {\n- left: 10,\n- position: 'absolute',\n- top: 8,\n- },\n- container: {\n- backgroundColor: 'transparent',\n- flex: 1,\n- },\n- contentContainer: {\n- height: 90,\n- },\n- icon: {\n- textAlign: 'center',\n- },\n- loadingText: {\n- bottom: 0,\n- color: 'white',\n- fontSize: 20,\n- left: 0,\n- position: 'absolute',\n- right: 0,\n- textAlign: 'center',\n- },\n- modalBackground: {\n- height: ('100%': number | string),\n- position: 'absolute',\n- width: ('100%': number | string),\n- },\n-});\n-\n-registerFetchKey(handleVerificationCodeActionTypes);\n-\n-const isForegroundSelector = createIsForegroundSelector(\n- VerificationModalRouteName,\n-);\n-\n-export default React.memo<BaseProps>(function ConnectedVerificationModal(\n- props: BaseProps,\n-) {\n- const navContext = React.useContext(NavContext);\n- const isForeground = isForegroundSelector(navContext);\n-\n- const dimensions = useSelector(derivedDimensionsInfoSelector);\n- const splashStyle = useSelector(splashStyleSelector);\n-\n- const dispatchActionPromise = useDispatchActionPromise();\n- const callHandleVerificationCode = useServerCall(handleVerificationCode);\n-\n- return (\n- <VerificationModal\n- {...props}\n- isForeground={isForeground}\n- dimensions={dimensions}\n- splashStyle={splashStyle}\n- dispatchActionPromise={dispatchActionPromise}\n- handleVerificationCode={callHandleVerificationCode}\n- />\n- );\n-});\n"
},
{
"change_type": "DELETE",
"old_path": "native/navigation/linking-handler.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import { CommonActions } from '@react-navigation/native';\n-import * as React from 'react';\n-import { Linking } from 'react-native';\n-\n-import { infoFromURL } from 'lib/utils/url-utils';\n-\n-import type { NavAction } from './navigation-context';\n-import { VerificationModalRouteName } from './route-names';\n-\n-type Props = {|\n- dispatch: (action: NavAction) => void,\n-|};\n-const LinkingHandler = React.memo<Props>((props: Props) => {\n- const { dispatch } = props;\n-\n- const handleURL = (url: string) => {\n- if (!url.startsWith('http')) {\n- return;\n- }\n- const { verify } = infoFromURL(url);\n- if (!verify) {\n- // TODO correctly handle non-verify URLs\n- return;\n- }\n- dispatch(\n- CommonActions.navigate({\n- name: VerificationModalRouteName,\n- key: 'VerificationModal',\n- params: { verifyCode: verify },\n- }),\n- );\n- };\n-\n- React.useEffect(() => {\n- (async () => {\n- const url = await Linking.getInitialURL();\n- if (url) {\n- handleURL(url);\n- }\n- })();\n- // eslint-disable-next-line react-hooks/exhaustive-deps\n- }, []);\n-\n- React.useEffect(() => {\n- const handleURLChange = (event: { url: string }) => handleURL(event.url);\n- Linking.addEventListener('url', handleURLChange);\n- return () => Linking.removeEventListener('url', handleURLChange);\n- });\n-\n- return null;\n-});\n-LinkingHandler.displayName = 'LinkingHandler';\n-\n-export default LinkingHandler;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/navigation-handler.react.js",
"new_path": "native/navigation/navigation-handler.react.js",
"diff": "@@ -8,7 +8,6 @@ import DevTools from '../redux/dev-tools.react';\nimport type { AppState } from '../redux/redux-setup';\nimport { useSelector } from '../redux/redux-utils';\nimport { logInActionType, logOutActionType } from './action-types';\n-import LinkingHandler from './linking-handler.react';\nimport ModalPruner from './modal-pruner.react';\nimport NavFromReduxHandler from './nav-from-redux-handler.react';\nimport { useIsAppLoggedIn } from './nav-selectors';\n@@ -40,7 +39,6 @@ const NavigationHandler = React.memo<{||}>(() => {\nreturn (\n<>\n<LogInHandler dispatch={dispatch} />\n- <LinkingHandler dispatch={dispatch} />\n<ThreadScreenTracker />\n<ModalPruner navContext={navContext} />\n{devTools}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/root-navigator.react.js",
"new_path": "native/navigation/root-navigator.react.js",
"diff": "@@ -15,7 +15,6 @@ import { Platform } from 'react-native';\nimport { enableScreens } from 'react-native-screens';\nimport LoggedOutModal from '../account/logged-out-modal.react';\n-import VerificationModal from '../account/verification-modal.react';\nimport ThreadPickerModal from '../calendar/thread-picker-modal.react';\nimport ImagePasteModal from '../chat/image-paste-modal.react';\nimport AddUsersModal from '../chat/settings/add-users-modal.react';\n@@ -28,7 +27,6 @@ import { RootNavigatorContext } from './root-navigator-context';\nimport RootRouter, { type RootRouterNavigationProp } from './root-router';\nimport {\nLoggedOutModalRouteName,\n- VerificationModalRouteName,\nAppRouteName,\nThreadPickerModalRouteName,\nImagePasteModalRouteName,\n@@ -155,10 +153,6 @@ const RootComponent = () => {\ncomponent={LoggedOutModal}\noptions={disableGesturesScreenOptions}\n/>\n- <Root.Screen\n- name={VerificationModalRouteName}\n- component={VerificationModal}\n- />\n<Root.Screen name={AppRouteName} component={AppNavigator} />\n<Root.Screen\nname={ThreadPickerModalRouteName}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/route-names.js",
"new_path": "native/navigation/route-names.js",
"diff": "import type { LeafRoute } from '@react-navigation/native';\n-import type { VerificationModalParams } from '../account/verification-modal.react';\nimport type { ThreadPickerModalParams } from '../calendar/thread-picker-modal.react';\nimport type { ComposeThreadParams } from '../chat/compose-thread.react';\nimport type { ImagePasteModalParams } from '../chat/image-paste-modal.react';\n@@ -30,7 +29,6 @@ export const ComposeThreadRouteName = 'ComposeThread';\nexport const DeleteThreadRouteName = 'DeleteThread';\nexport const ThreadSettingsRouteName = 'ThreadSettings';\nexport const MessageListRouteName = 'MessageList';\n-export const VerificationModalRouteName = 'VerificationModal';\nexport const LoggedOutModalRouteName = 'LoggedOutModal';\nexport const ProfileRouteName = 'Profile';\nexport const AppsRouteName = 'Apps';\n@@ -71,7 +69,6 @@ export const RobotextMessageTooltipModalRouteName =\nexport type RootParamList = {|\n+LoggedOutModal: void,\n- +VerificationModal: VerificationModalParams,\n+App: void,\n+ThreadPickerModal: ThreadPickerModalParams,\n+AddUsersModal: AddUsersModalParams,\n@@ -146,10 +143,7 @@ export type NavigationRoute<RouteName: string = $Keys<ScreenParamList>> = {|\n+params: $ElementType<ScreenParamList, RouteName>,\n|};\n-export const accountModals = [\n- LoggedOutModalRouteName,\n- VerificationModalRouteName,\n-];\n+export const accountModals = [LoggedOutModalRouteName];\nexport const scrollBlockingModals = [\nImageModalRouteName,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Get rid of verification functionality
Summary: This was used for verifying emails and resetting passwords, but since both of those rely on emails (which we're getting rid of), we can remove this code.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1446 |
129,187 | 22.06.2021 15:51:16 | 14,400 | 048fd22f43c4a3c5c9bac6e02914d806ff3fa989 | [native] Get rid of native deep linking config
Summary: We're not using this for verifications, and when we reintroduce it we'll want to do it for comm.app instead of squadcal.org anyways.
Test Plan: Make sure iOS and Android still run
Reviewers: atul, palys-swm
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/AndroidManifest.xml",
"new_path": "native/android/app/src/main/AndroidManifest.xml",
"diff": "<action android:name=\"android.intent.action.VIEW\" />\n<category android:name=\"android.intent.category.DEFAULT\" />\n<category android:name=\"android.intent.category.BROWSABLE\" />\n- <data android:scheme=\"http\" android:host=\"squadcal.org\" android:pathPrefix=\"/verify/\" />\n- <data android:scheme=\"https\" android:host=\"squadcal.org\" android:pathPrefix=\"/verify/\" />\n- <data android:scheme=\"http\" android:host=\"www.squadcal.org\" android:pathPrefix=\"/verify/\" />\n- <data android:scheme=\"https\" android:host=\"www.squadcal.org\" android:pathPrefix=\"/verify/\" />\n</intent-filter>\n</activity>\n<activity\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/Comm/AppDelegate.mm",
"new_path": "native/ios/Comm/AppDelegate.mm",
"diff": "#import <React/RCTBridge.h>\n#import <React/RCTBundleURLProvider.h>\n#import <React/RCTRootView.h>\n-#import <React/RCTLinkingManager.h>\n#import \"RNNotifications.h\"\n#import \"Orientation.h\"\n@@ -89,13 +88,6 @@ static void InitializeFlipper(UIApplication *application) {\nreturn extraModules;\n}\n-- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler\n-{\n- return [RCTLinkingManager application:application\n- continueUserActivity:userActivity\n- restorationHandler:restorationHandler];\n-}\n-\n- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\n{\n[RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/Comm/Comm.entitlements",
"new_path": "native/ios/Comm/Comm.entitlements",
"diff": "<string>development</string>\n<key>com.apple.developer.associated-domains</key>\n<array>\n- <string>applinks:squadcal.org</string>\n- <string>applinks:*.squadcal.org</string>\n<string>webcredentials:squadcal.org</string>\n<string>webcredentials:*.squadcal.org</string>\n</array>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Get rid of native deep linking config
Summary: We're not using this for verifications, and when we reintroduce it we'll want to do it for comm.app instead of squadcal.org anyways.
Test Plan: Make sure iOS and Android still run
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1447 |
129,187 | 22.06.2021 16:23:31 | 14,400 | 9ae6ca07bfb6912b257bbbb0318b09186f9a781a | [native] Get rid of email from profile screen
Test Plan: Flow, visual inspection
Reviewers: atul, palys-swm
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/navigation/route-names.js",
"new_path": "native/navigation/route-names.js",
"diff": "@@ -43,7 +43,6 @@ export const CalendarRouteName = 'Calendar';\nexport const BuildInfoRouteName = 'BuildInfo';\nexport const DeleteAccountRouteName = 'DeleteAccount';\nexport const DevToolsRouteName = 'DevTools';\n-export const EditEmailRouteName = 'EditEmail';\nexport const EditPasswordRouteName = 'EditPassword';\nexport const AppearancePreferencesRouteName = 'AppearancePreferences';\nexport const PrivacyPreferencesRouteName = 'PrivacyPreferences';\n"
},
{
"change_type": "DELETE",
"old_path": "native/profile/edit-email.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import { CommonActions } from '@react-navigation/native';\n-import invariant from 'invariant';\n-import * as React from 'react';\n-import {\n- Text,\n- View,\n- TextInput,\n- ScrollView,\n- Alert,\n- ActivityIndicator,\n-} from 'react-native';\n-\n-import {\n- changeUserSettingsActionTypes,\n- changeUserSettings,\n-} from 'lib/actions/user-actions';\n-import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import { validEmailRegex } from 'lib/shared/account-utils';\n-import type { ChangeUserSettingsResult } from 'lib/types/account-types';\n-import type { LoadingStatus } from 'lib/types/loading-types';\n-import type { AccountUpdate } from 'lib/types/user-types';\n-import {\n- type DispatchActionPromise,\n- useDispatchActionPromise,\n- useServerCall,\n-} from 'lib/utils/action-utils';\n-\n-import Button from '../components/button.react';\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';\n-import type { ProfileNavigationProp } from './profile.react';\n-\n-type BaseProps = {|\n- +navigation: ProfileNavigationProp<'EditEmail'>,\n- +route: NavigationRoute<'EditEmail'>,\n-|};\n-type Props = {|\n- ...BaseProps,\n- +email: ?string,\n- +loadingStatus: LoadingStatus,\n- +activeTheme: ?GlobalTheme,\n- +colors: Colors,\n- +styles: typeof unboundStyles,\n- +dispatchActionPromise: DispatchActionPromise,\n- +changeUserSettings: (\n- accountUpdate: AccountUpdate,\n- ) => Promise<ChangeUserSettingsResult>,\n-|};\n-type State = {|\n- +email: string,\n- +password: string,\n-|};\n-class EditEmail extends React.PureComponent<Props, State> {\n- mounted = false;\n- passwordInput: ?React.ElementRef<typeof TextInput>;\n- emailInput: ?React.ElementRef<typeof TextInput>;\n-\n- constructor(props: Props) {\n- super(props);\n- this.state = {\n- email: props.email ? props.email : '',\n- password: '',\n- };\n- }\n-\n- componentDidMount() {\n- this.mounted = true;\n- }\n-\n- componentWillUnmount() {\n- this.mounted = false;\n- }\n-\n- render() {\n- const buttonContent =\n- this.props.loadingStatus === 'loading' ? (\n- <ActivityIndicator size=\"small\" color=\"white\" />\n- ) : (\n- <Text style={this.props.styles.saveText}>Save</Text>\n- );\n- const { panelForegroundTertiaryLabel } = this.props.colors;\n- return (\n- <ScrollView\n- contentContainerStyle={this.props.styles.scrollViewContentContainer}\n- style={this.props.styles.scrollView}\n- >\n- <Text style={this.props.styles.header}>EMAIL</Text>\n- <View style={this.props.styles.section}>\n- <TextInput\n- style={this.props.styles.input}\n- value={this.state.email}\n- onChangeText={this.onChangeEmailText}\n- placeholder=\"Email address\"\n- placeholderTextColor={panelForegroundTertiaryLabel}\n- autoFocus={true}\n- selectTextOnFocus={true}\n- returnKeyType=\"next\"\n- autoCapitalize=\"none\"\n- keyboardType=\"email-address\"\n- textContentType=\"emailAddress\"\n- autoCompleteType=\"email\"\n- onSubmitEditing={this.focusPasswordInput}\n- ref={this.emailInputRef}\n- />\n- </View>\n- <Text style={this.props.styles.header}>PASSWORD</Text>\n- <View style={this.props.styles.section}>\n- <TextInput\n- style={this.props.styles.input}\n- value={this.state.password}\n- onChangeText={this.onChangePasswordText}\n- placeholder=\"Password\"\n- placeholderTextColor={panelForegroundTertiaryLabel}\n- secureTextEntry={true}\n- textContentType=\"password\"\n- autoCompleteType=\"password\"\n- returnKeyType=\"go\"\n- onSubmitEditing={this.submitEmail}\n- ref={this.passwordInputRef}\n- />\n- </View>\n- <Button onPress={this.submitEmail} style={this.props.styles.saveButton}>\n- {buttonContent}\n- </Button>\n- </ScrollView>\n- );\n- }\n-\n- onChangeEmailText = (newEmail: string) => {\n- this.setState({ email: newEmail });\n- };\n-\n- emailInputRef = (emailInput: ?React.ElementRef<typeof TextInput>) => {\n- this.emailInput = emailInput;\n- };\n-\n- focusEmailInput = () => {\n- invariant(this.emailInput, 'emailInput should be set');\n- this.emailInput.focus();\n- };\n-\n- onChangePasswordText = (newPassword: string) => {\n- this.setState({ password: newPassword });\n- };\n-\n- passwordInputRef = (passwordInput: ?React.ElementRef<typeof TextInput>) => {\n- this.passwordInput = passwordInput;\n- };\n-\n- focusPasswordInput = () => {\n- invariant(this.passwordInput, 'passwordInput should be set');\n- this.passwordInput.focus();\n- };\n-\n- goBackOnce() {\n- this.props.navigation.dispatch((state) => ({\n- ...CommonActions.goBack(),\n- target: state.key,\n- }));\n- }\n-\n- submitEmail = () => {\n- if (this.state.email.search(validEmailRegex) === -1) {\n- Alert.alert(\n- 'Invalid email address',\n- 'Valid email addresses only',\n- [{ text: 'OK', onPress: this.onEmailAlertAcknowledged }],\n- { cancelable: false },\n- );\n- } else if (this.state.password === '') {\n- Alert.alert(\n- 'Empty password',\n- 'Password cannot be empty',\n- [{ text: 'OK', onPress: this.onPasswordAlertAcknowledged }],\n- { cancelable: false },\n- );\n- } else if (this.state.email === this.props.email) {\n- this.goBackOnce();\n- } else {\n- this.props.dispatchActionPromise(\n- changeUserSettingsActionTypes,\n- this.saveEmail(),\n- );\n- }\n- };\n-\n- async saveEmail() {\n- try {\n- const result = await this.props.changeUserSettings({\n- updatedFields: {\n- email: this.state.email,\n- },\n- currentPassword: this.state.password,\n- });\n- this.goBackOnce();\n- Alert.alert(\n- 'Verify email',\n- \"We've sent you an email to verify your email address. Just click on \" +\n- 'the link in the email to complete the verification process.',\n- undefined,\n- { cancelable: true },\n- );\n- return result;\n- } catch (e) {\n- if (e.message === 'invalid_credentials') {\n- Alert.alert(\n- 'Incorrect password',\n- 'The password you entered is incorrect',\n- [{ text: 'OK', onPress: this.onPasswordAlertAcknowledged }],\n- { cancelable: false },\n- );\n- } else {\n- Alert.alert(\n- 'Unknown error',\n- 'Uhh... try again?',\n- [{ text: 'OK', onPress: this.onUnknownErrorAlertAcknowledged }],\n- { cancelable: false },\n- );\n- }\n- }\n- }\n-\n- onEmailAlertAcknowledged = () => {\n- const resetEmail = this.props.email ? this.props.email : '';\n- this.setState({ email: resetEmail }, this.focusEmailInput);\n- };\n-\n- onPasswordAlertAcknowledged = () => {\n- this.setState({ password: '' }, this.focusPasswordInput);\n- };\n-\n- onUnknownErrorAlertAcknowledged = () => {\n- const resetEmail = this.props.email ? this.props.email : '';\n- this.setState({ email: resetEmail, password: '' }, this.focusEmailInput);\n- };\n-}\n-\n-const unboundStyles = {\n- header: {\n- color: 'panelBackgroundLabel',\n- fontSize: 12,\n- fontWeight: '400',\n- paddingBottom: 3,\n- paddingHorizontal: 24,\n- },\n- input: {\n- color: 'panelForegroundLabel',\n- flex: 1,\n- fontFamily: 'Arial',\n- fontSize: 16,\n- paddingVertical: 0,\n- borderBottomColor: 'transparent',\n- },\n- saveButton: {\n- backgroundColor: 'greenButton',\n- borderRadius: 5,\n- flex: 1,\n- marginHorizontal: 24,\n- marginVertical: 12,\n- padding: 12,\n- },\n- saveText: {\n- color: 'white',\n- fontSize: 18,\n- textAlign: 'center',\n- },\n- scrollView: {\n- backgroundColor: 'panelBackground',\n- },\n- scrollViewContentContainer: {\n- paddingTop: 24,\n- },\n- section: {\n- backgroundColor: 'panelForeground',\n- borderBottomWidth: 1,\n- borderColor: 'panelForegroundBorder',\n- borderTopWidth: 1,\n- flexDirection: 'row',\n- justifyContent: 'space-between',\n- marginBottom: 24,\n- paddingHorizontal: 24,\n- paddingVertical: 12,\n- },\n-};\n-\n-const loadingStatusSelector = createLoadingStatusSelector(\n- changeUserSettingsActionTypes,\n-);\n-\n-export default React.memo<BaseProps>(function ConnectedEditEmail(\n- props: BaseProps,\n-) {\n- const email = useSelector((state) =>\n- state.currentUserInfo && !state.currentUserInfo.anonymous\n- ? state.currentUserInfo.email\n- : undefined,\n- );\n- const loadingStatus = useSelector(loadingStatusSelector);\n- const activeTheme = useSelector((state) => state.globalThemeInfo.activeTheme);\n- const colors = useColors();\n- const styles = useStyles(unboundStyles);\n- const callChangeUserSettings = useServerCall(changeUserSettings);\n- const dispatchActionPromise = useDispatchActionPromise();\n-\n- return (\n- <EditEmail\n- {...props}\n- email={email}\n- loadingStatus={loadingStatus}\n- activeTheme={activeTheme}\n- colors={colors}\n- styles={styles}\n- changeUserSettings={callChangeUserSettings}\n- dispatchActionPromise={dispatchActionPromise}\n- />\n- );\n-});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/profile/profile-screen.react.js",
"new_path": "native/profile/profile-screen.react.js",
"diff": "import invariant from 'invariant';\nimport * as React from 'react';\n-import {\n- View,\n- Text,\n- Alert,\n- Platform,\n- ScrollView,\n- ActivityIndicator,\n-} from 'react-native';\n+import { View, Text, Alert, Platform, ScrollView } from 'react-native';\nimport Icon from 'react-native-vector-icons/Ionicons';\n-import {\n- logOutActionTypes,\n- logOut,\n- resendVerificationEmailActionTypes,\n- resendVerificationEmail,\n-} from 'lib/actions/user-actions';\n+import { logOutActionTypes, logOut } from 'lib/actions/user-actions';\nimport { preRequestUserStateSelector } from 'lib/selectors/account-selectors';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { isStaff } from 'lib/shared/user-utils';\n@@ -39,7 +27,6 @@ import EditSettingButton from '../components/edit-setting-button.react';\nimport { SingleLine } from '../components/single-line.react';\nimport type { NavigationRoute } from '../navigation/route-names';\nimport {\n- EditEmailRouteName,\nEditPasswordRouteName,\nDeleteAccountRouteName,\nBuildInfoRouteName,\n@@ -61,13 +48,11 @@ type Props = {|\n...BaseProps,\n+currentUserInfo: ?CurrentUserInfo,\n+preRequestUserState: PreRequestUserState,\n- +resendVerificationLoading: boolean,\n+logOutLoading: boolean,\n+colors: Colors,\n+styles: typeof unboundStyles,\n+dispatchActionPromise: DispatchActionPromise,\n+logOut: (preRequestUserState: PreRequestUserState) => Promise<LogOutResult>,\n- +resendVerificationEmail: () => Promise<void>,\n|};\nclass ProfileScreen extends React.PureComponent<Props> {\nget username() {\n@@ -76,18 +61,6 @@ class ProfileScreen extends React.PureComponent<Props> {\n: undefined;\n}\n- get email() {\n- return this.props.currentUserInfo && !this.props.currentUserInfo.anonymous\n- ? this.props.currentUserInfo.email\n- : undefined;\n- }\n-\n- get emailVerified() {\n- return this.props.currentUserInfo && !this.props.currentUserInfo.anonymous\n- ? this.props.currentUserInfo.emailVerified\n- : undefined;\n- }\n-\nget loggedOutOrLoggingOut() {\nreturn (\n!this.props.currentUserInfo ||\n@@ -97,60 +70,6 @@ class ProfileScreen extends React.PureComponent<Props> {\n}\nrender() {\n- const { emailVerified } = this;\n- let emailVerifiedNode = null;\n- if (emailVerified === true) {\n- emailVerifiedNode = (\n- <Text\n- style={[\n- this.props.styles.verification,\n- this.props.styles.verificationText,\n- this.props.styles.emailVerified,\n- ]}\n- >\n- Verified\n- </Text>\n- );\n- } else if (emailVerified === false) {\n- let resendVerificationEmailSpinner;\n- if (this.props.resendVerificationLoading) {\n- resendVerificationEmailSpinner = (\n- <ActivityIndicator\n- size=\"small\"\n- style={this.props.styles.resendVerificationEmailSpinner}\n- color={this.props.colors.panelForegroundSecondaryLabel}\n- />\n- );\n- }\n- emailVerifiedNode = (\n- <View style={this.props.styles.verificationSection}>\n- <Text\n- style={[\n- this.props.styles.verificationText,\n- this.props.styles.emailNotVerified,\n- ]}\n- >\n- Not verified\n- </Text>\n- <Text style={this.props.styles.verificationText}>{' - '}</Text>\n- <Button\n- onPress={this.onPressResendVerificationEmail}\n- style={this.props.styles.resendVerificationEmailButton}\n- >\n- {resendVerificationEmailSpinner}\n- <Text\n- style={[\n- this.props.styles.verificationText,\n- this.props.styles.resendVerificationEmailText,\n- ]}\n- >\n- resend verification email\n- </Text>\n- </Button>\n- </View>\n- );\n- }\n-\nconst {\npanelIosHighlightUnderlay: underlay,\nlink: linkColor,\n@@ -191,8 +110,9 @@ class ProfileScreen extends React.PureComponent<Props> {\ncontentContainerStyle={this.props.styles.scrollViewContentContainer}\nstyle={this.props.styles.scrollView}\n>\n+ <Text style={this.props.styles.header}>ACCOUNT</Text>\n<View style={this.props.styles.section}>\n- <View style={this.props.styles.row}>\n+ <View style={this.props.styles.paddedRow}>\n<Text style={this.props.styles.loggedInLabel}>\n{'Logged in as '}\n</Text>\n@@ -208,24 +128,7 @@ class ProfileScreen extends React.PureComponent<Props> {\n<Text style={this.props.styles.logOutText}>Log out</Text>\n</Button>\n</View>\n- </View>\n- <Text style={this.props.styles.header}>ACCOUNT</Text>\n- <View style={this.props.styles.section}>\n- <View style={this.props.styles.row}>\n- <Text style={this.props.styles.label}>Email</Text>\n- <View style={this.props.styles.content}>\n- <SingleLine style={this.props.styles.value}>\n- {this.email}\n- </SingleLine>\n- {emailVerifiedNode}\n- </View>\n- <EditSettingButton\n- onPress={this.onPressEditEmail}\n- canChangeSettings={true}\n- style={this.props.styles.editEmailButton}\n- />\n- </View>\n- <View style={this.props.styles.row}>\n+ <View style={this.props.styles.paddedRow}>\n<Text style={this.props.styles.label}>Password</Text>\n<Text\nstyle={[this.props.styles.content, this.props.styles.value]}\n@@ -240,7 +143,7 @@ class ProfileScreen extends React.PureComponent<Props> {\n/>\n</View>\n</View>\n- <View style={this.props.styles.slightlyPaddedSection}>\n+ <View style={this.props.styles.section}>\n<Button\nonPress={this.onPressFriendList}\nstyle={this.props.styles.submenuButton}\n@@ -262,7 +165,7 @@ class ProfileScreen extends React.PureComponent<Props> {\n</View>\n<Text style={this.props.styles.header}>PREFERENCES</Text>\n- <View style={this.props.styles.slightlyPaddedSection}>\n+ <View style={this.props.styles.section}>\n{appearancePreferences}\n<Button\nonPress={this.onPressPrivacy}\n@@ -275,7 +178,7 @@ class ProfileScreen extends React.PureComponent<Props> {\n</Button>\n</View>\n- <View style={this.props.styles.slightlyPaddedSection}>\n+ <View style={this.props.styles.section}>\n<Button\nonPress={this.onPressBuildInfo}\nstyle={this.props.styles.submenuButton}\n@@ -360,32 +263,10 @@ class ProfileScreen extends React.PureComponent<Props> {\nawait deleteNativeCredentialsFor(username);\n}\n- onPressResendVerificationEmail = () => {\n- this.props.dispatchActionPromise(\n- resendVerificationEmailActionTypes,\n- this.resendVerificationEmailAction(),\n- );\n- };\n-\n- async resendVerificationEmailAction() {\n- await this.props.resendVerificationEmail();\n- Alert.alert(\n- 'Verify email',\n- \"We've sent you an email to verify your email address. Just click on \" +\n- 'the link in the email to complete the verification process.',\n- undefined,\n- { cancelable: true },\n- );\n- }\n-\nnavigateIfActive(name) {\nthis.props.navigation.navigate({ name });\n}\n- onPressEditEmail = () => {\n- this.navigateIfActive(EditEmailRouteName);\n- };\n-\nonPressEditPassword = () => {\nthis.navigateIfActive(EditPasswordRouteName);\n};\n@@ -435,18 +316,9 @@ const unboundStyles = {\nflex: 1,\nfontSize: 16,\n},\n- editEmailButton: {\n- paddingTop: Platform.OS === 'android' ? 9 : 7,\n- },\neditPasswordButton: {\npaddingTop: Platform.OS === 'android' ? 3 : 2,\n},\n- emailNotVerified: {\n- color: 'redText',\n- },\n- emailVerified: {\n- color: 'greenText',\n- },\nheader: {\ncolor: 'panelBackgroundLabel',\nfontSize: 12,\n@@ -468,18 +340,6 @@ const unboundStyles = {\nfontSize: 16,\npaddingLeft: 6,\n},\n- resendVerificationEmailButton: {\n- flexDirection: 'row',\n- paddingRight: 1,\n- },\n- resendVerificationEmailSpinner: {\n- marginTop: Platform.OS === 'ios' ? -4 : 0,\n- paddingHorizontal: 4,\n- },\n- resendVerificationEmailText: {\n- color: 'link',\n- fontStyle: 'italic',\n- },\nrow: {\nflex: 1,\nflexDirection: 'row',\n@@ -491,16 +351,14 @@ const unboundStyles = {\nscrollViewContentContainer: {\npaddingTop: 24,\n},\n- section: {\n- backgroundColor: 'panelForeground',\n- borderBottomWidth: 1,\n- borderColor: 'panelForegroundBorder',\n- borderTopWidth: 1,\n- marginBottom: 24,\n+ paddedRow: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ justifyContent: 'space-between',\npaddingHorizontal: 24,\n- paddingVertical: 12,\n+ paddingVertical: 10,\n},\n- slightlyPaddedSection: {\n+ section: {\nbackgroundColor: 'panelForeground',\nborderBottomWidth: 1,\nborderColor: 'panelForegroundBorder',\n@@ -535,42 +393,21 @@ const unboundStyles = {\nfontSize: 16,\ntextAlign: 'right',\n},\n- verification: {\n- alignSelf: 'flex-end',\n- flexDirection: 'row',\n- height: 20,\n- },\n- verificationSection: {\n- alignSelf: 'flex-end',\n- flexDirection: 'row',\n- height: 20,\n- },\n- verificationText: {\n- color: 'panelForegroundLabel',\n- fontSize: 13,\n- fontStyle: 'italic',\n- },\n};\nconst logOutLoadingStatusSelector = createLoadingStatusSelector(\nlogOutActionTypes,\n);\n-const resendVerificationLoadingStatusSelector = createLoadingStatusSelector(\n- resendVerificationEmailActionTypes,\n-);\nexport default React.memo<BaseProps>(function ConnectedProfileScreen(\nprops: BaseProps,\n) {\nconst currentUserInfo = useSelector((state) => state.currentUserInfo);\nconst preRequestUserState = useSelector(preRequestUserStateSelector);\n- const resendVerificationLoading =\n- useSelector(resendVerificationLoadingStatusSelector) === 'loading';\nconst logOutLoading = useSelector(logOutLoadingStatusSelector) === 'loading';\nconst colors = useColors();\nconst styles = useStyles(unboundStyles);\nconst callLogOut = useServerCall(logOut);\n- const callResendVerificationEmail = useServerCall(resendVerificationEmail);\nconst dispatchActionPromise = useDispatchActionPromise();\nreturn (\n@@ -578,12 +415,10 @@ export default React.memo<BaseProps>(function ConnectedProfileScreen(\n{...props}\ncurrentUserInfo={currentUserInfo}\npreRequestUserState={preRequestUserState}\n- resendVerificationLoading={resendVerificationLoading}\nlogOutLoading={logOutLoading}\ncolors={colors}\nstyles={styles}\nlogOut={callLogOut}\n- resendVerificationEmail={callResendVerificationEmail}\ndispatchActionPromise={dispatchActionPromise}\n/>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/profile/profile.react.js",
"new_path": "native/profile/profile.react.js",
"diff": "@@ -12,7 +12,6 @@ import KeyboardAvoidingView from '../components/keyboard-avoiding-view.react';\nimport HeaderBackButton from '../navigation/header-back-button.react';\nimport {\nProfileScreenRouteName,\n- EditEmailRouteName,\nEditPasswordRouteName,\nDeleteAccountRouteName,\nBuildInfoRouteName,\n@@ -29,7 +28,6 @@ import AppearancePreferences from './appearance-preferences.react';\nimport BuildInfo from './build-info.react';\nimport DeleteAccount from './delete-account.react';\nimport DevTools from './dev-tools.react';\n-import EditEmail from './edit-email.react';\nimport EditPassword from './edit-password.react';\nimport PrivacyPreferences from './privacy-preferences.react';\nimport ProfileHeader from './profile-header.react';\n@@ -43,7 +41,6 @@ const screenOptions = {\nheaderLeft: headerBackButton,\n};\nconst profileScreenOptions = { headerTitle: 'Profile' };\n-const editEmailOptions = { headerTitle: 'Change email' };\nconst editPasswordOptions = { headerTitle: 'Change password' };\nconst deleteAccountOptions = { headerTitle: 'Delete account' };\nconst buildInfoOptions = { headerTitle: 'Build info' };\n@@ -85,11 +82,6 @@ function ProfileComponent() {\ncomponent={ProfileScreen}\noptions={profileScreenOptions}\n/>\n- <Profile.Screen\n- name={EditEmailRouteName}\n- component={EditEmail}\n- options={editEmailOptions}\n- />\n<Profile.Screen\nname={EditPasswordRouteName}\ncomponent={EditPassword}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Get rid of email from profile screen
Test Plan: Flow, visual inspection
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1448 |
129,187 | 23.06.2021 12:36:46 | 14,400 | 2cd378d0d3f5b5bcc53d636723332764efb46c2c | [web] Get rid of email from UserSettingsModal
Test Plan: Visual inspection, Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "web/modals/account/user-settings-modal.react.js",
"new_path": "web/modals/account/user-settings-modal.react.js",
"diff": "@@ -9,12 +9,9 @@ import {\ndeleteAccount,\nchangeUserSettingsActionTypes,\nchangeUserSettings,\n- resendVerificationEmailActionTypes,\n- resendVerificationEmail,\n} from 'lib/actions/user-actions';\nimport { preRequestUserStateSelector } from 'lib/selectors/account-selectors';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import { validEmailRegex } from 'lib/shared/account-utils';\nimport type {\nLogOutResult,\nChangeUserSettingsResult,\n@@ -30,7 +27,6 @@ import {\nimport { useSelector } from '../../redux/redux-utils';\nimport css from '../../style.css';\nimport Modal from '../modal.react';\n-import VerifyEmailModal from './verify-email-modal.react';\ntype TabType = 'general' | 'delete';\ntype TabProps = {\n@@ -74,11 +70,8 @@ type Props = {|\n+changeUserSettings: (\naccountUpdate: AccountUpdate,\n) => Promise<ChangeUserSettingsResult>,\n- +resendVerificationEmail: () => Promise<void>,\n|};\ntype State = {\n- +email: ?string,\n- +emailVerified: ?boolean,\n+newPassword: string,\n+confirmNewPassword: string,\n+currentPassword: string,\n@@ -87,15 +80,12 @@ type State = {\n};\nclass UserSettingsModal extends React.PureComponent<Props, State> {\n- emailInput: ?HTMLInputElement;\nnewPasswordInput: ?HTMLInputElement;\ncurrentPasswordInput: ?HTMLInputElement;\nconstructor(props: Props) {\nsuper(props);\nthis.state = {\n- email: this.email,\n- emailVerified: this.emailVerified,\nnewPassword: '',\nconfirmNewPassword: '',\ncurrentPassword: '',\n@@ -105,8 +95,8 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\n}\ncomponentDidMount() {\n- invariant(this.emailInput, 'email ref unset');\n- this.emailInput.focus();\n+ invariant(this.newPasswordInput, 'newPasswordInput ref unset');\n+ this.newPasswordInput.focus();\n}\nget username() {\n@@ -115,41 +105,9 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\n: undefined;\n}\n- get email() {\n- return this.props.currentUserInfo && !this.props.currentUserInfo.anonymous\n- ? this.props.currentUserInfo.email\n- : undefined;\n- }\n-\n- get emailVerified() {\n- return this.props.currentUserInfo && !this.props.currentUserInfo.anonymous\n- ? this.props.currentUserInfo.emailVerified\n- : undefined;\n- }\n-\nrender() {\nlet mainContent = null;\nif (this.state.currentTabType === 'general') {\n- let verificationStatus = null;\n- if (this.state.emailVerified === true) {\n- verificationStatus = (\n- <div\n- className={`${css['form-subtitle']} ${css['verified-status-true']}`}\n- >\n- Verified\n- </div>\n- );\n- } else if (this.state.emailVerified === false) {\n- verificationStatus = (\n- <div className={css['form-subtitle']}>\n- <span className={css['verified-status-false']}>Not verified</span>\n- {' - '}\n- <a href=\"#\" onClick={this.onClickResendVerificationEmail}>\n- resend verification email\n- </a>\n- </div>\n- );\n- }\nmainContent = (\n<div>\n<div className={css['form-text']}>\n@@ -157,26 +115,12 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\n<div className={css['form-content']}>{this.username}</div>\n</div>\n<div>\n- <div className={css['form-title']}>Email</div>\n- <div className={css['form-content']}>\n- <input\n- type=\"text\"\n- placeholder=\"Email\"\n- value={this.state.email}\n- onChange={this.onChangeEmail}\n- ref={this.emailInputRef}\n- disabled={this.props.inputDisabled}\n- />\n- {verificationStatus}\n- </div>\n- </div>\n- <div>\n- <div className={css['form-title']}>New password (optional)</div>\n+ <div className={css['form-title']}>New password</div>\n<div className={css['form-content']}>\n<div>\n<input\ntype=\"password\"\n- placeholder=\"New password (optional)\"\n+ placeholder=\"New password\"\nvalue={this.state.newPassword}\nonChange={this.onChangeNewPassword}\nref={this.newPasswordInputRef}\n@@ -186,7 +130,7 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\n<div>\n<input\ntype=\"password\"\n- placeholder=\"Confirm new password (optional)\"\n+ placeholder=\"Confirm new password\"\nvalue={this.state.confirmNewPassword}\nonChange={this.onChangeConfirmNewPassword}\ndisabled={this.props.inputDisabled}\n@@ -275,10 +219,6 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\n);\n}\n- emailInputRef = (emailInput: ?HTMLInputElement) => {\n- this.emailInput = emailInput;\n- };\n-\nnewPasswordInputRef = (newPasswordInput: ?HTMLInputElement) => {\nthis.newPasswordInput = newPasswordInput;\n};\n@@ -291,15 +231,6 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\nthis.setState({ currentTabType: tabType });\n};\n- onChangeEmail = (event: SyntheticEvent<HTMLInputElement>) => {\n- const target = event.target;\n- invariant(target instanceof HTMLInputElement, 'target not input');\n- this.setState({\n- email: target.value,\n- emailVerified: target.value === this.email ? this.emailVerified : null,\n- });\n- };\n-\nonChangeNewPassword = (event: SyntheticEvent<HTMLInputElement>) => {\nconst target = event.target;\ninvariant(target instanceof HTMLInputElement, 'target not input');\n@@ -318,30 +249,15 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\nthis.setState({ currentPassword: target.value });\n};\n- onClickResendVerificationEmail = (\n- event: SyntheticEvent<HTMLAnchorElement>,\n- ) => {\n- event.preventDefault();\n- this.props.dispatchActionPromise(\n- resendVerificationEmailActionTypes,\n- this.resendVerificationEmailAction(),\n- );\n- };\n-\n- async resendVerificationEmailAction() {\n- await this.props.resendVerificationEmail();\n- this.props.setModal(<VerifyEmailModal onClose={this.clearModal} />);\n- }\n-\nonSubmit = (event: SyntheticEvent<HTMLInputElement>) => {\nevent.preventDefault();\n- if (this.state.newPassword !== this.state.confirmNewPassword) {\n+ if (this.state.newPassword === '') {\nthis.setState(\n{\nnewPassword: '',\nconfirmNewPassword: '',\n- errorMessage: \"passwords don't match\",\n+ errorMessage: 'empty password',\ncurrentTabType: 'general',\n},\n() => {\n@@ -349,20 +265,17 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\nthis.newPasswordInput.focus();\n},\n);\n- return;\n- }\n-\n- const { email } = this.state;\n- if (!email || email.search(validEmailRegex) === -1) {\n+ } else if (this.state.newPassword !== this.state.confirmNewPassword) {\nthis.setState(\n{\n- email: '',\n- errorMessage: 'invalid email address',\n+ newPassword: '',\n+ confirmNewPassword: '',\n+ errorMessage: \"passwords don't match\",\ncurrentTabType: 'general',\n},\n() => {\n- invariant(this.emailInput, 'emailInput ref unset');\n- this.emailInput.focus();\n+ invariant(this.newPasswordInput, 'newPasswordInput ref unset');\n+ this.newPasswordInput.focus();\n},\n);\nreturn;\n@@ -370,24 +283,19 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\nthis.props.dispatchActionPromise(\nchangeUserSettingsActionTypes,\n- this.changeUserSettingsAction(email),\n+ this.changeUserSettingsAction(),\n);\n};\n- async changeUserSettingsAction(email: string) {\n+ async changeUserSettingsAction() {\ntry {\nconst result = await this.props.changeUserSettings({\nupdatedFields: {\n- email,\npassword: this.state.newPassword,\n},\ncurrentPassword: this.state.currentPassword,\n});\n- if (email !== this.email) {\n- this.props.setModal(<VerifyEmailModal onClose={this.clearModal} />);\n- } else {\nthis.clearModal();\n- }\nreturn result;\n} catch (e) {\nif (e.message === 'invalid_credentials') {\n@@ -404,24 +312,9 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\nthis.currentPasswordInput.focus();\n},\n);\n- } else if (e.message === 'email_taken') {\n- this.setState(\n- {\n- email: this.email,\n- emailVerified: this.emailVerified,\n- errorMessage: 'email already taken',\n- currentTabType: 'general',\n- },\n- () => {\n- invariant(this.emailInput, 'emailInput ref unset');\n- this.emailInput.focus();\n- },\n- );\n} else {\nthis.setState(\n{\n- email: this.email,\n- emailVerified: this.emailVerified,\nnewPassword: '',\nconfirmNewPassword: '',\ncurrentPassword: '',\n@@ -429,8 +322,8 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\ncurrentTabType: 'general',\n},\n() => {\n- invariant(this.emailInput, 'emailInput ref unset');\n- this.emailInput.focus();\n+ invariant(this.newPasswordInput, 'newPasswordInput ref unset');\n+ this.newPasswordInput.focus();\n},\n);\n}\n@@ -487,9 +380,6 @@ const deleteAccountLoadingStatusSelector = createLoadingStatusSelector(\nconst changeUserSettingsLoadingStatusSelector = createLoadingStatusSelector(\nchangeUserSettingsActionTypes,\n);\n-const resendVerificationEmailLoadingStatusSelector = createLoadingStatusSelector(\n- resendVerificationEmailActionTypes,\n-);\nexport default React.memo<BaseProps>(function ConnectedUserSettingsModal(\nprops: BaseProps,\n@@ -499,12 +389,10 @@ export default React.memo<BaseProps>(function ConnectedUserSettingsModal(\nconst inputDisabled = useSelector(\n(state) =>\ndeleteAccountLoadingStatusSelector(state) === 'loading' ||\n- changeUserSettingsLoadingStatusSelector(state) === 'loading' ||\n- resendVerificationEmailLoadingStatusSelector(state) === 'loading',\n+ changeUserSettingsLoadingStatusSelector(state) === 'loading',\n);\nconst callDeleteAccount = useServerCall(deleteAccount);\nconst callChangeUserSettings = useServerCall(changeUserSettings);\n- const callResendVerificationEmail = useServerCall(resendVerificationEmail);\nconst dispatchActionPromise = useDispatchActionPromise();\nreturn (\n@@ -515,7 +403,6 @@ export default React.memo<BaseProps>(function ConnectedUserSettingsModal(\ninputDisabled={inputDisabled}\ndeleteAccount={callDeleteAccount}\nchangeUserSettings={callChangeUserSettings}\n- resendVerificationEmail={callResendVerificationEmail}\ndispatchActionPromise={dispatchActionPromise}\n/>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "web/style.css",
"new_path": "web/style.css",
"diff": "@@ -479,13 +479,6 @@ div.form-text > div.form-float-content {\nmargin-top: 5px;\n}\n-.verified-status-true {\n- color: green;\n-}\n-.verified-status-false {\n- color: red;\n-}\n-\n.hidden {\ndisplay: none;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Get rid of email from UserSettingsModal
Test Plan: Visual inspection, Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1455 |
129,187 | 23.06.2021 12:38:40 | 14,400 | a2a6b8f9818a9d8dfde658c1837a783d63206564 | [lib] Get rid of resendVerificationEmail
Summary: Nothing is using this anymore as the relevant stuff has been removed from both native and web.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/user-actions.js",
"new_path": "lib/actions/user-actions.js",
"diff": "@@ -201,17 +201,6 @@ const changeUserSettings = (fetchJSON: FetchJSON) => async (\nreturn { email: accountUpdate.updatedFields.email };\n};\n-const resendVerificationEmailActionTypes = Object.freeze({\n- started: 'RESEND_VERIFICATION_EMAIL_STARTED',\n- success: 'RESEND_VERIFICATION_EMAIL_SUCCESS',\n- failed: 'RESEND_VERIFICATION_EMAIL_FAILED',\n-});\n-const resendVerificationEmail = (\n- fetchJSON: FetchJSON,\n-) => async (): Promise<void> => {\n- await fetchJSON('send_verification_email', {});\n-};\n-\nconst handleVerificationCodeActionTypes = Object.freeze({\nstarted: 'HANDLE_VERIFICATION_CODE_STARTED',\nsuccess: 'HANDLE_VERIFICATION_CODE_SUCCESS',\n@@ -285,8 +274,6 @@ export {\nresetPassword,\nchangeUserSettingsActionTypes,\nchangeUserSettings,\n- resendVerificationEmailActionTypes,\n- resendVerificationEmail,\nhandleVerificationCodeActionTypes,\nhandleVerificationCode,\nsearchUsersActionTypes,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -289,22 +289,6 @@ export type BaseAction =\n|},\n+loadingInfo: LoadingInfo,\n|}\n- | {|\n- +type: 'RESEND_VERIFICATION_EMAIL_STARTED',\n- +payload?: void,\n- +loadingInfo: LoadingInfo,\n- |}\n- | {|\n- +type: 'RESEND_VERIFICATION_EMAIL_FAILED',\n- +error: true,\n- +payload: Error,\n- +loadingInfo: LoadingInfo,\n- |}\n- | {|\n- +type: 'RESEND_VERIFICATION_EMAIL_SUCCESS',\n- +payload?: void,\n- +loadingInfo: LoadingInfo,\n- |}\n| {|\n+type: 'CHANGE_THREAD_SETTINGS_STARTED',\n+payload?: void,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Get rid of resendVerificationEmail
Summary: Nothing is using this anymore as the relevant stuff has been removed from both native and web.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1456 |
129,187 | 23.06.2021 16:03:32 | 14,400 | e387fa019194237b37df6e2c1b0ac90296613e4a | [lib] Split ServerSocketMessage into ServerServerSocketMessage and ClientServerSocketMessage
Summary: We need these to be different because the server will need to support old clients, but the new client code will have updated types.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/socket/inflight-requests.js",
"new_path": "lib/socket/inflight-requests.js",
"diff": "@@ -7,9 +7,9 @@ import {\nclientRequestSocketTimeout,\n} from '../shared/timeouts';\nimport {\n- type ServerSocketMessage,\n+ type ClientServerSocketMessage,\ntype StateSyncServerSocketMessage,\n- type RequestsServerSocketMessage,\n+ type ClientRequestsServerSocketMessage,\ntype ActivityUpdateResponseServerSocketMessage,\ntype PongServerSocketMessage,\ntype APIResponseServerSocketMessage,\n@@ -21,12 +21,12 @@ import sleep from '../utils/sleep';\ntype ValidResponseMessageMap = {\na: StateSyncServerSocketMessage,\n- b: RequestsServerSocketMessage,\n+ b: ClientRequestsServerSocketMessage,\nc: ActivityUpdateResponseServerSocketMessage,\nd: PongServerSocketMessage,\ne: APIResponseServerSocketMessage,\n};\n-type BaseInflightRequest<Response: ServerSocketMessage> = {|\n+type BaseInflightRequest<Response: ClientServerSocketMessage> = {|\nexpectedResponseType: $PropertyType<Response, 'type'>,\nresolve: (response: Response) => void,\nreject: (error: Error) => void,\n@@ -170,7 +170,7 @@ class InflightRequests {\nthis.data = this.data.filter((request) => request !== requestToClear);\n}\n- resolveRequestsForMessage(message: ServerSocketMessage) {\n+ resolveRequestsForMessage(message: ClientServerSocketMessage) {\nfor (const inflightRequest of this.data) {\nif (\nmessage.responseTo === null ||\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/socket/message-handler.react.js",
"new_path": "lib/socket/message-handler.react.js",
"diff": "@@ -5,7 +5,7 @@ import { useDispatch } from 'react-redux';\nimport { processMessagesActionType } from '../actions/message-actions';\nimport {\n- type ServerSocketMessage,\n+ type ClientServerSocketMessage,\nserverSocketMessageTypes,\ntype SocketListener,\n} from '../types/socket-types';\n@@ -19,7 +19,7 @@ export default function MessageHandler(props: Props) {\nconst dispatch = useDispatch();\nconst onMessage = React.useCallback(\n- (message: ServerSocketMessage) => {\n+ (message: ClientServerSocketMessage) => {\nif (message.type !== serverSocketMessageTypes.MESSAGES) {\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/socket/request-response-handler.react.js",
"new_path": "lib/socket/request-response-handler.react.js",
"diff": "@@ -12,8 +12,8 @@ import {\ntype ServerRequest,\n} from '../types/request-types';\nimport {\n- type RequestsServerSocketMessage,\n- type ServerSocketMessage,\n+ type ClientRequestsServerSocketMessage,\n+ type ClientServerSocketMessage,\nclientSocketMessageTypes,\nserverSocketMessageTypes,\ntype ClientSocketMessageWithoutID,\n@@ -52,7 +52,7 @@ class RequestResponseHandler extends React.PureComponent<Props> {\nreturn null;\n}\n- onMessage = (message: ServerSocketMessage) => {\n+ onMessage = (message: ClientServerSocketMessage) => {\nif (message.type !== serverSocketMessageTypes.REQUESTS) {\nreturn;\n}\n@@ -76,7 +76,7 @@ class RequestResponseHandler extends React.PureComponent<Props> {\nsendClientResponses(\nclientResponses: $ReadOnlyArray<ClientClientResponse>,\n- ): Promise<RequestsServerSocketMessage> {\n+ ): Promise<ClientRequestsServerSocketMessage> {\nconst { inflightRequests } = this.props;\ninvariant(\ninflightRequests,\n@@ -103,7 +103,7 @@ class RequestResponseHandler extends React.PureComponent<Props> {\n}\nasync handleClientResponsesToServerRequests(\n- promise: Promise<RequestsServerSocketMessage>,\n+ promise: Promise<ClientRequestsServerSocketMessage>,\nclientResponses: $ReadOnlyArray<ClientClientResponse>,\nretriesLeft: number = 1,\n): Promise<void> {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/socket/socket.react.js",
"new_path": "lib/socket/socket.react.js",
"diff": "@@ -33,7 +33,7 @@ import {\nclientSocketMessageTypes,\ntype ClientClientSocketMessage,\nserverSocketMessageTypes,\n- type ServerSocketMessage,\n+ type ClientServerSocketMessage,\nstateSyncPayloadTypes,\nfullStateSyncActionType,\nincrementalStateSyncActionType,\n@@ -380,7 +380,7 @@ class Socket extends React.PureComponent<Props, State> {\nsocket.send(JSON.stringify(message));\n}\n- static messageFromEvent(event: MessageEvent): ?ServerSocketMessage {\n+ static messageFromEvent(event: MessageEvent): ?ClientServerSocketMessage {\nif (typeof event.data !== 'string') {\nconsole.log('socket received a non-string message');\nreturn null;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/socket/update-handler.react.js",
"new_path": "lib/socket/update-handler.react.js",
"diff": "@@ -7,7 +7,7 @@ import { useDispatch } from 'react-redux';\nimport {\ntype ClientSocketMessageWithoutID,\ntype SocketListener,\n- type ServerSocketMessage,\n+ type ClientServerSocketMessage,\nserverSocketMessageTypes,\nclientSocketMessageTypes,\n} from '../types/socket-types';\n@@ -25,7 +25,7 @@ export default function UpdateHandler(props: Props) {\nconst dispatch = useDispatch();\nconst connectionStatus = useSelector((state) => state.connection.status);\nconst onMessage = React.useCallback(\n- (message: ServerSocketMessage) => {\n+ (message: ClientServerSocketMessage) => {\nif (message.type !== serverSocketMessageTypes.UPDATES) {\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/socket-types.js",
"new_path": "lib/types/socket-types.js",
"diff": "@@ -200,7 +200,7 @@ export type StateSyncServerSocketMessage = {|\n+responseTo: number,\n+payload: StateSyncSocketPayload,\n|};\n-export type RequestsServerSocketMessage = {|\n+export type ServerRequestsServerSocketMessage = {|\n+type: 1,\n+responseTo?: number,\n+payload: {|\n@@ -246,9 +246,9 @@ export type APIResponseServerSocketMessage = {|\n+responseTo: number,\n+payload: Object,\n|};\n-export type ServerSocketMessage =\n+export type ServerServerSocketMessage =\n| StateSyncServerSocketMessage\n- | RequestsServerSocketMessage\n+ | ServerRequestsServerSocketMessage\n| ErrorServerSocketMessage\n| AuthErrorServerSocketMessage\n| ActivityUpdateResponseServerSocketMessage\n@@ -257,7 +257,25 @@ export type ServerSocketMessage =\n| MessagesServerSocketMessage\n| APIResponseServerSocketMessage;\n-export type SocketListener = (message: ServerSocketMessage) => void;\n+export type ClientRequestsServerSocketMessage = {|\n+ +type: 1,\n+ +responseTo?: number,\n+ +payload: {|\n+ +serverRequests: $ReadOnlyArray<ServerRequest>,\n+ |},\n+|};\n+export type ClientServerSocketMessage =\n+ | StateSyncServerSocketMessage\n+ | ClientRequestsServerSocketMessage\n+ | ErrorServerSocketMessage\n+ | AuthErrorServerSocketMessage\n+ | ActivityUpdateResponseServerSocketMessage\n+ | PongServerSocketMessage\n+ | UpdatesServerSocketMessage\n+ | MessagesServerSocketMessage\n+ | APIResponseServerSocketMessage;\n+\n+export type SocketListener = (message: ClientServerSocketMessage) => void;\nexport type ConnectionStatus =\n| 'connecting'\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/socket/socket.js",
"new_path": "server/src/socket/socket.js",
"diff": "@@ -26,7 +26,7 @@ import {\ntype InitialClientSocketMessage,\ntype ResponsesClientSocketMessage,\ntype StateSyncFullSocketPayload,\n- type ServerSocketMessage,\n+ type ServerServerSocketMessage,\ntype ErrorServerSocketMessage,\ntype AuthErrorServerSocketMessage,\ntype PingClientSocketMessage,\n@@ -162,7 +162,7 @@ class Socket {\nhttpRequest: $Request;\nviewer: ?Viewer;\nredis: ?RedisSubscriber;\n- redisPromiseResolver: SequentialPromiseResolver<ServerSocketMessage>;\n+ redisPromiseResolver: SequentialPromiseResolver<ServerServerSocketMessage>;\nstateCheckConditions: StateCheckConditions = {\nactivityRecentlyOccurred: true,\n@@ -358,7 +358,7 @@ class Socket {\n}\n};\n- sendMessage = (message: ServerSocketMessage) => {\n+ sendMessage = (message: ServerServerSocketMessage) => {\ninvariant(\nthis.ws.readyState > 0,\n\"shouldn't send message until connection established\",\n@@ -370,7 +370,7 @@ class Socket {\nasync handleClientSocketMessage(\nmessage: ClientSocketMessage,\n- ): Promise<ServerSocketMessage[]> {\n+ ): Promise<ServerServerSocketMessage[]> {\nconst resultPromise = (async () => {\nif (message.type === clientSocketMessageTypes.INITIAL) {\nthis.markActivityOccurred();\n@@ -398,7 +398,7 @@ class Socket {\nasync handleInitialClientSocketMessage(\nmessage: InitialClientSocketMessage,\n- ): Promise<ServerSocketMessage[]> {\n+ ): Promise<ServerServerSocketMessage[]> {\nconst { viewer } = this;\ninvariant(viewer, 'should be set');\n@@ -551,7 +551,7 @@ class Socket {\nasync handleResponsesClientSocketMessage(\nmessage: ResponsesClientSocketMessage,\n- ): Promise<ServerSocketMessage[]> {\n+ ): Promise<ServerServerSocketMessage[]> {\nconst { viewer } = this;\ninvariant(viewer, 'should be set');\n@@ -590,7 +590,7 @@ class Socket {\nasync handlePingClientSocketMessage(\nmessage: PingClientSocketMessage,\n- ): Promise<ServerSocketMessage[]> {\n+ ): Promise<ServerServerSocketMessage[]> {\nthis.updateActivityTime();\nreturn [\n{\n@@ -602,7 +602,7 @@ class Socket {\nasync handleAckUpdatesClientSocketMessage(\nmessage: AckUpdatesClientSocketMessage,\n- ): Promise<ServerSocketMessage[]> {\n+ ): Promise<ServerServerSocketMessage[]> {\nconst { viewer } = this;\ninvariant(viewer, 'should be set');\nconst { currentAsOf } = message.payload;\n@@ -615,7 +615,7 @@ class Socket {\nasync handleAPIRequestClientSocketMessage(\nmessage: APIRequestClientSocketMessage,\n- ): Promise<ServerSocketMessage[]> {\n+ ): Promise<ServerServerSocketMessage[]> {\nif (!endpointIsSocketSafe(message.payload.endpoint)) {\nthrow new ServerError('endpoint_unsafe_for_socket');\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Split ServerSocketMessage into ServerServerSocketMessage and ClientServerSocketMessage
Summary: We need these to be different because the server will need to support old clients, but the new client code will have updated types.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1459 |
129,187 | 23.06.2021 16:06:26 | 14,400 | ce8051ddcdf5a003684c2b623aa4efe472322dd4 | [lib] Split ServerRequest into ServerServerRequest and ClientServerRequest
Summary: We need these to be different because the server will need to support old clients, but the new client code will have updated types.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/socket-selectors.js",
"new_path": "lib/selectors/socket-selectors.js",
"diff": "@@ -17,7 +17,7 @@ import type {\n} from '../types/report-types';\nimport {\nserverRequestTypes,\n- type ServerRequest,\n+ type ClientServerRequest,\ntype ClientClientResponse,\n} from '../types/request-types';\nimport type { SessionState } from '../types/session-types';\n@@ -48,7 +48,7 @@ const getClientResponsesSelector: (\nstate: AppState,\n) => (\ncalendarActive: boolean,\n- serverRequests: $ReadOnlyArray<ServerRequest>,\n+ serverRequests: $ReadOnlyArray<ClientServerRequest>,\n) => $ReadOnlyArray<ClientClientResponse> = createSelector(\n(state: AppState) => state.threadStore.threadInfos,\n(state: AppState) => state.entryStore.entryInfos,\n@@ -63,7 +63,7 @@ const getClientResponsesSelector: (\ncalendarQuery: (calendarActive: boolean) => CalendarQuery,\n) => (\ncalendarActive: boolean,\n- serverRequests: $ReadOnlyArray<ServerRequest>,\n+ serverRequests: $ReadOnlyArray<ClientServerRequest>,\n): $ReadOnlyArray<ClientClientResponse> => {\nconst clientResponses = [];\nconst serverRequestedPlatformDetails = serverRequests.some(\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/socket/request-response-handler.react.js",
"new_path": "lib/socket/request-response-handler.react.js",
"diff": "@@ -9,7 +9,7 @@ import type { Dispatch } from '../types/redux-types';\nimport {\nprocessServerRequestsActionType,\ntype ClientClientResponse,\n- type ServerRequest,\n+ type ClientServerRequest,\n} from '../types/request-types';\nimport {\ntype ClientRequestsServerSocketMessage,\n@@ -30,7 +30,7 @@ type BaseProps = {|\n+addListener: (listener: SocketListener) => void,\n+removeListener: (listener: SocketListener) => void,\n+getClientResponses: (\n- activeServerRequests: $ReadOnlyArray<ServerRequest>,\n+ activeServerRequests: $ReadOnlyArray<ClientServerRequest>,\n) => $ReadOnlyArray<ClientClientResponse>,\n+currentCalendarQuery: () => CalendarQuery,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/socket/socket.react.js",
"new_path": "lib/socket/socket.react.js",
"diff": "@@ -22,7 +22,7 @@ import type { Dispatch } from '../types/redux-types';\nimport {\nserverRequestTypes,\ntype ClientClientResponse,\n- type ServerRequest,\n+ type ClientServerRequest,\n} from '../types/request-types';\nimport {\ntype SessionState,\n@@ -86,7 +86,7 @@ type Props = {|\n+active: boolean,\n+openSocket: () => WebSocket,\n+getClientResponses: (\n- activeServerRequests: $ReadOnlyArray<ServerRequest>,\n+ activeServerRequests: $ReadOnlyArray<ClientServerRequest>,\n) => $ReadOnlyArray<ClientClientResponse>,\n+activeThread: ?string,\n+sessionStateFunc: () => SessionState,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/request-types.js",
"new_path": "lib/types/request-types.js",
"diff": "@@ -71,25 +71,25 @@ export type EntryInconsistencyClientResponse = {|\nexport type CheckStateServerRequest = {|\ntype: 6,\n- hashesToCheck: { [key: string]: number },\n+ hashesToCheck: { +[key: string]: number },\nfailUnmentioned?: Shape<{|\n- threadInfos: boolean,\n- entryInfos: boolean,\n- userInfos: boolean,\n+ +threadInfos: boolean,\n+ +entryInfos: boolean,\n+ +userInfos: boolean,\n|}>,\nstateChanges?: Shape<{|\n- rawThreadInfos: RawThreadInfo[],\n- rawEntryInfos: RawEntryInfo[],\n- currentUserInfo: CurrentUserInfo,\n- userInfos: AccountUserInfo[],\n- deleteThreadIDs: string[],\n- deleteEntryIDs: string[],\n- deleteUserInfoIDs: string[],\n+ +rawThreadInfos: RawThreadInfo[],\n+ +rawEntryInfos: RawEntryInfo[],\n+ +currentUserInfo: CurrentUserInfo,\n+ +userInfos: AccountUserInfo[],\n+ +deleteThreadIDs: string[],\n+ +deleteEntryIDs: string[],\n+ +deleteUserInfoIDs: string[],\n|}>,\n|};\ntype CheckStateClientResponse = {|\ntype: 6,\n- hashResults: { [key: string]: boolean },\n+ hashResults: { +[key: string]: boolean },\n|};\ntype InitialActivityUpdatesClientResponse = {|\n@@ -97,7 +97,7 @@ type InitialActivityUpdatesClientResponse = {|\nactivityUpdates: $ReadOnlyArray<ActivityUpdate>,\n|};\n-export type ServerRequest =\n+export type ServerServerRequest =\n| PlatformServerRequest\n| PlatformDetailsServerRequest\n| CheckStateServerRequest;\n@@ -109,6 +109,11 @@ export type ClientResponse =\n| CheckStateClientResponse\n| InitialActivityUpdatesClientResponse;\n+export type ClientServerRequest =\n+ | PlatformServerRequest\n+ | PlatformDetailsServerRequest\n+ | CheckStateServerRequest;\n+\n// This is just the client variant of ClientResponse. The server needs to handle\n// multiple client versions so the type supports old versions of certain client\n// responses, but the client variant only need to support the latest version.\n@@ -134,6 +139,6 @@ export type ClientInconsistencyResponse =\nexport const processServerRequestsActionType = 'PROCESS_SERVER_REQUESTS';\nexport type ProcessServerRequestsPayload = {|\n- serverRequests: $ReadOnlyArray<ServerRequest>,\n+ serverRequests: $ReadOnlyArray<ClientServerRequest>,\ncalendarQuery: CalendarQuery,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/socket-types.js",
"new_path": "lib/types/socket-types.js",
"diff": "@@ -15,7 +15,8 @@ import {\n} from './entry-types';\nimport type { MessagesResponse, NewMessagesPayload } from './message-types';\nimport type {\n- ServerRequest,\n+ ServerServerRequest,\n+ ClientServerRequest,\nClientResponse,\nClientClientResponse,\n} from './request-types';\n@@ -204,7 +205,7 @@ export type ServerRequestsServerSocketMessage = {|\n+type: 1,\n+responseTo?: number,\n+payload: {|\n- +serverRequests: $ReadOnlyArray<ServerRequest>,\n+ +serverRequests: $ReadOnlyArray<ServerServerRequest>,\n|},\n|};\nexport type ErrorServerSocketMessage = {|\n@@ -261,7 +262,7 @@ export type ClientRequestsServerSocketMessage = {|\n+type: 1,\n+responseTo?: number,\n+payload: {|\n- +serverRequests: $ReadOnlyArray<ServerRequest>,\n+ +serverRequests: $ReadOnlyArray<ClientServerRequest>,\n|},\n|};\nexport type ClientServerSocketMessage =\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/socket-selectors.js",
"new_path": "native/selectors/socket-selectors.js",
"diff": "@@ -8,7 +8,7 @@ import {\n} from 'lib/selectors/socket-selectors';\nimport { createOpenSocketFunction } from 'lib/shared/socket-utils';\nimport type {\n- ServerRequest,\n+ ClientServerRequest,\nClientClientResponse,\n} from 'lib/types/request-types';\nimport type {\n@@ -41,17 +41,17 @@ const sessionIdentificationSelector: (\nconst nativeGetClientResponsesSelector: (\ninput: NavPlusRedux,\n) => (\n- serverRequests: $ReadOnlyArray<ServerRequest>,\n+ serverRequests: $ReadOnlyArray<ClientServerRequest>,\n) => $ReadOnlyArray<ClientClientResponse> = createSelector(\n(input: NavPlusRedux) => getClientResponsesSelector(input.redux),\n(input: NavPlusRedux) => calendarActiveSelector(input.navContext),\n(\ngetClientResponsesFunc: (\ncalendarActive: boolean,\n- serverRequests: $ReadOnlyArray<ServerRequest>,\n+ serverRequests: $ReadOnlyArray<ClientServerRequest>,\n) => $ReadOnlyArray<ClientClientResponse>,\ncalendarActive: boolean,\n- ) => (serverRequests: $ReadOnlyArray<ServerRequest>) =>\n+ ) => (serverRequests: $ReadOnlyArray<ClientServerRequest>) =>\ngetClientResponsesFunc(calendarActive, serverRequests),\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/socket/session-utils.js",
"new_path": "server/src/socket/session-utils.js",
"diff": "@@ -26,7 +26,7 @@ import {\ntype ThreadInconsistencyClientResponse,\ntype EntryInconsistencyClientResponse,\ntype ClientResponse,\n- type ServerRequest,\n+ type ServerServerRequest,\ntype CheckStateServerRequest,\n} from 'lib/types/request-types';\nimport { sessionCheckFrequency } from 'lib/types/session-types';\n@@ -112,7 +112,7 @@ type StateCheckStatus =\n| {| status: 'state_invalid', invalidKeys: $ReadOnlyArray<string> |}\n| {| status: 'state_check' |};\ntype ProcessClientResponsesResult = {|\n- serverRequests: ServerRequest[],\n+ serverRequests: ServerServerRequest[],\nstateCheckStatus: ?StateCheckStatus,\nactivityUpdateResult: ?UpdateActivityResult,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "web/selectors/socket-selectors.js",
"new_path": "web/selectors/socket-selectors.js",
"diff": "@@ -8,7 +8,7 @@ import {\n} from 'lib/selectors/socket-selectors';\nimport { createOpenSocketFunction } from 'lib/shared/socket-utils';\nimport type {\n- ServerRequest,\n+ ClientServerRequest,\nClientClientResponse,\n} from 'lib/types/request-types';\nimport type {\n@@ -33,17 +33,17 @@ const sessionIdentificationSelector: (\nconst webGetClientResponsesSelector: (\nstate: AppState,\n) => (\n- serverRequests: $ReadOnlyArray<ServerRequest>,\n+ serverRequests: $ReadOnlyArray<ClientServerRequest>,\n) => $ReadOnlyArray<ClientClientResponse> = createSelector(\ngetClientResponsesSelector,\n(state: AppState) => state.navInfo.tab === 'calendar',\n(\ngetClientResponsesFunc: (\ncalendarActive: boolean,\n- serverRequests: $ReadOnlyArray<ServerRequest>,\n+ serverRequests: $ReadOnlyArray<ClientServerRequest>,\n) => $ReadOnlyArray<ClientClientResponse>,\ncalendarActive: boolean,\n- ) => (serverRequests: $ReadOnlyArray<ServerRequest>) =>\n+ ) => (serverRequests: $ReadOnlyArray<ClientServerRequest>) =>\ngetClientResponsesFunc(calendarActive, serverRequests),\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Split ServerRequest into ServerServerRequest and ClientServerRequest
Summary: We need these to be different because the server will need to support old clients, but the new client code will have updated types.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1460 |
129,187 | 23.06.2021 16:18:40 | 14,400 | 183c01aca3985fcb9a393f91ca90f135396d7d18 | [lib] Split StateSyncSocketPayload into ServerStateSyncSocketPayload and ClientStateSyncSocketPayload
Summary: We need these to be different because the server will need to support old clients, but the new client code will have updated types.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/socket/inflight-requests.js",
"new_path": "lib/socket/inflight-requests.js",
"diff": "@@ -8,7 +8,7 @@ import {\n} from '../shared/timeouts';\nimport {\ntype ClientServerSocketMessage,\n- type StateSyncServerSocketMessage,\n+ type ClientStateSyncServerSocketMessage,\ntype ClientRequestsServerSocketMessage,\ntype ActivityUpdateResponseServerSocketMessage,\ntype PongServerSocketMessage,\n@@ -20,7 +20,7 @@ import { ServerError, ExtendableError } from '../utils/errors';\nimport sleep from '../utils/sleep';\ntype ValidResponseMessageMap = {\n- a: StateSyncServerSocketMessage,\n+ a: ClientStateSyncServerSocketMessage,\nb: ClientRequestsServerSocketMessage,\nc: ActivityUpdateResponseServerSocketMessage,\nd: PongServerSocketMessage,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/socket-types.js",
"new_path": "lib/types/socket-types.js",
"diff": "@@ -155,21 +155,36 @@ export const stateSyncPayloadTypes = Object.freeze({\nINCREMENTAL: 1,\n});\n-export type FullStateSync = {|\n+export const fullStateSyncActionType = 'FULL_STATE_SYNC';\n+export type BaseFullStateSync = {|\n+messagesResult: MessagesResponse,\n+threadInfos: { [id: string]: RawThreadInfo },\n- +currentUserInfo: CurrentUserInfo,\n+rawEntryInfos: $ReadOnlyArray<RawEntryInfo>,\n+userInfos: $ReadOnlyArray<UserInfo>,\n+updatesCurrentAsOf: number,\n|};\n+\n+export type ClientFullStateSync = {|\n+ ...BaseFullStateSync,\n+ +currentUserInfo: CurrentUserInfo,\n+|};\nexport type StateSyncFullActionPayload = {|\n- ...FullStateSync,\n+ ...ClientFullStateSync,\n+calendarQuery: CalendarQuery,\n|};\n-export const fullStateSyncActionType = 'FULL_STATE_SYNC';\n-export type StateSyncFullSocketPayload = {|\n- ...FullStateSync,\n+export type ClientStateSyncFullSocketPayload = {|\n+ ...ClientFullStateSync,\n+ +type: 0,\n+ // Included iff client is using sessionIdentifierTypes.BODY_SESSION_ID\n+ +sessionID?: string,\n+|};\n+\n+export type ServerFullStateSync = {|\n+ ...BaseFullStateSync,\n+ +currentUserInfo: CurrentUserInfo,\n+|};\n+export type ServerStateSyncFullSocketPayload = {|\n+ ...ServerFullStateSync,\n+type: 0,\n// Included iff client is using sessionIdentifierTypes.BODY_SESSION_ID\n+sessionID?: string,\n@@ -192,14 +207,17 @@ type StateSyncIncrementalSocketPayload = {|\n...IncrementalStateSync,\n|};\n-export type StateSyncSocketPayload =\n- | StateSyncFullSocketPayload\n+export type ClientStateSyncSocketPayload =\n+ | ClientStateSyncFullSocketPayload\n+ | StateSyncIncrementalSocketPayload;\n+export type ServerStateSyncSocketPayload =\n+ | ServerStateSyncFullSocketPayload\n| StateSyncIncrementalSocketPayload;\n-export type StateSyncServerSocketMessage = {|\n+export type ServerStateSyncServerSocketMessage = {|\n+type: 0,\n+responseTo: number,\n- +payload: StateSyncSocketPayload,\n+ +payload: ServerStateSyncSocketPayload,\n|};\nexport type ServerRequestsServerSocketMessage = {|\n+type: 1,\n@@ -248,7 +266,7 @@ export type APIResponseServerSocketMessage = {|\n+payload: Object,\n|};\nexport type ServerServerSocketMessage =\n- | StateSyncServerSocketMessage\n+ | ServerStateSyncServerSocketMessage\n| ServerRequestsServerSocketMessage\n| ErrorServerSocketMessage\n| AuthErrorServerSocketMessage\n@@ -265,8 +283,13 @@ export type ClientRequestsServerSocketMessage = {|\n+serverRequests: $ReadOnlyArray<ClientServerRequest>,\n|},\n|};\n+export type ClientStateSyncServerSocketMessage = {|\n+ +type: 0,\n+ +responseTo: number,\n+ +payload: ClientStateSyncSocketPayload,\n+|};\nexport type ClientServerSocketMessage =\n- | StateSyncServerSocketMessage\n+ | ClientStateSyncServerSocketMessage\n| ClientRequestsServerSocketMessage\n| ErrorServerSocketMessage\n| AuthErrorServerSocketMessage\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/socket/socket.js",
"new_path": "server/src/socket/socket.js",
"diff": "@@ -25,7 +25,7 @@ import {\ntype ClientSocketMessage,\ntype InitialClientSocketMessage,\ntype ResponsesClientSocketMessage,\n- type StateSyncFullSocketPayload,\n+ type ServerStateSyncFullSocketPayload,\ntype ServerServerSocketMessage,\ntype ErrorServerSocketMessage,\ntype AuthErrorServerSocketMessage,\n@@ -457,7 +457,7 @@ class Socket {\nfetchCurrentUserInfo(viewer),\nfetchKnownUserInfos(viewer),\n]);\n- const payload: StateSyncFullSocketPayload = {\n+ const payload: ServerStateSyncFullSocketPayload = {\ntype: stateSyncPayloadTypes.FULL,\nmessagesResult,\nthreadInfos: threadsResult.threadInfos,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Split StateSyncSocketPayload into ServerStateSyncSocketPayload and ClientStateSyncSocketPayload
Summary: We need these to be different because the server will need to support old clients, but the new client code will have updated types.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1461 |
129,187 | 23.06.2021 16:38:10 | 14,400 | 61c5caf766623e14d8f02acbd89b3c71d9a741bf | [lib] Split UpdatesResult into ServerUpdatesResult and ClientUpdatesResult
Summary: We need these to be different because the server will need to support old clients, but the new client code will have updated types.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -69,7 +69,7 @@ import type {\nNewThreadResult,\nThreadJoinPayload,\n} from './thread-types';\n-import type { UpdatesResultWithUserInfos } from './update-types';\n+import type { ClientUpdatesResultWithUserInfos } from './update-types';\nimport type { CurrentUserInfo, UserStore } from './user-types';\nexport type BaseAppState<NavInfo: BaseNavInfo> = {\n@@ -716,7 +716,7 @@ export type BaseAction =\n|}\n| {|\n+type: 'PROCESS_UPDATES',\n- +payload: UpdatesResultWithUserInfos,\n+ +payload: ClientUpdatesResultWithUserInfos,\n|}\n| {|\n+type: 'PROCESS_MESSAGES',\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/socket-types.js",
"new_path": "lib/types/socket-types.js",
"diff": "@@ -22,7 +22,12 @@ import type {\n} from './request-types';\nimport type { SessionState, SessionIdentification } from './session-types';\nimport type { RawThreadInfo } from './thread-types';\n-import type { UpdatesResult, UpdatesResultWithUserInfos } from './update-types';\n+import type {\n+ ClientUpdatesResult,\n+ ClientUpdatesResultWithUserInfos,\n+ ServerUpdatesResult,\n+ ServerUpdatesResultWithUserInfos,\n+} from './update-types';\nimport type {\nUserInfo,\nCurrentUserInfo,\n@@ -190,29 +195,42 @@ export type ServerStateSyncFullSocketPayload = {|\n+sessionID?: string,\n|};\n-export type IncrementalStateSync = {|\n+export const incrementalStateSyncActionType = 'INCREMENTAL_STATE_SYNC';\n+export type BaseIncrementalStateSync = {|\n+messagesResult: MessagesResponse,\n- +updatesResult: UpdatesResult,\n+deltaEntryInfos: $ReadOnlyArray<RawEntryInfo>,\n+deletedEntryIDs: $ReadOnlyArray<string>,\n+userInfos: $ReadOnlyArray<UserInfo>,\n|};\n+\n+export type ClientIncrementalStateSync = {|\n+ ...BaseIncrementalStateSync,\n+ +updatesResult: ClientUpdatesResult,\n+|};\nexport type StateSyncIncrementalActionPayload = {|\n- ...IncrementalStateSync,\n+ ...ClientIncrementalStateSync,\n+calendarQuery: CalendarQuery,\n|};\n-export const incrementalStateSyncActionType = 'INCREMENTAL_STATE_SYNC';\n-type StateSyncIncrementalSocketPayload = {|\n+type ClientStateSyncIncrementalSocketPayload = {|\n+type: 1,\n- ...IncrementalStateSync,\n+ ...ClientIncrementalStateSync,\n+|};\n+\n+export type ServerIncrementalStateSync = {|\n+ ...BaseIncrementalStateSync,\n+ +updatesResult: ServerUpdatesResult,\n+|};\n+type ServerStateSyncIncrementalSocketPayload = {|\n+ +type: 1,\n+ ...ServerIncrementalStateSync,\n|};\nexport type ClientStateSyncSocketPayload =\n| ClientStateSyncFullSocketPayload\n- | StateSyncIncrementalSocketPayload;\n+ | ClientStateSyncIncrementalSocketPayload;\nexport type ServerStateSyncSocketPayload =\n| ServerStateSyncFullSocketPayload\n- | StateSyncIncrementalSocketPayload;\n+ | ServerStateSyncIncrementalSocketPayload;\nexport type ServerStateSyncServerSocketMessage = {|\n+type: 0,\n@@ -252,9 +270,9 @@ export type PongServerSocketMessage = {|\n+type: 5,\n+responseTo: number,\n|};\n-export type UpdatesServerSocketMessage = {|\n+export type ServerUpdatesServerSocketMessage = {|\n+type: 6,\n- +payload: UpdatesResultWithUserInfos,\n+ +payload: ServerUpdatesResultWithUserInfos,\n|};\nexport type MessagesServerSocketMessage = {|\n+type: 7,\n@@ -272,7 +290,7 @@ export type ServerServerSocketMessage =\n| AuthErrorServerSocketMessage\n| ActivityUpdateResponseServerSocketMessage\n| PongServerSocketMessage\n- | UpdatesServerSocketMessage\n+ | ServerUpdatesServerSocketMessage\n| MessagesServerSocketMessage\n| APIResponseServerSocketMessage;\n@@ -288,6 +306,10 @@ export type ClientStateSyncServerSocketMessage = {|\n+responseTo: number,\n+payload: ClientStateSyncSocketPayload,\n|};\n+export type ClientUpdatesServerSocketMessage = {|\n+ +type: 6,\n+ +payload: ClientUpdatesResultWithUserInfos,\n+|};\nexport type ClientServerSocketMessage =\n| ClientStateSyncServerSocketMessage\n| ClientRequestsServerSocketMessage\n@@ -295,7 +317,7 @@ export type ClientServerSocketMessage =\n| AuthErrorServerSocketMessage\n| ActivityUpdateResponseServerSocketMessage\n| PongServerSocketMessage\n- | UpdatesServerSocketMessage\n+ | ClientUpdatesServerSocketMessage\n| MessagesServerSocketMessage\n| APIResponseServerSocketMessage;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/update-types.js",
"new_path": "lib/types/update-types.js",
"diff": "@@ -267,12 +267,21 @@ export type ServerUpdateInfo =\n| CurrentUserUpdateInfo\n| UserUpdateInfo;\n-export type UpdatesResult = {|\n+export type ServerUpdatesResult = {|\n+ currentAsOf: number,\n+ newUpdates: $ReadOnlyArray<ServerUpdateInfo>,\n+|};\n+export type ServerUpdatesResultWithUserInfos = {|\n+ updatesResult: ServerUpdatesResult,\n+ userInfos: $ReadOnlyArray<UserInfo>,\n+|};\n+\n+export type ClientUpdatesResult = {|\ncurrentAsOf: number,\nnewUpdates: $ReadOnlyArray<ClientUpdateInfo>,\n|};\n-export type UpdatesResultWithUserInfos = {|\n- updatesResult: UpdatesResult,\n+export type ClientUpdatesResultWithUserInfos = {|\n+ updatesResult: ClientUpdatesResult,\nuserInfos: $ReadOnlyArray<UserInfo>,\n|};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Split UpdatesResult into ServerUpdatesResult and ClientUpdatesResult
Summary: We need these to be different because the server will need to support old clients, but the new client code will have updated types.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1462 |
129,187 | 23.06.2021 16:44:47 | 14,400 | e52ff498338febc63a49ca0f32ef4fc1e6e55db1 | Remove email and emailVerified from CurrentUserInfo
Summary: This was complicated because the server still needs to include these for old clients.
Test Plan: Test with old clients and new clients on the new server
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/user-actions.js",
"new_path": "lib/actions/user-actions.js",
"diff": "@@ -74,8 +74,6 @@ const register = (fetchJSON: FetchJSON) => async (\ncurrentUserInfo: {\nid: response.id,\nusername: registerInfo.username,\n- email: registerInfo.email,\n- emailVerified: false,\n},\nrawMessageInfos: response.rawMessageInfos,\nthreadInfos: response.cookieChange.threadInfos,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/user-reducer.js",
"new_path": "lib/reducers/user-reducer.js",
"diff": "// @flow\n-import invariant from 'invariant';\nimport _isEqual from 'lodash/fp/isEqual';\nimport _keyBy from 'lodash/fp/keyBy';\n@@ -14,7 +13,6 @@ import {\nlogInActionTypes,\nregisterActionTypes,\nresetPasswordActionTypes,\n- changeUserSettingsActionTypes,\n} from '../actions/user-actions';\nimport type { BaseAction } from '../types/redux-types';\nimport {\n@@ -79,21 +77,6 @@ function reduceCurrentUserInfo(\nreturn update.currentUserInfo;\n}\n}\n- } else if (action.type === changeUserSettingsActionTypes.success) {\n- invariant(\n- state && !state.anonymous,\n- \"can't change settings if not logged in\",\n- );\n- const email = action.payload.email;\n- if (!email) {\n- return state;\n- }\n- return {\n- id: state.id,\n- username: state.username,\n- email: email,\n- emailVerified: false,\n- };\n} else if (action.type === processServerRequestsActionType) {\nconst checkStateRequest = action.payload.serverRequests.find(\n(candidate) => candidate.type === serverRequestTypes.CHECK_STATE,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/account-types.js",
"new_path": "lib/types/account-types.js",
"diff": "@@ -17,6 +17,7 @@ import type {\nUserInfo,\nLoggedOutUserInfo,\nLoggedInUserInfo,\n+ OldLoggedInUserInfo,\n} from './user-types';\nexport type ResetPasswordRequest = {|\n@@ -110,7 +111,7 @@ export type LogInRequest = {|\n|};\nexport type LogInResponse = {|\n- currentUserInfo: LoggedInUserInfo,\n+ currentUserInfo: LoggedInUserInfo | OldLoggedInUserInfo,\nrawMessageInfos: $ReadOnlyArray<RawMessageInfo>,\ntruncationStatuses: MessageTruncationStatuses,\nuserInfos: $ReadOnlyArray<UserInfo>,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/request-types.js",
"new_path": "lib/types/request-types.js",
"diff": "@@ -13,7 +13,11 @@ import type {\nClientEntryInconsistencyReportShape,\n} from './report-types';\nimport type { RawThreadInfo } from './thread-types';\n-import type { CurrentUserInfo, AccountUserInfo } from './user-types';\n+import type {\n+ CurrentUserInfo,\n+ OldCurrentUserInfo,\n+ AccountUserInfo,\n+} from './user-types';\n// \"Server requests\" are requests for information that the server delivers to\n// clients. Clients then respond to those requests with a \"client response\".\n@@ -69,7 +73,7 @@ export type EntryInconsistencyClientResponse = {|\n...EntryInconsistencyReportShape,\n|};\n-export type CheckStateServerRequest = {|\n+export type ServerCheckStateServerRequest = {|\ntype: 6,\nhashesToCheck: { +[key: string]: number },\nfailUnmentioned?: Shape<{|\n@@ -80,7 +84,7 @@ export type CheckStateServerRequest = {|\nstateChanges?: Shape<{|\n+rawThreadInfos: RawThreadInfo[],\n+rawEntryInfos: RawEntryInfo[],\n- +currentUserInfo: CurrentUserInfo,\n+ +currentUserInfo: CurrentUserInfo | OldCurrentUserInfo,\n+userInfos: AccountUserInfo[],\n+deleteThreadIDs: string[],\n+deleteEntryIDs: string[],\n@@ -100,7 +104,7 @@ type InitialActivityUpdatesClientResponse = {|\nexport type ServerServerRequest =\n| PlatformServerRequest\n| PlatformDetailsServerRequest\n- | CheckStateServerRequest;\n+ | ServerCheckStateServerRequest;\nexport type ClientResponse =\n| PlatformClientResponse\n| ThreadInconsistencyClientResponse\n@@ -109,10 +113,28 @@ export type ClientResponse =\n| CheckStateClientResponse\n| InitialActivityUpdatesClientResponse;\n+export type ClientCheckStateServerRequest = {|\n+ type: 6,\n+ hashesToCheck: { +[key: string]: number },\n+ failUnmentioned?: Shape<{|\n+ +threadInfos: boolean,\n+ +entryInfos: boolean,\n+ +userInfos: boolean,\n+ |}>,\n+ stateChanges?: Shape<{|\n+ +rawThreadInfos: RawThreadInfo[],\n+ +rawEntryInfos: RawEntryInfo[],\n+ +currentUserInfo: CurrentUserInfo,\n+ +userInfos: AccountUserInfo[],\n+ +deleteThreadIDs: string[],\n+ +deleteEntryIDs: string[],\n+ +deleteUserInfoIDs: string[],\n+ |}>,\n+|};\nexport type ClientServerRequest =\n| PlatformServerRequest\n| PlatformDetailsServerRequest\n- | CheckStateServerRequest;\n+ | ClientCheckStateServerRequest;\n// This is just the client variant of ClientResponse. The server needs to handle\n// multiple client versions so the type supports old versions of certain client\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/socket-types.js",
"new_path": "lib/types/socket-types.js",
"diff": "@@ -31,6 +31,7 @@ import type {\nimport type {\nUserInfo,\nCurrentUserInfo,\n+ OldCurrentUserInfo,\nLoggedOutUserInfo,\n} from './user-types';\n@@ -186,7 +187,7 @@ export type ClientStateSyncFullSocketPayload = {|\nexport type ServerFullStateSync = {|\n...BaseFullStateSync,\n- +currentUserInfo: CurrentUserInfo,\n+ +currentUserInfo: CurrentUserInfo | OldCurrentUserInfo,\n|};\nexport type ServerStateSyncFullSocketPayload = {|\n...ServerFullStateSync,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/update-types.js",
"new_path": "lib/types/update-types.js",
"diff": "@@ -5,7 +5,12 @@ import invariant from 'invariant';\nimport type { RawEntryInfo } from './entry-types';\nimport type { RawMessageInfo, MessageTruncationStatus } from './message-types';\nimport type { RawThreadInfo } from './thread-types';\n-import type { UserInfo, AccountUserInfo, LoggedInUserInfo } from './user-types';\n+import type {\n+ UserInfo,\n+ AccountUserInfo,\n+ LoggedInUserInfo,\n+ OldLoggedInUserInfo,\n+} from './user-types';\nexport const updateTypes = Object.freeze({\nDELETE_ACCOUNT: 0,\n@@ -256,6 +261,12 @@ export type ClientUpdateInfo =\n| CurrentUserUpdateInfo\n| UserUpdateInfo;\n+type ServerCurrentUserUpdateInfo = {|\n+ type: 7,\n+ id: string,\n+ time: number,\n+ currentUserInfo: LoggedInUserInfo | OldLoggedInUserInfo,\n+|};\nexport type ServerUpdateInfo =\n| AccountDeletionUpdateInfo\n| ThreadUpdateInfo\n@@ -264,7 +275,7 @@ export type ServerUpdateInfo =\n| ThreadJoinUpdateInfo\n| BadDeviceTokenUpdateInfo\n| EntryUpdateInfo\n- | CurrentUserUpdateInfo\n+ | ServerCurrentUserUpdateInfo\n| UserUpdateInfo;\nexport type ServerUpdatesResult = {|\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/user-types.js",
"new_path": "lib/types/user-types.js",
"diff": "@@ -37,18 +37,24 @@ export type RelativeUserInfo = {|\n+isViewer: boolean,\n|};\n-export type LoggedInUserInfo = {|\n+export type OldLoggedInUserInfo = {|\n+id: string,\n+username: string,\n+email: string,\n+emailVerified: boolean,\n|};\n+export type LoggedInUserInfo = {|\n+ +id: string,\n+ +username: string,\n+|};\n+\nexport type LoggedOutUserInfo = {|\n+id: string,\n+anonymous: true,\n|};\n+export type OldCurrentUserInfo = OldLoggedInUserInfo | LoggedOutUserInfo;\nexport type CurrentUserInfo = LoggedInUserInfo | LoggedOutUserInfo;\nexport type AccountUpdate = {|\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux/persist.js",
"new_path": "native/redux/persist.js",
"diff": "@@ -217,6 +217,19 @@ const migrations = {\n...state,\ncrashReportsEnabled: __DEV__,\n}),\n+ [26]: (state) => {\n+ const { currentUserInfo } = state;\n+ if (currentUserInfo.anonymous) {\n+ return state;\n+ }\n+ return {\n+ ...state,\n+ currentUserInfo: {\n+ id: currentUserInfo.id,\n+ username: currentUserInfo.username,\n+ },\n+ };\n+ },\n};\nconst persistConfig = {\n@@ -231,7 +244,7 @@ const persistConfig = {\n'frozen',\n],\ndebug: __DEV__,\n- version: 25,\n+ version: 26,\nmigrate: createMigrate(migrations, { debug: __DEV__ }),\ntimeout: __DEV__ ? 0 : undefined,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/update-creator.js",
"new_path": "server/src/creators/update-creator.js",
"diff": "@@ -31,7 +31,11 @@ import {\ntype CreateUpdatesResult,\nupdateTypes,\n} from 'lib/types/update-types';\n-import type { AccountUserInfo, LoggedInUserInfo } from 'lib/types/user-types';\n+import type {\n+ AccountUserInfo,\n+ LoggedInUserInfo,\n+ OldLoggedInUserInfo,\n+} from 'lib/types/user-types';\nimport { promiseAll } from 'lib/utils/promises';\nimport {\n@@ -483,7 +487,9 @@ export type UpdateInfosRawData = {|\nmessageInfosResult: ?FetchMessageInfosResult,\ncalendarResult: ?FetchEntryInfosBase,\nentryInfosResult: ?$ReadOnlyArray<RawEntryInfo>,\n- currentUserInfosResult: ?$ReadOnlyArray<LoggedInUserInfo>,\n+ currentUserInfosResult: ?$ReadOnlyArray<\n+ OldLoggedInUserInfo | LoggedInUserInfo,\n+ >,\n|};\nasync function updateInfosFromRawUpdateInfos(\nviewer: Viewer,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/user-fetchers.js",
"new_path": "server/src/fetchers/user-fetchers.js",
"diff": "// @flow\n+import { hasMinCodeVersion } from 'lib/shared/version-utils';\nimport {\nundirectedStatus,\ndirectedStatus,\n@@ -8,7 +9,9 @@ import {\nimport type {\nUserInfos,\nCurrentUserInfo,\n+ OldCurrentUserInfo,\nLoggedInUserInfo,\n+ OldLoggedInUserInfo,\nGlobalUserInfo,\n} from 'lib/types/user-types';\nimport { ServerError } from 'lib/utils/errors';\n@@ -179,20 +182,28 @@ async function verifyUserOrCookieIDs(\nreturn result.map((row) => row.id.toString());\n}\n-async function fetchCurrentUserInfo(viewer: Viewer): Promise<CurrentUserInfo> {\n+async function fetchCurrentUserInfo(\n+ viewer: Viewer,\n+): Promise<OldCurrentUserInfo | CurrentUserInfo> {\nif (!viewer.loggedIn) {\n- return { id: viewer.cookieID, anonymous: true };\n+ return ({ id: viewer.cookieID, anonymous: true }: CurrentUserInfo);\n}\nconst currentUserInfos = await fetchLoggedInUserInfos([viewer.userID]);\nif (currentUserInfos.length === 0) {\nthrow new ServerError('unknown_error');\n}\n- return currentUserInfos[0];\n+ const currentUserInfo = currentUserInfos[0];\n+ const hasCodeVersionBelow87 = !hasMinCodeVersion(viewer.platformDetails, 87);\n+ if (hasCodeVersionBelow87) {\n+ return currentUserInfo;\n+ }\n+ const { id, username } = currentUserInfo;\n+ return { id, username };\n}\nasync function fetchLoggedInUserInfos(\nuserIDs: $ReadOnlyArray<string>,\n-): Promise<LoggedInUserInfo[]> {\n+): Promise<Array<OldLoggedInUserInfo | LoggedInUserInfo>> {\nconst query = SQL`\nSELECT id, username, email, email_verified\nFROM users\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/website-responders.js",
"new_path": "server/src/responders/website-responders.js",
"diff": "@@ -21,6 +21,7 @@ import { defaultCalendarFilters } from 'lib/types/filter-types';\nimport { defaultNumberPerThread } from 'lib/types/message-types';\nimport { defaultConnectionInfo } from 'lib/types/socket-types';\nimport { threadPermissions } from 'lib/types/thread-types';\n+import type { CurrentUserInfo } from 'lib/types/user-types';\nimport { currentDateInTimeZone } from 'lib/utils/date-utils';\nimport { ServerError } from 'lib/utils/errors';\nimport { promiseAll } from 'lib/utils/promises';\n@@ -251,7 +252,7 @@ async function websiteResponder(\nconst statePromises = {\nnavInfo: navInfoPromise,\n- currentUserInfo: currentUserInfoPromise,\n+ currentUserInfo: ((currentUserInfoPromise: any): Promise<CurrentUserInfo>),\nsessionID: sessionIDPromise,\nentryStore: entryStorePromise,\nthreadStore: threadStorePromise,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/socket/session-utils.js",
"new_path": "server/src/socket/session-utils.js",
"diff": "@@ -27,7 +27,7 @@ import {\ntype EntryInconsistencyClientResponse,\ntype ClientResponse,\ntype ServerServerRequest,\n- type CheckStateServerRequest,\n+ type ServerCheckStateServerRequest,\n} from 'lib/types/request-types';\nimport { sessionCheckFrequency } from 'lib/types/session-types';\nimport { hash } from 'lib/utils/objects';\n@@ -285,7 +285,7 @@ async function initializeSession(\ntype StateCheckResult = {|\nsessionUpdate?: SessionUpdate,\n- checkStateRequest?: CheckStateServerRequest,\n+ checkStateRequest?: ServerCheckStateServerRequest,\n|};\nasync function checkState(\nviewer: Viewer,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Remove email and emailVerified from CurrentUserInfo
Summary: This was complicated because the server still needs to include these for old clients.
Test Plan: Test with old clients and new clients on the new server
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1463 |
129,187 | 23.06.2021 16:50:32 | 14,400 | aff85c8432a34e699c9e61b5271d20d5ae3b71fb | [native] Reduce spacing between wordmark and user input for short Androids
Summary: The spacing between `LogInPanel` and `RegisterPanel` is too much for short Android screens. This change makes it look more natural.
Test Plan: Visual inspection on Nexus 4 emulator
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/account/panel-components.react.js",
"new_path": "native/account/panel-components.react.js",
"diff": "@@ -129,7 +129,7 @@ class InnerPanel extends React.PureComponent<PanelProps, PanelState> {\nconst windowHeight = this.props.dimensions.height;\nconst containerStyle = {\nopacity: this.props.opacityValue,\n- marginTop: windowHeight < 600 ? 15 : 40,\n+ marginTop: windowHeight < 641 ? 15 : 40,\n};\nconst content = (\n<Animated.View\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Reduce spacing between wordmark and user input for short Androids
Summary: The spacing between `LogInPanel` and `RegisterPanel` is too much for short Android screens. This change makes it look more natural.
Test Plan: Visual inspection on Nexus 4 emulator
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1464 |
129,187 | 23.06.2021 16:52:55 | 14,400 | 0bb11ddce3a52e21cb83693c2d2de5500f3582be | [native] Remove email from RegisterPanel
Summary: This also let me simplify some height logic by making `RegisterPanel` shorter.
Test Plan: Visual inspection on iPhone 5s simulator
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/types/account-types.js",
"new_path": "lib/types/account-types.js",
"diff": "@@ -36,7 +36,6 @@ export type LogOutResponse = {|\nexport type RegisterInfo = {|\n...LogInExtraInfo,\n+username: string,\n- +email: string,\n+password: string,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -171,7 +171,6 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nregisterState: {\nstate: {\nusernameInputText: '',\n- emailInputText: '',\npasswordInputText: '',\nconfirmPasswordInputText: '',\n},\n@@ -321,31 +320,14 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\npanelPaddingTop() {\nconst headerHeight = Platform.OS === 'ios' ? 62.33 : 58.54;\nconst promptButtonsSize = Platform.OS === 'ios' ? 40 : 61;\n- const logInContainerSize = 165;\n- const registerPanelSize = 246;\n-\n- // On large enough devices, we want to properly center the panels on screen.\n- // But on smaller Android devices, this can lead to an issue, since on\n- // Android, ratchetAlongWithKeyboardHeight won't adjust the panel's position\n- // when the keyboard size changes. To avoid this issue, we artifically\n- // increase the panel sizes so that they get positioned a little higher than\n- // center on small devices.\n- const smallDeviceThreshold = 600;\n- const smallDeviceRegisterPanelSize = 261;\n+ const logInContainerSize = 140;\n+ const registerPanelSize = Platform.OS === 'ios' ? 181 : 180;\nconst containerSize = add(\nheaderHeight,\ncond(not(isPastPrompt(this.modeValue)), promptButtonsSize, 0),\ncond(eq(this.modeValue, modeNumbers['log-in']), logInContainerSize, 0),\n- cond(\n- eq(this.modeValue, modeNumbers['register']),\n- cond(\n- lessThan(this.contentHeight, smallDeviceThreshold),\n- smallDeviceRegisterPanelSize,\n- registerPanelSize,\n- ),\n- 0,\n- ),\n+ cond(eq(this.modeValue, modeNumbers['register']), registerPanelSize, 0),\n);\nconst potentialPanelPaddingTop = divide(\nmax(sub(this.contentHeight, this.keyboardHeightValue, containerSize), 0),\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/register-panel.react.js",
"new_path": "native/account/register-panel.react.js",
"diff": "@@ -8,7 +8,7 @@ import Icon from 'react-native-vector-icons/FontAwesome';\nimport { registerActionTypes, register } from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import { validUsernameRegex, validEmailRegex } from 'lib/shared/account-utils';\n+import { validUsernameRegex } from 'lib/shared/account-utils';\nimport type {\nRegisterInfo,\nLogInExtraInfo,\n@@ -32,7 +32,6 @@ import { PanelButton, Panel } from './panel-components.react';\nexport type RegisterState = {|\n+usernameInputText: string,\n- +emailInputText: string,\n+passwordInputText: string,\n+confirmPasswordInputText: string,\n|};\n@@ -59,7 +58,6 @@ class RegisterPanel extends React.PureComponent<Props, State> {\nconfirmPasswordFocused: false,\n};\nusernameInput: ?TextInput;\n- emailInput: ?TextInput;\npasswordInput: ?TextInput;\nconfirmPasswordInput: ?TextInput;\npasswordBeingAutoFilled = false;\n@@ -84,32 +82,6 @@ class RegisterPanel extends React.PureComponent<Props, State> {\nreturn (\n<Panel opacityValue={this.props.opacityValue} style={styles.container}>\n- <View>\n- <Icon\n- name=\"envelope\"\n- size={18}\n- color=\"#777\"\n- style={[styles.icon, styles.envelopeIcon]}\n- />\n- <TextInput\n- style={styles.input}\n- value={this.props.registerState.state.emailInputText}\n- onChangeText={this.onChangeEmailInputText}\n- placeholder=\"Email address\"\n- autoFocus={true}\n- autoCorrect={false}\n- autoCapitalize=\"none\"\n- keyboardType=\"email-address\"\n- textContentType=\"emailAddress\"\n- autoCompleteType=\"email\"\n- returnKeyType=\"next\"\n- blurOnSubmit={false}\n- onSubmitEditing={this.focusUsernameInput}\n- onBlur={this.onEmailBlur}\n- editable={this.props.loadingStatus !== 'loading'}\n- ref={this.emailInputRef}\n- />\n- </View>\n<View>\n<Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n<TextInput\n@@ -117,6 +89,7 @@ class RegisterPanel extends React.PureComponent<Props, State> {\nvalue={this.props.registerState.state.usernameInputText}\nonChangeText={this.onChangeUsernameInputText}\nplaceholder=\"Username\"\n+ autoFocus={true}\nautoCorrect={false}\nautoCapitalize=\"none\"\nkeyboardType=\"ascii-capable\"\n@@ -176,10 +149,6 @@ class RegisterPanel extends React.PureComponent<Props, State> {\nthis.usernameInput = usernameInput;\n};\n- emailInputRef = (emailInput: ?TextInput) => {\n- this.emailInput = emailInput;\n- };\n-\npasswordInputRef = (passwordInput: ?TextInput) => {\nthis.passwordInput = passwordInput;\n};\n@@ -207,23 +176,6 @@ class RegisterPanel extends React.PureComponent<Props, State> {\nthis.props.registerState.setState({ usernameInputText: text });\n};\n- onChangeEmailInputText = (text: string) => {\n- this.props.registerState.setState({ emailInputText: text });\n- if (\n- this.props.registerState.state.emailInputText.length === 0 &&\n- text.length > 1\n- ) {\n- this.focusUsernameInput();\n- }\n- };\n-\n- onEmailBlur = () => {\n- const trimmedEmail = this.props.registerState.state.emailInputText.trim();\n- if (trimmedEmail !== this.props.registerState.state.emailInputText) {\n- this.props.registerState.setState({ emailInputText: trimmedEmail });\n- }\n- };\n-\nonChangePasswordInputText = (text: string) => {\nconst stateUpdate = {};\nstateUpdate.passwordInputText = text;\n@@ -288,16 +240,6 @@ class RegisterPanel extends React.PureComponent<Props, State> {\n[{ text: 'OK', onPress: this.onUsernameAlertAcknowledged }],\n{ cancelable: false },\n);\n- } else if (\n- this.props.registerState.state.emailInputText.search(validEmailRegex) ===\n- -1\n- ) {\n- Alert.alert(\n- 'Invalid email address',\n- 'Valid email addresses only',\n- [{ text: 'OK', onPress: this.onEmailAlertAcknowledged }],\n- { cancelable: false },\n- );\n} else {\nKeyboard.dismiss();\nconst extraInfo = this.props.logInExtraInfo();\n@@ -337,24 +279,10 @@ class RegisterPanel extends React.PureComponent<Props, State> {\n);\n};\n- onEmailAlertAcknowledged = () => {\n- this.props.setActiveAlert(false);\n- this.props.registerState.setState(\n- {\n- emailInputText: '',\n- },\n- () => {\n- invariant(this.emailInput, 'ref should exist');\n- this.emailInput.focus();\n- },\n- );\n- };\n-\nasync registerAction(extraInfo: LogInExtraInfo) {\ntry {\nconst result = await this.props.register({\nusername: this.props.registerState.state.usernameInputText,\n- email: this.props.registerState.state.emailInputText,\npassword: this.props.registerState.state.passwordInputText,\n...extraInfo,\n});\n@@ -372,13 +300,6 @@ class RegisterPanel extends React.PureComponent<Props, State> {\n[{ text: 'OK', onPress: this.onUsernameAlertAcknowledged }],\n{ cancelable: false },\n);\n- } else if (e.message === 'email_taken') {\n- Alert.alert(\n- 'Email taken',\n- 'An account with that email already exists',\n- [{ text: 'OK', onPress: this.onEmailAlertAcknowledged }],\n- { cancelable: false },\n- );\n} else if (e.message === 'client_version_unsupported') {\nconst app = Platform.select({\nios: 'Testflight',\n@@ -408,7 +329,6 @@ class RegisterPanel extends React.PureComponent<Props, State> {\nthis.props.registerState.setState(\n{\nusernameInputText: '',\n- emailInputText: '',\npasswordInputText: '',\nconfirmPasswordInputText: '',\n},\n@@ -429,10 +349,6 @@ const styles = StyleSheet.create({\npaddingBottom: Platform.OS === 'ios' ? 37 : 36,\nzIndex: 2,\n},\n- envelopeIcon: {\n- bottom: 10,\n- left: 3,\n- },\nicon: {\nbottom: 8,\nleft: 4,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Remove email from RegisterPanel
Summary: This also let me simplify some height logic by making `RegisterPanel` shorter.
Test Plan: Visual inspection on iPhone 5s simulator
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1465 |
129,187 | 23.06.2021 17:13:19 | 14,400 | 96c7199b60c98a739351cc528e8b288cb6c6fb89 | [native] Get rid of ResetPasswordPanel
Summary: Forgot to remove this when I removed `VerificationModal`.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "DELETE",
"old_path": "native/account/reset-password-panel.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import invariant from 'invariant';\n-import React from 'react';\n-import {\n- Alert,\n- StyleSheet,\n- Keyboard,\n- View,\n- Text,\n- Platform,\n-} from 'react-native';\n-import Animated from 'react-native-reanimated';\n-import Icon from 'react-native-vector-icons/FontAwesome';\n-\n-import {\n- resetPasswordActionTypes,\n- resetPassword,\n-} from 'lib/actions/user-actions';\n-import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import type {\n- UpdatePasswordInfo,\n- LogInExtraInfo,\n- LogInResult,\n- LogInStartingPayload,\n-} from 'lib/types/account-types';\n-import type { LoadingStatus } from 'lib/types/loading-types';\n-import {\n- useServerCall,\n- useDispatchActionPromise,\n- type DispatchActionPromise,\n-} from 'lib/utils/action-utils';\n-\n-import { NavContext } from '../navigation/navigation-context';\n-import { useSelector } from '../redux/redux-utils';\n-import { nativeLogInExtraInfoSelector } from '../selectors/account-selectors';\n-import { TextInput } from './modal-components.react';\n-import { PanelButton, Panel } from './panel-components.react';\n-\n-type BaseProps = {|\n- +verifyCode: string,\n- +username: string,\n- +onSuccess: () => Promise<void>,\n- +setActiveAlert: (activeAlert: boolean) => void,\n- +opacityValue: Animated.Value,\n-|};\n-type Props = {|\n- ...BaseProps,\n- // Redux state\n- +loadingStatus: LoadingStatus,\n- +logInExtraInfo: () => LogInExtraInfo,\n- // Redux dispatch functions\n- +dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- +resetPassword: (info: UpdatePasswordInfo) => Promise<LogInResult>,\n-|};\n-type State = {|\n- +passwordInputText: string,\n- +confirmPasswordInputText: string,\n-|};\n-class ResetPasswordPanel extends React.PureComponent<Props, State> {\n- state: State = {\n- passwordInputText: '',\n- confirmPasswordInputText: '',\n- };\n- passwordInput: ?TextInput;\n- confirmPasswordInput: ?TextInput;\n- passwordBeingAutoFilled = false;\n-\n- render() {\n- let onPasswordKeyPress;\n- if (Platform.OS === 'ios') {\n- onPasswordKeyPress = this.onPasswordKeyPress;\n- }\n- return (\n- <Panel opacityValue={this.props.opacityValue} style={styles.container}>\n- <View>\n- <Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n- <View style={styles.usernameContainer}>\n- <Text style={styles.usernameText}>{this.props.username}</Text>\n- </View>\n- </View>\n- <View>\n- <Icon name=\"lock\" size={22} color=\"#777\" style={styles.icon} />\n- <TextInput\n- style={styles.input}\n- value={this.state.passwordInputText}\n- onChangeText={this.onChangePasswordInputText}\n- onKeyPress={onPasswordKeyPress}\n- placeholder=\"New password\"\n- autoFocus={true}\n- secureTextEntry={true}\n- textContentType=\"password\"\n- autoCompleteType=\"password\"\n- returnKeyType=\"next\"\n- blurOnSubmit={false}\n- onSubmitEditing={this.focusConfirmPasswordInput}\n- editable={this.props.loadingStatus !== 'loading'}\n- ref={this.passwordInputRef}\n- />\n- </View>\n- <View>\n- <TextInput\n- style={styles.input}\n- value={this.state.confirmPasswordInputText}\n- onChangeText={this.onChangeConfirmPasswordInputText}\n- placeholder=\"Confirm password\"\n- secureTextEntry={true}\n- textContentType=\"password\"\n- autoCompleteType=\"password\"\n- returnKeyType=\"go\"\n- blurOnSubmit={false}\n- onSubmitEditing={this.onSubmit}\n- editable={this.props.loadingStatus !== 'loading'}\n- ref={this.confirmPasswordInputRef}\n- />\n- </View>\n- <PanelButton\n- text=\"RESET PASSWORD\"\n- loadingStatus={this.props.loadingStatus}\n- onSubmit={this.onSubmit}\n- />\n- </Panel>\n- );\n- }\n-\n- passwordInputRef = (passwordInput: ?TextInput) => {\n- this.passwordInput = passwordInput;\n- };\n-\n- confirmPasswordInputRef = (confirmPasswordInput: ?TextInput) => {\n- this.confirmPasswordInput = confirmPasswordInput;\n- };\n-\n- focusConfirmPasswordInput = () => {\n- invariant(this.confirmPasswordInput, 'ref should be set');\n- this.confirmPasswordInput.focus();\n- };\n-\n- onChangePasswordInputText = (text: string) => {\n- const stateUpdate = {};\n- stateUpdate.passwordInputText = text;\n- if (this.passwordBeingAutoFilled) {\n- this.passwordBeingAutoFilled = false;\n- stateUpdate.confirmPasswordInputText = text;\n- }\n- this.setState(stateUpdate);\n- };\n-\n- onPasswordKeyPress = (\n- event: $ReadOnly<{ nativeEvent: $ReadOnly<{ key: string }> }>,\n- ) => {\n- const { key } = event.nativeEvent;\n- if (\n- key.length > 1 &&\n- key !== 'Backspace' &&\n- key !== 'Enter' &&\n- this.state.confirmPasswordInputText.length === 0\n- ) {\n- this.passwordBeingAutoFilled = true;\n- }\n- };\n-\n- onChangeConfirmPasswordInputText = (text: string) => {\n- this.setState({ confirmPasswordInputText: text });\n- };\n-\n- onSubmit = () => {\n- this.props.setActiveAlert(true);\n- if (this.state.passwordInputText === '') {\n- Alert.alert(\n- 'Empty password',\n- 'Password cannot be empty',\n- [{ text: 'OK', onPress: this.onPasswordAlertAcknowledged }],\n- { cancelable: false },\n- );\n- return;\n- } else if (\n- this.state.passwordInputText !== this.state.confirmPasswordInputText\n- ) {\n- Alert.alert(\n- \"Passwords don't match\",\n- 'Password fields must contain the same password',\n- [{ text: 'OK', onPress: this.onPasswordAlertAcknowledged }],\n- { cancelable: false },\n- );\n- return;\n- }\n- Keyboard.dismiss();\n- const extraInfo = this.props.logInExtraInfo();\n- this.props.dispatchActionPromise(\n- resetPasswordActionTypes,\n- this.resetPasswordAction(extraInfo),\n- undefined,\n- ({ calendarQuery: extraInfo.calendarQuery }: LogInStartingPayload),\n- );\n- };\n-\n- onPasswordAlertAcknowledged = () => {\n- this.props.setActiveAlert(false);\n- this.setState(\n- {\n- passwordInputText: '',\n- confirmPasswordInputText: '',\n- },\n- () => {\n- invariant(this.passwordInput, 'ref should exist');\n- this.passwordInput.focus();\n- },\n- );\n- };\n-\n- async resetPasswordAction(extraInfo: LogInExtraInfo) {\n- try {\n- const result = await this.props.resetPassword({\n- ...extraInfo,\n- code: this.props.verifyCode,\n- password: this.state.passwordInputText,\n- });\n- this.props.setActiveAlert(false);\n- await this.props.onSuccess();\n- return result;\n- } catch (e) {\n- if (e.message === 'client_version_unsupported') {\n- const app = Platform.select({\n- ios: 'Testflight',\n- android: 'Play Store',\n- });\n- Alert.alert(\n- 'App out of date',\n- \"Your app version is pretty old, and the server doesn't know how \" +\n- `to speak to it anymore. Please use the ${app} app to update!`,\n- [{ text: 'OK', onPress: this.onAppOutOfDateAlertAcknowledged }],\n- { cancelable: false },\n- );\n- } else {\n- Alert.alert(\n- 'Unknown error',\n- 'Uhh... try again?',\n- [{ text: 'OK', onPress: this.onPasswordAlertAcknowledged }],\n- { cancelable: false },\n- );\n- throw e;\n- }\n- }\n- }\n-\n- onAppOutOfDateAlertAcknowledged = () => {\n- this.props.setActiveAlert(false);\n- };\n-}\n-\n-const styles = StyleSheet.create({\n- container: {\n- marginTop: 0,\n- },\n- icon: {\n- bottom: 8,\n- left: 4,\n- position: 'absolute',\n- },\n- input: {\n- paddingLeft: 35,\n- },\n- usernameContainer: {\n- borderBottomColor: '#BBBBBB',\n- borderBottomWidth: 1,\n- paddingLeft: 35,\n- },\n- usernameText: {\n- color: '#444',\n- fontSize: 20,\n- height: 40,\n- paddingTop: 8,\n- },\n-});\n-\n-const loadingStatusSelector = createLoadingStatusSelector(\n- resetPasswordActionTypes,\n-);\n-\n-export default React.memo<BaseProps>(function ConnectedResetPasswordPanel(\n- props: BaseProps,\n-) {\n- const loadingStatus = useSelector(loadingStatusSelector);\n-\n- const navContext = React.useContext(NavContext);\n- const logInExtraInfo = useSelector((state) =>\n- nativeLogInExtraInfoSelector({\n- redux: state,\n- navContext,\n- }),\n- );\n-\n- const dispatchActionPromise = useDispatchActionPromise();\n- const callResetPassword = useServerCall(resetPassword);\n-\n- return (\n- <ResetPasswordPanel\n- {...props}\n- loadingStatus={loadingStatus}\n- logInExtraInfo={logInExtraInfo}\n- dispatchActionPromise={dispatchActionPromise}\n- resetPassword={callResetPassword}\n- />\n- );\n-});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Get rid of ResetPasswordPanel
Summary: Forgot to remove this when I removed `VerificationModal`.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1466 |
129,187 | 23.06.2021 17:17:57 | 14,400 | d8dfa820f3b25740820116ee26480579844c8fdb | [lib] Get rid of resetPassword
Summary: No endpoints calling this action so it can be removed now!
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/user-actions.js",
"new_path": "lib/actions/user-actions.js",
"diff": "@@ -7,7 +7,6 @@ import type {\nLogInInfo,\nLogInResult,\nRegisterResult,\n- UpdatePasswordInfo,\nRegisterInfo,\nAccessRequest,\n} from '../types/account-types';\n@@ -147,46 +146,6 @@ const logIn = (fetchJSON: FetchJSON) => async (\n};\n};\n-const resetPasswordActionTypes = Object.freeze({\n- started: 'RESET_PASSWORD_STARTED',\n- success: 'RESET_PASSWORD_SUCCESS',\n- failed: 'RESET_PASSWORD_FAILED',\n-});\n-const resetPassword = (fetchJSON: FetchJSON) => async (\n- updatePasswordInfo: UpdatePasswordInfo,\n-): Promise<LogInResult> => {\n- const watchedIDs = threadWatcher.getWatchedIDs();\n- const response = await fetchJSON(\n- 'update_password',\n- {\n- ...updatePasswordInfo,\n- watchedIDs,\n- platformDetails: getConfig().platformDetails,\n- },\n- logInFetchJSONOptions,\n- );\n- const userInfos = mergeUserInfos(\n- response.userInfos,\n- response.cookieChange.userInfos,\n- );\n- return {\n- threadInfos: response.cookieChange.threadInfos,\n- currentUserInfo: response.currentUserInfo,\n- calendarResult: {\n- calendarQuery: updatePasswordInfo.calendarQuery,\n- rawEntryInfos: response.rawEntryInfos,\n- },\n- messagesResult: {\n- messageInfos: response.rawMessageInfos,\n- truncationStatus: response.truncationStatuses,\n- watchedIDsAtRequestTime: watchedIDs,\n- currentAsOf: response.serverTime,\n- },\n- userInfos,\n- updatesCurrentAsOf: response.serverTime,\n- };\n-};\n-\nconst changeUserSettingsActionTypes = Object.freeze({\nstarted: 'CHANGE_USER_SETTINGS_STARTED',\nsuccess: 'CHANGE_USER_SETTINGS_SUCCESS',\n@@ -268,8 +227,6 @@ export {\nsocketAuthErrorResolutionAttempt,\nlogInActionTypes,\nlogIn,\n- resetPasswordActionTypes,\n- resetPassword,\nchangeUserSettingsActionTypes,\nchangeUserSettings,\nhandleVerificationCodeActionTypes,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/calendar-filters-reducer.js",
"new_path": "lib/reducers/calendar-filters-reducer.js",
"diff": "@@ -10,7 +10,6 @@ import {\nlogOutActionTypes,\ndeleteAccountActionTypes,\nlogInActionTypes,\n- resetPasswordActionTypes,\nregisterActionTypes,\n} from '../actions/user-actions';\nimport {\n@@ -49,7 +48,6 @@ export default function reduceCalendarFilters(\naction.type === deleteAccountActionTypes.success ||\naction.type === logInActionTypes.success ||\naction.type === registerActionTypes.success ||\n- action.type === resetPasswordActionTypes.success ||\n(action.type === setNewSessionActionType &&\naction.payload.sessionChange.cookieInvalidated)\n) {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/connection-reducer.js",
"new_path": "lib/reducers/connection-reducer.js",
"diff": "@@ -6,7 +6,6 @@ import {\nlogOutActionTypes,\ndeleteAccountActionTypes,\nlogInActionTypes,\n- resetPasswordActionTypes,\nregisterActionTypes,\n} from '../actions/user-actions';\nimport { queueActivityUpdatesActionType } from '../types/activity-types';\n@@ -74,10 +73,7 @@ export default function reduceConnectionInfo(\ngetConfig().platformDetails.platform,\n),\n};\n- } else if (\n- action.type === logInActionTypes.success ||\n- action.type === resetPasswordActionTypes.success\n- ) {\n+ } else if (action.type === logInActionTypes.success) {\nreturn {\n...state,\nactualizedCalendarQuery: action.payload.calendarResult.calendarQuery,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/data-loaded-reducer.js",
"new_path": "lib/reducers/data-loaded-reducer.js",
"diff": "@@ -5,7 +5,6 @@ import {\ndeleteAccountActionTypes,\nlogInActionTypes,\nregisterActionTypes,\n- resetPasswordActionTypes,\n} from '../actions/user-actions';\nimport type { BaseAction } from '../types/redux-types';\nimport { setNewSessionActionType } from '../utils/action-utils';\n@@ -13,7 +12,6 @@ import { setNewSessionActionType } from '../utils/action-utils';\nexport default function reduceDataLoaded(state: boolean, action: BaseAction) {\nif (\naction.type === logInActionTypes.success ||\n- action.type === resetPasswordActionTypes.success ||\naction.type === registerActionTypes.success\n) {\nreturn true;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -41,7 +41,6 @@ import {\nlogOutActionTypes,\ndeleteAccountActionTypes,\nlogInActionTypes,\n- resetPasswordActionTypes,\n} from '../actions/user-actions';\nimport {\nentryID,\n@@ -465,10 +464,7 @@ function reduceEntryInfos(\nlastUserInteractionCalendar: Date.now(),\ninconsistencyReports,\n};\n- } else if (\n- action.type === logInActionTypes.success ||\n- action.type === resetPasswordActionTypes.success\n- ) {\n+ } else if (action.type === logInActionTypes.success) {\nconst { calendarResult } = action.payload;\nif (calendarResult) {\nconst [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/master-reducer.js",
"new_path": "lib/reducers/master-reducer.js",
"diff": "// @flow\n-import {\n- registerActionTypes,\n- logInActionTypes,\n- resetPasswordActionTypes,\n-} from '../actions/user-actions';\n+import { registerActionTypes, logInActionTypes } from '../actions/user-actions';\nimport type { BaseNavInfo } from '../types/nav-types';\nimport type { BaseAppState, BaseAction } from '../types/redux-types';\nimport {\n@@ -52,8 +48,7 @@ export default function baseReducer<N: BaseNavInfo, T: BaseAppState<N>>(\naction.type !== incrementalStateSyncActionType &&\naction.type !== fullStateSyncActionType &&\naction.type !== registerActionTypes.success &&\n- action.type !== logInActionTypes.success &&\n- action.type !== resetPasswordActionTypes.success\n+ action.type !== logInActionTypes.success\n) {\nif (messageStore.currentAsOf !== state.messageStore.currentAsOf) {\nmessageStore = {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/message-reducer.js",
"new_path": "lib/reducers/message-reducer.js",
"diff": "@@ -44,7 +44,6 @@ import {\nlogOutActionTypes,\ndeleteAccountActionTypes,\nlogInActionTypes,\n- resetPasswordActionTypes,\nregisterActionTypes,\n} from '../actions/user-actions';\nimport { pendingToRealizedThreadIDsSelector } from '../selectors/thread-selectors';\n@@ -542,10 +541,7 @@ function reduceMessageStore(\naction: BaseAction,\nnewThreadInfos: { [id: string]: RawThreadInfo },\n): MessageStore {\n- if (\n- action.type === logInActionTypes.success ||\n- action.type === resetPasswordActionTypes.success\n- ) {\n+ if (action.type === logInActionTypes.success) {\nconst messagesResult = action.payload.messagesResult;\nreturn freshMessageStore(\nmessagesResult.messageInfos,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/nav-reducer.js",
"new_path": "lib/reducers/nav-reducer.js",
"diff": "// @flow\nimport { updateCalendarQueryActionTypes } from '../actions/entry-actions';\n-import {\n- logInActionTypes,\n- resetPasswordActionTypes,\n- registerActionTypes,\n-} from '../actions/user-actions';\n+import { logInActionTypes, registerActionTypes } from '../actions/user-actions';\nimport type { BaseNavInfo } from '../types/nav-types';\nimport type { BaseAction } from '../types/redux-types';\nimport {\n@@ -19,7 +15,6 @@ export default function reduceBaseNavInfo<T: BaseNavInfo>(\n): T {\nif (\naction.type === logInActionTypes.started ||\n- action.type === resetPasswordActionTypes.started ||\naction.type === registerActionTypes.started ||\naction.type === fullStateSyncActionType ||\naction.type === incrementalStateSyncActionType\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/thread-reducer.js",
"new_path": "lib/reducers/thread-reducer.js",
"diff": "@@ -24,7 +24,6 @@ import {\nlogOutActionTypes,\ndeleteAccountActionTypes,\nlogInActionTypes,\n- resetPasswordActionTypes,\nregisterActionTypes,\nupdateSubscriptionActionTypes,\n} from '../actions/user-actions';\n@@ -138,7 +137,6 @@ export default function reduceThreadInfos(\nif (\naction.type === logInActionTypes.success ||\naction.type === registerActionTypes.success ||\n- action.type === resetPasswordActionTypes.success ||\naction.type === fullStateSyncActionType\n) {\nif (_isEqual(state.threadInfos)(action.payload.threadInfos)) {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/updates-reducer.js",
"new_path": "lib/reducers/updates-reducer.js",
"diff": "// @flow\n-import {\n- logInActionTypes,\n- resetPasswordActionTypes,\n-} from '../actions/user-actions';\n+import { logInActionTypes } from '../actions/user-actions';\nimport type { BaseAction } from '../types/redux-types';\nimport {\nfullStateSyncActionType,\n@@ -15,10 +12,7 @@ function reduceUpdatesCurrentAsOf(\ncurrentAsOf: number,\naction: BaseAction,\n): number {\n- if (\n- action.type === logInActionTypes.success ||\n- action.type === resetPasswordActionTypes.success\n- ) {\n+ if (action.type === logInActionTypes.success) {\nreturn action.payload.updatesCurrentAsOf;\n} else if (action.type === fullStateSyncActionType) {\nreturn action.payload.updatesCurrentAsOf;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/user-reducer.js",
"new_path": "lib/reducers/user-reducer.js",
"diff": "@@ -12,7 +12,6 @@ import {\ndeleteAccountActionTypes,\nlogInActionTypes,\nregisterActionTypes,\n- resetPasswordActionTypes,\n} from '../actions/user-actions';\nimport type { BaseAction } from '../types/redux-types';\nimport {\n@@ -44,7 +43,6 @@ function reduceCurrentUserInfo(\n): ?CurrentUserInfo {\nif (\naction.type === logInActionTypes.success ||\n- action.type === resetPasswordActionTypes.success ||\naction.type === registerActionTypes.success ||\naction.type === logOutActionTypes.success ||\naction.type === deleteAccountActionTypes.success\n@@ -145,7 +143,6 @@ function reduceUserInfos(state: UserStore, action: BaseAction): UserStore {\n} else if (\naction.type === logInActionTypes.success ||\naction.type === registerActionTypes.success ||\n- action.type === resetPasswordActionTypes.success ||\naction.type === fullStateSyncActionType\n) {\nconst newUserInfos = _keyBy((userInfo) => userInfo.id)(\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/account-types.js",
"new_path": "lib/types/account-types.js",
"diff": "@@ -132,12 +132,6 @@ export type LogInResult = {|\n+source?: ?LogInActionSource,\n|};\n-export type UpdatePasswordInfo = {|\n- ...LogInExtraInfo,\n- +code: string,\n- +password: string,\n-|};\n-\nexport type UpdatePasswordRequest = {|\ncode: string,\npassword: string,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -15,7 +15,6 @@ import type { EnabledApps, SupportedApps } from './enabled-apps';\nimport type {\nRawEntryInfo,\nEntryStore,\n- CalendarQuery,\nSaveEntryPayload,\nCreateEntryPayload,\nDeleteEntryResult,\n@@ -255,22 +254,6 @@ export type BaseAction =\n+payload: RegisterResult,\n+loadingInfo: LoadingInfo,\n|}\n- | {|\n- +type: 'RESET_PASSWORD_STARTED',\n- +payload: {| calendarQuery: CalendarQuery |},\n- +loadingInfo: LoadingInfo,\n- |}\n- | {|\n- +type: 'RESET_PASSWORD_FAILED',\n- +error: true,\n- +payload: Error,\n- +loadingInfo: LoadingInfo,\n- |}\n- | {|\n- +type: 'RESET_PASSWORD_SUCCESS',\n- +payload: LogInResult,\n- +loadingInfo: LoadingInfo,\n- |}\n| {|\n+type: 'CHANGE_USER_SETTINGS_STARTED',\n+payload?: void,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Get rid of resetPassword
Summary: No endpoints calling this action so it can be removed now!
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1467 |
129,187 | 23.06.2021 17:22:42 | 14,400 | 28e046d4740fd57fcee20676b4e6e4378546d7e3 | [lib] Get rid of handleVerificationCode
Summary: No endpoints calling this action so it can be removed now!
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/user-actions.js",
"new_path": "lib/actions/user-actions.js",
"diff": "@@ -17,7 +17,6 @@ import type {\nSubscriptionUpdateResult,\n} from '../types/subscription-types';\nimport type { UserInfo, AccountUpdate } from '../types/user-types';\n-import type { HandleVerificationCodeResult } from '../types/verify-types';\nimport { getConfig } from '../utils/config';\nimport type { FetchJSON } from '../utils/fetch-json';\nimport sleep from '../utils/sleep';\n@@ -158,19 +157,6 @@ const changeUserSettings = (fetchJSON: FetchJSON) => async (\nreturn { email: accountUpdate.updatedFields.email };\n};\n-const handleVerificationCodeActionTypes = Object.freeze({\n- started: 'HANDLE_VERIFICATION_CODE_STARTED',\n- success: 'HANDLE_VERIFICATION_CODE_SUCCESS',\n- failed: 'HANDLE_VERIFICATION_CODE_FAILED',\n-});\n-const handleVerificationCode = (fetchJSON: FetchJSON) => async (\n- code: string,\n-): Promise<HandleVerificationCodeResult> => {\n- const result = await fetchJSON('verify_code', { code });\n- const { verifyField, resetPasswordUsername } = result;\n- return { verifyField, resetPasswordUsername };\n-};\n-\nconst searchUsersActionTypes = Object.freeze({\nstarted: 'SEARCH_USERS_STARTED',\nsuccess: 'SEARCH_USERS_SUCCESS',\n@@ -229,8 +215,6 @@ export {\nlogIn,\nchangeUserSettingsActionTypes,\nchangeUserSettings,\n- handleVerificationCodeActionTypes,\n- handleVerificationCode,\nsearchUsersActionTypes,\nsearchUsers,\nupdateSubscriptionActionTypes,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -553,22 +553,6 @@ export type BaseAction =\n+payload: string,\n+loadingInfo: LoadingInfo,\n|}\n- | {|\n- +type: 'HANDLE_VERIFICATION_CODE_STARTED',\n- +payload?: void,\n- +loadingInfo: LoadingInfo,\n- |}\n- | {|\n- +type: 'HANDLE_VERIFICATION_CODE_FAILED',\n- +error: true,\n- +payload: Error,\n- +loadingInfo: LoadingInfo,\n- |}\n- | {|\n- +type: 'HANDLE_VERIFICATION_CODE_SUCCESS',\n- +payload?: void,\n- +loadingInfo: LoadingInfo,\n- |}\n| {|\n+type: 'SEND_REPORT_STARTED',\n+payload?: void,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Get rid of handleVerificationCode
Summary: No endpoints calling this action so it can be removed now!
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1468 |
129,187 | 23.06.2021 18:35:06 | 14,400 | 863ff92125f758392c3810b3ea12c358156742f1 | Get rid of ChangeUserSettingsResult
Summary: The only thing that can be changed now is the user's password, and that doesn't go in Redux.
Test Plan: Flow
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/user-actions.js",
"new_path": "lib/actions/user-actions.js",
"diff": "import threadWatcher from '../shared/thread-watcher';\nimport type {\n- ChangeUserSettingsResult,\nLogOutResult,\nLogInInfo,\nLogInResult,\n@@ -152,9 +151,8 @@ const changeUserSettingsActionTypes = Object.freeze({\n});\nconst changeUserSettings = (fetchJSON: FetchJSON) => async (\naccountUpdate: AccountUpdate,\n-): Promise<ChangeUserSettingsResult> => {\n+): Promise<void> => {\nawait fetchJSON('update_account', accountUpdate);\n- return { email: accountUpdate.updatedFields.email };\n};\nconst searchUsersActionTypes = Object.freeze({\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/account-types.js",
"new_path": "lib/types/account-types.js",
"diff": "@@ -73,10 +73,6 @@ export type DeleteAccountRequest = {|\n+password: string,\n|};\n-export type ChangeUserSettingsResult = {|\n- +email: ?string,\n-|};\n-\nexport type LogInActionSource =\n| 'COOKIE_INVALIDATION_RESOLUTION_ATTEMPT'\n| 'APP_START_NATIVE_CREDENTIALS_AUTO_LOG_IN'\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -267,9 +267,7 @@ export type BaseAction =\n|}\n| {|\n+type: 'CHANGE_USER_SETTINGS_SUCCESS',\n- +payload: {|\n- +email: string,\n- |},\n+ +payload?: void,\n+loadingInfo: LoadingInfo,\n|}\n| {|\n"
},
{
"change_type": "MODIFY",
"old_path": "native/profile/edit-password.react.js",
"new_path": "native/profile/edit-password.react.js",
"diff": "@@ -17,7 +17,6 @@ import {\nchangeUserSettings,\n} from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import type { ChangeUserSettingsResult } from 'lib/types/account-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { AccountUpdate } from 'lib/types/user-types';\nimport {\n@@ -49,9 +48,7 @@ type Props = {|\n// Redux dispatch functions\n+dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- +changeUserSettings: (\n- accountUpdate: AccountUpdate,\n- ) => Promise<ChangeUserSettingsResult>,\n+ +changeUserSettings: (accountUpdate: AccountUpdate) => Promise<void>,\n|};\ntype State = {|\n+currentPassword: string,\n@@ -232,7 +229,7 @@ class EditPassword extends React.PureComponent<Props, State> {\nreturn;\n}\ntry {\n- const result = await this.props.changeUserSettings({\n+ await this.props.changeUserSettings({\nupdatedFields: {\npassword: this.state.newPassword,\n},\n@@ -243,7 +240,6 @@ class EditPassword extends React.PureComponent<Props, State> {\npassword: this.state.newPassword,\n});\nthis.goBackOnce();\n- return result;\n} catch (e) {\nif (e.message === 'invalid_credentials') {\nAlert.alert(\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/account/user-settings-modal.react.js",
"new_path": "web/modals/account/user-settings-modal.react.js",
"diff": "@@ -12,10 +12,7 @@ import {\n} from 'lib/actions/user-actions';\nimport { preRequestUserStateSelector } from 'lib/selectors/account-selectors';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import type {\n- LogOutResult,\n- ChangeUserSettingsResult,\n-} from 'lib/types/account-types';\n+import type { LogOutResult } from 'lib/types/account-types';\nimport { type PreRequestUserState } from 'lib/types/session-types';\nimport { type AccountUpdate, type CurrentUserInfo } from 'lib/types/user-types';\nimport {\n@@ -67,9 +64,7 @@ type Props = {|\npassword: string,\npreRequestUserState: PreRequestUserState,\n) => Promise<LogOutResult>,\n- +changeUserSettings: (\n- accountUpdate: AccountUpdate,\n- ) => Promise<ChangeUserSettingsResult>,\n+ +changeUserSettings: (accountUpdate: AccountUpdate) => Promise<void>,\n|};\ntype State = {\n+newPassword: string,\n@@ -289,14 +284,13 @@ class UserSettingsModal extends React.PureComponent<Props, State> {\nasync changeUserSettingsAction() {\ntry {\n- const result = await this.props.changeUserSettings({\n+ await this.props.changeUserSettings({\nupdatedFields: {\npassword: this.state.newPassword,\n},\ncurrentPassword: this.state.currentPassword,\n});\nthis.clearModal();\n- return result;\n} catch (e) {\nif (e.message === 'invalid_credentials') {\nthis.setState(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Get rid of ChangeUserSettingsResult
Summary: The only thing that can be changed now is the user's password, and that doesn't go in Redux.
Test Plan: Flow
Reviewers: palys-swm, atul
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1469 |
129,187 | 23.06.2021 18:46:57 | 14,400 | c66de2962994135e419241ce1816c2aa6250bb4e | [server] Ignore emails in accountUpdater
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/types/user-types.js",
"new_path": "lib/types/user-types.js",
"diff": "@@ -59,7 +59,6 @@ export type CurrentUserInfo = LoggedInUserInfo | LoggedOutUserInfo;\nexport type AccountUpdate = {|\n+updatedFields: {|\n- +email?: ?string,\n+password?: ?string,\n|},\n+currentPassword: string,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/account-updaters.js",
"new_path": "server/src/updaters/account-updaters.js",
"diff": "import bcrypt from 'twin-bcrypt';\n-import { validEmailRegex } from 'lib/shared/account-utils';\nimport type {\nResetPasswordRequest,\nLogInResponse,\n@@ -37,24 +36,17 @@ async function accountUpdater(\nthrow new ServerError('not_logged_in');\n}\n- const email = update.updatedFields.email;\nconst newPassword = update.updatedFields.password;\n-\n- const fetchPromises = {};\n- if (email) {\n- if (email.search(validEmailRegex) === -1) {\n- throw new ServerError('invalid_email');\n- }\n- fetchPromises.emailQuery = dbQuery(SQL`\n- SELECT COUNT(id) AS count FROM users WHERE email = ${email}\n- `);\n+ if (!newPassword) {\n+ // If it's an old client it may have given us an email,\n+ // but we don't store those anymore\n+ return;\n}\n- fetchPromises.verifyQuery = dbQuery(SQL`\n- SELECT username, email, hash FROM users WHERE id = ${viewer.userID}\n- `);\n- const { verifyQuery, emailQuery } = await promiseAll(fetchPromises);\n- const [verifyResult] = verifyQuery;\n+ const verifyQuery = SQL`\n+ SELECT username, hash FROM users WHERE id = ${viewer.userID}\n+ `;\n+ const [verifyResult] = await dbQuery(verifyQuery);\nif (verifyResult.length === 0) {\nthrow new ServerError('internal_error');\n}\n@@ -63,43 +55,12 @@ async function accountUpdater(\nthrow new ServerError('invalid_credentials');\n}\n- const savePromises = [];\n- const changedFields = {};\n- let currentUserInfoChanged = false;\n- if (email && email !== verifyRow.email) {\n- const [emailResult] = emailQuery;\n- const emailRow = emailResult[0];\n- if (emailRow.count !== 0) {\n- throw new ServerError('email_taken');\n- }\n-\n- changedFields.email = email;\n- changedFields.email_verified = 0;\n- currentUserInfoChanged = true;\n-\n- savePromises.push(\n- sendEmailAddressVerificationEmail(\n- viewer.userID,\n- verifyRow.username,\n- email,\n- ),\n- );\n- }\n- if (newPassword) {\n- changedFields.hash = bcrypt.hashSync(newPassword);\n- }\n-\n- if (Object.keys(changedFields).length > 0) {\n- savePromises.push(\n- dbQuery(SQL`\n+ const changedFields = { hash: bcrypt.hashSync(newPassword) };\n+ const saveQuery = SQL`\nUPDATE users SET ${changedFields} WHERE id = ${viewer.userID}\n- `),\n- );\n- }\n-\n- await Promise.all(savePromises);\n+ `;\n+ await dbQuery(saveQuery);\n- if (currentUserInfoChanged) {\nconst updateDatas = [\n{\ntype: updateTypes.UPDATE_CURRENT_USER,\n@@ -112,7 +73,6 @@ async function accountUpdater(\nupdatesForCurrentSession: 'broadcast',\n});\n}\n-}\nasync function checkAndSendVerificationEmail(viewer: Viewer): Promise<void> {\nif (!viewer.loggedIn) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Ignore emails in accountUpdater
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1470 |
129,187 | 23.06.2021 18:52:33 | 14,400 | c6c8193107d66aa65382da910cb486db952d76e6 | [server] Ignore emails in createAccount
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/types/account-types.js",
"new_path": "lib/types/account-types.js",
"diff": "@@ -45,7 +45,6 @@ type DeviceTokenUpdateRequest = {|\nexport type RegisterRequest = {|\n+username: string,\n- +email: string,\n+password: string,\n+calendarQuery?: ?CalendarQuery,\n+deviceTokenUpdateRequest?: ?DeviceTokenUpdateRequest,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/account-creator.js",
"new_path": "server/src/creators/account-creator.js",
"diff": "@@ -9,7 +9,6 @@ import genesis from 'lib/facts/genesis';\nimport {\nvalidUsernameRegex,\noldValidUsernameRegex,\n- validEmailRegex,\n} from 'lib/shared/account-utils';\nimport { hasMinCodeVersion } from 'lib/shared/version-utils';\nimport type {\n@@ -23,7 +22,6 @@ import { values } from 'lib/utils/objects';\nimport { dbQuery, SQL } from '../database/database';\nimport { deleteCookie } from '../deleters/cookie-deleters';\n-import { sendEmailAddressVerificationEmail } from '../emails/verification';\nimport { fetchThreadInfos } from '../fetchers/thread-fetchers';\nimport { fetchKnownUserInfos } from '../fetchers/user-fetchers';\nimport { verifyCalendarQueryThreadIDs } from '../responders/entry-responders';\n@@ -62,32 +60,21 @@ async function createAccount(\nif (request.username.search(usernameRegex) === -1) {\nthrow new ServerError('invalid_username');\n}\n- if (request.email.search(validEmailRegex) === -1) {\n- throw new ServerError('invalid_email');\n- }\nconst usernameQuery = SQL`\nSELECT COUNT(id) AS count\nFROM users\nWHERE LCASE(username) = LCASE(${request.username})\n`;\n- const emailQuery = SQL`\n- SELECT COUNT(id) AS count\n- FROM users\n- WHERE LCASE(email) = LCASE(${request.email})\n- `;\n- const promises = [dbQuery(usernameQuery), dbQuery(emailQuery)];\n+ const promises = [dbQuery(usernameQuery)];\nconst { calendarQuery } = request;\nif (calendarQuery) {\npromises.push(verifyCalendarQueryThreadIDs(calendarQuery));\n}\n- const [[usernameResult], [emailResult]] = await Promise.all(promises);\n+ const [[usernameResult]] = await Promise.all(promises);\nif (usernameResult[0].count !== 0) {\nthrow new ServerError('username_taken');\n}\n- if (emailResult[0].count !== 0) {\n- throw new ServerError('email_taken');\n- }\nconst hash = bcrypt.hashSync(request.password);\nconst time = Date.now();\n@@ -95,7 +82,7 @@ async function createAccount(\n? request.deviceTokenUpdateRequest.deviceToken\n: viewer.deviceToken;\nconst [id] = await createIDs('users', 1);\n- const newUserRow = [id, request.username, hash, request.email, time];\n+ const newUserRow = [id, request.username, hash, '', time];\nconst newUserQuery = SQL`\nINSERT INTO users(id, username, hash, email, creation_time)\nVALUES ${[newUserRow]}\n@@ -107,12 +94,6 @@ async function createAccount(\n}),\ndeleteCookie(viewer.cookieID),\ndbQuery(newUserQuery),\n- sendEmailAddressVerificationEmail(\n- id,\n- request.username,\n- request.email,\n- true,\n- ),\n]);\nviewer.setNewCookie(userViewerData);\nif (calendarQuery) {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/user-responders.js",
"new_path": "server/src/responders/user-responders.js",
"diff": "@@ -158,7 +158,7 @@ const deviceTokenUpdateRequestInputValidator = tShape({\nconst registerRequestInputValidator = tShape({\nusername: t.String,\n- email: tEmail,\n+ email: t.maybe(tEmail),\npassword: tPassword,\ncalendarQuery: t.maybe(newEntryQueryInputValidator),\ndeviceTokenUpdateRequest: t.maybe(deviceTokenUpdateRequestInputValidator),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Ignore emails in createAccount
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1471 |
129,187 | 23.06.2021 18:55:49 | 14,400 | d59f6c64df6966e0285842da5d758fda5d279d4f | [server] Delete code for sending verification emails
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "DELETE",
"old_path": "server/src/emails/verification.js",
"new_path": null,
"diff": "-// @flow\n-\n-import React from 'react';\n-import { Item, Span, A, renderEmail } from 'react-html-email';\n-\n-import { verifyField } from 'lib/types/verify-types';\n-\n-import { createVerificationCode } from '../models/verification';\n-import { getAppURLFacts } from '../utils/urls';\n-import sendmail from './sendmail';\n-import Template from './template.react';\n-\n-const { baseDomain, basePath } = getAppURLFacts();\n-\n-async function sendEmailAddressVerificationEmail(\n- userID: string,\n- username: string,\n- emailAddress: string,\n- welcome: boolean = false,\n-): Promise<void> {\n- const code = await createVerificationCode(userID, verifyField.EMAIL);\n- const link = baseDomain + basePath + `verify/${code}/`;\n-\n- let welcomeText = null;\n- let action = 'verify your email';\n- if (welcome) {\n- welcomeText = (\n- <Item align=\"left\">\n- <Span fontSize={24}>{`Welcome to SquadCal, ${username}! `}</Span>\n- </Item>\n- );\n- action = `complete your registration and ${action}`;\n- }\n-\n- const title = 'Verify email for SquadCal';\n- const email = (\n- <Template title={title}>\n- {welcomeText}\n- <Item align=\"left\">\n- <Span>\n- {`Please ${action} by clicking this link: `}\n- <A href={link}>{link}</A>\n- </Span>\n- </Item>\n- </Template>\n- );\n- const html = renderEmail(email);\n-\n- await sendmail.sendMail({\n- from: 'no-reply@squadcal.org',\n- to: emailAddress,\n- subject: title,\n- html,\n- });\n-}\n-\n-export { sendEmailAddressVerificationEmail };\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/account-updaters.js",
"new_path": "server/src/updaters/account-updaters.js",
"diff": "@@ -18,7 +18,6 @@ import { promiseAll } from 'lib/utils/promises';\nimport { createUpdates } from '../creators/update-creator';\nimport { dbQuery, SQL } from '../database/database';\nimport { sendPasswordResetEmail } from '../emails/reset-password';\n-import { sendEmailAddressVerificationEmail } from '../emails/verification';\nimport { fetchEntryInfos } from '../fetchers/entry-fetchers';\nimport { fetchMessageInfos } from '../fetchers/message-fetchers';\nimport { fetchThreadInfos } from '../fetchers/thread-fetchers';\n@@ -74,30 +73,10 @@ async function accountUpdater(\n});\n}\n+// eslint-disable-next-line no-unused-vars\nasync function checkAndSendVerificationEmail(viewer: Viewer): Promise<void> {\n- if (!viewer.loggedIn) {\n- throw new ServerError('not_logged_in');\n- }\n-\n- const query = SQL`\n- SELECT username, email, email_verified\n- FROM users\n- WHERE id = ${viewer.userID}\n- `;\n- const [result] = await dbQuery(query);\n- if (result.length === 0) {\n- throw new ServerError('internal_error');\n- }\n- const row = result[0];\n- if (row.email_verified) {\n- throw new ServerError('already_verified');\n- }\n-\n- await sendEmailAddressVerificationEmail(\n- viewer.userID,\n- row.username,\n- row.email,\n- );\n+ // We don't want to crash old clients that call this,\n+ // but we have nothing we can do because we no longer store email addresses\n}\nasync function checkAndSendPasswordResetEmail(request: ResetPasswordRequest) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Delete code for sending verification emails
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1472 |
129,187 | 23.06.2021 19:22:48 | 14,400 | c0cb1786836627dc36f8bf61699efa841f6d0e3c | [server] Deprecate updatePassword
Summary: (This is the endpoint you would previously reach if you press the link in a "reset your password" email.)
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/account-updaters.js",
"new_path": "server/src/updaters/account-updaters.js",
"diff": "@@ -4,27 +4,15 @@ import bcrypt from 'twin-bcrypt';\nimport type {\nResetPasswordRequest,\n- LogInResponse,\nUpdatePasswordRequest,\n} from 'lib/types/account-types';\n-import { defaultNumberPerThread } from 'lib/types/message-types';\nimport { updateTypes } from 'lib/types/update-types';\nimport type { AccountUpdate } from 'lib/types/user-types';\n-import { verifyField } from 'lib/types/verify-types';\nimport { ServerError } from 'lib/utils/errors';\n-import { values } from 'lib/utils/objects';\n-import { promiseAll } from 'lib/utils/promises';\nimport { createUpdates } from '../creators/update-creator';\nimport { dbQuery, SQL } from '../database/database';\nimport { sendPasswordResetEmail } from '../emails/reset-password';\n-import { fetchEntryInfos } from '../fetchers/entry-fetchers';\n-import { fetchMessageInfos } from '../fetchers/message-fetchers';\n-import { fetchThreadInfos } from '../fetchers/thread-fetchers';\n-import { fetchKnownUserInfos } from '../fetchers/user-fetchers';\n-import { verifyCode, clearVerifyCodes } from '../models/verification';\n-import { verifyCalendarQueryThreadIDs } from '../responders/entry-responders';\n-import { createNewUserCookie, setNewSession } from '../session/cookies';\nimport type { Viewer } from '../session/viewer';\nasync function accountUpdater(\n@@ -95,98 +83,14 @@ async function checkAndSendPasswordResetEmail(request: ResetPasswordRequest) {\nawait sendPasswordResetEmail(row.id.toString(), row.username, row.email);\n}\n+/* eslint-disable no-unused-vars */\nasync function updatePassword(\nviewer: Viewer,\nrequest: UpdatePasswordRequest,\n-): Promise<LogInResponse> {\n- if (request.password.trim() === '') {\n- throw new ServerError('empty_password');\n- }\n-\n- const calendarQuery = request.calendarQuery;\n- const promises = {};\n- if (calendarQuery) {\n- promises.verifyCalendarQueryThreadIDs = verifyCalendarQueryThreadIDs(\n- calendarQuery,\n- );\n- }\n- promises.verificationResult = verifyCode(request.code);\n- const { verificationResult } = await promiseAll(promises);\n-\n- const { userID, field } = verificationResult;\n- if (field !== verifyField.RESET_PASSWORD) {\n- throw new ServerError('invalid_code');\n- }\n-\n- const userQuery = SQL`\n- SELECT username, email, email_verified FROM users WHERE id = ${userID}\n- `;\n- const hash = bcrypt.hashSync(request.password);\n- const updateQuery = SQL`UPDATE users SET hash = ${hash} WHERE id = ${userID}`;\n- const [[userResult]] = await Promise.all([\n- dbQuery(userQuery),\n- dbQuery(updateQuery),\n- ]);\n- if (userResult.length === 0) {\n- throw new ServerError('invalid_parameters');\n- }\n- const userRow = userResult[0];\n-\n- const newServerTime = Date.now();\n- const deviceToken = request.deviceTokenUpdateRequest\n- ? request.deviceTokenUpdateRequest.deviceToken\n- : viewer.deviceToken;\n- const [userViewerData] = await Promise.all([\n- createNewUserCookie(userID, {\n- platformDetails: request.platformDetails,\n- deviceToken,\n- }),\n- clearVerifyCodes(verificationResult),\n- ]);\n- viewer.setNewCookie(userViewerData);\n- if (calendarQuery) {\n- await setNewSession(viewer, calendarQuery, newServerTime);\n- }\n-\n- const threadCursors = {};\n- for (const watchedThreadID of request.watchedIDs) {\n- threadCursors[watchedThreadID] = null;\n- }\n- const threadSelectionCriteria = { threadCursors, joinedThreads: true };\n-\n- const [\n- threadsResult,\n- messagesResult,\n- entriesResult,\n- userInfos,\n- ] = await Promise.all([\n- fetchThreadInfos(viewer),\n- fetchMessageInfos(viewer, threadSelectionCriteria, defaultNumberPerThread),\n- calendarQuery ? fetchEntryInfos(viewer, [calendarQuery]) : undefined,\n- fetchKnownUserInfos(viewer),\n- ]);\n-\n- const rawEntryInfos = entriesResult ? entriesResult.rawEntryInfos : null;\n- const response: LogInResponse = {\n- currentUserInfo: {\n- id: userID,\n- username: userRow.username,\n- email: userRow.email,\n- emailVerified: !!userRow.email_verified,\n- },\n- rawMessageInfos: messagesResult.rawMessageInfos,\n- truncationStatuses: messagesResult.truncationStatuses,\n- serverTime: newServerTime,\n- userInfos: values(userInfos),\n- cookieChange: {\n- threadInfos: threadsResult.threadInfos,\n- userInfos: [],\n- },\n- };\n- if (rawEntryInfos) {\n- response.rawEntryInfos = rawEntryInfos;\n- }\n- return response;\n+): Promise<void> {\n+ /* eslint-enable no-unused-vars */\n+ // We have no way to handle this request anymore\n+ throw new ServerError('deprecated');\n}\nexport {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Deprecate updatePassword
Summary: (This is the endpoint you would previously reach if you press the link in a "reset your password" email.)
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1473 |
129,187 | 23.06.2021 19:25:52 | 14,400 | fe849cfcfb0378d9648ea385fded2ffa0f39fdc9 | [server] Don't include email/emailVerified fields in logIn response for new clients
Summary: (Otherwise this will be detected as inconsistent and patched later.)
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/responders/user-responders.js",
"new_path": "server/src/responders/user-responders.js",
"diff": "@@ -4,6 +4,7 @@ import invariant from 'invariant';\nimport t from 'tcomb';\nimport bcrypt from 'twin-bcrypt';\n+import { hasMinCodeVersion } from 'lib/shared/version-utils';\nimport type {\nResetPasswordRequest,\nLogOutResponse,\n@@ -257,14 +258,20 @@ async function logInResponder(\nfetchKnownUserInfos(viewer),\n]);\n- const rawEntryInfos = entriesResult ? entriesResult.rawEntryInfos : null;\n- const response: LogInResponse = {\n- currentUserInfo: {\n+ const oldCurrentUserInfo = {\nid,\nusername: userRow.username,\nemail: userRow.email,\nemailVerified: !!userRow.email_verified,\n- },\n+ };\n+ const hasCodeVersionBelow87 = !hasMinCodeVersion(viewer.platformDetails, 87);\n+ const currentUserInfo = hasCodeVersionBelow87\n+ ? oldCurrentUserInfo\n+ : { id, username: userRow.username };\n+\n+ const rawEntryInfos = entriesResult ? entriesResult.rawEntryInfos : null;\n+ const response: LogInResponse = {\n+ currentUserInfo,\nrawMessageInfos: messagesResult.rawMessageInfos,\ntruncationStatuses: messagesResult.truncationStatuses,\nserverTime: newServerTime,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Don't include email/emailVerified fields in logIn response for new clients
Summary: (Otherwise this will be detected as inconsistent and patched later.)
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1474 |
129,187 | 23.06.2021 19:27:16 | 14,400 | 550b751170c60ee3bad993e3758bd546a0720c54 | [server] Shown placeholder in place of email field for old clients
Summary: This change will force inconsistency to be detected across all existing clients and should automatically replace their `currentUserInfo` with the placeholder-having version.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/user-fetchers.js",
"new_path": "server/src/fetchers/user-fetchers.js",
"diff": "@@ -205,7 +205,7 @@ async function fetchLoggedInUserInfos(\nuserIDs: $ReadOnlyArray<string>,\n): Promise<Array<OldLoggedInUserInfo | LoggedInUserInfo>> {\nconst query = SQL`\n- SELECT id, username, email, email_verified\n+ SELECT id, username\nFROM users\nWHERE id IN (${userIDs})\n`;\n@@ -213,8 +213,8 @@ async function fetchLoggedInUserInfos(\nreturn result.map((row) => ({\nid: row.id.toString(),\nusername: row.username,\n- email: row.email,\n- emailVerified: !!row.email_verified,\n+ email: 'removed from DB',\n+ emailVerified: true,\n}));\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/user-responders.js",
"new_path": "server/src/responders/user-responders.js",
"diff": "@@ -206,7 +206,7 @@ async function logInResponder(\nthrow new ServerError('invalid_parameters');\n}\nconst userQuery = SQL`\n- SELECT id, hash, username, email, email_verified\n+ SELECT id, hash, username\nFROM users\nWHERE LCASE(username) = LCASE(${username})\n`;\n@@ -261,8 +261,8 @@ async function logInResponder(\nconst oldCurrentUserInfo = {\nid,\nusername: userRow.username,\n- email: userRow.email,\n- emailVerified: !!userRow.email_verified,\n+ email: 'removed from DB',\n+ emailVerified: true,\n};\nconst hasCodeVersionBelow87 = !hasMinCodeVersion(viewer.platformDetails, 87);\nconst currentUserInfo = hasCodeVersionBelow87\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Shown placeholder in place of email field for old clients
Summary: This change will force inconsistency to be detected across all existing clients and should automatically replace their `currentUserInfo` with the placeholder-having version.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1475 |
129,187 | 23.06.2021 19:31:39 | 14,400 | 63bc402d5bd4b151216079aa532a740c5f418477 | [server] Deprecate checkAndSendPasswordResetEmail
Summary: (This is the endpoint you would previously reach if you entered a valid email in the "Forgot password" flow.)
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "DELETE",
"old_path": "server/src/emails/reset-password.js",
"new_path": null,
"diff": "-// @flow\n-\n-import React from 'react';\n-import { Item, Span, A, renderEmail } from 'react-html-email';\n-\n-import { verifyField } from 'lib/types/verify-types';\n-\n-import { createVerificationCode } from '../models/verification';\n-import { getAppURLFacts } from '../utils/urls';\n-import sendmail from './sendmail';\n-import Template from './template.react';\n-\n-const { baseDomain, basePath } = getAppURLFacts();\n-\n-async function sendPasswordResetEmail(\n- userID: string,\n- username: string,\n- emailAddress: string,\n-): Promise<void> {\n- const code = await createVerificationCode(userID, verifyField.RESET_PASSWORD);\n- const link = baseDomain + basePath + `verify/${code}/`;\n-\n- const title = 'Reset password for SquadCal';\n- const text =\n- 'We received a request to reset the password associated with your ' +\n- `account ${username} on SquadCal. If you did not issue this request, you ` +\n- 'do not need to do anything, and your password will remain the same. ' +\n- 'However, if you did issue this request, please visit this link to reset ' +\n- 'your password: ';\n- const email = (\n- <Template title={title}>\n- <Item align=\"left\">\n- <Span>\n- {text}\n- <A href={link}>{link}</A>\n- </Span>\n- </Item>\n- </Template>\n- );\n- const html = renderEmail(email);\n-\n- await sendmail.sendMail({\n- from: 'no-reply@squadcal.org',\n- to: emailAddress,\n- subject: title,\n- html,\n- });\n-}\n-\n-export { sendPasswordResetEmail };\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/account-updaters.js",
"new_path": "server/src/updaters/account-updaters.js",
"diff": "@@ -12,7 +12,6 @@ import { ServerError } from 'lib/utils/errors';\nimport { createUpdates } from '../creators/update-creator';\nimport { dbQuery, SQL } from '../database/database';\n-import { sendPasswordResetEmail } from '../emails/reset-password';\nimport type { Viewer } from '../session/viewer';\nasync function accountUpdater(\n@@ -67,20 +66,12 @@ async function checkAndSendVerificationEmail(viewer: Viewer): Promise<void> {\n// but we have nothing we can do because we no longer store email addresses\n}\n-async function checkAndSendPasswordResetEmail(request: ResetPasswordRequest) {\n- const query = SQL`\n- SELECT id, username, email\n- FROM users\n- WHERE LCASE(username) = LCASE(${request.usernameOrEmail})\n- OR LCASE(email) = LCASE(${request.usernameOrEmail})\n- `;\n- const [result] = await dbQuery(query);\n- if (result.length === 0) {\n- throw new ServerError('invalid_user');\n- }\n- const row = result[0];\n-\n- await sendPasswordResetEmail(row.id.toString(), row.username, row.email);\n+async function checkAndSendPasswordResetEmail(\n+ // eslint-disable-next-line no-unused-vars\n+ request: ResetPasswordRequest,\n+): Promise<void> {\n+ // We don't want to crash old clients that call this,\n+ // but we have nothing we can do because we no longer store email addresses\n}\n/* eslint-disable no-unused-vars */\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Deprecate checkAndSendPasswordResetEmail
Summary: (This is the endpoint you would previously reach if you entered a valid email in the "Forgot password" flow.)
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1476 |
129,187 | 23.06.2021 19:38:05 | 14,400 | 58186b5970d1a8c7039d93f69c93fe0198db18e8 | [server] Deprecate codeVerificationResponder
Summary: (This endpoint would get triggered when you press a verification link in an email.)
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/responders/verification-responders.js",
"new_path": "server/src/responders/verification-responders.js",
"diff": "import t from 'tcomb';\n-import type {\n- CodeVerificationRequest,\n- HandleVerificationCodeResult,\n-} from 'lib/types/verify-types';\n-import { verifyField } from 'lib/types/verify-types';\n+import type { HandleVerificationCodeResult } from 'lib/types/verify-types';\nimport { ServerError } from 'lib/utils/errors';\n-import { handleCodeVerificationRequest } from '../models/verification';\nimport type { Viewer } from '../session/viewer';\nimport { validateInput, tShape } from '../utils/validation-utils';\n@@ -17,23 +12,15 @@ const codeVerificationRequestInputValidator = tShape({\ncode: t.String,\n});\n+/* eslint-disable no-unused-vars */\nasync function codeVerificationResponder(\nviewer: Viewer,\ninput: any,\n): Promise<HandleVerificationCodeResult> {\n- const request: CodeVerificationRequest = input;\n- await validateInput(viewer, codeVerificationRequestInputValidator, request);\n-\n- const result = await handleCodeVerificationRequest(viewer, request.code);\n- if (result.field === verifyField.EMAIL) {\n- return { verifyField: result.field };\n- } else if (result.field === verifyField.RESET_PASSWORD) {\n- return {\n- verifyField: result.field,\n- resetPasswordUsername: result.username,\n- };\n- }\n- throw new ServerError('invalid_code');\n+ /* eslint-enable no-unused-vars */\n+ await validateInput(viewer, codeVerificationRequestInputValidator, input);\n+ // We have no way to handle this request anymore\n+ throw new ServerError('deprecated');\n}\nexport { codeVerificationResponder };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Deprecate codeVerificationResponder
Summary: (This endpoint would get triggered when you press a verification link in an email.)
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1477 |
129,187 | 23.06.2021 19:40:11 | 14,400 | 29b05eda49984b274a12c0919af2d65d359df1d3 | [server] Delete code for handling verifications
Summary: We don't need to handle verification links sent in emails anymore.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/cron/cron.js",
"new_path": "server/src/cron/cron.js",
"diff": "@@ -19,7 +19,6 @@ import {\nimport { deleteInaccessibleThreads } from '../deleters/thread-deleters';\nimport { deleteExpiredUpdates } from '../deleters/update-deleters';\nimport { deleteUnassignedUploads } from '../deleters/upload-deleters';\n-import { deleteExpiredVerifications } from '../models/verification';\nimport { backupDB } from './backups';\nimport { updateAndReloadGeoipDB } from './update-geoip-db';\n@@ -31,7 +30,6 @@ if (cluster.isMaster) {\n// Do everything one at a time to reduce load since we're in no hurry,\n// and since some queries depend on previous ones.\nawait deleteExpiredCookies();\n- await deleteExpiredVerifications();\nawait deleteInaccessibleThreads();\nawait deleteOrphanedMemberships();\nawait deleteOrphanedDays();\n"
},
{
"change_type": "DELETE",
"old_path": "server/src/models/verification.js",
"new_path": null,
"diff": "-// @flow\n-\n-import crypto from 'crypto';\n-import bcrypt from 'twin-bcrypt';\n-\n-import { updateTypes } from 'lib/types/update-types';\n-import {\n- type VerifyField,\n- verifyField,\n- assertVerifyField,\n- type ServerSuccessfulVerificationResult,\n-} from 'lib/types/verify-types';\n-import { ServerError } from 'lib/utils/errors';\n-\n-import createIDs from '../creators/id-creator';\n-import { createUpdates } from '../creators/update-creator';\n-import { dbQuery, SQL, mergeOrConditions } from '../database/database';\n-import type { Viewer } from '../session/viewer';\n-\n-const day = 24 * 60 * 60 * 1000; // in ms\n-const verifyCodeLifetimes = {\n- [verifyField.EMAIL]: day * 30,\n- [verifyField.RESET_PASSWORD]: day,\n-};\n-\n-async function createVerificationCode(\n- userID: string,\n- field: VerifyField,\n-): Promise<string> {\n- const code = crypto.randomBytes(4).toString('hex');\n- const hash = bcrypt.hashSync(code);\n- const [id] = await createIDs('verifications', 1);\n- const time = Date.now();\n- const row = [id, userID, field, hash, time];\n- const query = SQL`\n- INSERT INTO verifications(id, user, field, hash, creation_time)\n- VALUES ${[row]}\n- `;\n- await dbQuery(query);\n- return `${code}${parseInt(id, 10).toString(16)}`;\n-}\n-\n-type CodeVerification = {|\n- userID: string,\n- field: VerifyField,\n-|};\n-async function verifyCode(hex: string): Promise<CodeVerification> {\n- const code = hex.substr(0, 8);\n- const id = parseInt(hex.substr(8), 16);\n- if (isNaN(id)) {\n- throw new ServerError('invalid_code');\n- }\n-\n- const query = SQL`\n- SELECT hash, user, field, creation_time\n- FROM verifications WHERE id = ${id}\n- `;\n- const [result] = await dbQuery(query);\n- if (result.length === 0) {\n- throw new ServerError('invalid_code');\n- }\n-\n- const row = result[0];\n- if (!bcrypt.compareSync(code, row.hash)) {\n- throw new ServerError('invalid_code');\n- }\n-\n- const field = assertVerifyField(row.field);\n- const verifyCodeLifetime = verifyCodeLifetimes[field];\n- if (\n- verifyCodeLifetime &&\n- row.creation_time + verifyCodeLifetime <= Date.now()\n- ) {\n- // Code is expired. Delete it...\n- const deleteQuery = SQL`\n- DELETE v, i\n- FROM verifications v\n- LEFT JOIN ids i ON i.id = v.id\n- WHERE v.id = ${id}\n- `;\n- await dbQuery(deleteQuery);\n- throw new ServerError('invalid_code');\n- }\n-\n- return {\n- userID: row.user.toString(),\n- field,\n- };\n-}\n-\n-// Call this function after a successful verification\n-async function clearVerifyCodes(result: CodeVerification) {\n- const deleteQuery = SQL`\n- DELETE v, i\n- FROM verifications v\n- LEFT JOIN ids i ON i.id = v.id\n- WHERE v.user = ${result.userID} and v.field = ${result.field}\n- `;\n- await dbQuery(deleteQuery);\n-}\n-\n-async function handleCodeVerificationRequest(\n- viewer: Viewer,\n- code: string,\n-): Promise<ServerSuccessfulVerificationResult> {\n- const { userID, field } = await verifyCode(code);\n- if (field === verifyField.EMAIL) {\n- const query = SQL`UPDATE users SET email_verified = 1 WHERE id = ${userID}`;\n- await dbQuery(query);\n- const updateDatas = [\n- {\n- type: updateTypes.UPDATE_CURRENT_USER,\n- userID,\n- time: Date.now(),\n- },\n- ];\n- await createUpdates(updateDatas, {\n- viewer,\n- updatesForCurrentSession: 'broadcast',\n- });\n- return { success: true, field: verifyField.EMAIL };\n- } else if (field === verifyField.RESET_PASSWORD) {\n- const usernameQuery = SQL`SELECT username FROM users WHERE id = ${userID}`;\n- const [usernameResult] = await dbQuery(usernameQuery);\n- if (usernameResult.length === 0) {\n- throw new ServerError('invalid_code');\n- }\n- const usernameRow = usernameResult[0];\n- return {\n- success: true,\n- field: verifyField.RESET_PASSWORD,\n- username: usernameRow.username,\n- };\n- }\n- throw new ServerError('invalid_code');\n-}\n-\n-async function deleteExpiredVerifications(): Promise<void> {\n- const creationTimeConditions = [];\n- for (const field in verifyCodeLifetimes) {\n- const lifetime = verifyCodeLifetimes[field];\n- const earliestInvalid = Date.now() - lifetime;\n- creationTimeConditions.push(\n- SQL`v.field = ${field} AND v.creation_time <= ${earliestInvalid}`,\n- );\n- }\n- const creationTimeClause = mergeOrConditions(creationTimeConditions);\n- const query = SQL`\n- DELETE v, i\n- FROM verifications v\n- LEFT JOIN ids i ON i.id = v.id\n- WHERE\n- `;\n- query.append(creationTimeClause);\n- await dbQuery(query);\n-}\n-\n-export {\n- createVerificationCode,\n- verifyCode,\n- clearVerifyCodes,\n- handleCodeVerificationRequest,\n- deleteExpiredVerifications,\n-};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Delete code for handling verifications
Summary: We don't need to handle verification links sent in emails anymore.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1478 |
129,187 | 23.06.2021 20:13:22 | 14,400 | fc9b809cfe99d2cf42ded9b4c242977c1bad2e52 | [web] Get rid of email modals
Summary: (I deleted their uses earlier but I forgot to delete the modals themselves.)
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "DELETE",
"old_path": "web/modals/account/password-reset-email-modal.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import React from 'react';\n-\n-import css from '../../style.css';\n-import Modal from '../modal.react';\n-\n-type Props = {\n- onClose: () => void,\n-};\n-\n-export default function PasswordResetEmailModal(props: Props) {\n- return (\n- <Modal name=\"Password reset email sent\" onClose={props.onClose}>\n- <div className={css['modal-body']}>\n- <p>\n- {\"We've sent you an email with instructions on how to reset \"}\n- {'your password. Note that the email will expire in a day.'}\n- </p>\n- </div>\n- </Modal>\n- );\n-}\n"
},
{
"change_type": "DELETE",
"old_path": "web/modals/account/verify-email-modal.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import React from 'react';\n-\n-import css from '../../style.css';\n-import Modal from '../modal.react';\n-\n-type Props = {\n- onClose: () => void,\n-};\n-\n-export default function VerifyEmailModal(props: Props) {\n- return (\n- <Modal name=\"Verify email\" onClose={props.onClose}>\n- <div className={css['modal-body']}>\n- <p>\n- We've sent you an email to verify your email address. Just click\n- on the link in the email to complete the verification process.\n- </p>\n- <p>\n- Note that the email will expire in a day, but another email can be\n- sent from “Edit account” in the user menu at any time.\n- </p>\n- </div>\n- </Modal>\n- );\n-}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Get rid of email modals
Summary: (I deleted their uses earlier but I forgot to delete the modals themselves.)
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1479 |
129,187 | 23.06.2021 20:16:21 | 14,400 | 98590217b5cd239be065755a8d60d9c068b9f301 | [server] Get rid of email columns in users table
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/creators/account-creator.js",
"new_path": "server/src/creators/account-creator.js",
"diff": "@@ -82,9 +82,9 @@ async function createAccount(\n? request.deviceTokenUpdateRequest.deviceToken\n: viewer.deviceToken;\nconst [id] = await createIDs('users', 1);\n- const newUserRow = [id, request.username, hash, '', time];\n+ const newUserRow = [id, request.username, hash, time];\nconst newUserQuery = SQL`\n- INSERT INTO users(id, username, hash, email, creation_time)\n+ INSERT INTO users(id, username, hash, creation_time)\nVALUES ${[newUserRow]}\n`;\nconst [userViewerData] = await Promise.all([\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/create-db.js",
"new_path": "server/src/scripts/create-db.js",
"diff": "@@ -188,8 +188,6 @@ async function createTables() {\nid bigint(20) NOT NULL,\nusername varchar(${usernameMaxLength}) COLLATE utf8mb4_bin NOT NULL,\nhash char(60) COLLATE utf8mb4_bin NOT NULL,\n- email varchar(191) COLLATE utf8mb4_bin NOT NULL,\n- email_verified tinyint(1) UNSIGNED NOT NULL DEFAULT '0',\navatar varchar(191) COLLATE utf8mb4_bin DEFAULT NULL,\ncreation_time bigint(20) NOT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;\n@@ -296,8 +294,7 @@ async function createTables() {\nALTER TABLE users\nADD PRIMARY KEY (id),\n- ADD UNIQUE KEY username (username),\n- ADD UNIQUE KEY email (email);\n+ ADD UNIQUE KEY username (username);\nALTER TABLE relationships_undirected\nADD UNIQUE KEY user1_user2 (user1,user2),\n@@ -328,13 +325,10 @@ async function createUsers() {\nVALUES\n(${bots.squadbot.userID}, 'users'),\n(${ashoat.id}, 'users');\n- INSERT INTO users (id, username, hash, email, email_verified, avatar,\n- creation_time)\n+ INSERT INTO users (id, username, hash, avatar, creation_time)\nVALUES\n- (${bots.squadbot.userID}, 'squadbot', '', 'squadbot@squadcal.org', 1,\n- NULL, 1530049900980),\n- (${ashoat.id}, 'ashoat', '', ${ashoat.email}, 1,\n- NULL, 1463588881886);\n+ (${bots.squadbot.userID}, 'squadbot', '', NULL, 1530049900980),\n+ (${ashoat.id}, 'ashoat', '', NULL, 1463588881886);\nINSERT INTO relationships_undirected (user1, user2, status)\nVALUES (${user1}, ${user2}, ${undirectedStatus.KNOW_OF});\n`);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Get rid of email columns in users table
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1480 |
129,187 | 23.06.2021 20:18:34 | 14,400 | fd6e26e7ff44a1f24fcbe9d86ec6f0b9e6fa5f3d | [server] Remove verifications table from create-db script
Test Plan: Ran the query
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/create-db.js",
"new_path": "server/src/scripts/create-db.js",
"diff": "@@ -204,14 +204,6 @@ async function createTables() {\nstatus tinyint(1) UNSIGNED NOT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;\n- CREATE TABLE verifications (\n- id bigint(20) NOT NULL,\n- user bigint(20) NOT NULL,\n- field tinyint(1) UNSIGNED NOT NULL,\n- hash char(60) NOT NULL,\n- creation_time bigint(20) NOT NULL\n- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;\n-\nCREATE TABLE versions (\nid bigint(20) NOT NULL,\ncode_version int(11) NOT NULL,\n@@ -304,10 +296,6 @@ async function createTables() {\nADD UNIQUE KEY user1_user2 (user1,user2),\nADD UNIQUE KEY user2_user1 (user2,user1);\n- ALTER TABLE verifications\n- ADD PRIMARY KEY (id),\n- ADD KEY user_field (user,field);\n-\nALTER TABLE versions\nADD PRIMARY KEY (id),\nADD UNIQUE KEY code_version_platform (code_version,platform);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Remove verifications table from create-db script
Test Plan: Ran the query
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1481 |
129,187 | 23.06.2021 20:19:01 | 14,400 | cb9b588445bf0cc5fdc873f1f6d5699d247b84f8 | [server] Migration to delete verifications table and email columns in users table
Test Plan: Ran the queries
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/delete-emails.js",
"diff": "+// @flow\n+\n+import { dbQuery, SQL } from '../database/database';\n+import { setScriptContext } from './script-context';\n+import { main } from './utils';\n+\n+setScriptContext({\n+ allowMultiStatementSQLQueries: true,\n+});\n+\n+async function deleteEmails() {\n+ await dbQuery(SQL`\n+ DROP TABLE verifications;\n+ ALTER TABLE users DROP email, DROP email_verified;\n+ `);\n+}\n+\n+main([deleteEmails]);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Migration to delete verifications table and email columns in users table
Test Plan: Ran the queries
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1482 |
129,187 | 23.06.2021 20:19:35 | 14,400 | f02a321753de84232e6cd8ceec870259f2a10987 | [web] Rename usernameOrEmail to username in LogInModal
Summary: I removed the email logic in D1441 but forgot to rename the property.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "web/modals/account/log-in-modal.react.js",
"new_path": "web/modals/account/log-in-modal.react.js",
"diff": "@@ -34,26 +34,26 @@ type Props = {|\n+logIn: (logInInfo: LogInInfo) => Promise<LogInResult>,\n|};\ntype State = {|\n- +usernameOrEmail: string,\n+ +username: string,\n+password: string,\n+errorMessage: string,\n|};\nclass LogInModal extends React.PureComponent<Props, State> {\n- usernameOrEmailInput: ?HTMLInputElement;\n+ usernameInput: ?HTMLInputElement;\npasswordInput: ?HTMLInputElement;\nconstructor(props: Props) {\nsuper(props);\nthis.state = {\n- usernameOrEmail: '',\n+ username: '',\npassword: '',\nerrorMessage: '',\n};\n}\ncomponentDidMount() {\n- invariant(this.usernameOrEmailInput, 'usernameOrEmail ref unset');\n- this.usernameOrEmailInput.focus();\n+ invariant(this.usernameInput, 'username ref unset');\n+ this.usernameInput.focus();\n}\nrender() {\n@@ -67,9 +67,9 @@ class LogInModal extends React.PureComponent<Props, State> {\n<input\ntype=\"text\"\nplaceholder=\"Username\"\n- value={this.state.usernameOrEmail}\n- onChange={this.onChangeUsernameOrEmail}\n- ref={this.usernameOrEmailInputRef}\n+ value={this.state.username}\n+ onChange={this.onChangeUsername}\n+ ref={this.usernameInputRef}\ndisabled={this.props.inputDisabled}\n/>\n</div>\n@@ -104,18 +104,18 @@ class LogInModal extends React.PureComponent<Props, State> {\n);\n}\n- usernameOrEmailInputRef = (usernameOrEmailInput: ?HTMLInputElement) => {\n- this.usernameOrEmailInput = usernameOrEmailInput;\n+ usernameInputRef = (usernameInput: ?HTMLInputElement) => {\n+ this.usernameInput = usernameInput;\n};\npasswordInputRef = (passwordInput: ?HTMLInputElement) => {\nthis.passwordInput = passwordInput;\n};\n- onChangeUsernameOrEmail = (event: SyntheticEvent<HTMLInputElement>) => {\n+ onChangeUsername = (event: SyntheticEvent<HTMLInputElement>) => {\nconst target = event.target;\ninvariant(target instanceof HTMLInputElement, 'target not input');\n- this.setState({ usernameOrEmail: target.value });\n+ this.setState({ username: target.value });\n};\nonChangePassword = (event: SyntheticEvent<HTMLInputElement>) => {\n@@ -127,18 +127,15 @@ class LogInModal extends React.PureComponent<Props, State> {\nonSubmit = (event: SyntheticEvent<HTMLInputElement>) => {\nevent.preventDefault();\n- if (this.state.usernameOrEmail.search(oldValidUsernameRegex) === -1) {\n+ if (this.state.username.search(oldValidUsernameRegex) === -1) {\nthis.setState(\n{\n- usernameOrEmail: '',\n+ username: '',\nerrorMessage: 'alphanumeric usernames only',\n},\n() => {\n- invariant(\n- this.usernameOrEmailInput,\n- 'usernameOrEmailInput ref unset',\n- );\n- this.usernameOrEmailInput.focus();\n+ invariant(this.usernameInput, 'usernameInput ref unset');\n+ this.usernameInput.focus();\n},\n);\nreturn;\n@@ -156,7 +153,7 @@ class LogInModal extends React.PureComponent<Props, State> {\nasync logInAction(extraInfo: LogInExtraInfo) {\ntry {\nconst result = await this.props.logIn({\n- username: this.state.usernameOrEmail,\n+ username: this.state.username,\npassword: this.state.password,\n...extraInfo,\n});\n@@ -166,15 +163,12 @@ class LogInModal extends React.PureComponent<Props, State> {\nif (e.message === 'invalid_parameters') {\nthis.setState(\n{\n- usernameOrEmail: '',\n+ username: '',\nerrorMessage: \"user doesn't exist\",\n},\n() => {\n- invariant(\n- this.usernameOrEmailInput,\n- 'usernameOrEmailInput ref unset',\n- );\n- this.usernameOrEmailInput.focus();\n+ invariant(this.usernameInput, 'usernameInput ref unset');\n+ this.usernameInput.focus();\n},\n);\n} else if (e.message === 'invalid_credentials') {\n@@ -191,16 +185,13 @@ class LogInModal extends React.PureComponent<Props, State> {\n} else {\nthis.setState(\n{\n- usernameOrEmail: '',\n+ username: '',\npassword: '',\nerrorMessage: 'unknown error',\n},\n() => {\n- invariant(\n- this.usernameOrEmailInput,\n- 'usernameOrEmailInput ref unset',\n- );\n- this.usernameOrEmailInput.focus();\n+ invariant(this.usernameInput, 'usernameInput ref unset');\n+ this.usernameInput.focus();\n},\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Rename usernameOrEmail to username in LogInModal
Summary: I removed the email logic in D1441 but forgot to rename the property.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1483 |
129,187 | 23.06.2021 20:20:26 | 14,400 | 7e60665ec67863a8ee53024dc250ac1a82dbb904 | [server] Update merge-users script to not handle emails
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/merge-users.js",
"new_path": "server/src/scripts/merge-users.js",
"diff": "@@ -28,7 +28,6 @@ async function main() {\ntype ReplaceUserInfo = Shape<{|\n+username: boolean,\n- +email: boolean,\n+password: boolean,\n|}>;\nasync function mergeUsers(\n@@ -158,7 +157,7 @@ async function replaceUser(\n}\nconst fromUserQuery = SQL`\n- SELECT username, hash, email, email_verified\n+ SELECT username, hash\nFROM users\nWHERE id = ${fromUserID}\n`;\n@@ -172,10 +171,6 @@ async function replaceUser(\nif (replaceUserInfo.username) {\nchangedFields.username = firstResult.username;\n}\n- if (replaceUserInfo.email) {\n- changedFields.email = firstResult.email;\n- changedFields.email_verified = firstResult.email_verified;\n- }\nif (replaceUserInfo.password) {\nchangedFields.hash = firstResult.hash;\n}\n@@ -185,7 +180,7 @@ async function replaceUser(\n`;\nconst updateDatas = [];\n- if (replaceUserInfo.username || replaceUserInfo.email) {\n+ if (replaceUserInfo.username) {\nupdateDatas.push({\ntype: updateTypes.UPDATE_CURRENT_USER,\nuserID: toUserID,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Update merge-users script to not handle emails
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1484 |
129,187 | 23.06.2021 20:20:50 | 14,400 | 35400bef5ecf857739ed19b177c4466981f2f3bf | Remaining emails-related cleanup
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/types/verify-types.js",
"new_path": "lib/types/verify-types.js",
"diff": "// @flow\n-import invariant from 'invariant';\n-\nexport const verifyField = Object.freeze({\nEMAIL: 0,\nRESET_PASSWORD: 1,\n});\nexport type VerifyField = $Values<typeof verifyField>;\n-export function assertVerifyField(ourVerifyField: number): VerifyField {\n- invariant(\n- ourVerifyField === 0 || ourVerifyField === 1,\n- 'number is not VerifyField enum',\n- );\n- return ourVerifyField;\n-}\n-\n-export type CodeVerificationRequest = {|\n- +code: string,\n-|};\nexport type HandleVerificationCodeResult = {|\n+verifyField: VerifyField,\n+resetPasswordUsername?: string,\n|};\n-\n-type EmailServerVerificationResult = {|\n- +success: true,\n- +field: 0,\n-|};\n-type ResetPasswordServerVerificationResult = {|\n- +success: true,\n- +field: 1,\n- +username: string,\n-|};\n-export type ServerSuccessfulVerificationResult =\n- | EmailServerVerificationResult\n- | ResetPasswordServerVerificationResult;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/route-names.js",
"new_path": "native/navigation/route-names.js",
"diff": "@@ -117,7 +117,6 @@ export type ChatTopTabsParamList = {|\nexport type ProfileParamList = {|\n+ProfileScreen: void,\n- +EditEmail: void,\n+EditPassword: void,\n+DeleteAccount: void,\n+BuildInfo: void,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/user-responders.js",
"new_path": "server/src/responders/user-responders.js",
"diff": "@@ -177,7 +177,7 @@ async function accountCreationResponder(\nconst logInRequestInputValidator = tShape({\nusername: t.maybe(t.String),\n- usernameOrEmail: t.maybe(t.String),\n+ usernameOrEmail: t.union([tEmail, tOldValidUsername]),\npassword: tPassword,\nwatchedIDs: t.list(t.String),\ncalendarQuery: t.maybe(entryQueryInputValidator),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Remaining emails-related cleanup
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1485 |
129,187 | 24.06.2021 12:01:52 | 14,400 | 1ac2ea564a167ad94e482b9c7cc76c87964aafe4 | [lib] Convert report, request, and update types to $ReadOnly
Test Plan: Flow
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/types/report-types.js",
"new_path": "lib/types/report-types.js",
"diff": "@@ -38,70 +38,70 @@ export type FlatErrorData = {|\n|};\nexport type ActionSummary = {|\n- type: $PropertyType<BaseAction, 'type'>,\n- time: number,\n- summary: string,\n+ +type: $PropertyType<BaseAction, 'type'>,\n+ +time: number,\n+ +summary: string,\n|};\nexport type ThreadInconsistencyReportShape = {|\n- platformDetails: PlatformDetails,\n- beforeAction: { [id: string]: RawThreadInfo },\n- action: BaseAction,\n- pollResult?: { [id: string]: RawThreadInfo },\n- pushResult: { [id: string]: RawThreadInfo },\n- lastActionTypes?: $ReadOnlyArray<$PropertyType<BaseAction, 'type'>>,\n- lastActions?: $ReadOnlyArray<ActionSummary>,\n- time?: number,\n+ +platformDetails: PlatformDetails,\n+ +beforeAction: { [id: string]: RawThreadInfo },\n+ +action: BaseAction,\n+ +pollResult?: { [id: string]: RawThreadInfo },\n+ +pushResult: { [id: string]: RawThreadInfo },\n+ +lastActionTypes?: $ReadOnlyArray<$PropertyType<BaseAction, 'type'>>,\n+ +lastActions?: $ReadOnlyArray<ActionSummary>,\n+ +time?: number,\n|};\nexport type EntryInconsistencyReportShape = {|\n- platformDetails: PlatformDetails,\n- beforeAction: { [id: string]: RawEntryInfo },\n- action: BaseAction,\n- calendarQuery: CalendarQuery,\n- pollResult?: { [id: string]: RawEntryInfo },\n- pushResult: { [id: string]: RawEntryInfo },\n- lastActionTypes?: $ReadOnlyArray<$PropertyType<BaseAction, 'type'>>,\n- lastActions?: $ReadOnlyArray<ActionSummary>,\n- time: number,\n+ +platformDetails: PlatformDetails,\n+ +beforeAction: { [id: string]: RawEntryInfo },\n+ +action: BaseAction,\n+ +calendarQuery: CalendarQuery,\n+ +pollResult?: { [id: string]: RawEntryInfo },\n+ +pushResult: { [id: string]: RawEntryInfo },\n+ +lastActionTypes?: $ReadOnlyArray<$PropertyType<BaseAction, 'type'>>,\n+ +lastActions?: $ReadOnlyArray<ActionSummary>,\n+ +time: number,\n|};\nexport type UserInconsistencyReportShape = {|\n- platformDetails: PlatformDetails,\n- action: BaseAction,\n- beforeStateCheck: UserInfos,\n- afterStateCheck: UserInfos,\n- lastActions: $ReadOnlyArray<ActionSummary>,\n- time: number,\n+ +platformDetails: PlatformDetails,\n+ +action: BaseAction,\n+ +beforeStateCheck: UserInfos,\n+ +afterStateCheck: UserInfos,\n+ +lastActions: $ReadOnlyArray<ActionSummary>,\n+ +time: number,\n|};\ntype ErrorReportCreationRequest = {|\n- type: 0,\n- platformDetails: PlatformDetails,\n- errors: $ReadOnlyArray<FlatErrorData>,\n- preloadedState: AppState,\n- currentState: AppState,\n- actions: $ReadOnlyArray<BaseAction>,\n+ +type: 0,\n+ +platformDetails: PlatformDetails,\n+ +errors: $ReadOnlyArray<FlatErrorData>,\n+ +preloadedState: AppState,\n+ +currentState: AppState,\n+ +actions: $ReadOnlyArray<BaseAction>,\n|};\nexport type ThreadInconsistencyReportCreationRequest = {|\n...ThreadInconsistencyReportShape,\n- type: 1,\n+ +type: 1,\n|};\nexport type EntryInconsistencyReportCreationRequest = {|\n...EntryInconsistencyReportShape,\n- type: 2,\n+ +type: 2,\n|};\nexport type MediaMissionReportCreationRequest = {|\n- type: 3,\n- platformDetails: PlatformDetails,\n- time: number, // ms\n- mediaMission: MediaMission,\n- uploadServerID?: ?string,\n- uploadLocalID?: ?string,\n- mediaLocalID?: ?string, // deprecated\n- messageServerID?: ?string,\n- messageLocalID?: ?string,\n+ +type: 3,\n+ +platformDetails: PlatformDetails,\n+ +time: number, // ms\n+ +mediaMission: MediaMission,\n+ +uploadServerID?: ?string,\n+ +uploadLocalID?: ?string,\n+ +mediaLocalID?: ?string, // deprecated\n+ +messageServerID?: ?string,\n+ +messageLocalID?: ?string,\n|};\nexport type UserInconsistencyReportCreationRequest = {|\n...UserInconsistencyReportShape,\n- type: 4,\n+ +type: 4,\n|};\nexport type ReportCreationRequest =\n| ErrorReportCreationRequest\n@@ -111,30 +111,30 @@ export type ReportCreationRequest =\n| UserInconsistencyReportCreationRequest;\nexport type ClientThreadInconsistencyReportShape = {|\n- platformDetails: PlatformDetails,\n- beforeAction: { [id: string]: RawThreadInfo },\n- action: BaseAction,\n- pushResult: { [id: string]: RawThreadInfo },\n- lastActions: $ReadOnlyArray<ActionSummary>,\n- time: number,\n+ +platformDetails: PlatformDetails,\n+ +beforeAction: { [id: string]: RawThreadInfo },\n+ +action: BaseAction,\n+ +pushResult: { [id: string]: RawThreadInfo },\n+ +lastActions: $ReadOnlyArray<ActionSummary>,\n+ +time: number,\n|};\nexport type ClientEntryInconsistencyReportShape = {|\n- platformDetails: PlatformDetails,\n- beforeAction: { [id: string]: RawEntryInfo },\n- action: BaseAction,\n- calendarQuery: CalendarQuery,\n- pushResult: { [id: string]: RawEntryInfo },\n- lastActions: $ReadOnlyArray<ActionSummary>,\n- time: number,\n+ +platformDetails: PlatformDetails,\n+ +beforeAction: { [id: string]: RawEntryInfo },\n+ +action: BaseAction,\n+ +calendarQuery: CalendarQuery,\n+ +pushResult: { [id: string]: RawEntryInfo },\n+ +lastActions: $ReadOnlyArray<ActionSummary>,\n+ +time: number,\n|};\nexport type ClientThreadInconsistencyReportCreationRequest = {|\n...ClientThreadInconsistencyReportShape,\n- type: 1,\n+ +type: 1,\n|};\nexport type ClientEntryInconsistencyReportCreationRequest = {|\n...ClientEntryInconsistencyReportShape,\n- type: 2,\n+ +type: 2,\n|};\nexport type ClientReportCreationRequest =\n@@ -145,34 +145,34 @@ export type ClientReportCreationRequest =\n| UserInconsistencyReportCreationRequest;\nexport type QueueReportsPayload = {|\n- reports: $ReadOnlyArray<ClientReportCreationRequest>,\n+ +reports: $ReadOnlyArray<ClientReportCreationRequest>,\n|};\nexport type ClearDeliveredReportsPayload = {|\n- reports: $ReadOnlyArray<ClientReportCreationRequest>,\n+ +reports: $ReadOnlyArray<ClientReportCreationRequest>,\n|};\nexport type ReportCreationResponse = {|\n- id: string,\n+ +id: string,\n|};\ntype ReportInfo = {|\n- id: string,\n- viewerID: string,\n- platformDetails: PlatformDetails,\n- creationTime: number,\n+ +id: string,\n+ +viewerID: string,\n+ +platformDetails: PlatformDetails,\n+ +creationTime: number,\n|};\nexport type FetchErrorReportInfosRequest = {|\n- cursor: ?string,\n+ +cursor: ?string,\n|};\nexport type FetchErrorReportInfosResponse = {|\n- reports: $ReadOnlyArray<ReportInfo>,\n- userInfos: $ReadOnlyArray<UserInfo>,\n+ +reports: $ReadOnlyArray<ReportInfo>,\n+ +userInfos: $ReadOnlyArray<UserInfo>,\n|};\nexport type ReduxToolsImport = {|\n- preloadedState: AppState,\n- payload: $ReadOnlyArray<BaseAction>,\n+ +preloadedState: AppState,\n+ +payload: $ReadOnlyArray<BaseAction>,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/request-types.js",
"new_path": "lib/types/request-types.js",
"diff": "@@ -48,16 +48,16 @@ export function assertServerRequestType(\n}\ntype PlatformServerRequest = {|\n- type: 0,\n+ +type: 0,\n|};\ntype PlatformClientResponse = {|\n- type: 0,\n- platform: Platform,\n+ +type: 0,\n+ +platform: Platform,\n|};\nexport type ThreadInconsistencyClientResponse = {|\n...ThreadInconsistencyReportShape,\n- type: 2,\n+ +type: 2,\n|};\ntype PlatformDetailsServerRequest = {|\n@@ -74,14 +74,14 @@ export type EntryInconsistencyClientResponse = {|\n|};\nexport type ServerCheckStateServerRequest = {|\n- type: 6,\n- hashesToCheck: { +[key: string]: number },\n- failUnmentioned?: Shape<{|\n+ +type: 6,\n+ +hashesToCheck: { +[key: string]: number },\n+ +failUnmentioned?: Shape<{|\n+threadInfos: boolean,\n+entryInfos: boolean,\n+userInfos: boolean,\n|}>,\n- stateChanges?: Shape<{|\n+ +stateChanges?: Shape<{|\n+rawThreadInfos: RawThreadInfo[],\n+rawEntryInfos: RawEntryInfo[],\n+currentUserInfo: CurrentUserInfo | OldCurrentUserInfo,\n@@ -92,13 +92,13 @@ export type ServerCheckStateServerRequest = {|\n|}>,\n|};\ntype CheckStateClientResponse = {|\n- type: 6,\n- hashResults: { +[key: string]: boolean },\n+ +type: 6,\n+ +hashResults: { +[key: string]: boolean },\n|};\ntype InitialActivityUpdatesClientResponse = {|\n- type: 7,\n- activityUpdates: $ReadOnlyArray<ActivityUpdate>,\n+ +type: 7,\n+ +activityUpdates: $ReadOnlyArray<ActivityUpdate>,\n|};\nexport type ServerServerRequest =\n@@ -114,14 +114,14 @@ export type ClientResponse =\n| InitialActivityUpdatesClientResponse;\nexport type ClientCheckStateServerRequest = {|\n- type: 6,\n- hashesToCheck: { +[key: string]: number },\n- failUnmentioned?: Shape<{|\n+ +type: 6,\n+ +hashesToCheck: { +[key: string]: number },\n+ +failUnmentioned?: Shape<{|\n+threadInfos: boolean,\n+entryInfos: boolean,\n+userInfos: boolean,\n|}>,\n- stateChanges?: Shape<{|\n+ +stateChanges?: Shape<{|\n+rawThreadInfos: RawThreadInfo[],\n+rawEntryInfos: RawEntryInfo[],\n+currentUserInfo: CurrentUserInfo,\n@@ -141,10 +141,10 @@ export type ClientServerRequest =\n// responses, but the client variant only need to support the latest version.\ntype ClientThreadInconsistencyClientResponse = {|\n...ClientThreadInconsistencyReportShape,\n- type: 2,\n+ +type: 2,\n|};\ntype ClientEntryInconsistencyClientResponse = {|\n- type: 5,\n+ +type: 5,\n...ClientEntryInconsistencyReportShape,\n|};\nexport type ClientClientResponse =\n@@ -161,6 +161,6 @@ export type ClientInconsistencyResponse =\nexport const processServerRequestsActionType = 'PROCESS_SERVER_REQUESTS';\nexport type ProcessServerRequestsPayload = {|\n- serverRequests: $ReadOnlyArray<ClientServerRequest>,\n- calendarQuery: CalendarQuery,\n+ +serverRequests: $ReadOnlyArray<ClientServerRequest>,\n+ +calendarQuery: CalendarQuery,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/update-types.js",
"new_path": "lib/types/update-types.js",
"diff": "@@ -41,84 +41,84 @@ export function assertUpdateType(ourUpdateType: number): UpdateType {\n}\ntype AccountDeletionData = {|\n- deletedUserID: string,\n+ +deletedUserID: string,\n|};\ntype ThreadData = {|\n- threadID: string,\n+ +threadID: string,\n|};\ntype ThreadReadStatusData = {|\n- threadID: string,\n- unread: boolean,\n+ +threadID: string,\n+ +unread: boolean,\n|};\ntype ThreadDeletionData = {|\n- threadID: string,\n+ +threadID: string,\n|};\ntype ThreadJoinData = {|\n- threadID: string,\n+ +threadID: string,\n|};\ntype BadDeviceTokenData = {|\n- deviceToken: string,\n+ +deviceToken: string,\n|};\ntype EntryData = {|\n- entryID: string,\n+ +entryID: string,\n|};\ntype CurrentUserData = {||};\ntype UserData = {|\n// ID of the UserInfo being updated\n- updatedUserID: string,\n+ +updatedUserID: string,\n|};\ntype SharedUpdateData = {|\n- userID: string,\n- time: number,\n+ +userID: string,\n+ +time: number,\n|};\ntype AccountDeletionUpdateData = {|\n...SharedUpdateData,\n...AccountDeletionData,\n- type: 0,\n+ +type: 0,\n|};\ntype ThreadUpdateData = {|\n...SharedUpdateData,\n...ThreadData,\n- type: 1,\n- targetSession?: string,\n+ +type: 1,\n+ +targetSession?: string,\n|};\ntype ThreadReadStatusUpdateData = {|\n...SharedUpdateData,\n...ThreadReadStatusData,\n- type: 2,\n+ +type: 2,\n|};\ntype ThreadDeletionUpdateData = {|\n...SharedUpdateData,\n...ThreadDeletionData,\n- type: 3,\n+ +type: 3,\n|};\ntype ThreadJoinUpdateData = {|\n...SharedUpdateData,\n...ThreadJoinData,\n- type: 4,\n+ +type: 4,\n|};\ntype BadDeviceTokenUpdateData = {|\n...SharedUpdateData,\n...BadDeviceTokenData,\n- type: 5,\n- targetCookie: string,\n+ +type: 5,\n+ +targetCookie: string,\n|};\ntype EntryUpdateData = {|\n...SharedUpdateData,\n...EntryData,\n- type: 6,\n- targetSession: string,\n+ +type: 6,\n+ +targetSession: string,\n|};\ntype CurrentUserUpdateData = {|\n...SharedUpdateData,\n...CurrentUserData,\n- type: 7,\n+ +type: 7,\n|};\ntype UserUpdateData = {|\n...SharedUpdateData,\n...UserData,\n- type: 8,\n+ +type: 8,\n|};\nexport type UpdateData =\n| AccountDeletionUpdateData\n@@ -132,53 +132,53 @@ export type UpdateData =\n| UserUpdateData;\ntype SharedRawUpdateInfo = {|\n- id: string,\n- time: number,\n+ +id: string,\n+ +time: number,\n|};\ntype AccountDeletionRawUpdateInfo = {|\n...SharedRawUpdateInfo,\n...AccountDeletionData,\n- type: 0,\n+ +type: 0,\n|};\ntype ThreadRawUpdateInfo = {|\n...SharedRawUpdateInfo,\n...ThreadData,\n- type: 1,\n+ +type: 1,\n|};\ntype ThreadReadStatusRawUpdateInfo = {|\n...SharedRawUpdateInfo,\n...ThreadReadStatusData,\n- type: 2,\n+ +type: 2,\n|};\ntype ThreadDeletionRawUpdateInfo = {|\n...SharedRawUpdateInfo,\n...ThreadDeletionData,\n- type: 3,\n+ +type: 3,\n|};\ntype ThreadJoinRawUpdateInfo = {|\n...SharedRawUpdateInfo,\n...ThreadJoinData,\n- type: 4,\n+ +type: 4,\n|};\ntype BadDeviceTokenRawUpdateInfo = {|\n...SharedRawUpdateInfo,\n...BadDeviceTokenData,\n- type: 5,\n+ +type: 5,\n|};\ntype EntryRawUpdateInfo = {|\n...SharedRawUpdateInfo,\n...EntryData,\n- type: 6,\n+ +type: 6,\n|};\ntype CurrentUserRawUpdateInfo = {|\n...SharedRawUpdateInfo,\n...CurrentUserData,\n- type: 7,\n+ +type: 7,\n|};\ntype UserRawUpdateInfo = {|\n...SharedRawUpdateInfo,\n...UserData,\n- type: 8,\n+ +type: 8,\n|};\nexport type RawUpdateInfo =\n| AccountDeletionRawUpdateInfo\n@@ -192,63 +192,63 @@ export type RawUpdateInfo =\n| UserRawUpdateInfo;\ntype AccountDeletionUpdateInfo = {|\n- type: 0,\n- id: string,\n- time: number,\n- deletedUserID: string,\n+ +type: 0,\n+ +id: string,\n+ +time: number,\n+ +deletedUserID: string,\n|};\ntype ThreadUpdateInfo = {|\n- type: 1,\n- id: string,\n- time: number,\n- threadInfo: RawThreadInfo,\n+ +type: 1,\n+ +id: string,\n+ +time: number,\n+ +threadInfo: RawThreadInfo,\n|};\ntype ThreadReadStatusUpdateInfo = {|\n- type: 2,\n- id: string,\n- time: number,\n- threadID: string,\n- unread: boolean,\n+ +type: 2,\n+ +id: string,\n+ +time: number,\n+ +threadID: string,\n+ +unread: boolean,\n|};\ntype ThreadDeletionUpdateInfo = {|\n- type: 3,\n- id: string,\n- time: number,\n- threadID: string,\n+ +type: 3,\n+ +id: string,\n+ +time: number,\n+ +threadID: string,\n|};\ntype ThreadJoinUpdateInfo = {|\n- type: 4,\n- id: string,\n- time: number,\n- threadInfo: RawThreadInfo,\n- rawMessageInfos: $ReadOnlyArray<RawMessageInfo>,\n- truncationStatus: MessageTruncationStatus,\n- rawEntryInfos: $ReadOnlyArray<RawEntryInfo>,\n+ +type: 4,\n+ +id: string,\n+ +time: number,\n+ +threadInfo: RawThreadInfo,\n+ +rawMessageInfos: $ReadOnlyArray<RawMessageInfo>,\n+ +truncationStatus: MessageTruncationStatus,\n+ +rawEntryInfos: $ReadOnlyArray<RawEntryInfo>,\n|};\ntype BadDeviceTokenUpdateInfo = {|\n- type: 5,\n- id: string,\n- time: number,\n- deviceToken: string,\n+ +type: 5,\n+ +id: string,\n+ +time: number,\n+ +deviceToken: string,\n|};\ntype EntryUpdateInfo = {|\n- type: 6,\n- id: string,\n- time: number,\n- entryInfo: RawEntryInfo,\n+ +type: 6,\n+ +id: string,\n+ +time: number,\n+ +entryInfo: RawEntryInfo,\n|};\ntype CurrentUserUpdateInfo = {|\n- type: 7,\n- id: string,\n- time: number,\n- currentUserInfo: LoggedInUserInfo,\n+ +type: 7,\n+ +id: string,\n+ +time: number,\n+ +currentUserInfo: LoggedInUserInfo,\n|};\ntype UserUpdateInfo = {|\n- type: 8,\n- id: string,\n- time: number,\n+ +type: 8,\n+ +id: string,\n+ +time: number,\n// Updated UserInfo is already contained within the UpdatesResultWithUserInfos\n- updatedUserID: string,\n+ +updatedUserID: string,\n|};\nexport type ClientUpdateInfo =\n| AccountDeletionUpdateInfo\n@@ -262,10 +262,10 @@ export type ClientUpdateInfo =\n| UserUpdateInfo;\ntype ServerCurrentUserUpdateInfo = {|\n- type: 7,\n- id: string,\n- time: number,\n- currentUserInfo: LoggedInUserInfo | OldLoggedInUserInfo,\n+ +type: 7,\n+ +id: string,\n+ +time: number,\n+ +currentUserInfo: LoggedInUserInfo | OldLoggedInUserInfo,\n|};\nexport type ServerUpdateInfo =\n| AccountDeletionUpdateInfo\n@@ -279,36 +279,36 @@ export type ServerUpdateInfo =\n| UserUpdateInfo;\nexport type ServerUpdatesResult = {|\n- currentAsOf: number,\n- newUpdates: $ReadOnlyArray<ServerUpdateInfo>,\n+ +currentAsOf: number,\n+ +newUpdates: $ReadOnlyArray<ServerUpdateInfo>,\n|};\nexport type ServerUpdatesResultWithUserInfos = {|\n- updatesResult: ServerUpdatesResult,\n- userInfos: $ReadOnlyArray<UserInfo>,\n+ +updatesResult: ServerUpdatesResult,\n+ +userInfos: $ReadOnlyArray<UserInfo>,\n|};\nexport type ClientUpdatesResult = {|\n- currentAsOf: number,\n- newUpdates: $ReadOnlyArray<ClientUpdateInfo>,\n+ +currentAsOf: number,\n+ +newUpdates: $ReadOnlyArray<ClientUpdateInfo>,\n|};\nexport type ClientUpdatesResultWithUserInfos = {|\n- updatesResult: ClientUpdatesResult,\n- userInfos: $ReadOnlyArray<UserInfo>,\n+ +updatesResult: ClientUpdatesResult,\n+ +userInfos: $ReadOnlyArray<UserInfo>,\n|};\nexport type CreateUpdatesResult = {|\n- viewerUpdates: $ReadOnlyArray<ServerUpdateInfo>,\n- userInfos: { [id: string]: AccountUserInfo },\n+ +viewerUpdates: $ReadOnlyArray<ServerUpdateInfo>,\n+ +userInfos: { [id: string]: AccountUserInfo },\n|};\nexport type ServerCreateUpdatesResponse = {|\n- viewerUpdates: $ReadOnlyArray<ServerUpdateInfo>,\n- userInfos: $ReadOnlyArray<AccountUserInfo>,\n+ +viewerUpdates: $ReadOnlyArray<ServerUpdateInfo>,\n+ +userInfos: $ReadOnlyArray<AccountUserInfo>,\n|};\nexport type ClientCreateUpdatesResponse = {|\n- viewerUpdates: $ReadOnlyArray<ClientUpdateInfo>,\n- userInfos: $ReadOnlyArray<AccountUserInfo>,\n+ +viewerUpdates: $ReadOnlyArray<ClientUpdateInfo>,\n+ +userInfos: $ReadOnlyArray<AccountUserInfo>,\n|};\nexport const processUpdatesActionType = 'PROCESS_UPDATES';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Convert report, request, and update types to $ReadOnly
Test Plan: Flow
Reviewers: palys-swm, atul
Reviewed By: atul
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1488 |
129,187 | 24.06.2021 12:36:26 | 14,400 | a798da0c7196a9e137b9d2dfdd9896fff7276ea7 | [server] Use more explanatory var name for deciding when to use OldCurrentUserInfo
Test Plan: Flow
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/user-fetchers.js",
"new_path": "server/src/fetchers/user-fetchers.js",
"diff": "@@ -193,8 +193,11 @@ async function fetchCurrentUserInfo(\nthrow new ServerError('unknown_error');\n}\nconst currentUserInfo = currentUserInfos[0];\n- const hasCodeVersionBelow87 = !hasMinCodeVersion(viewer.platformDetails, 87);\n- if (hasCodeVersionBelow87) {\n+ const stillExpectsEmailFields = !hasMinCodeVersion(\n+ viewer.platformDetails,\n+ 87,\n+ );\n+ if (stillExpectsEmailFields) {\nreturn currentUserInfo;\n}\nconst { id, username } = currentUserInfo;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Use more explanatory var name for deciding when to use OldCurrentUserInfo
Test Plan: Flow
Reviewers: palys-swm, atul
Reviewed By: atul
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1490 |
129,184 | 23.06.2021 15:26:04 | 14,400 | 3b2d37b14c06e19ee61f6273ad97c4df70d08a00 | [redux] Add `enabledReports` to redux
Summary: Add `enabledReports` to redux so we don't have separate entries for `crashReportsEnabled`, `inconsistencyReportsEnabled`, etc
Test Plan: Tested with upcoming commit that replaces `crashReportsEnabled` where it is currently being used.
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/reducers/enabled-reports-reducer.js",
"diff": "+// @flow\n+\n+import type { EnabledReports } from '../types/enabled-reports';\n+import type { BaseAction } from '../types/redux-types';\n+\n+export const updateReportsEnabledActionType = 'UPDATE_REPORTS_ENABLED';\n+\n+export default function reduceEnabledReports(\n+ state: EnabledReports,\n+ action: BaseAction,\n+): EnabledReports {\n+ if (action.type === updateReportsEnabledActionType) {\n+ return { ...state, ...action.payload };\n+ }\n+ return state;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/master-reducer.js",
"new_path": "lib/reducers/master-reducer.js",
"diff": "@@ -12,6 +12,7 @@ import reduceConnectionInfo from './connection-reducer';\nimport reduceCrashReportsEnabled from './crash-reports-enabled-reducer';\nimport reduceDataLoaded from './data-loaded-reducer';\nimport reduceEnabledApps from './enabled-apps-reducer';\n+import reduceEnabledReports from './enabled-reports-reducer';\nimport { reduceEntryInfos } from './entry-reducer';\nimport reduceLifecycleState from './lifecycle-state-reducer';\nimport { reduceLoadingStatuses } from './loading-reducer';\n@@ -76,6 +77,7 @@ export default function baseReducer<N: BaseNavInfo, T: BaseAppState<N>>(\nconnection,\nlifecycleState: reduceLifecycleState(state.lifecycleState, action),\nenabledApps: reduceEnabledApps(state.enabledApps, action),\n+ enabledReports: reduceEnabledReports(state.enabledReports, action),\ncrashReportsEnabled: reduceCrashReportsEnabled(\nstate.crashReportsEnabled,\naction,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/types/enabled-reports.js",
"diff": "+// @flow\n+\n+export type EnabledReports = {|\n+ +crashReports: boolean,\n+ +inconsistencyReports: boolean,\n+ +mediaReports: boolean,\n+|};\n+\n+export type SupportedReports = $Keys<EnabledReports>;\n+\n+export const defaultEnabledReports: EnabledReports = {\n+ crashReports: false,\n+ inconsistencyReports: false,\n+ mediaReports: false,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "// @flow\n+import type { Shape } from '../types/core';\nimport type {\nLogOutResult,\nLogInStartingPayload,\n@@ -12,6 +13,7 @@ import type {\nSetThreadUnreadStatusPayload,\n} from './activity-types';\nimport type { EnabledApps, SupportedApps } from './enabled-apps';\n+import type { EnabledReports } from './enabled-reports';\nimport type {\nRawEntryInfo,\nEntryStore,\n@@ -86,6 +88,7 @@ export type BaseAppState<NavInfo: BaseNavInfo> = {\nwatchedThreadIDs: $ReadOnlyArray<string>,\nlifecycleState: LifecycleState,\nenabledApps: EnabledApps,\n+ enabledReports: EnabledReports,\ncrashReportsEnabled: boolean,\nnextLocalID: number,\nqueuedReports: $ReadOnlyArray<ClientReportCreationRequest>,\n@@ -675,6 +678,10 @@ export type BaseAction =\n+type: 'DISABLE_APP',\n+payload: SupportedApps,\n|}\n+ | {|\n+ +type: 'UPDATE_REPORTS_ENABLED',\n+ +payload: Shape<EnabledReports>,\n+ |}\n| {|\n+type: 'UPDATE_CRASH_REPORTS_ENABLED',\n+payload: boolean,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux/persist.js",
"new_path": "native/redux/persist.js",
"diff": "@@ -228,6 +228,11 @@ const migrations = {\nid: currentUserInfo.id,\nusername: currentUserInfo.username,\n},\n+ enabledReports: {\n+ crashReports: __DEV__,\n+ inconsistencyReports: __DEV__,\n+ mediaReports: __DEV__,\n+ },\n};\n},\n};\n@@ -244,7 +249,7 @@ const persistConfig = {\n'frozen',\n],\ndebug: __DEV__,\n- version: 26,\n+ version: 27,\nmigrate: createMigrate(migrations, { debug: __DEV__ }),\ntimeout: __DEV__ ? 0 : undefined,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux/redux-setup.js",
"new_path": "native/redux/redux-setup.js",
"diff": "@@ -20,6 +20,7 @@ import {\ninvalidSessionRecovery,\n} from 'lib/shared/account-utils';\nimport { type EnabledApps, defaultEnabledApps } from 'lib/types/enabled-apps';\n+import { type EnabledReports } from 'lib/types/enabled-reports';\nimport { type EntryStore } from 'lib/types/entry-types';\nimport {\ntype CalendarFilter,\n@@ -110,6 +111,7 @@ export type AppState = {|\nwatchedThreadIDs: $ReadOnlyArray<string>,\nlifecycleState: LifecycleState,\nenabledApps: EnabledApps,\n+ enabledReports: EnabledReports,\ncrashReportsEnabled: boolean,\nnextLocalID: number,\nqueuedReports: $ReadOnlyArray<ClientReportCreationRequest>,\n@@ -160,6 +162,11 @@ const defaultState = ({\nwatchedThreadIDs: [],\nlifecycleState: 'active',\nenabledApps: defaultEnabledApps,\n+ enabledReports: {\n+ crashReports: __DEV__,\n+ inconsistencyReports: __DEV__,\n+ mediaReports: __DEV__,\n+ },\ncrashReportsEnabled: __DEV__,\nnextLocalID: 0,\nqueuedReports: [],\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/website-responders.js",
"new_path": "server/src/responders/website-responders.js",
"diff": "@@ -17,6 +17,7 @@ import { mostRecentReadThread } from 'lib/selectors/thread-selectors';\nimport { mostRecentMessageTimestamp } from 'lib/shared/message-utils';\nimport { threadHasPermission } from 'lib/shared/thread-utils';\nimport { defaultWebEnabledApps } from 'lib/types/enabled-apps';\n+import { defaultEnabledReports } from 'lib/types/enabled-reports';\nimport { defaultCalendarFilters } from 'lib/types/filter-types';\nimport { defaultNumberPerThread } from 'lib/types/message-types';\nimport { defaultConnectionInfo } from 'lib/types/socket-types';\n@@ -272,6 +273,7 @@ async function websiteResponder(\nwatchedThreadIDs: [],\nlifecycleState: 'active',\nenabledApps: defaultWebEnabledApps,\n+ enabledReports: defaultEnabledReports,\ncrashReportsEnabled: false,\nnextLocalID: 0,\nqueuedReports: [],\n"
},
{
"change_type": "MODIFY",
"old_path": "web/redux/redux-setup.js",
"new_path": "web/redux/redux-setup.js",
"diff": "@@ -11,6 +11,7 @@ import { mostRecentReadThreadSelector } from 'lib/selectors/thread-selectors';\nimport { invalidSessionDowngrade } from 'lib/shared/account-utils';\nimport type { Shape } from 'lib/types/core';\nimport type { EnabledApps } from 'lib/types/enabled-apps';\n+import type { EnabledReports } from 'lib/types/enabled-reports';\nimport type { EntryStore } from 'lib/types/entry-types';\nimport type { CalendarFilter } from 'lib/types/filter-types';\nimport type { LifecycleState } from 'lib/types/lifecycle-state-types';\n@@ -50,6 +51,7 @@ export type AppState = {|\nwatchedThreadIDs: $ReadOnlyArray<string>,\nlifecycleState: LifecycleState,\nenabledApps: EnabledApps,\n+ enabledReports: EnabledReports,\ncrashReportsEnabled: boolean,\nnextLocalID: number,\nqueuedReports: $ReadOnlyArray<ClientReportCreationRequest>,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [redux] Add `enabledReports` to redux
Summary: Add `enabledReports` to redux so we don't have separate entries for `crashReportsEnabled`, `inconsistencyReportsEnabled`, etc
Test Plan: Tested with upcoming commit that replaces `crashReportsEnabled` where it is currently being used.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1450 |
129,184 | 23.06.2021 15:59:42 | 14,400 | cc67ab5442a96c64fa937e98ee837a8f9edd7e3c | [redux] Remove `crashReportsEnabled`, replace with `enabledReports.crashReports`
Summary: Replace usage of `crashReportsEnabled` with `enabledReports.crashReports`
Test Plan: Tried existing `toggle-crash-reports` screen and ensured that it continued to work as expected via redux dev tools
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "DELETE",
"old_path": "lib/reducers/crash-reports-enabled-reducer.js",
"new_path": null,
"diff": "-// @flow\n-\n-import type { BaseAction } from '../types/redux-types';\n-\n-export const updateCrashReportsEnabledActionType =\n- 'UPDATE_CRASH_REPORTS_ENABLED';\n-\n-export default function reduceCrashReportsEnabled(\n- state: boolean,\n- action: BaseAction,\n-): boolean {\n- if (action.type === updateCrashReportsEnabledActionType) {\n- return action.payload;\n- }\n- return state;\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/master-reducer.js",
"new_path": "lib/reducers/master-reducer.js",
"diff": "@@ -9,7 +9,6 @@ import {\n} from '../types/socket-types';\nimport reduceCalendarFilters from './calendar-filters-reducer';\nimport reduceConnectionInfo from './connection-reducer';\n-import reduceCrashReportsEnabled from './crash-reports-enabled-reducer';\nimport reduceDataLoaded from './data-loaded-reducer';\nimport reduceEnabledApps from './enabled-apps-reducer';\nimport reduceEnabledReports from './enabled-reports-reducer';\n@@ -78,10 +77,6 @@ export default function baseReducer<N: BaseNavInfo, T: BaseAppState<N>>(\nlifecycleState: reduceLifecycleState(state.lifecycleState, action),\nenabledApps: reduceEnabledApps(state.enabledApps, action),\nenabledReports: reduceEnabledReports(state.enabledReports, action),\n- crashReportsEnabled: reduceCrashReportsEnabled(\n- state.crashReportsEnabled,\n- action,\n- ),\nnextLocalID: reduceNextLocalID(state.nextLocalID, action),\nqueuedReports: reduceQueuedReports(state.queuedReports, action),\ndataLoaded: reduceDataLoaded(state.dataLoaded, action),\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -89,7 +89,6 @@ export type BaseAppState<NavInfo: BaseNavInfo> = {\nlifecycleState: LifecycleState,\nenabledApps: EnabledApps,\nenabledReports: EnabledReports,\n- crashReportsEnabled: boolean,\nnextLocalID: number,\nqueuedReports: $ReadOnlyArray<ClientReportCreationRequest>,\ndataLoaded: boolean,\n@@ -682,10 +681,6 @@ export type BaseAction =\n+type: 'UPDATE_REPORTS_ENABLED',\n+payload: Shape<EnabledReports>,\n|}\n- | {|\n- +type: 'UPDATE_CRASH_REPORTS_ENABLED',\n- +payload: boolean,\n- |}\n| {|\n+type: 'PROCESS_UPDATES',\n+payload: ClientUpdatesResultWithUserInfos,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/profile/toggle-crash-reports.react.js",
"new_path": "native/profile/toggle-crash-reports.react.js",
"diff": "@@ -4,7 +4,7 @@ import * as React from 'react';\nimport { Text, View, Switch } from 'react-native';\nimport { useDispatch } from 'react-redux';\n-import { updateCrashReportsEnabledActionType } from 'lib/reducers/crash-reports-enabled-reducer';\n+import { updateReportsEnabledActionType } from 'lib/reducers/enabled-reports-reducer';\nimport { useStyles } from '../themes/colors';\nimport { useIsCrashReportingEnabled } from '../utils/crash-utils';\n@@ -16,7 +16,10 @@ function ToggleCrashReports() {\nconst onCrashReportsToggled = React.useCallback(\n(value) => {\n- dispatch({ type: updateCrashReportsEnabledActionType, payload: value });\n+ dispatch({\n+ type: updateReportsEnabledActionType,\n+ payload: { crashReports: value },\n+ });\n},\n[dispatch],\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux/persist.js",
"new_path": "native/redux/persist.js",
"diff": "@@ -224,6 +224,7 @@ const migrations = {\n}\nreturn {\n...state,\n+ crashReportsEnabled: undefined,\ncurrentUserInfo: {\nid: currentUserInfo.id,\nusername: currentUserInfo.username,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux/redux-setup.js",
"new_path": "native/redux/redux-setup.js",
"diff": "@@ -112,7 +112,6 @@ export type AppState = {|\nlifecycleState: LifecycleState,\nenabledApps: EnabledApps,\nenabledReports: EnabledReports,\n- crashReportsEnabled: boolean,\nnextLocalID: number,\nqueuedReports: $ReadOnlyArray<ClientReportCreationRequest>,\n_persist: ?PersistState,\n@@ -167,7 +166,6 @@ const defaultState = ({\ninconsistencyReports: __DEV__,\nmediaReports: __DEV__,\n},\n- crashReportsEnabled: __DEV__,\nnextLocalID: 0,\nqueuedReports: [],\n_persist: null,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/utils/crash-utils.js",
"new_path": "native/utils/crash-utils.js",
"diff": "@@ -19,7 +19,7 @@ async function wipeAndExit() {\n}\nfunction useIsCrashReportingEnabled(): boolean {\n- return useSelector((state) => state.crashReportsEnabled);\n+ return useSelector((state) => state.enabledReports.crashReports);\n}\nexport { wipeAndExit, useIsCrashReportingEnabled };\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/website-responders.js",
"new_path": "server/src/responders/website-responders.js",
"diff": "@@ -274,7 +274,6 @@ async function websiteResponder(\nlifecycleState: 'active',\nenabledApps: defaultWebEnabledApps,\nenabledReports: defaultEnabledReports,\n- crashReportsEnabled: false,\nnextLocalID: 0,\nqueuedReports: [],\ntimeZone: viewer.timeZone,\n"
},
{
"change_type": "MODIFY",
"old_path": "web/redux/redux-setup.js",
"new_path": "web/redux/redux-setup.js",
"diff": "@@ -52,7 +52,6 @@ export type AppState = {|\nlifecycleState: LifecycleState,\nenabledApps: EnabledApps,\nenabledReports: EnabledReports,\n- crashReportsEnabled: boolean,\nnextLocalID: number,\nqueuedReports: $ReadOnlyArray<ClientReportCreationRequest>,\ntimeZone: ?string,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [redux] Remove `crashReportsEnabled`, replace with `enabledReports.crashReports`
Summary: Replace usage of `crashReportsEnabled` with `enabledReports.crashReports`
Test Plan: Tried existing `toggle-crash-reports` screen and ensured that it continued to work as expected via redux dev tools
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1451 |
129,184 | 23.06.2021 16:27:48 | 14,400 | 34ff7ce455f42b4fdb96dec33964c1b0edcf5dfa | [lib][native] Introduce hook to check whether specified report type is enabled
Summary: Replace `useIsCrashReportingEnabled` with `useIsReportEnabled(reportType: SupportedReports)` to determine whether particular report type is enabled.
Test Plan: Checked via redux dev tools that `toggle-crash-reports` component continues to work as expected.
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/utils/report-utils.js",
"diff": "+// @flow\n+\n+import { type SupportedReports } from '../types/enabled-reports';\n+import { useSelector } from './redux-utils';\n+\n+function useIsReportEnabled(reportType: SupportedReports): boolean {\n+ return useSelector((state) => state.enabledReports[reportType]);\n+}\n+\n+export { useIsReportEnabled };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/crash.react.js",
"new_path": "native/crash.react.js",
"diff": "@@ -32,6 +32,7 @@ import {\nuseServerCall,\nuseDispatchActionPromise,\n} from 'lib/utils/action-utils';\n+import { useIsReportEnabled } from 'lib/utils/report-utils';\nimport {\nsanitizeReduxReport,\ntype ReduxCrashReport,\n@@ -42,7 +43,7 @@ import Button from './components/button.react';\nimport ConnectedStatusBar from './connected-status-bar.react';\nimport { persistConfig, codeVersion } from './redux/persist';\nimport { useSelector } from './redux/redux-utils';\n-import { useIsCrashReportingEnabled, wipeAndExit } from './utils/crash-utils';\n+import { wipeAndExit } from './utils/crash-utils';\nconst errorTitles = ['Oh no!!', 'Womp womp womp...'];\n@@ -274,7 +275,7 @@ export default React.memo<BaseProps>(function ConnectedCrash(props: BaseProps) {\nconst dispatchActionPromise = useDispatchActionPromise();\nconst callSendReport = useServerCall(sendReport);\nconst callLogOut = useServerCall(logOut);\n- const crashReportingEnabled = useIsCrashReportingEnabled();\n+ const crashReportingEnabled = useIsReportEnabled('crashReports');\nreturn (\n<Crash\n{...props}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/profile/toggle-crash-reports.react.js",
"new_path": "native/profile/toggle-crash-reports.react.js",
"diff": "@@ -5,14 +5,14 @@ import { Text, View, Switch } from 'react-native';\nimport { useDispatch } from 'react-redux';\nimport { updateReportsEnabledActionType } from 'lib/reducers/enabled-reports-reducer';\n+import { useIsReportEnabled } from 'lib/utils/report-utils';\nimport { useStyles } from '../themes/colors';\n-import { useIsCrashReportingEnabled } from '../utils/crash-utils';\nfunction ToggleCrashReports() {\nconst styles = useStyles(unboundStyles);\nconst dispatch = useDispatch();\n- const crashReportsEnabled = useIsCrashReportingEnabled();\n+ const crashReportsEnabled = useIsReportEnabled('crashReports');\nconst onCrashReportsToggled = React.useCallback(\n(value) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/utils/crash-utils.js",
"new_path": "native/utils/crash-utils.js",
"diff": "import AsyncStorage from '@react-native-community/async-storage';\nimport ExitApp from 'react-native-exit-app';\n-import { useSelector } from 'lib/utils/redux-utils';\nimport sleep from 'lib/utils/sleep';\nimport { navStateAsyncStorageKey } from '../navigation/persistance';\n@@ -18,8 +17,4 @@ async function wipeAndExit() {\nExitApp.exitApp();\n}\n-function useIsCrashReportingEnabled(): boolean {\n- return useSelector((state) => state.enabledReports.crashReports);\n-}\n-\n-export { wipeAndExit, useIsCrashReportingEnabled };\n+export { wipeAndExit };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib][native] Introduce hook to check whether specified report type is enabled
Summary: Replace `useIsCrashReportingEnabled` with `useIsReportEnabled(reportType: SupportedReports)` to determine whether particular report type is enabled.
Test Plan: Checked via redux dev tools that `toggle-crash-reports` component continues to work as expected.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1452 |
129,187 | 24.06.2021 15:23:57 | 14,400 | 98a9847c665b9ba881c7e57bb6cc6f2db0e948ea | [server] Make usernameOrEmail optional in log in input validator
Summary: I accidentally took the `t.maybe` out in D1485.
Test Plan: Make sure log in works again
Reviewers: palys-swm, atul
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "server/src/responders/user-responders.js",
"new_path": "server/src/responders/user-responders.js",
"diff": "@@ -177,7 +177,7 @@ async function accountCreationResponder(\nconst logInRequestInputValidator = tShape({\nusername: t.maybe(t.String),\n- usernameOrEmail: t.union([tEmail, tOldValidUsername]),\n+ usernameOrEmail: t.maybe(t.union([tEmail, tOldValidUsername])),\npassword: tPassword,\nwatchedIDs: t.list(t.String),\ncalendarQuery: t.maybe(entryQueryInputValidator),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Make usernameOrEmail optional in log in input validator
Summary: I accidentally took the `t.maybe` out in D1485.
Test Plan: Make sure log in works again
Reviewers: palys-swm, atul
Reviewed By: atul
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1494 |
129,184 | 24.06.2021 16:00:52 | 14,400 | c00ebedc3aee097edd5ef98f22aa8dd12325f65a | [fix] Decrement redux version 27 -> 26
Summary: Merged `enabledReports` migration with the previous migration but missed decrementing redux version before landing.
Test Plan: na
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/redux/persist.js",
"new_path": "native/redux/persist.js",
"diff": "@@ -250,7 +250,7 @@ const persistConfig = {\n'frozen',\n],\ndebug: __DEV__,\n- version: 27,\n+ version: 26,\nmigrate: createMigrate(migrations, { debug: __DEV__ }),\ntimeout: __DEV__ ? 0 : undefined,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [fix] Decrement redux version 27 -> 26
Summary: Merged `enabledReports` migration with the previous migration but missed decrementing redux version before landing.
Test Plan: na
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1495 |
129,184 | 24.06.2021 12:32:56 | 14,400 | 9ac8873d06524b3863091f02dad440d8c585873f | [native] Add report opt-in toggles to `privacy-preferences`
Summary: Here's how it looks:
Test Plan: Verified expected behavior with Redux dev tools
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/profile/privacy-preferences.react.js",
"new_path": "native/profile/privacy-preferences.react.js",
"diff": "@@ -4,7 +4,7 @@ import * as React from 'react';\nimport { View, Text, ScrollView } from 'react-native';\nimport { useStyles } from '../themes/colors';\n-import ToggleCrashReports from './toggle-crash-reports.react';\n+import ToggleReport from './toggle-report.react';\nfunction PrivacyPreferences(): React.Node {\nconst styles = useStyles(unboundStyles);\n@@ -14,9 +14,22 @@ function PrivacyPreferences(): React.Node {\ncontentContainerStyle={styles.scrollViewContentContainer}\nstyle={styles.scrollView}\n>\n- <Text style={styles.header}>CRASH REPORTS</Text>\n+ <Text style={styles.header}>REPORTS</Text>\n<View style={styles.section}>\n- <ToggleCrashReports />\n+ <View style={styles.submenuButton}>\n+ <Text style={styles.submenuText}>Toggle crash reports</Text>\n+ <ToggleReport reportType=\"crashReports\" />\n+ </View>\n+\n+ <View style={styles.submenuButton}>\n+ <Text style={styles.submenuText}>Toggle media reports</Text>\n+ <ToggleReport reportType=\"mediaReports\" />\n+ </View>\n+\n+ <View style={styles.submenuButton}>\n+ <Text style={styles.submenuText}>Toggle inconsistency reports</Text>\n+ <ToggleReport reportType=\"inconsistencyReports\" />\n+ </View>\n</View>\n</ScrollView>\n);\n@@ -44,6 +57,17 @@ const unboundStyles = {\npaddingBottom: 3,\npaddingHorizontal: 24,\n},\n+ submenuButton: {\n+ flexDirection: 'row',\n+ paddingHorizontal: 24,\n+ paddingVertical: 10,\n+ alignItems: 'center',\n+ },\n+ submenuText: {\n+ color: 'panelForegroundLabel',\n+ flex: 1,\n+ fontSize: 16,\n+ },\n};\nexport default PrivacyPreferences;\n"
},
{
"change_type": "DELETE",
"old_path": "native/profile/toggle-crash-reports.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import * as React from 'react';\n-import { Text, View, Switch } from 'react-native';\n-import { useDispatch } from 'react-redux';\n-\n-import { updateReportsEnabledActionType } from 'lib/reducers/enabled-reports-reducer';\n-import { useIsReportEnabled } from 'lib/utils/report-utils';\n-\n-import { useStyles } from '../themes/colors';\n-\n-function ToggleCrashReports() {\n- const styles = useStyles(unboundStyles);\n- const dispatch = useDispatch();\n- const crashReportsEnabled = useIsReportEnabled('crashReports');\n-\n- const onCrashReportsToggled = React.useCallback(\n- (value) => {\n- dispatch({\n- type: updateReportsEnabledActionType,\n- payload: { crashReports: value },\n- });\n- },\n- [dispatch],\n- );\n-\n- return (\n- <View style={styles.submenuButton}>\n- <Text style={styles.submenuText}>Send crash reports</Text>\n- <Switch\n- value={crashReportsEnabled}\n- onValueChange={onCrashReportsToggled}\n- />\n- </View>\n- );\n-}\n-\n-const unboundStyles = {\n- submenuButton: {\n- flexDirection: 'row',\n- paddingHorizontal: 24,\n- paddingVertical: 10,\n- alignItems: 'center',\n- },\n- submenuText: {\n- color: 'panelForegroundLabel',\n- flex: 1,\n- fontSize: 16,\n- },\n-};\n-\n-export default ToggleCrashReports;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/profile/toggle-report.react.js",
"diff": "+// @flow\n+\n+import * as React from 'react';\n+import { Switch } from 'react-native';\n+import { useDispatch } from 'react-redux';\n+\n+import { updateReportsEnabledActionType } from 'lib/reducers/enabled-reports-reducer';\n+import { type SupportedReports } from 'lib/types/enabled-reports';\n+import { useIsReportEnabled } from 'lib/utils/report-utils';\n+\n+type Props = {|\n+ +reportType: SupportedReports,\n+|};\n+function ToggleReport(props: Props): React.Node {\n+ const dispatch = useDispatch();\n+ const { reportType } = props;\n+ const isReportEnabled = useIsReportEnabled(reportType);\n+\n+ const onReportToggled = React.useCallback(\n+ (value) => {\n+ dispatch({\n+ type: updateReportsEnabledActionType,\n+ payload: { [(reportType: string)]: value },\n+ });\n+ },\n+ [dispatch, reportType],\n+ );\n+\n+ return <Switch value={isReportEnabled} onValueChange={onReportToggled} />;\n+}\n+\n+export default ToggleReport;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Add report opt-in toggles to `privacy-preferences`
Summary: Here's how it looks: https://blob.sh/atul/privacy-preferences-screen.png
Test Plan: Verified expected behavior with Redux dev tools
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1491 |
129,187 | 25.06.2021 10:57:24 | 14,400 | 95a2d238c74b857c3b72796b13b9ac7ee7327760 | [server] Rename squadbot to commbot
Summary: This diff is just simple renames
Test Plan: Flow
Reviewers: atul
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/facts/bots.json",
"new_path": "lib/facts/bots.json",
"diff": "{\n- \"squadbot\": {\n+ \"commbot\": {\n\"userID\": \"5\",\n\"staffThreadID\": \"83794\"\n}\n"
},
{
"change_type": "RENAME",
"old_path": "server/src/bots/squadbot.js",
"new_path": "server/src/bots/commbot.js",
"diff": "@@ -8,15 +8,15 @@ import { threadTypes } from 'lib/types/thread-types';\nimport { createThread } from '../creators/thread-creator';\nimport { createBotViewer } from '../session/bots';\n-const { squadbot } = bots;\n+const { commbot } = bots;\n-async function createSquadbotThread(userID: string): Promise<string> {\n- const squadbotViewer = createBotViewer(squadbot.userID);\n+async function createCommbotThread(userID: string): Promise<string> {\n+ const commbotViewer = createBotViewer(commbot.userID);\nconst newThreadRequest = {\ntype: threadTypes.PERSONAL,\ninitialMemberIDs: [userID],\n};\n- const result = await createThread(squadbotViewer, newThreadRequest, {\n+ const result = await createThread(commbotViewer, newThreadRequest, {\nforceAddMembers: true,\n});\nconst { newThreadID } = result;\n@@ -27,4 +27,4 @@ async function createSquadbotThread(userID: string): Promise<string> {\nreturn newThreadID;\n}\n-export { createSquadbotThread };\n+export { createCommbotThread };\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/account-creator.js",
"new_path": "server/src/creators/account-creator.js",
"diff": "@@ -37,7 +37,7 @@ import {\nprivateThreadDescription,\n} from './thread-creator';\n-const { squadbot } = bots;\n+const { commbot } = bots;\nconst ashoatMessages = [\n'welcome to SquadCal! thanks for helping to test the alpha.',\n@@ -142,7 +142,7 @@ async function createAccount(\nconst privateMessageDatas = privateMessages.map((message) => ({\ntype: messageTypes.TEXT,\nthreadID: privateThreadID,\n- creatorID: squadbot.userID,\n+ creatorID: commbot.userID,\ntime: messageTime++,\ntext: message,\n}));\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/report-creator.js",
"new_path": "server/src/creators/report-creator.js",
"diff": "@@ -32,7 +32,7 @@ import createIDs from './id-creator';\nimport createMessages from './message-creator';\nconst { baseDomain, basePath } = getAppURLFacts();\n-const { squadbot } = bots;\n+const { commbot } = bots;\nasync function createReport(\nviewer: Viewer,\n@@ -98,11 +98,11 @@ async function sendSquadbotMessage(\nreturn;\n}\nconst time = Date.now();\n- await createMessages(createBotViewer(squadbot.userID), [\n+ await createMessages(createBotViewer(commbot.userID), [\n{\ntype: messageTypes.TEXT,\n- threadID: squadbot.staffThreadID,\n- creatorID: squadbot.userID,\n+ threadID: commbot.staffThreadID,\n+ creatorID: commbot.userID,\ntime,\ntext: message,\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/thread-creator.js",
"new_path": "server/src/creators/thread-creator.js",
"diff": "@@ -47,7 +47,7 @@ import {\n} from './role-creator';\nimport type { UpdatesForCurrentSession } from './update-creator';\n-const { squadbot } = bots;\n+const { commbot } = bots;\nconst privateThreadDescription =\n'This is your private thread, ' +\n@@ -495,7 +495,7 @@ function createPrivateThread(\ntype: threadTypes.PRIVATE,\nname: username,\ndescription: privateThreadDescription,\n- ghostMemberIDs: [squadbot.userID],\n+ ghostMemberIDs: [commbot.userID],\n},\n{\nforceAddMembers: true,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/add-staff.js",
"new_path": "server/src/scripts/add-staff.js",
"diff": "@@ -10,9 +10,9 @@ const newStaffIDs = ['518252'];\nasync function addStaff() {\nawait updateThread(\n- createScriptViewer(bots.squadbot.userID),\n+ createScriptViewer(bots.commbot.userID),\n{\n- threadID: bots.squadbot.staffThreadID,\n+ threadID: bots.commbot.staffThreadID,\nchanges: {\nnewMemberIDs: newStaffIDs,\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/create-db.js",
"new_path": "server/src/scripts/create-db.js",
"diff": "@@ -307,15 +307,15 @@ async function createTables() {\n}\nasync function createUsers() {\n- const [user1, user2] = sortIDs(bots.squadbot.userID, ashoat.id);\n+ const [user1, user2] = sortIDs(bots.commbot.userID, ashoat.id);\nawait dbQuery(SQL`\nINSERT INTO ids (id, table_name)\nVALUES\n- (${bots.squadbot.userID}, 'users'),\n+ (${bots.commbot.userID}, 'users'),\n(${ashoat.id}, 'users');\nINSERT INTO users (id, username, hash, avatar, creation_time)\nVALUES\n- (${bots.squadbot.userID}, 'squadbot', '', NULL, 1530049900980),\n+ (${bots.commbot.userID}, 'commbot', '', NULL, 1530049900980),\n(${ashoat.id}, 'ashoat', '', NULL, 1463588881886);\nINSERT INTO relationships_undirected (user1, user2, status)\nVALUES (${user1}, ${user2}, ${undirectedStatus.KNOW_OF});\n@@ -329,7 +329,7 @@ async function createThreads() {\nINSERT INTO ids (id, table_name)\nVALUES\n(${genesis.id}, 'threads'),\n- (${bots.squadbot.staffThreadID}, 'threads');\n+ (${bots.commbot.staffThreadID}, 'threads');\n`);\nconst ashoatViewer = createScriptViewer(ashoat.id);\n@@ -340,17 +340,17 @@ async function createThreads() {\ntype: threadTypes.GENESIS,\nname: genesis.name,\ndescription: genesis.description,\n- initialMemberIDs: [bots.squadbot.userID],\n+ initialMemberIDs: [bots.commbot.userID],\n},\ncreateThreadOptions,\n);\nawait Promise.all([insertIDsPromise, createGenesisPromise]);\n- const squadbotViewer = createScriptViewer(bots.squadbot.userID);\n+ const commbotViewer = createScriptViewer(bots.commbot.userID);\nawait createThread(\n- squadbotViewer,\n+ commbotViewer,\n{\n- id: bots.squadbot.staffThreadID,\n+ id: bots.commbot.staffThreadID,\ntype: threadTypes.COMMUNITY_SECRET_SUBTHREAD,\ninitialMemberIDs: [ashoat.id],\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/fix-new-thread-types.js",
"new_path": "server/src/scripts/fix-new-thread-types.js",
"diff": "@@ -100,7 +100,7 @@ async function fixNewThreadTypes() {\n});\n}\n- const viewer = createScriptViewer(bots.squadbot.userID);\n+ const viewer = createScriptViewer(bots.commbot.userID);\nwhile (updateThreadRequests.length > 0) {\nconst batch = updateThreadRequests.splice(0, batchSize);\nawait Promise.all(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/rename-user.js",
"new_path": "server/src/scripts/rename-user.js",
"diff": "@@ -8,8 +8,8 @@ import { fetchKnownUserInfos } from '../fetchers/user-fetchers';\nimport { createScriptViewer } from '../session/scripts';\nimport { main } from './utils';\n-const userID = '518252';\n-const newUsername = 'atul';\n+const userID = '5';\n+const newUsername = 'commbot';\nasync function renameUser() {\nconst [adjacentUsers] = await Promise.all([\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/sidebar-know-of-migration.js",
"new_path": "server/src/scripts/sidebar-know-of-migration.js",
"diff": "@@ -32,7 +32,7 @@ async function updateThreads(threadType: ThreadType) {\nconst [result] = await dbQuery(fetchThreads);\nconst threadIDs = result.map((row) => row.id.toString());\n- const viewer = createScriptViewer(bots.squadbot.userID);\n+ const viewer = createScriptViewer(bots.commbot.userID);\nwhile (threadIDs.length > 0) {\nconst batch = threadIDs.splice(0, batchSize);\nconst membershipRows = [];\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/scripts/soft-launch-migration.js",
"new_path": "server/src/scripts/soft-launch-migration.js",
"diff": "@@ -156,7 +156,7 @@ async function convertExistingCommunities() {\n`;\nconst [convertToCommunity] = await dbQuery(communityQuery);\n- const botViewer = createScriptViewer(bots.squadbot.userID);\n+ const botViewer = createScriptViewer(bots.commbot.userID);\nawait convertThreads(\nbotViewer,\nconvertToCommunity,\n@@ -216,7 +216,7 @@ async function convertAnnouncementCommunities() {\nannouncementCommunityQuery,\n);\n- const botViewer = createScriptViewer(bots.squadbot.userID);\n+ const botViewer = createScriptViewer(bots.commbot.userID);\nawait convertThreads(\nbotViewer,\nconvertToAnnouncementCommunity,\n@@ -235,7 +235,7 @@ async function convertAnnouncementSubthreads() {\nannouncementSubthreadQuery,\n);\n- const botViewer = createScriptViewer(bots.squadbot.userID);\n+ const botViewer = createScriptViewer(bots.commbot.userID);\nawait convertThreads(\nbotViewer,\nconvertToAnnouncementSubthread,\n@@ -254,7 +254,7 @@ async function fixThreadsWithMissingParent() {\nthreadsWithMissingParentQuery,\n);\n- const botViewer = createScriptViewer(bots.squadbot.userID);\n+ const botViewer = createScriptViewer(bots.commbot.userID);\nwhile (threadsWithMissingParentResult.length > 0) {\nconst batch = threadsWithMissingParentResult.splice(0, batchSize);\nawait Promise.all(\n@@ -284,7 +284,7 @@ async function fixPersonalThreadsWithMissingMembers() {\n`;\nconst [missingMembers] = await dbQuery(missingMembersQuery);\n- const botViewer = createScriptViewer(bots.squadbot.userID);\n+ const botViewer = createScriptViewer(bots.commbot.userID);\nfor (const row of missingMembers) {\nconsole.log(`fixing ${JSON.stringify(row)} with missing member`);\nawait updateThread(\n@@ -311,7 +311,7 @@ async function moveThreadsToGenesis() {\n`;\nconst [noParentThreads] = await dbQuery(noParentQuery);\n- const botViewer = createScriptViewer(bots.squadbot.userID);\n+ const botViewer = createScriptViewer(bots.commbot.userID);\nwhile (noParentThreads.length > 0) {\nconst batch = noParentThreads.splice(0, batchSize);\nawait Promise.all(\n@@ -370,7 +370,7 @@ async function clearMembershipPermissions() {\nreturn;\n}\n- const botViewer = createScriptViewer(bots.squadbot.userID);\n+ const botViewer = createScriptViewer(bots.commbot.userID);\nfor (const row of membershipPermissionResult) {\nconst threadID = row.thread.toString();\nconsole.log(`clearing membership permissions for ${threadID}`);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/updaters/thread-permission-updaters.js",
"new_path": "server/src/updaters/thread-permission-updaters.js",
"diff": "@@ -1116,7 +1116,7 @@ async function recalculateAllThreadPermissions() {\n// If the changeset resulting from the parent call isn't committed before the\n// calculation is done for the child, the calculation done for the child can\n// be incorrect.\n- const viewer = createScriptViewer(bots.squadbot.userID);\n+ const viewer = createScriptViewer(bots.commbot.userID);\nfor (const row of result) {\nconst threadID = row.id.toString();\nconst changeset = await recalculateThreadPermissions(threadID);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Rename squadbot to commbot
Summary: This diff is just simple renames
Test Plan: Flow
Reviewers: atul
Reviewed By: atul
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1500 |
129,184 | 25.06.2021 12:21:37 | 14,400 | 67c0950df61537151d838036b43ec65f003f060c | [eslint] Remove `*.cjs` from `lintstaged`
Summary: na
Test Plan: na
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": ".lintstagedrc.js",
"new_path": ".lintstagedrc.js",
"diff": "@@ -3,7 +3,7 @@ const { CLIEngine } = require('eslint');\nconst cli = new CLIEngine({});\nmodule.exports = {\n- '*.{js,mjs,cjs}': function eslint(files) {\n+ '*.{js,mjs}': function eslint(files) {\nreturn (\n'eslint --cache --fix --max-warnings=0 ' +\nfiles.filter((file) => !cli.isPathIgnored(file)).join(' ')\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [eslint] Remove `*.cjs` from `lintstaged`
Summary: na
Test Plan: na
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1501 |
129,184 | 25.06.2021 12:34:56 | 14,400 | cb386f9f032f86b3faecdd10c22dd0228af2d426 | [server] `dev` -> `development`
Summary: Renamed `NODE_ENV` from `dev` -> `development` to keep it consistent across lib/web/server/native
Test Plan: `console.log`ged before conditionals involving `NODE_ENV` and made sure value matched up with expectation
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/webpack/shared.cjs",
"new_path": "lib/webpack/shared.cjs",
"diff": "@@ -162,7 +162,7 @@ function createDevBrowserConfig(baseConfig, babelConfig) {\n...browserConfig.plugins,\nnew webpack.DefinePlugin({\n'process.env': {\n- NODE_ENV: JSON.stringify('dev'),\n+ NODE_ENV: JSON.stringify('development'),\nBROWSER: true,\n},\n}),\n"
},
{
"change_type": "MODIFY",
"old_path": "server/package.json",
"new_path": "server/package.json",
"diff": "\"update-geoip\": \"yarn script dist/scripts/update-geoip.js\",\n\"prod\": \"node --trace-warnings --experimental-json-modules --loader=./loader.mjs --experimental-specifier-resolution=node dist/server\",\n\"dev-rsync\": \"yarn --silent chokidar --initial --silent -s 'src/**/*.json' 'src/**/*.cjs' -c 'yarn rsync > /dev/null 2>&1'\",\n- \"dev\": \"yarn concurrently --names=\\\"BABEL,RSYNC,NODEM\\\" -c \\\"bgBlue.bold,bgMagenta.bold,bgGreen.bold\\\" \\\"yarn babel-build --watch\\\" \\\"yarn dev-rsync\\\" \\\". bash/source-nvm.sh && NODE_ENV=dev nodemon -e js,json,cjs --watch dist --experimental-json-modules --loader=./loader.mjs --experimental-specifier-resolution=node dist/server\\\"\",\n- \"script\": \". bash/source-nvm.sh && NODE_ENV=dev node --experimental-json-modules --loader=./loader.mjs --experimental-specifier-resolution=node\",\n+ \"dev\": \"yarn concurrently --names=\\\"BABEL,RSYNC,NODEM\\\" -c \\\"bgBlue.bold,bgMagenta.bold,bgGreen.bold\\\" \\\"yarn babel-build --watch\\\" \\\"yarn dev-rsync\\\" \\\". bash/source-nvm.sh && NODE_ENV=development nodemon -e js,json,cjs --watch dist --experimental-json-modules --loader=./loader.mjs --experimental-specifier-resolution=node dist/server\\\"\",\n+ \"script\": \". bash/source-nvm.sh && NODE_ENV=development node --experimental-json-modules --loader=./loader.mjs --experimental-specifier-resolution=node\",\n\"test\": \"jest\"\n},\n\"devDependencies\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/push/utils.js",
"new_path": "server/src/push/utils.js",
"diff": "@@ -72,7 +72,7 @@ async function apnPush(\ndeviceTokens: $ReadOnlyArray<string>,\n) {\nconst apnProvider = await getAPNProvider();\n- if (!apnProvider && process.env.NODE_ENV === 'dev') {\n+ if (!apnProvider && process.env.NODE_ENV === 'development') {\nconsole.log('no server/secrets/apn_config.json so ignoring notifs');\nreturn { success: true };\n}\n@@ -105,7 +105,7 @@ async function fcmPush(\ncollapseKey: ?string,\n) {\nconst initialized = await initializeFCMApp();\n- if (!initialized && process.env.NODE_ENV === 'dev') {\n+ if (!initialized && process.env.NODE_ENV === 'development') {\nconsole.log('no server/secrets/fcm_config.json so ignoring notifs');\nreturn { success: true };\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/landing-handler.js",
"new_path": "server/src/responders/landing-handler.js",
"diff": "@@ -41,7 +41,7 @@ async function getAssetInfo() {\nif (assetInfo) {\nreturn assetInfo;\n}\n- if (process.env.NODE_ENV === 'dev') {\n+ if (process.env.NODE_ENV === 'development') {\nconst fontsURL = await getFontsURL();\nassetInfo = {\njsURL: 'http://localhost:8082/dev.build.js',\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/responders/website-responders.js",
"new_path": "server/src/responders/website-responders.js",
"diff": "@@ -68,7 +68,7 @@ async function getAssetInfo() {\nif (assetInfo) {\nreturn assetInfo;\n}\n- if (process.env.NODE_ENV === 'dev') {\n+ if (process.env.NODE_ENV === 'development') {\nconst fontsURL = await getFontsURL();\nassetInfo = {\njsURL: 'http://localhost:8080/dev.build.js',\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/server.js",
"new_path": "server/src/server.js",
"diff": "@@ -43,7 +43,7 @@ if (cluster.isMaster) {\nconst router = express.Router();\nrouter.use('/images', express.static('images'));\nrouter.use('/commlanding/images', express.static('images'));\n- if (process.env.NODE_ENV === 'dev') {\n+ if (process.env.NODE_ENV === 'development') {\nrouter.use('/fonts', express.static('fonts'));\nrouter.use('/commlanding/fonts', express.static('fonts'));\n}\n@@ -59,7 +59,7 @@ if (cluster.isMaster) {\n),\n);\nconst compiledFolderOptions =\n- process.env.NODE_ENV === 'dev'\n+ process.env.NODE_ENV === 'development'\n? undefined\n: { maxAge: '1y', immutable: true };\nrouter.use(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] `dev` -> `development`
Summary: Renamed `NODE_ENV` from `dev` -> `development` to keep it consistent across lib/web/server/native
Test Plan: `console.log`ged before conditionals involving `NODE_ENV` and made sure value matched up with expectation
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1502 |
129,184 | 25.06.2021 12:37:06 | 14,400 | b7b7ae58a6e177fc7c694241f92ce229ec648224 | [web][lib] Add `process` to `.eslint:global`
Summary: na
Test Plan: no more `eslint` issues
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/.eslintrc.json",
"new_path": "lib/.eslintrc.json",
"diff": "{\n\"env\": {\n\"browser\": true\n+ },\n+ \"globals\": {\n+ \"process\": true\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/.eslintrc.json",
"new_path": "web/.eslintrc.json",
"diff": "{\n\"env\": {\n\"browser\": true\n+ },\n+ \"globals\": {\n+ \"process\": true\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web][lib] Add `process` to `.eslint:global`
Summary: na
Test Plan: no more `eslint` issues
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1503 |
129,184 | 24.06.2021 14:38:09 | 14,400 | 6d265f29932113710e18b80c1ccd628b20a57a86 | [lib] Reset `enabledReports` on logout/account deletion/session invalidation
Summary: For non-dev/staff, disable all reports on logout/account deletion/session invalidation. For dev/staff, enable all reports on login
Test Plan: Logged in/out and checked redux dev tools to verify state changed as expected
Reviewers: ashoat
Subscribers: KatPo, palys-swm, Adrian | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/enabled-reports-reducer.js",
"new_path": "lib/reducers/enabled-reports-reducer.js",
"diff": "// @flow\n-import type { EnabledReports } from '../types/enabled-reports';\n+import {\n+ logOutActionTypes,\n+ deleteAccountActionTypes,\n+ logInActionTypes,\n+} from '../actions/user-actions';\n+import { isStaff } from '../shared/user-utils';\n+import {\n+ type EnabledReports,\n+ defaultEnabledReports,\n+ defaultDevEnabledReports,\n+} from '../types/enabled-reports';\nimport type { BaseAction } from '../types/redux-types';\n+import { setNewSessionActionType } from '../utils/action-utils';\n+import { isDev } from '../utils/dev-utils';\nexport const updateReportsEnabledActionType = 'UPDATE_REPORTS_ENABLED';\n@@ -11,6 +23,17 @@ export default function reduceEnabledReports(\n): EnabledReports {\nif (action.type === updateReportsEnabledActionType) {\nreturn { ...state, ...action.payload };\n+ } else if (\n+ action.type === logOutActionTypes.success ||\n+ action.type === deleteAccountActionTypes.success ||\n+ (action.type === setNewSessionActionType &&\n+ action.payload.sessionChange.cookieInvalidated)\n+ ) {\n+ return isDev ? defaultDevEnabledReports : defaultEnabledReports;\n+ } else if (action.type === logInActionTypes.success) {\n+ return isStaff(action.payload.currentUserInfo.id) || isDev\n+ ? defaultDevEnabledReports\n+ : defaultEnabledReports;\n}\nreturn state;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/enabled-reports.js",
"new_path": "lib/types/enabled-reports.js",
"diff": "@@ -13,3 +13,9 @@ export const defaultEnabledReports: EnabledReports = {\ninconsistencyReports: false,\nmediaReports: false,\n};\n+\n+export const defaultDevEnabledReports: EnabledReports = {\n+ crashReports: true,\n+ inconsistencyReports: true,\n+ mediaReports: true,\n+};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/utils/dev-utils.js",
"diff": "+// @flow\n+\n+export const isDev = process.env.NODE_ENV === 'development';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Reset `enabledReports` on logout/account deletion/session invalidation
Summary: For non-dev/staff, disable all reports on logout/account deletion/session invalidation. For dev/staff, enable all reports on login
Test Plan: Logged in/out and checked redux dev tools to verify state changed as expected
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, palys-swm, Adrian
Differential Revision: https://phabricator.ashoat.com/D1492 |
129,190 | 28.06.2021 08:50:49 | -7,200 | 0be689e0d7e83665f4af6712c0582aa3064f8c6c | [native] Add removeAllDrafts
Summary: Add `removeAllDrafts` functionality to comm core module, so we can clear the drafts.
Test Plan: call `removeAllDrafts` and see if they've been cleaned up or not.
Reviewers: palys-swm, ashoat
Subscribers: ashoat, KatPo, palys-swm, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h",
"new_path": "native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h",
"diff": "@@ -20,6 +20,7 @@ public:\nvirtual void updateDraft(std::string key, std::string text) const = 0;\nvirtual bool moveDraft(std::string oldKey, std::string newKey) const = 0;\nvirtual std::vector<Draft> getAllDrafts() const = 0;\n+ virtual void removeAllDrafts() const = 0;\n};\n} // namespace comm\n"
},
{
"change_type": "MODIFY",
"old_path": "native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp",
"new_path": "native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp",
"diff": "@@ -76,4 +76,8 @@ std::vector<Draft> SQLiteQueryExecutor::getAllDrafts() const {\nreturn SQLiteQueryExecutor::getStorage().get_all<Draft>();\n}\n+void SQLiteQueryExecutor::removeAllDrafts() const {\n+ SQLiteQueryExecutor::getStorage().remove_all<Draft>();\n+}\n+\n} // namespace comm\n"
},
{
"change_type": "MODIFY",
"old_path": "native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h",
"new_path": "native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h",
"diff": "@@ -19,6 +19,7 @@ public:\nvoid updateDraft(std::string key, std::string text) const override;\nbool moveDraft(std::string oldKey, std::string newKey) const override;\nstd::vector<Draft> getAllDrafts() const override;\n+ void removeAllDrafts() const override;\n};\n} // namespace comm\n"
},
{
"change_type": "MODIFY",
"old_path": "native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp",
"new_path": "native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp",
"diff": "@@ -127,6 +127,28 @@ jsi::Value CommCoreModule::getAllDrafts(jsi::Runtime &rt) {\n});\n}\n+jsi::Value CommCoreModule::removeAllDrafts(jsi::Runtime &rt) {\n+ return createPromiseAsJSIValue(\n+ rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {\n+ taskType job = [=, &innerRt]() {\n+ std::string error;\n+ try {\n+ DatabaseManager::getQueryExecutor().removeAllDrafts();\n+ } catch (std::system_error &e) {\n+ error = e.what();\n+ }\n+ this->jsInvoker_->invokeAsync([=, &innerRt]() {\n+ if (error.size()) {\n+ promise->reject(error);\n+ return;\n+ }\n+ promise->resolve(jsi::Value::undefined());\n+ });\n+ };\n+ this->databaseThread.scheduleTask(job);\n+ });\n+}\n+\nCommCoreModule::CommCoreModule(\nstd::shared_ptr<facebook::react::CallInvoker> jsInvoker)\n: facebook::react::CommCoreModuleSchemaCxxSpecJSI(jsInvoker),\n"
},
{
"change_type": "MODIFY",
"old_path": "native/cpp/CommonCpp/NativeModules/CommCoreModule.h",
"new_path": "native/cpp/CommonCpp/NativeModules/CommCoreModule.h",
"diff": "@@ -18,6 +18,7 @@ class CommCoreModule : public facebook::react::CommCoreModuleSchemaCxxSpecJSI {\nconst jsi::String &oldKey,\nconst jsi::String &newKey) override;\njsi::Value getAllDrafts(jsi::Runtime &rt) override;\n+ jsi::Value removeAllDrafts(jsi::Runtime &rt) override;\npublic:\nCommCoreModule(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/cpp/CommonCpp/NativeModules/NativeModules.cpp",
"new_path": "native/cpp/CommonCpp/NativeModules/NativeModules.cpp",
"diff": "@@ -44,6 +44,14 @@ static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllDrafts(\nreturn static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)\n->getAllDrafts(rt);\n}\n+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeAllDrafts(\n+ jsi::Runtime &rt,\n+ TurboModule &turboModule,\n+ const jsi::Value *args,\n+ size_t count) {\n+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)\n+ ->removeAllDrafts(rt);\n+}\nCommCoreModuleSchemaCxxSpecJSI::CommCoreModuleSchemaCxxSpecJSI(\nstd::shared_ptr<CallInvoker> jsInvoker)\n@@ -56,6 +64,8 @@ CommCoreModuleSchemaCxxSpecJSI::CommCoreModuleSchemaCxxSpecJSI(\n2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_moveDraft};\nmethodMap_[\"getAllDrafts\"] = MethodMetadata{\n0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllDrafts};\n+ methodMap_[\"removeAllDrafts\"] = MethodMetadata{\n+ 0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeAllDrafts};\n}\n} // namespace react\n"
},
{
"change_type": "MODIFY",
"old_path": "native/cpp/CommonCpp/NativeModules/NativeModules.h",
"new_path": "native/cpp/CommonCpp/NativeModules/NativeModules.h",
"diff": "@@ -26,6 +26,7 @@ public:\nconst jsi::String &oldKey,\nconst jsi::String &newKey) = 0;\nvirtual jsi::Value getAllDrafts(jsi::Runtime &rt) = 0;\n+ virtual jsi::Value removeAllDrafts(jsi::Runtime &rt) = 0;\n};\n} // namespace react\n"
},
{
"change_type": "MODIFY",
"old_path": "native/data/core-module-shim.js",
"new_path": "native/data/core-module-shim.js",
"diff": "@@ -12,6 +12,7 @@ if (!global.CommCoreModule) {\nupdateDraft: () => Promise.resolve(false),\nmoveDraft: () => Promise.resolve(false),\ngetAllDrafts: () => Promise.resolve([]),\n+ removeAllDrafts: () => Promise.resolve(),\n};\nglobal.CommCoreModule = SpecImpl;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/schema/CommCoreModuleSchema.js",
"new_path": "native/schema/CommCoreModuleSchema.js",
"diff": "@@ -15,6 +15,7 @@ export interface Spec extends TurboModule {\n+updateDraft: (draft: Draft) => Promise<boolean>;\n+moveDraft: (oldKey: string, newKey: string) => Promise<boolean>;\n+getAllDrafts: () => Promise<$ReadOnlyArray<Draft>>;\n+ +removeAllDrafts: () => Promise<void>;\n}\nexport default TurboModuleRegistry.getEnforcing<Spec>('CommTurboModule');\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Add removeAllDrafts
Summary: Add `removeAllDrafts` functionality to comm core module, so we can clear the drafts.
Test Plan: call `removeAllDrafts` and see if they've been cleaned up or not.
Reviewers: palys-swm, ashoat
Reviewed By: ashoat
Subscribers: ashoat, KatPo, palys-swm, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1429 |
129,191 | 11.06.2021 11:32:07 | -7,200 | f5045ed507d86b67475042ba3146ebe1feb5870a | [native] Create chat context interface
Summary: Create an interface with one function which measures messages heights and returns a promise with the result
Test Plan: Tested with other diffs
Reviewers: ashoat
Subscribers: KatPo, Adrian, atul | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/chat-context.js",
"diff": "+// @flow\n+\n+import * as React from 'react';\n+\n+import type { ChatMessageItem } from 'lib/selectors/chat-selectors';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+\n+import type { ChatMessageItemWithHeight } from './message-list-container.react';\n+\n+export type MessagesMeasurer = (\n+ $ReadOnlyArray<ChatMessageItem>,\n+ ThreadInfo,\n+ ($ReadOnlyArray<ChatMessageItemWithHeight>) => mixed,\n+) => void;\n+\n+export type ChatContextType = {|\n+ +registerMeasurer: () => {|\n+ +measure: MessagesMeasurer,\n+ +unregister: () => void,\n+ |},\n+|};\n+const ChatContext: React.Context<?ChatContextType> = React.createContext(null);\n+\n+export { ChatContext };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Create chat context interface
Summary: Create an interface with one function which measures messages heights and returns a promise with the result
Test Plan: Tested with other diffs
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1400 |
129,191 | 11.06.2021 12:21:23 | -7,200 | b5d54e09f81f55bd952c879e12b4c6690fa588fe | [native] Create chat context
Summary: Created an empty context which currently doesn't do anything useful
Test Plan: Tested with other diffs
Reviewers: ashoat
Subscribers: KatPo, Adrian, atul | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/chat-context-provider.react.js",
"diff": "+// @flow\n+\n+import * as React from 'react';\n+\n+import type { ChatMessageItem } from 'lib/selectors/chat-selectors';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+\n+import { ChatContext } from './chat-context';\n+import type { ChatMessageItemWithHeight } from './message-list-container.react';\n+\n+type BaseProps = {|\n+ +children: React.Node,\n+|};\n+type Props = {|\n+ ...BaseProps,\n+|};\n+\n+class ChatContextProvider extends React.PureComponent<Props> {\n+ registerMeasurer = () => ({\n+ measure: (\n+ // eslint-disable-next-line no-unused-vars\n+ messages: $ReadOnlyArray<ChatMessageItem>,\n+ // eslint-disable-next-line no-unused-vars\n+ threadInfo: ThreadInfo,\n+ // eslint-disable-next-line no-unused-vars\n+ onMessagesMeasured: ($ReadOnlyArray<ChatMessageItemWithHeight>) => mixed,\n+ ) => {},\n+ unregister: () => {},\n+ });\n+\n+ contextValue = {\n+ registerMeasurer: this.registerMeasurer,\n+ };\n+\n+ render() {\n+ return (\n+ <ChatContext.Provider value={this.contextValue}>\n+ {this.props.children}\n+ </ChatContext.Provider>\n+ );\n+ }\n+}\n+\n+export default React.memo<BaseProps>(function ConnectedChatContextProvider(\n+ props: BaseProps,\n+) {\n+ return <ChatContextProvider {...props} />;\n+});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Create chat context
Summary: Created an empty context which currently doesn't do anything useful
Test Plan: Tested with other diffs
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1401 |
129,191 | 21.06.2021 13:58:30 | -7,200 | baf29d85c44de621797074df17f69e5b89f69d83 | [native] Create ChatItemHeightMeasurer
Summary: Create a new component based on comment
Test Plan: Tested with D1403
Reviewers: ashoat
Subscribers: atul, Adrian, KatPo | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-context-provider.react.js",
"new_path": "native/chat/chat-context-provider.react.js",
"diff": "@@ -15,6 +15,15 @@ type Props = {|\n...BaseProps,\n|};\n+export type MeasurementTask = {|\n+ +messages: $ReadOnlyArray<ChatMessageItem>,\n+ +threadInfo: ThreadInfo,\n+ +onMessagesMeasured: (\n+ messagesWithHeight: $ReadOnlyArray<ChatMessageItemWithHeight>,\n+ ) => mixed,\n+ +measurerID: number,\n+|};\n+\nclass ChatContextProvider extends React.PureComponent<Props> {\nregisterMeasurer = () => ({\nmeasure: (\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/chat-item-height-measurer.react.js",
"diff": "+// @flow\n+\n+import invariant from 'invariant';\n+import * as React from 'react';\n+\n+import type { ChatMessageItem } from 'lib/selectors/chat-selectors';\n+import { messageID } from 'lib/shared/message-utils';\n+import { messageTypes } from 'lib/types/message-types';\n+\n+import NodeHeightMeasurer from '../components/node-height-measurer.react';\n+import { InputStateContext } from '../input/input-state';\n+import { useSelector } from '../redux/redux-utils';\n+import type { MeasurementTask } from './chat-context-provider.react';\n+import { chatMessageItemKey } from './chat-list.react';\n+import { composedMessageMaxWidthSelector } from './composed-message-width';\n+import { dummyNodeForRobotextMessageHeightMeasurement } from './inner-robotext-message.react';\n+import { dummyNodeForTextMessageHeightMeasurement } from './inner-text-message.react';\n+import { MessageListContextProvider } from './message-list-types';\n+import { multimediaMessageContentSizes } from './multimedia-message.react';\n+\n+type Props = {|\n+ +measurement: MeasurementTask,\n+|};\n+\n+const heightMeasurerKey = (item: ChatMessageItem) => {\n+ if (item.itemType !== 'message') {\n+ return null;\n+ }\n+ const { messageInfo } = item;\n+ if (messageInfo.type === messageTypes.TEXT) {\n+ return messageInfo.text;\n+ } else if (item.robotext && typeof item.robotext === 'string') {\n+ return item.robotext;\n+ }\n+ return null;\n+};\n+\n+const heightMeasurerDummy = (item: ChatMessageItem) => {\n+ invariant(\n+ item.itemType === 'message',\n+ 'NodeHeightMeasurer asked for dummy for non-message item',\n+ );\n+ const { messageInfo } = item;\n+ if (messageInfo.type === messageTypes.TEXT) {\n+ return dummyNodeForTextMessageHeightMeasurement(messageInfo.text);\n+ } else if (item.robotext && typeof item.robotext === 'string') {\n+ return dummyNodeForRobotextMessageHeightMeasurement(item.robotext);\n+ }\n+ invariant(false, 'NodeHeightMeasurer asked for dummy for non-text message');\n+};\n+\n+function ChatItemHeightMeasurer(props: Props) {\n+ const composedMessageMaxWidth = useSelector(composedMessageMaxWidthSelector);\n+ const inputState = React.useContext(InputStateContext);\n+ const inputStatePendingUploads = inputState?.pendingUploads;\n+\n+ const { measurement } = props;\n+ const { threadInfo } = measurement;\n+ const heightMeasurerMergeItem = React.useCallback(\n+ (item: ChatMessageItem, height: ?number) => {\n+ if (item.itemType !== 'message') {\n+ return item;\n+ }\n+\n+ const { messageInfo } = item;\n+ invariant(\n+ messageInfo.type !== messageTypes.SIDEBAR_SOURCE,\n+ 'Sidebar source messages should be replaced by sourceMessage before being measured',\n+ );\n+\n+ if (\n+ messageInfo.type === messageTypes.IMAGES ||\n+ messageInfo.type === messageTypes.MULTIMEDIA\n+ ) {\n+ // Conditional due to Flow...\n+ const localMessageInfo = item.localMessageInfo\n+ ? item.localMessageInfo\n+ : null;\n+ const id = messageID(messageInfo);\n+ const pendingUploads = inputStatePendingUploads?.[id];\n+ const sizes = multimediaMessageContentSizes(\n+ messageInfo,\n+ composedMessageMaxWidth,\n+ );\n+ return {\n+ itemType: 'message',\n+ messageShapeType: 'multimedia',\n+ messageInfo,\n+ localMessageInfo,\n+ threadInfo,\n+ startsConversation: item.startsConversation,\n+ startsCluster: item.startsCluster,\n+ endsCluster: item.endsCluster,\n+ threadCreatedFromMessage: item.threadCreatedFromMessage,\n+ pendingUploads,\n+ ...sizes,\n+ };\n+ }\n+\n+ invariant(\n+ height !== null && height !== undefined,\n+ 'height should be set',\n+ );\n+ if (messageInfo.type === messageTypes.TEXT) {\n+ // Conditional due to Flow...\n+ const localMessageInfo = item.localMessageInfo\n+ ? item.localMessageInfo\n+ : null;\n+ return {\n+ itemType: 'message',\n+ messageShapeType: 'text',\n+ messageInfo,\n+ localMessageInfo,\n+ threadInfo,\n+ startsConversation: item.startsConversation,\n+ startsCluster: item.startsCluster,\n+ endsCluster: item.endsCluster,\n+ threadCreatedFromMessage: item.threadCreatedFromMessage,\n+ contentHeight: height,\n+ };\n+ } else {\n+ invariant(\n+ typeof item.robotext === 'string',\n+ \"Flow can't handle our fancy types :(\",\n+ );\n+ return {\n+ itemType: 'message',\n+ messageShapeType: 'robotext',\n+ messageInfo,\n+ threadInfo,\n+ startsConversation: item.startsConversation,\n+ startsCluster: item.startsCluster,\n+ endsCluster: item.endsCluster,\n+ threadCreatedFromMessage: item.threadCreatedFromMessage,\n+ robotext: item.robotext,\n+ contentHeight: height,\n+ };\n+ }\n+ },\n+ [composedMessageMaxWidth, inputStatePendingUploads, threadInfo],\n+ );\n+\n+ return (\n+ <MessageListContextProvider\n+ threadID={threadInfo.id}\n+ key={measurement.measurerID}\n+ >\n+ <NodeHeightMeasurer\n+ listData={measurement.messages}\n+ itemToID={chatMessageItemKey}\n+ itemToMeasureKey={heightMeasurerKey}\n+ itemToDummy={heightMeasurerDummy}\n+ mergeItemWithHeight={heightMeasurerMergeItem}\n+ allHeightsMeasured={measurement.onMessagesMeasured}\n+ inputState={inputState}\n+ composedMessageMaxWidth={composedMessageMaxWidth}\n+ />\n+ </MessageListContextProvider>\n+ );\n+}\n+\n+export default React.memo<Props>(ChatItemHeightMeasurer);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Create ChatItemHeightMeasurer
Summary: Create a new component based on https://phabricator.ashoat.com/D1403#inline-7568 comment
Test Plan: Tested with D1403
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: atul, Adrian, KatPo
Differential Revision: https://phabricator.ashoat.com/D1431 |
129,191 | 11.06.2021 18:32:14 | -7,200 | b56af81e0773438016651b86235e279b2f844884 | [native] Use chat context provider
Summary: Wrap chat navigator with the new container. At this point it shouldn't have any visible impact.
Test Plan: Tested with other diffs.
Reviewers: ashoat
Subscribers: KatPo, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/root.react.js",
"new_path": "native/root.react.js",
"diff": "@@ -18,6 +18,7 @@ import { PersistGate } from 'redux-persist/integration/react';\nimport { actionLogger } from 'lib/utils/action-logger';\n+import ChatContextProvider from './chat/chat-context-provider.react';\nimport ConnectedStatusBar from './connected-status-bar.react';\nimport CoreDataProvider from './data/core-data-provider.react';\nimport ErrorBoundary from './error-boundary.react';\n@@ -251,10 +252,12 @@ function Root() {\n<RootContext.Provider value={rootContext}>\n<InputStateContainer>\n<SafeAreaProvider initialMetrics={initialWindowMetrics}>\n+ <ChatContextProvider>\n<ConnectedStatusBar />\n<PersistGate persistor={getPersistor()}>{gated}</PersistGate>\n{navigation}\n<NavigationHandler />\n+ </ChatContextProvider>\n</SafeAreaProvider>\n</InputStateContainer>\n</RootContext.Provider>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use chat context provider
Summary: Wrap chat navigator with the new container. At this point it shouldn't have any visible impact.
Test Plan: Tested with other diffs.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1404 |
129,191 | 11.06.2021 14:47:40 | -7,200 | 1b34f7d8a9971446be2e16457b0c1650df5c724f | [native] Create height measurer hook
Summary: Introduce a new hook which checks if message list or threadInfo change, schedules a new measurement task when they do, and returns a promise with the result.
Test Plan: Tested with other diffs.
Reviewers: ashoat
Subscribers: KatPo, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-context.js",
"new_path": "native/chat/chat-context.js",
"diff": "// @flow\n+import invariant from 'invariant';\nimport * as React from 'react';\nimport type { ChatMessageItem } from 'lib/selectors/chat-selectors';\n@@ -21,4 +22,19 @@ export type ChatContextType = {|\n|};\nconst ChatContext: React.Context<?ChatContextType> = React.createContext(null);\n-export { ChatContext };\n+function useHeightMeasurer(): MessagesMeasurer {\n+ const chatContext = React.useContext(ChatContext);\n+ invariant(chatContext, 'Chat context should be set');\n+\n+ const measureRegistrationRef = React.useRef();\n+ if (!measureRegistrationRef.current) {\n+ measureRegistrationRef.current = chatContext.registerMeasurer();\n+ }\n+ const measureRegistration = measureRegistrationRef.current;\n+ React.useEffect(() => {\n+ return measureRegistration.unregister;\n+ }, [measureRegistration]);\n+ return measureRegistration.measure;\n+}\n+\n+export { ChatContext, useHeightMeasurer };\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Create height measurer hook
Summary: Introduce a new hook which checks if message list or threadInfo change, schedules a new measurement task when they do, and returns a promise with the result.
Test Plan: Tested with other diffs.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1405 |
129,191 | 15.06.2021 12:47:21 | -7,200 | 03e9e4c99b50d4db29e2d46ffe75f06a22c821fe | [native] Use MessageListContextProvider
Summary: Replace all the usages of `useMessageListContext` with `MessageListContextProvider` component
Test Plan: Check if messages list with text messages is rendered correctly. Open a tooltip with text message and check if it is correct.
Reviewers: ashoat
Subscribers: KatPo, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -30,10 +30,7 @@ import { type MessagesMeasurer, useHeightMeasurer } from './chat-context';\nimport ChatInputBar from './chat-input-bar.react';\nimport type { ChatNavigationProp } from './chat.react';\nimport MessageListThreadSearch from './message-list-thread-search.react';\n-import {\n- MessageListContext,\n- useMessageListContext,\n-} from './message-list-types';\n+import { MessageListContextProvider } from './message-list-types';\nimport MessageList from './message-list.react';\nimport type { ChatMessageInfoItemWithHeight } from './message.react';\n@@ -290,10 +287,9 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\nconst colors = useColors();\nconst styles = useStyles(unboundStyles);\nconst overlayContext = React.useContext(OverlayContext);\n- const messageListContext = useMessageListContext(threadID);\nconst measureMessages = useHeightMeasurer();\nreturn (\n- <MessageListContext.Provider value={messageListContext}>\n+ <MessageListContextProvider threadID={threadID}>\n<MessageListContainer\n{...props}\nusernameInputText={usernameInputText}\n@@ -310,6 +306,6 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\noverlayContext={overlayContext}\nmeasureMessages={measureMessages}\n/>\n- </MessageListContext.Provider>\n+ </MessageListContextProvider>\n);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-types.js",
"new_path": "native/chat/message-list-types.js",
"diff": "@@ -43,8 +43,4 @@ function MessageListContextProvider(props: Props) {\n);\n}\n-export {\n- MessageListContext,\n- useMessageListContext,\n- MessageListContextProvider,\n-};\n+export { MessageListContext, MessageListContextProvider };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message-tooltip-button.react.js",
"new_path": "native/chat/text-message-tooltip-button.react.js",
"diff": "@@ -8,10 +8,7 @@ import type { TooltipRoute } from '../navigation/tooltip.react';\nimport { useSelector } from '../redux/redux-utils';\nimport { InnerTextMessage } from './inner-text-message.react';\nimport { MessageHeader } from './message-header.react';\n-import {\n- MessageListContext,\n- useMessageListContext,\n-} from './message-list-types';\n+import { MessageListContextProvider } from './message-list-types';\n/* eslint-disable import/no-named-as-default-member */\nconst { Value } = Animated;\n@@ -39,16 +36,15 @@ function TextMessageTooltipButton(props: Props) {\nconst { item } = props.route.params;\nconst threadID = item.threadInfo.id;\n- const messageListContext = useMessageListContext(threadID);\nconst { navigation } = props;\nreturn (\n- <MessageListContext.Provider value={messageListContext}>\n+ <MessageListContextProvider threadID={threadID}>\n<Animated.View style={headerStyle}>\n<MessageHeader item={item} focused={true} display=\"modal\" />\n</Animated.View>\n<InnerTextMessage item={item} onPress={navigation.goBackOnce} />\n- </MessageListContext.Provider>\n+ </MessageListContextProvider>\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use MessageListContextProvider
Summary: Replace all the usages of `useMessageListContext` with `MessageListContextProvider` component
Test Plan: Check if messages list with text messages is rendered correctly. Open a tooltip with text message and check if it is correct.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1412 |
129,191 | 10.06.2021 13:37:07 | -7,200 | e3386bcc8a7f77bf5c406370b8a9b6294cb1a5cd | [native] Merge sidebar navigation functions
Summary: The functions are now the same so it makes sense to merge them together.
Test Plan: Test for multimedia, text and robotext messages: open pending sidebar, create it, reopen and check if everything is correct.
Reviewers: ashoat
Subscribers: KatPo, Adrian, atul | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-tooltip-modal.react.js",
"new_path": "native/chat/multimedia-tooltip-modal.react.js",
"diff": "@@ -11,7 +11,7 @@ import {\n} from '../navigation/tooltip.react';\nimport type { ChatMultimediaMessageInfoItem } from './multimedia-message.react';\nimport MultimediaTooltipButton from './multimedia-tooltip-button.react';\n-import { onPressGoToSidebar, onPressCreateSidebar } from './sidebar-navigation';\n+import { navigateToSidebar } from './sidebar-navigation';\nexport type MultimediaTooltipModalParams = TooltipParams<{|\n+item: ChatMultimediaMessageInfoItem,\n@@ -33,12 +33,12 @@ const spec = {\n{\nid: 'create_sidebar',\ntext: 'Create sidebar',\n- onPress: onPressCreateSidebar,\n+ onPress: navigateToSidebar,\n},\n{\nid: 'open_sidebar',\ntext: 'Go to sidebar',\n- onPress: onPressGoToSidebar,\n+ onPress: navigateToSidebar,\n},\n],\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message-tooltip-modal.react.js",
"new_path": "native/chat/robotext-message-tooltip-modal.react.js",
"diff": "@@ -7,7 +7,7 @@ import {\n} from '../navigation/tooltip.react';\nimport RobotextMessageTooltipButton from './robotext-message-tooltip-button.react';\nimport type { ChatRobotextMessageInfoItemWithHeight } from './robotext-message.react';\n-import { onPressGoToSidebar, onPressCreateSidebar } from './sidebar-navigation';\n+import { navigateToSidebar } from './sidebar-navigation';\nexport type RobotextMessageTooltipModalParams = TooltipParams<{|\n+item: ChatRobotextMessageInfoItemWithHeight,\n@@ -18,12 +18,12 @@ const spec = {\n{\nid: 'create_sidebar',\ntext: 'Create sidebar',\n- onPress: onPressCreateSidebar,\n+ onPress: navigateToSidebar,\n},\n{\nid: 'open_sidebar',\ntext: 'Go to sidebar',\n- onPress: onPressGoToSidebar,\n+ onPress: navigateToSidebar,\n},\n],\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/sidebar-navigation.js",
"new_path": "native/chat/sidebar-navigation.js",
"diff": "@@ -8,7 +8,7 @@ import { MessageListRouteName } from '../navigation/route-names';\nimport type { TooltipRoute } from '../navigation/tooltip.react';\nimport { getSidebarThreadInfo } from './utils';\n-function onPressGoToSidebar(\n+function navigateToSidebar(\nroute:\n| TooltipRoute<'RobotextMessageTooltipModal'>\n| TooltipRoute<'TextMessageTooltipModal'>\n@@ -37,33 +37,4 @@ function onPressGoToSidebar(\n});\n}\n-function onPressCreateSidebar(\n- route:\n- | TooltipRoute<'RobotextMessageTooltipModal'>\n- | TooltipRoute<'TextMessageTooltipModal'>\n- | TooltipRoute<'MultimediaTooltipModal'>,\n- dispatchFunctions: DispatchFunctions,\n- bindServerCall: <F>(serverCall: ActionFunc<F>) => F,\n- inputState: ?InputState,\n- navigation:\n- | AppNavigationProp<'RobotextMessageTooltipModal'>\n- | AppNavigationProp<'TextMessageTooltipModal'>\n- | AppNavigationProp<'MultimediaTooltipModal'>,\n- viewerID: ?string,\n-) {\n- const threadInfo = getSidebarThreadInfo(route.params.item, viewerID);\n- // Necessary for Flow...\n- // eslint-disable-next-line no-empty\n- if (route.name === 'RobotextMessageTooltipModal') {\n- }\n-\n- navigation.navigate({\n- name: MessageListRouteName,\n- params: {\n- threadInfo,\n- },\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- });\n-}\n-\n-export { onPressGoToSidebar, onPressCreateSidebar };\n+export { navigateToSidebar };\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": "@@ -14,7 +14,7 @@ import {\ntype TooltipParams,\ntype TooltipRoute,\n} from '../navigation/tooltip.react';\n-import { onPressGoToSidebar, onPressCreateSidebar } from './sidebar-navigation';\n+import { navigateToSidebar } from './sidebar-navigation';\nimport TextMessageTooltipButton from './text-message-tooltip-button.react';\nimport type { ChatTextMessageInfoItemWithHeight } from './text-message.react';\n@@ -49,12 +49,12 @@ const spec = {\n{\nid: 'create_sidebar',\ntext: 'Create sidebar',\n- onPress: onPressCreateSidebar,\n+ onPress: navigateToSidebar,\n},\n{\nid: 'open_sidebar',\ntext: 'Go to sidebar',\n- onPress: onPressGoToSidebar,\n+ onPress: navigateToSidebar,\n},\n],\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Merge sidebar navigation functions
Summary: The functions are now the same so it makes sense to merge them together.
Test Plan: Test for multimedia, text and robotext messages: open pending sidebar, create it, reopen and check if everything is correct.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: KatPo, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1509 |
129,187 | 28.06.2021 14:49:48 | 14,400 | 6907ab31fe8ea71b727b68f0d51085dac16a1c3a | [native] Add ParentThreadHeader to MessageListContainer while searching
Summary: [Here's what](https://www.dropbox.com/s/9ocbhj39ub2j9na/Screen%20Recording%202021-06-28%20at%202.51.02%20PM.mov?dl=0) it looks like.
Test Plan: Play around with it
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -4,16 +4,21 @@ import invariant from 'invariant';\nimport * as React from 'react';\nimport { View } from 'react-native';\n+import genesis from 'lib/facts/genesis';\nimport {\ntype ChatMessageItem,\nuseMessageListData,\n} from 'lib/selectors/chat-selectors';\n+import { threadInfoSelector } from 'lib/selectors/thread-selectors';\nimport {\nuserInfoSelectorForPotentialMembers,\nuserSearchIndexForPotentialMembers,\n} from 'lib/selectors/user-selectors';\nimport { getPotentialMemberItems } from 'lib/shared/search-utils';\n-import { useExistingThreadInfoFinder } from 'lib/shared/thread-utils';\n+import {\n+ useExistingThreadInfoFinder,\n+ pendingThreadType,\n+} from 'lib/shared/thread-utils';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport type { AccountUserInfo, UserListItem } from 'lib/types/user-types';\n@@ -33,6 +38,7 @@ import MessageListThreadSearch from './message-list-thread-search.react';\nimport { MessageListContextProvider } from './message-list-types';\nimport MessageList from './message-list.react';\nimport type { ChatMessageInfoItemWithHeight } from './message.react';\n+import ParentThreadHeader from './parent-thread-header.react';\nexport type ChatMessageItemWithHeight =\n| {| itemType: 'loader' |}\n@@ -53,6 +59,7 @@ type Props = {|\n+otherUserInfos: { [id: string]: AccountUserInfo },\n+userSearchResults: $ReadOnlyArray<UserListItem>,\n+threadInfo: ThreadInfo,\n+ +genesisThreadInfo: ?ThreadInfo,\n+messageListData: $ReadOnlyArray<ChatMessageItem>,\n+colors: Colors,\n+styles: typeof unboundStyles,\n@@ -118,16 +125,31 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nlet searchComponent = null;\nif (searching) {\n+ const { userInfoInputArray, genesisThreadInfo } = this.props;\n+ // It's technically possible for the client to be missing the Genesis\n+ // ThreadInfo when it first opens up (before the server delivers it)\n+ let parentThreadHeader;\n+ if (genesisThreadInfo) {\n+ parentThreadHeader = (\n+ <ParentThreadHeader\n+ parentThreadInfo={genesisThreadInfo}\n+ childThreadType={pendingThreadType(userInfoInputArray.length)}\n+ />\n+ );\n+ }\nsearchComponent = (\n+ <>\n+ {parentThreadHeader}\n<MessageListThreadSearch\nusernameInputText={this.props.usernameInputText}\nupdateUsernameInput={this.props.updateUsernameInput}\n- userInfoInputArray={this.props.userInfoInputArray}\n+ userInfoInputArray={userInfoInputArray}\nupdateTagInput={this.props.updateTagInput}\nresolveToUser={this.props.resolveToUser}\notherUserInfos={this.props.otherUserInfos}\nuserSearchResults={this.props.userSearchResults}\n/>\n+ </>\n);\n}\n@@ -288,6 +310,11 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\nconst styles = useStyles(unboundStyles);\nconst overlayContext = React.useContext(OverlayContext);\nconst measureMessages = useHeightMeasurer();\n+\n+ const genesisThreadInfo = useSelector(\n+ (state) => threadInfoSelector(state)[genesis.id],\n+ );\n+\nreturn (\n<MessageListContextProvider threadID={threadID}>\n<MessageListContainer\n@@ -300,6 +327,7 @@ export default React.memo<BaseProps>(function ConnectedMessageListContainer(\notherUserInfos={otherUserInfos}\nuserSearchResults={userSearchResults}\nthreadInfo={threadInfo}\n+ genesisThreadInfo={genesisThreadInfo}\nmessageListData={messageListData}\ncolors={colors}\nstyles={styles}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Add ParentThreadHeader to MessageListContainer while searching
Summary: [Here's what](https://www.dropbox.com/s/9ocbhj39ub2j9na/Screen%20Recording%202021-06-28%20at%202.51.02%20PM.mov?dl=0) it looks like.
Test Plan: Play around with it
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1518 |
129,187 | 28.06.2021 15:21:31 | 14,400 | 3d5ff8786b4e44b48e3d16f1b57b2ff1e1032ca6 | [native] Introduce ThreadPill component
Summary: Figured it would be good to factor this out so we only need to edit one place when we want to change it.
Test Plan: Test the various places it's used
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-child-thread.react.js",
"new_path": "native/chat/settings/thread-settings-child-thread.react.js",
"diff": "@@ -6,8 +6,8 @@ import { View, Platform } from 'react-native';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport Button from '../../components/button.react';\n-import Pill from '../../components/pill.react';\nimport ThreadIcon from '../../components/thread-icon.react';\n+import ThreadPill from '../../components/thread-pill.react';\nimport { MessageListRouteName } from '../../navigation/route-names';\nimport { useColors, useStyles } from '../../themes/colors';\nimport type { ThreadSettingsNavigate } from './thread-settings.react';\n@@ -37,10 +37,7 @@ function ThreadSettingsChildThread(props: Props) {\n<View style={styles.container}>\n<Button onPress={onPress} style={[styles.button, firstItem, lastItem]}>\n<View style={styles.leftSide}>\n- <Pill\n- backgroundColor={`#${threadInfo.color}`}\n- label={threadInfo.uiName}\n- />\n+ <ThreadPill threadInfo={threadInfo} />\n</View>\n<ThreadIcon\nthreadType={threadInfo.type}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-parent.react.js",
"new_path": "native/chat/settings/thread-settings-parent.react.js",
"diff": "@@ -7,7 +7,7 @@ import { Text, View } from 'react-native';\nimport { type ThreadInfo } from 'lib/types/thread-types';\nimport Button from '../../components/button.react';\n-import Pill from '../../components/pill.react';\n+import ThreadPill from '../../components/thread-pill.react';\nimport { MessageListRouteName } from '../../navigation/route-names';\nimport { useStyles } from '../../themes/colors';\nimport type { ThreadSettingsNavigate } from './thread-settings.react';\n@@ -27,10 +27,7 @@ class ThreadSettingsParent extends React.PureComponent<Props> {\nif (this.props.parentThreadInfo) {\nparent = (\n<Button onPress={this.onPressParentThread}>\n- <Pill\n- label={this.props.parentThreadInfo.uiName}\n- backgroundColor={`#${this.props.parentThreadInfo.color}`}\n- />\n+ <ThreadPill threadInfo={this.props.parentThreadInfo} />\n</Button>\n);\n} else if (this.props.threadInfo.parentThreadID) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/thread-ancestors.react.js",
"new_path": "native/components/thread-ancestors.react.js",
"diff": "@@ -14,6 +14,7 @@ import { useSelector } from '../redux/redux-utils';\nimport { useColors, useStyles } from '../themes/colors';\nimport Button from './button.react';\nimport Pill from './pill.react';\n+import ThreadPill from './thread-pill.react';\ntype Props = {|\n+threadInfo: ThreadInfo,\n@@ -70,8 +71,6 @@ function ThreadAncestors(props: Props): React.Node {\nconst elements = [];\nfor (const [idx, ancestorThreadInfo] of ancestorThreads.entries()) {\nconst isLastThread = idx === ancestorThreads.length - 1;\n- const backgroundColor = `#${ancestorThreadInfo.color}`;\n-\nelements.push(\n<View key={ancestorThreadInfo.id} style={styles.pathItem}>\n<Button\n@@ -79,10 +78,9 @@ function ThreadAncestors(props: Props): React.Node {\nonPress={() => navigateToThread(ancestorThreadInfo)}\n>\n{idx === 0 ? adminLabel : null}\n- <Pill\n- backgroundColor={backgroundColor}\n+ <ThreadPill\n+ threadInfo={ancestorThreadInfo}\nroundCorners={{ left: !(idx === 0), right: true }}\n- label={ancestorThreadInfo.uiName}\n/>\n</Button>\n{!isLastThread ? rightArrow : null}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/components/thread-pill.react.js",
"diff": "+// @flow\n+\n+import * as React from 'react';\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+\n+import Pill from './pill.react';\n+\n+type Props = {|\n+ +threadInfo: ThreadInfo,\n+ +roundCorners?: {| +left: boolean, +right: boolean |},\n+|};\n+function ThreadPill(props: Props): React.Node {\n+ const { threadInfo, roundCorners } = props;\n+ return (\n+ <Pill\n+ backgroundColor={`#${threadInfo.color}`}\n+ label={threadInfo.uiName}\n+ roundCorners={roundCorners}\n+ />\n+ );\n+}\n+\n+export default ThreadPill;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Introduce ThreadPill component
Summary: Figured it would be good to factor this out so we only need to edit one place when we want to change it.
Test Plan: Test the various places it's used
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1520 |
129,187 | 28.06.2021 15:37:39 | 14,400 | cd335202d5cd5fc69526f7635aa8bb2a65100706 | [native] Introduce CommunityPill component
Summary: I want to use this inside `ParentThreadHeader` too so I'm factoring it out.
Test Plan: Make sure `ThreadAncestors` still looks correct
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/components/community-pill.react.js",
"diff": "+// @flow\n+\n+import * as React from 'react';\n+import { View, StyleSheet } from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome5';\n+\n+import { memberHasAdminPowers } from 'lib/shared/thread-utils';\n+import type { ThreadInfo, MemberInfo } from 'lib/types/thread-types';\n+\n+import { useSelector } from '../redux/redux-utils';\n+import { useColors } from '../themes/colors';\n+import Pill from './pill.react';\n+import ThreadPill from './thread-pill.react';\n+\n+type Props = {|\n+ +community: ThreadInfo,\n+|};\n+function CommunityPill(props: Props): React.Node {\n+ const { community } = props;\n+\n+ const userInfos = useSelector((state) => state.userStore.userInfos);\n+ const keyserverOperatorUsername: ?string = React.useMemo(() => {\n+ for (const member: MemberInfo of community.members) {\n+ if (memberHasAdminPowers(member)) {\n+ return userInfos[member.id].username;\n+ }\n+ }\n+ }, [community, userInfos]);\n+\n+ const colors = useColors();\n+ const keyserverOperatorLabel: ?React.Node = React.useMemo(() => {\n+ if (!keyserverOperatorUsername) {\n+ return undefined;\n+ }\n+ const icon = (\n+ <Icon name=\"cloud\" size={12} color={colors.panelForegroundLabel} />\n+ );\n+ return (\n+ <Pill\n+ backgroundColor={colors.codeBackground}\n+ roundCorners={{ left: true, right: false }}\n+ label={keyserverOperatorUsername}\n+ icon={icon}\n+ />\n+ );\n+ }, [\n+ colors.codeBackground,\n+ colors.panelForegroundLabel,\n+ keyserverOperatorUsername,\n+ ]);\n+\n+ return (\n+ <View style={styles.container}>\n+ {keyserverOperatorLabel}\n+ <ThreadPill\n+ threadInfo={community}\n+ roundCorners={{ left: false, right: true }}\n+ />\n+ </View>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flexDirection: 'row',\n+ },\n+});\n+\n+export default CommunityPill;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/thread-ancestors.react.js",
"new_path": "native/components/thread-ancestors.react.js",
"diff": "@@ -6,14 +6,13 @@ import { View, ScrollView } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome5';\nimport { ancestorThreadInfos } from 'lib/selectors/thread-selectors';\n-import { memberHasAdminPowers } from 'lib/shared/thread-utils';\n-import { type ThreadInfo, type MemberInfo } from 'lib/types/thread-types';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport { MessageListRouteName } from '../navigation/route-names';\nimport { useSelector } from '../redux/redux-utils';\n-import { useColors, useStyles } from '../themes/colors';\n+import { useStyles } from '../themes/colors';\nimport Button from './button.react';\n-import Pill from './pill.react';\n+import CommunityPill from './community-pill.react';\nimport ThreadPill from './thread-pill.react';\ntype Props = {|\n@@ -24,9 +23,7 @@ function ThreadAncestors(props: Props): React.Node {\nconst { threadInfo } = props;\nconst navigation = useNavigation();\nconst styles = useStyles(unboundStyles);\n- const colors = useColors();\n- const userInfos = useSelector((state) => state.userStore.userInfos);\nconst ancestorThreads: $ReadOnlyArray<ThreadInfo> = useSelector(\nancestorThreadInfos(threadInfo.id),\n);\n@@ -42,59 +39,30 @@ function ThreadAncestors(props: Props): React.Node {\n[navigation],\n);\n- const parentAdmin: ?string = React.useMemo(() => {\n- for (const member: MemberInfo of ancestorThreads[0].members) {\n- if (memberHasAdminPowers(member)) {\n- return userInfos[member.id].username;\n- }\n- }\n- }, [ancestorThreads, userInfos]);\n-\n- const adminLabel: ?React.Node = React.useMemo(() => {\n- if (!parentAdmin) {\n- return undefined;\n- }\n- const icon = (\n- <Icon name=\"cloud\" size={12} color={colors.panelForegroundLabel} />\n- );\n- return (\n- <Pill\n- backgroundColor={colors.codeBackground}\n- roundCorners={{ left: true, right: false }}\n- label={parentAdmin}\n- icon={icon}\n- />\n- );\n- }, [colors.codeBackground, colors.panelForegroundLabel, parentAdmin]);\n-\nconst pathElements = React.useMemo(() => {\nconst elements = [];\nfor (const [idx, ancestorThreadInfo] of ancestorThreads.entries()) {\nconst isLastThread = idx === ancestorThreads.length - 1;\n+ const pill =\n+ idx === 0 ? (\n+ <CommunityPill community={ancestorThreadInfo} />\n+ ) : (\n+ <ThreadPill threadInfo={ancestorThreadInfo} />\n+ );\nelements.push(\n<View key={ancestorThreadInfo.id} style={styles.pathItem}>\n<Button\nstyle={styles.row}\nonPress={() => navigateToThread(ancestorThreadInfo)}\n>\n- {idx === 0 ? adminLabel : null}\n- <ThreadPill\n- threadInfo={ancestorThreadInfo}\n- roundCorners={{ left: !(idx === 0), right: true }}\n- />\n+ {pill}\n</Button>\n{!isLastThread ? rightArrow : null}\n</View>,\n);\n}\nreturn <View style={styles.pathItem}>{elements}</View>;\n- }, [\n- adminLabel,\n- ancestorThreads,\n- navigateToThread,\n- styles.pathItem,\n- styles.row,\n- ]);\n+ }, [ancestorThreads, navigateToThread, styles.pathItem, styles.row]);\nreturn (\n<View style={styles.container}>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Introduce CommunityPill component
Summary: I want to use this inside `ParentThreadHeader` too so I'm factoring it out.
Test Plan: Make sure `ThreadAncestors` still looks correct
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1521 |
129,187 | 28.06.2021 15:41:41 | 14,400 | 91bb833ddc600f0da9932dab0c72f7bd1bb10492 | [native] Use CommunityPill in ParentThreadHeader
Summary: Trying to make the UI more consistent, and make it more discoverable that the parent thread is pressable (implemented in next diff).
Test Plan: Make sure it looks good
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/parent-thread-header.react.js",
"new_path": "native/chat/parent-thread-header.react.js",
"diff": "@@ -5,7 +5,7 @@ import { View, Text } from 'react-native';\nimport type { ThreadInfo, ThreadType } from 'lib/types/thread-types';\n-import { SingleLine } from '../components/single-line.react';\n+import CommunityPill from '../components/community-pill.react';\nimport ThreadVisibility from '../components/thread-visibility.react';\nimport { useColors, useStyles } from '../themes/colors';\n@@ -27,9 +27,7 @@ function ParentThreadHeader(props: Props): React.Node {\ncolor={threadVisibilityColor}\n/>\n<Text style={styles.parentThreadLabel}>within</Text>\n- <SingleLine style={styles.parentThreadName}>\n- {parentThreadInfo.uiName}\n- </SingleLine>\n+ <CommunityPill community={parentThreadInfo} />\n</View>\n);\n}\n@@ -45,7 +43,7 @@ const unboundStyles = {\nparentThreadLabel: {\ncolor: 'modalSubtextLabel',\nfontSize: 16,\n- paddingLeft: 6,\n+ paddingHorizontal: 6,\n},\nparentThreadName: {\ncolor: 'modalForegroundLabel',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use CommunityPill in ParentThreadHeader
Summary: Trying to make the UI more consistent, and make it more discoverable that the parent thread is pressable (implemented in next diff).
Test Plan: Make sure it looks good
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1522 |
129,187 | 28.06.2021 15:55:09 | 14,400 | 750be11fd260c5848957d929701c897441a1131b | [native] Convert ThreadSettingsParent to a function component
Summary: The single callback in this file is about to be factored out into a Hook, so I figured it would be cleaner to make `ThreadSettingsParent` a function component now.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-parent.react.js",
"new_path": "native/chat/settings/thread-settings-parent.react.js",
"diff": "@@ -12,32 +12,35 @@ import { MessageListRouteName } from '../../navigation/route-names';\nimport { useStyles } from '../../themes/colors';\nimport type { ThreadSettingsNavigate } from './thread-settings.react';\n-type BaseProps = {|\n+type Props = {|\n+threadInfo: ThreadInfo,\n+parentThreadInfo: ?ThreadInfo,\n+navigate: ThreadSettingsNavigate,\n|};\n-type Props = {|\n- ...BaseProps,\n- +styles: typeof unboundStyles,\n-|};\n-class ThreadSettingsParent extends React.PureComponent<Props> {\n- render() {\n+function ThreadSettingsParent(props: Props): React.Node {\n+ const { threadInfo, parentThreadInfo, navigate } = props;\n+ const styles = useStyles(unboundStyles);\n+\n+ const onPressParentThread = React.useCallback(() => {\n+ invariant(parentThreadInfo, 'should be set');\n+ navigate({\n+ name: MessageListRouteName,\n+ params: { threadInfo: parentThreadInfo },\n+ key: `${MessageListRouteName}${parentThreadInfo.id}`,\n+ });\n+ }, [parentThreadInfo, navigate]);\n+\nlet parent;\n- if (this.props.parentThreadInfo) {\n+ if (parentThreadInfo) {\nparent = (\n- <Button onPress={this.onPressParentThread}>\n- <ThreadPill threadInfo={this.props.parentThreadInfo} />\n+ <Button onPress={onPressParentThread}>\n+ <ThreadPill threadInfo={parentThreadInfo} />\n</Button>\n);\n- } else if (this.props.threadInfo.parentThreadID) {\n+ } else if (threadInfo.parentThreadID) {\nparent = (\n<Text\n- style={[\n- this.props.styles.currentValue,\n- this.props.styles.currentValueText,\n- this.props.styles.noParent,\n- ]}\n+ style={[styles.currentValue, styles.currentValueText, styles.noParent]}\nnumberOfLines={1}\n>\nSecret parent\n@@ -46,20 +49,17 @@ class ThreadSettingsParent extends React.PureComponent<Props> {\n} else {\nparent = (\n<Text\n- style={[\n- this.props.styles.currentValue,\n- this.props.styles.currentValueText,\n- this.props.styles.noParent,\n- ]}\n+ style={[styles.currentValue, styles.currentValueText, styles.noParent]}\nnumberOfLines={1}\n>\nNo parent\n</Text>\n);\n}\n+\nreturn (\n- <View style={this.props.styles.row}>\n- <Text style={this.props.styles.label} numberOfLines={1}>\n+ <View style={styles.row}>\n+ <Text style={styles.label} numberOfLines={1}>\nParent\n</Text>\n{parent}\n@@ -67,17 +67,6 @@ class ThreadSettingsParent extends React.PureComponent<Props> {\n);\n}\n- onPressParentThread = () => {\n- const threadInfo = this.props.parentThreadInfo;\n- invariant(threadInfo, 'should be set');\n- this.props.navigate({\n- name: MessageListRouteName,\n- params: { threadInfo },\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- });\n- };\n-}\n-\nconst unboundStyles = {\ncurrentValue: {\nflex: 1,\n@@ -107,9 +96,4 @@ const unboundStyles = {\n},\n};\n-export default React.memo<BaseProps>(function ConnectedThreadSettingsParent(\n- props: BaseProps,\n-) {\n- const styles = useStyles(unboundStyles);\n- return <ThreadSettingsParent {...props} styles={styles} />;\n-});\n+export default React.memo<Props>(ThreadSettingsParent);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Convert ThreadSettingsParent to a function component
Summary: The single callback in this file is about to be factored out into a Hook, so I figured it would be cleaner to make `ThreadSettingsParent` a function component now.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1523 |
129,187 | 28.06.2021 16:07:17 | 14,400 | 8b9e13a137da2ed303733002614ee9a1fc93b9bf | [native] Make React Navigation navigate function param $ReadOnly
Summary: I'll want to PR this up on `flow-typed` as well
Test Plan: Flow, tested in combination with next diff
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/@react-navigation/bottom-tabs_v5.x.x.js",
"new_path": "native/flow-typed/npm/@react-navigation/bottom-tabs_v5.x.x.js",
"diff": "@@ -786,13 +786,13 @@ declare module '@react-navigation/bottom-tabs' {\n& <DestinationRouteName: $Keys<ParamList>>(\nroute:\n| {|\n- key: string,\n- params?: $ElementType<ParamList, DestinationRouteName>,\n+ +key: string,\n+ +params?: $ElementType<ParamList, DestinationRouteName>,\n|}\n| {|\n- name: DestinationRouteName,\n- key?: string,\n- params?: $ElementType<ParamList, DestinationRouteName>,\n+ +name: DestinationRouteName,\n+ +key?: string,\n+ +params?: $ElementType<ParamList, DestinationRouteName>,\n|},\n) => void;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/@react-navigation/devtools_v5.x.x.js",
"new_path": "native/flow-typed/npm/@react-navigation/devtools_v5.x.x.js",
"diff": "@@ -786,13 +786,13 @@ declare module '@react-navigation/devtools' {\n& <DestinationRouteName: $Keys<ParamList>>(\nroute:\n| {|\n- key: string,\n- params?: $ElementType<ParamList, DestinationRouteName>,\n+ +key: string,\n+ +params?: $ElementType<ParamList, DestinationRouteName>,\n|}\n| {|\n- name: DestinationRouteName,\n- key?: string,\n- params?: $ElementType<ParamList, DestinationRouteName>,\n+ +name: DestinationRouteName,\n+ +key?: string,\n+ +params?: $ElementType<ParamList, DestinationRouteName>,\n|},\n) => void;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/@react-navigation/material-top-tabs_v5.x.x.js",
"new_path": "native/flow-typed/npm/@react-navigation/material-top-tabs_v5.x.x.js",
"diff": "@@ -786,13 +786,13 @@ declare module '@react-navigation/material-top-tabs' {\n& <DestinationRouteName: $Keys<ParamList>>(\nroute:\n| {|\n- key: string,\n- params?: $ElementType<ParamList, DestinationRouteName>,\n+ +key: string,\n+ +params?: $ElementType<ParamList, DestinationRouteName>,\n|}\n| {|\n- name: DestinationRouteName,\n- key?: string,\n- params?: $ElementType<ParamList, DestinationRouteName>,\n+ +name: DestinationRouteName,\n+ +key?: string,\n+ +params?: $ElementType<ParamList, DestinationRouteName>,\n|},\n) => void;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/@react-navigation/native_v5.x.x.js",
"new_path": "native/flow-typed/npm/@react-navigation/native_v5.x.x.js",
"diff": "@@ -786,13 +786,13 @@ declare module '@react-navigation/native' {\n& <DestinationRouteName: $Keys<ParamList>>(\nroute:\n| {|\n- key: string,\n- params?: $ElementType<ParamList, DestinationRouteName>,\n+ +key: string,\n+ +params?: $ElementType<ParamList, DestinationRouteName>,\n|}\n| {|\n- name: DestinationRouteName,\n- key?: string,\n- params?: $ElementType<ParamList, DestinationRouteName>,\n+ +name: DestinationRouteName,\n+ +key?: string,\n+ +params?: $ElementType<ParamList, DestinationRouteName>,\n|},\n) => void;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/@react-navigation/stack_v5.x.x.js",
"new_path": "native/flow-typed/npm/@react-navigation/stack_v5.x.x.js",
"diff": "@@ -786,13 +786,13 @@ declare module '@react-navigation/stack' {\n& <DestinationRouteName: $Keys<ParamList>>(\nroute:\n| {|\n- key: string,\n- params?: $ElementType<ParamList, DestinationRouteName>,\n+ +key: string,\n+ +params?: $ElementType<ParamList, DestinationRouteName>,\n|}\n| {|\n- name: DestinationRouteName,\n- key?: string,\n- params?: $ElementType<ParamList, DestinationRouteName>,\n+ +name: DestinationRouteName,\n+ +key?: string,\n+ +params?: $ElementType<ParamList, DestinationRouteName>,\n|},\n) => void;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Make React Navigation navigate function param $ReadOnly
Summary: I'll want to PR this up on `flow-typed` as well
Test Plan: Flow, tested in combination with next diff
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1524 |
129,187 | 28.06.2021 16:43:06 | 14,400 | 0b0acdbff946e9f57a847e101d22a6607e102cfb | [native] Factor out useNavigateToThread
Summary: We currently repeat the logic for constructing the key of a `MessageListRouteName` route in many places. This diff makes it so we only define it in one place.
Test Plan: Flow
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -53,6 +53,10 @@ import { dateString } from 'lib/utils/date-utils';\nimport { ServerError } from 'lib/utils/errors';\nimport sleep from 'lib/utils/sleep';\n+import {\n+ type MessageListParams,\n+ useNavigateToThread,\n+} from '../chat/message-list-types';\nimport Button from '../components/button.react';\nimport { SingleLine } from '../components/single-line.react';\nimport Markdown from '../markdown/markdown.react';\n@@ -63,10 +67,7 @@ import {\nnonThreadCalendarQuery,\n} from '../navigation/nav-selectors';\nimport { NavContext } from '../navigation/navigation-context';\n-import {\n- MessageListRouteName,\n- ThreadPickerModalRouteName,\n-} from '../navigation/route-names';\n+import { ThreadPickerModalRouteName } from '../navigation/route-names';\nimport { useSelector } from '../redux/redux-utils';\nimport { colors, useStyles } from '../themes/colors';\nimport type { LayoutEvent } from '../types/react-native';\n@@ -111,6 +112,7 @@ type Props = {|\n+styles: typeof unboundStyles,\n// Nav state\n+threadPickerActive: boolean,\n+ +navigateToThread: (params: MessageListParams) => void,\n// Redux dispatch functions\n+dispatch: Dispatch,\n+dispatchActionPromise: DispatchActionPromise,\n@@ -666,12 +668,7 @@ class InternalEntry extends React.Component<Props, State> {\nonPressThreadName = () => {\nKeyboard.dismiss();\n- const { threadInfo } = this.props;\n- this.props.navigation.navigate({\n- name: MessageListRouteName,\n- params: { threadInfo },\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- });\n+ this.props.navigateToThread({ threadInfo: this.props.threadInfo });\n};\n}\n@@ -771,6 +768,8 @@ const Entry = React.memo<BaseProps>(function ConnectedEntry(props: BaseProps) {\n);\nconst styles = useStyles(unboundStyles);\n+ const navigateToThread = useNavigateToThread();\n+\nconst dispatch = useDispatch();\nconst dispatchActionPromise = useDispatchActionPromise();\nconst callCreateEntry = useServerCall(createEntry);\n@@ -784,6 +783,7 @@ const Entry = React.memo<BaseProps>(function ConnectedEntry(props: BaseProps) {\ncalendarQuery={calendarQuery}\nonline={online}\nstyles={styles}\n+ navigateToThread={navigateToThread}\ndispatch={dispatch}\ndispatchActionPromise={dispatchActionPromise}\ncreateEntry={callCreateEntry}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-router.js",
"new_path": "native/chat/chat-router.js",
"diff": "@@ -27,9 +27,9 @@ import {\n} from '../navigation/navigation-utils';\nimport {\nChatThreadListRouteName,\n- MessageListRouteName,\nComposeThreadRouteName,\n} from '../navigation/route-names';\n+import { createNavigateToThreadAction } from './message-list-types';\ntype ClearScreensAction = {|\n+type: 'CLEAR_SCREENS',\n@@ -107,11 +107,9 @@ function ChatRouter(\n(route: Route<>) =>\nroute.name === ChatThreadListRouteName ? 'keep' : 'remove',\n);\n- const navigateAction = CommonActions.navigate({\n- name: MessageListRouteName,\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- params: { threadInfo },\n- });\n+ const navigateAction = CommonActions.navigate(\n+ createNavigateToThreadAction({ threadInfo }),\n+ );\nreturn baseGetStateForAction(clearedState, navigateAction, options);\n} else if (action.type === clearThreadsActionType) {\nconst threadIDs = new Set(action.payload.threadIDs);\n@@ -131,11 +129,9 @@ function ChatRouter(\n(route: Route<>) =>\nroute.name === ComposeThreadRouteName ? 'remove' : 'break',\n);\n- const navigateAction = CommonActions.navigate({\n- name: MessageListRouteName,\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- params: { threadInfo },\n- });\n+ const navigateAction = CommonActions.navigate(\n+ createNavigateToThreadAction({ threadInfo }),\n+ );\nreturn baseGetStateForAction(clearedState, navigateAction, options);\n} else {\nreturn baseGetStateForAction(lastState, action, options);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -38,7 +38,6 @@ import Button from '../components/button.react';\nimport Search from '../components/search.react';\nimport type { TabNavigationProp } from '../navigation/app-navigator.react';\nimport {\n- MessageListRouteName,\nSidebarListModalRouteName,\nHomeChatThreadListRouteName,\nBackgroundChatThreadListRouteName,\n@@ -59,6 +58,10 @@ import type {\nChatTopTabsNavigationProp,\nChatNavigationProp,\n} from './chat.react';\n+import {\n+ type MessageListParams,\n+ useNavigateToThread,\n+} from './message-list-types';\nconst floatingActions = [\n{\n@@ -97,6 +100,7 @@ type Props = {|\n+styles: typeof unboundStyles,\n+indicatorStyle: IndicatorStyle,\n+usersWithPersonalThread: $ReadOnlySet<string>,\n+ +navigateToThread: (params: MessageListParams) => void,\n// async functions that hit server APIs\n+searchUsers: (usernamePrefix: string) => Promise<UserSearchResult>,\n|};\n@@ -524,11 +528,7 @@ class ChatThreadList extends React.PureComponent<Props, State> {\nif (this.searchInput) {\nthis.searchInput.blur();\n}\n- this.props.navigation.navigate({\n- name: MessageListRouteName,\n- params: { threadInfo, pendingPersonalThreadUserInfo },\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- });\n+ this.props.navigateToThread({ threadInfo, pendingPersonalThreadUserInfo });\n};\nonPressSeeMoreSidebars = (threadInfo: ThreadInfo) => {\n@@ -547,18 +547,14 @@ class ChatThreadList extends React.PureComponent<Props, State> {\n};\ncomposeThread = () => {\n- if (this.props.viewerID) {\n- this.props.navigation.navigate({\n- name: MessageListRouteName,\n- params: {\n- threadInfo: createPendingThread({\n+ if (!this.props.viewerID) {\n+ return;\n+ }\n+ const threadInfo = createPendingThread({\nviewerID: this.props.viewerID,\nthreadType: threadTypes.LOCAL,\n- }),\n- searching: true,\n- },\n});\n- }\n+ this.props.navigateToThread({ threadInfo, searching: true });\n};\n}\n@@ -615,6 +611,8 @@ export default React.memo<BaseProps>(function ConnectedChatThreadList(\nconst callSearchUsers = useServerCall(searchUsers);\nconst usersWithPersonalThread = useSelector(usersWithPersonalThreadSelector);\n+ const navigateToThread = useNavigateToThread();\n+\nreturn (\n<ChatThreadList\n{...props}\n@@ -625,6 +623,7 @@ export default React.memo<BaseProps>(function ConnectedChatThreadList(\nindicatorStyle={indicatorStyle}\nsearchUsers={callSearchUsers}\nusersWithPersonalThread={usersWithPersonalThread}\n+ navigateToThread={navigateToThread}\n/>\n);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/compose-thread.react.js",
"new_path": "native/chat/compose-thread.react.js",
"diff": "@@ -40,10 +40,13 @@ import ThreadList from '../components/thread-list.react';\nimport UserList from '../components/user-list.react';\nimport { useCalendarQuery } from '../navigation/nav-selectors';\nimport type { NavigationRoute } from '../navigation/route-names';\n-import { MessageListRouteName } from '../navigation/route-names';\nimport { useSelector } from '../redux/redux-utils';\nimport { useStyles } from '../themes/colors';\nimport type { ChatNavigationProp } from './chat.react';\n+import {\n+ type MessageListParams,\n+ useNavigateToThread,\n+} from './message-list-types';\nimport ParentThreadHeader from './parent-thread-header.react';\nconst TagInput = createTagInput<AccountUserInfo>();\n@@ -73,6 +76,7 @@ type Props = {|\n+threadInfos: { +[id: string]: ThreadInfo },\n+styles: typeof unboundStyles,\n+calendarQuery: () => CalendarQuery,\n+ +navigateToThread: (params: MessageListParams) => void,\n// Redux dispatch functions\n+dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -379,11 +383,7 @@ class ComposeThread extends React.PureComponent<Props, State> {\nonSelectExistingThread = (threadID: string) => {\nconst threadInfo = this.props.threadInfos[threadID];\n- this.props.navigation.navigate({\n- name: MessageListRouteName,\n- params: { threadInfo },\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- });\n+ this.props.navigateToThread({ threadInfo });\n};\n}\n@@ -456,9 +456,11 @@ export default React.memo<BaseProps>(function ConnectedComposeThread(\nconst userSearchIndex = useSelector(userSearchIndexForPotentialMembers);\nconst threadInfos = useSelector(threadInfoSelector);\nconst styles = useStyles(unboundStyles);\n- const dispatchActionPromise = useDispatchActionPromise();\nconst calendarQuery = useCalendarQuery();\n+ const navigateToThread = useNavigateToThread();\n+\n+ const dispatchActionPromise = useDispatchActionPromise();\nconst callNewThread = useServerCall(newThread);\nreturn (\n<ComposeThread\n@@ -470,6 +472,7 @@ export default React.memo<BaseProps>(function ConnectedComposeThread(\nthreadInfos={threadInfos}\nstyles={styles}\ncalendarQuery={calendarQuery}\n+ navigateToThread={navigateToThread}\ndispatchActionPromise={dispatchActionPromise}\nnewThread={callNewThread}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/inline-sidebar.react.js",
"new_path": "native/chat/inline-sidebar.react.js",
"diff": "// @flow\n-import { useNavigation } from '@react-navigation/native';\nimport * as React from 'react';\nimport { Text, View } from 'react-native';\nimport Icon from 'react-native-vector-icons/Feather';\n@@ -11,10 +10,9 @@ import type { ThreadInfo } from 'lib/types/thread-types';\nimport { pluralizeAndTrim } from 'lib/utils/text-utils';\nimport Button from '../components/button.react';\n-import { MessageListRouteName } from '../navigation/route-names';\nimport { useSelector } from '../redux/redux-utils';\nimport { useStyles } from '../themes/colors';\n-import type { ChatNavigationProp } from './chat.react';\n+import { useNavigateToThread } from './message-list-types';\ntype Props = {|\n+threadInfo: ThreadInfo,\n@@ -22,15 +20,11 @@ type Props = {|\n|};\nfunction InlineSidebar(props: Props) {\nconst { threadInfo } = props;\n- const navigation: ChatNavigationProp<'MessageList'> = (useNavigation(): any);\n+ const navigateToThread = useNavigateToThread();\nconst onPress = React.useCallback(() => {\n- navigation.navigate({\n- name: MessageListRouteName,\n- params: { threadInfo },\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- });\n- }, [navigation, threadInfo]);\n+ navigateToThread({ threadInfo });\n+ }, [navigateToThread, threadInfo]);\nconst styles = useStyles(unboundStyles);\nlet viewerIcon, nonViewerIcon, alignStyle;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/inner-robotext-message.react.js",
"new_path": "native/chat/inner-robotext-message.react.js",
"diff": "@@ -13,11 +13,9 @@ import {\nimport Markdown from '../markdown/markdown.react';\nimport { inlineMarkdownRules } from '../markdown/rules.react';\n-import type { AppNavigationProp } from '../navigation/app-navigator.react';\n-import { MessageListRouteName } from '../navigation/route-names';\nimport { useSelector } from '../redux/redux-utils';\nimport { useOverlayStyles } from '../themes/colors';\n-import type { ChatNavigationProp } from './chat.react';\n+import { useNavigateToThread } from './message-list-types';\nimport type { ChatRobotextMessageInfoItemWithHeight } from './robotext-message.react';\nfunction dummyNodeForRobotextMessageHeightMeasurement(robotext: string) {\n@@ -32,14 +30,11 @@ function dummyNodeForRobotextMessageHeightMeasurement(robotext: string) {\ntype InnerRobotextMessageProps = {|\n+item: ChatRobotextMessageInfoItemWithHeight,\n- +navigation:\n- | ChatNavigationProp<'MessageList'>\n- | AppNavigationProp<'RobotextMessageTooltipModal'>,\n+onPress: () => void,\n+onLongPress?: () => void,\n|};\nfunction InnerRobotextMessage(props: InnerRobotextMessageProps) {\n- const { item, navigation, onLongPress, onPress } = props;\n+ const { item, onLongPress, onPress } = props;\nconst activeTheme = useSelector((state) => state.globalThemeInfo.activeTheme);\nconst styles = useOverlayStyles(unboundStyles);\nconst { robotext } = item;\n@@ -69,14 +64,7 @@ function InnerRobotextMessage(props: InnerRobotextMessageProps) {\nconst { rawText, entityType, id } = parseRobotextEntity(splitPart);\nif (entityType === 't' && id !== item.messageInfo.threadID) {\n- textParts.push(\n- <ThreadEntity\n- key={id}\n- id={id}\n- name={rawText}\n- navigation={navigation}\n- />,\n- );\n+ textParts.push(<ThreadEntity key={id} id={id} name={rawText} />);\n} else if (entityType === 'c') {\ntextParts.push(<ColorEntity key={id} color={rawText} />);\n} else {\n@@ -103,9 +91,6 @@ function InnerRobotextMessage(props: InnerRobotextMessageProps) {\ntype ThreadEntityProps = {|\n+id: string,\n+name: string,\n- +navigation:\n- | ChatNavigationProp<'MessageList'>\n- | AppNavigationProp<'RobotextMessageTooltipModal'>,\n|};\nfunction ThreadEntity(props: ThreadEntityProps) {\nconst threadID = props.id;\n@@ -115,15 +100,11 @@ function ThreadEntity(props: ThreadEntityProps) {\nconst styles = useOverlayStyles(unboundStyles);\n- const { navigate } = props.navigation;\n+ const navigateToThread = useNavigateToThread();\nconst onPressThread = React.useCallback(() => {\ninvariant(threadInfo, 'onPressThread should have threadInfo');\n- navigate({\n- name: MessageListRouteName,\n- params: { threadInfo },\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- });\n- }, [threadInfo, navigate]);\n+ navigateToThread({ threadInfo });\n+ }, [threadInfo, navigateToThread]);\nif (!threadInfo) {\nreturn <Text>{props.name}</Text>;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-types.js",
"new_path": "native/chat/message-list-types.js",
"diff": "// @flow\n+import { useNavigation } from '@react-navigation/native';\nimport * as React from 'react';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n@@ -7,6 +8,7 @@ import { type UserInfo } from 'lib/types/user-types';\nimport type { MarkdownRules } from '../markdown/rules.react';\nimport { useTextMessageRulesFunc } from '../markdown/rules.react';\n+import { MessageListRouteName } from '../navigation/route-names';\nexport type MessageListParams = {|\n+threadInfo: ThreadInfo,\n@@ -43,4 +45,34 @@ function MessageListContextProvider(props: Props) {\n);\n}\n-export { MessageListContext, MessageListContextProvider };\n+type NavigateToThreadAction = {|\n+ +name: typeof MessageListRouteName,\n+ +params: MessageListParams,\n+ +key: string,\n+|};\n+function createNavigateToThreadAction(\n+ params: MessageListParams,\n+): NavigateToThreadAction {\n+ return {\n+ name: MessageListRouteName,\n+ params,\n+ key: `${MessageListRouteName}${params.threadInfo.id}`,\n+ };\n+}\n+\n+function useNavigateToThread(): (params: MessageListParams) => void {\n+ const { navigate } = useNavigation();\n+ return React.useCallback(\n+ (params: MessageListParams) => {\n+ navigate(createNavigateToThreadAction(params));\n+ },\n+ [navigate],\n+ );\n+}\n+\n+export {\n+ MessageListContext,\n+ MessageListContextProvider,\n+ createNavigateToThreadAction,\n+ useNavigateToThread,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message-tooltip-button.react.js",
"new_path": "native/chat/robotext-message-tooltip-button.react.js",
"diff": "@@ -41,11 +41,7 @@ function RobotextMessageTooltipButton(props: Props) {\n<Animated.View style={headerStyle}>\n<Timestamp time={item.messageInfo.time} display=\"modal\" />\n</Animated.View>\n- <InnerRobotextMessage\n- item={item}\n- navigation={navigation}\n- onPress={navigation.goBackOnce}\n- />\n+ <InnerRobotextMessage item={item} onPress={navigation.goBackOnce} />\n</React.Fragment>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "@@ -192,7 +192,6 @@ function RobotextMessage(props: Props) {\n<View onLayout={onLayout} ref={viewRef}>\n<InnerRobotextMessage\nitem={item}\n- navigation={navigation}\nonPress={onPress}\nonLongPress={onLongPress}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-child-thread.react.js",
"new_path": "native/chat/settings/thread-settings-child-thread.react.js",
"diff": "@@ -8,25 +8,21 @@ import type { ThreadInfo } from 'lib/types/thread-types';\nimport Button from '../../components/button.react';\nimport ThreadIcon from '../../components/thread-icon.react';\nimport ThreadPill from '../../components/thread-pill.react';\n-import { MessageListRouteName } from '../../navigation/route-names';\nimport { useColors, useStyles } from '../../themes/colors';\n-import type { ThreadSettingsNavigate } from './thread-settings.react';\n+import { useNavigateToThread } from '../message-list-types';\ntype Props = {|\n+threadInfo: ThreadInfo,\n- +navigate: ThreadSettingsNavigate,\n+firstListItem: boolean,\n+lastListItem: boolean,\n|};\nfunction ThreadSettingsChildThread(props: Props) {\n- const { navigate, threadInfo } = props;\n+ const { threadInfo } = props;\n+\n+ const navigateToThread = useNavigateToThread();\nconst onPress = React.useCallback(() => {\n- navigate({\n- name: MessageListRouteName,\n- params: { threadInfo },\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- });\n- }, [navigate, threadInfo]);\n+ navigateToThread({ threadInfo });\n+ }, [threadInfo, navigateToThread]);\nconst styles = useStyles(unboundStyles);\nconst colors = useColors();\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-parent.react.js",
"new_path": "native/chat/settings/thread-settings-parent.react.js",
"diff": "@@ -8,27 +8,22 @@ import { type ThreadInfo } from 'lib/types/thread-types';\nimport Button from '../../components/button.react';\nimport ThreadPill from '../../components/thread-pill.react';\n-import { MessageListRouteName } from '../../navigation/route-names';\nimport { useStyles } from '../../themes/colors';\n-import type { ThreadSettingsNavigate } from './thread-settings.react';\n+import { useNavigateToThread } from '../message-list-types';\ntype Props = {|\n+threadInfo: ThreadInfo,\n+parentThreadInfo: ?ThreadInfo,\n- +navigate: ThreadSettingsNavigate,\n|};\nfunction ThreadSettingsParent(props: Props): React.Node {\n- const { threadInfo, parentThreadInfo, navigate } = props;\n+ const { threadInfo, parentThreadInfo } = props;\nconst styles = useStyles(unboundStyles);\n+ const navigateToThread = useNavigateToThread();\nconst onPressParentThread = React.useCallback(() => {\ninvariant(parentThreadInfo, 'should be set');\n- navigate({\n- name: MessageListRouteName,\n- params: { threadInfo: parentThreadInfo },\n- key: `${MessageListRouteName}${parentThreadInfo.id}`,\n- });\n- }, [parentThreadInfo, navigate]);\n+ navigateToThread({ threadInfo: parentThreadInfo });\n+ }, [parentThreadInfo, navigateToThread]);\nlet parent;\nif (parentThreadInfo) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -135,7 +135,6 @@ type ChatSettingsItem =\n+key: string,\n+threadInfo: ThreadInfo,\n+parentThreadInfo: ?ThreadInfo,\n- +navigate: ThreadSettingsNavigate,\n|}\n| {|\n+itemType: 'visibility',\n@@ -161,7 +160,6 @@ type ChatSettingsItem =\n+itemType: 'childThread',\n+key: string,\n+threadInfo: ThreadInfo,\n- +navigate: ThreadSettingsNavigate,\n+firstListItem: boolean,\n+lastListItem: boolean,\n|}\n@@ -446,7 +444,6 @@ class ThreadSettings extends React.PureComponent<Props, State> {\nkey: 'parent',\nthreadInfo,\nparentThreadInfo,\n- navigate,\n});\nlistData.push({\nitemType: 'footer',\n@@ -504,7 +501,6 @@ class ThreadSettings extends React.PureComponent<Props, State> {\nitemType: 'childThread',\nkey: `childThread${subthreadInfo.id}`,\nthreadInfo: subthreadInfo,\n- navigate,\nfirstListItem: i === 0 && !canCreateSubthreads,\nlastListItem: i === numItems - 1 && numItems === subthreads.length,\n});\n@@ -561,7 +557,6 @@ class ThreadSettings extends React.PureComponent<Props, State> {\nitemType: 'childThread',\nkey: `childThread${sidebarInfo.id}`,\nthreadInfo: sidebarInfo,\n- navigate,\nfirstListItem: i === 0,\nlastListItem: i === numItems - 1 && numItems === sidebars.length,\n});\n@@ -916,7 +911,6 @@ class ThreadSettings extends React.PureComponent<Props, State> {\n<ThreadSettingsParent\nthreadInfo={item.threadInfo}\nparentThreadInfo={item.parentThreadInfo}\n- navigate={item.navigate}\n/>\n);\n} else if (item.itemType === 'visibility') {\n@@ -931,7 +925,6 @@ class ThreadSettings extends React.PureComponent<Props, State> {\nreturn (\n<ThreadSettingsChildThread\nthreadInfo={item.threadInfo}\n- navigate={item.navigate}\nfirstListItem={item.firstListItem}\nlastListItem={item.lastListItem}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/sidebar-list-modal.react.js",
"new_path": "native/chat/sidebar-list-modal.react.js",
"diff": "@@ -12,10 +12,10 @@ import Modal from '../components/modal.react';\nimport Search from '../components/search.react';\nimport type { RootNavigationProp } from '../navigation/root-navigator.react';\nimport type { NavigationRoute } from '../navigation/route-names';\n-import { MessageListRouteName } from '../navigation/route-names';\nimport { useSelector } from '../redux/redux-utils';\nimport { useIndicatorStyle } from '../themes/colors';\nimport { waitForModalInputFocus } from '../utils/timers';\n+import { useNavigateToThread } from './message-list-types';\nimport SidebarItem from './sidebar-item.react';\nexport type SidebarListModalParams = {|\n@@ -99,8 +99,7 @@ function SidebarListModal(props: Props) {\n[],\n);\n- const { navigation } = props;\n- const { navigate } = navigation;\n+ const navigateToThread = useNavigateToThread();\nconst onPressItem = React.useCallback(\n(threadInfo: ThreadInfo) => {\nsetSearchState({\n@@ -110,13 +109,9 @@ function SidebarListModal(props: Props) {\nif (searchTextInputRef.current) {\nsearchTextInputRef.current.blur();\n}\n- navigate({\n- name: MessageListRouteName,\n- params: { threadInfo },\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- });\n+ navigateToThread({ threadInfo });\n},\n- [navigate],\n+ [navigateToThread],\n);\nconst renderItem = React.useCallback(\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/sidebar-navigation.js",
"new_path": "native/chat/sidebar-navigation.js",
"diff": "@@ -4,8 +4,8 @@ import type { DispatchFunctions, ActionFunc } from 'lib/utils/action-utils';\nimport type { InputState } from '../input/input-state';\nimport type { AppNavigationProp } from '../navigation/app-navigator.react';\n-import { MessageListRouteName } from '../navigation/route-names';\nimport type { TooltipRoute } from '../navigation/tooltip.react';\n+import { createNavigateToThreadAction } from './message-list-types';\nimport { getSidebarThreadInfo } from './utils';\nfunction navigateToSidebar(\n@@ -28,13 +28,7 @@ function navigateToSidebar(\nif (route.name === 'RobotextMessageTooltipModal') {\n}\n- navigation.navigate({\n- name: MessageListRouteName,\n- params: {\n- threadInfo,\n- },\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- });\n+ navigation.navigate(createNavigateToThreadAction({ threadInfo }));\n}\nexport { navigateToSidebar };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/thread-ancestors.react.js",
"new_path": "native/components/thread-ancestors.react.js",
"diff": "// @flow\n-import { useNavigation } from '@react-navigation/native';\nimport * as React from 'react';\nimport { View, ScrollView } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome5';\n@@ -8,7 +7,7 @@ import Icon from 'react-native-vector-icons/FontAwesome5';\nimport { ancestorThreadInfos } from 'lib/selectors/thread-selectors';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n-import { MessageListRouteName } from '../navigation/route-names';\n+import { useNavigateToThread } from '../chat/message-list-types';\nimport { useSelector } from '../redux/redux-utils';\nimport { useStyles } from '../themes/colors';\nimport Button from './button.react';\n@@ -21,24 +20,13 @@ type Props = {|\nfunction ThreadAncestors(props: Props): React.Node {\nconst { threadInfo } = props;\n- const navigation = useNavigation();\nconst styles = useStyles(unboundStyles);\nconst ancestorThreads: $ReadOnlyArray<ThreadInfo> = useSelector(\nancestorThreadInfos(threadInfo.id),\n);\n- const navigateToThread = React.useCallback(\n- (ancestorThreadInfo) => {\n- navigation.navigate({\n- name: MessageListRouteName,\n- params: { threadInfo: ancestorThreadInfo },\n- key: `${MessageListRouteName}${ancestorThreadInfo.id}`,\n- });\n- },\n- [navigation],\n- );\n-\n+ const navigateToThread = useNavigateToThread();\nconst pathElements = React.useMemo(() => {\nconst elements = [];\nfor (const [idx, ancestorThreadInfo] of ancestorThreads.entries()) {\n@@ -53,7 +41,7 @@ function ThreadAncestors(props: Props): React.Node {\n<View key={ancestorThreadInfo.id} style={styles.pathItem}>\n<Button\nstyle={styles.row}\n- onPress={() => navigateToThread(ancestorThreadInfo)}\n+ onPress={() => navigateToThread({ threadInfo: ancestorThreadInfo })}\n>\n{pill}\n</Button>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/push/push-handler.react.js",
"new_path": "native/push/push-handler.react.js",
"diff": "@@ -29,6 +29,10 @@ import {\ntype DispatchActionPromise,\n} from 'lib/utils/action-utils';\n+import {\n+ type MessageListParams,\n+ useNavigateToThread,\n+} from '../chat/message-list-types';\nimport {\naddLifecycleListener,\ngetCurrentLifecycleState,\n@@ -37,7 +41,6 @@ import { replaceWithThreadActionType } from '../navigation/action-types';\nimport { activeMessageListSelector } from '../navigation/nav-selectors';\nimport { NavContext } from '../navigation/navigation-context';\nimport type { RootNavigationProp } from '../navigation/root-navigator.react';\n-import { MessageListRouteName } from '../navigation/route-names';\nimport {\nrecordNotifPermissionAlertActionType,\nclearAndroidNotificationsActionType,\n@@ -86,6 +89,7 @@ type Props = {|\n+updatesCurrentAsOf: number,\n+activeTheme: ?GlobalTheme,\n+loggedIn: boolean,\n+ +navigateToThread: (params: MessageListParams) => void,\n// Redux dispatch functions\n+dispatch: Dispatch,\n+dispatchActionPromise: DispatchActionPromise,\n@@ -440,11 +444,7 @@ class PushHandler extends React.PureComponent<Props, State> {\npayload: { threadInfo },\n});\n} else {\n- this.props.navigation.navigate({\n- name: MessageListRouteName,\n- key: `${MessageListRouteName}${threadInfo.id}`,\n- params: { threadInfo },\n- });\n+ this.props.navigateToThread({ threadInfo });\n}\n}\n@@ -601,6 +601,7 @@ export default React.memo<BaseProps>(function ConnectedPushHandler(\nconst updatesCurrentAsOf = useSelector((state) => state.updatesCurrentAsOf);\nconst activeTheme = useSelector((state) => state.globalThemeInfo.activeTheme);\nconst loggedIn = useSelector(isLoggedIn);\n+ const navigateToThread = useNavigateToThread();\nconst dispatch = useDispatch();\nconst dispatchActionPromise = useDispatchActionPromise();\nconst boundSetDeviceToken = useServerCall(setDeviceToken);\n@@ -617,6 +618,7 @@ export default React.memo<BaseProps>(function ConnectedPushHandler(\nupdatesCurrentAsOf={updatesCurrentAsOf}\nactiveTheme={activeTheme}\nloggedIn={loggedIn}\n+ navigateToThread={navigateToThread}\ndispatch={dispatch}\ndispatchActionPromise={dispatchActionPromise}\nsetDeviceToken={boundSetDeviceToken}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Factor out useNavigateToThread
Summary: We currently repeat the logic for constructing the key of a `MessageListRouteName` route in many places. This diff makes it so we only define it in one place.
Test Plan: Flow
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1525 |
129,187 | 28.06.2021 16:45:11 | 14,400 | 642554534e5a88e27306cc20d362324184670fa2 | [native] Use PRIVATE instead of LOCAL for empty pending thread
Summary: This gets ignored / overwritten anyways, but I figured it's better to be consistent / correct.
Test Plan: Make sure pending thread `searching` state still works
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -552,7 +552,7 @@ class ChatThreadList extends React.PureComponent<Props, State> {\n}\nconst threadInfo = createPendingThread({\nviewerID: this.props.viewerID,\n- threadType: threadTypes.LOCAL,\n+ threadType: threadTypes.PRIVATE,\n});\nthis.props.navigateToThread({ threadInfo, searching: true });\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use PRIVATE instead of LOCAL for empty pending thread
Summary: This gets ignored / overwritten anyways, but I figured it's better to be consistent / correct.
Test Plan: Make sure pending thread `searching` state still works
Reviewers: atul, palys-swm
Reviewed By: palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1526 |
129,187 | 28.06.2021 16:49:36 | 14,400 | 338dab186a8460aae4fb7c96445e96fd417dae71 | [native] Make ParentThreadHeader pressable
Test Plan: Press it
Reviewers: atul, palys-swm
Subscribers: KatPo, Adrian | [
{
"change_type": "MODIFY",
"old_path": "native/chat/parent-thread-header.react.js",
"new_path": "native/chat/parent-thread-header.react.js",
"diff": "@@ -5,9 +5,11 @@ import { View, Text } from 'react-native';\nimport type { ThreadInfo, ThreadType } from 'lib/types/thread-types';\n+import Button from '../components/button.react';\nimport CommunityPill from '../components/community-pill.react';\nimport ThreadVisibility from '../components/thread-visibility.react';\nimport { useColors, useStyles } from '../themes/colors';\n+import { useNavigateToThread } from './message-list-types';\ntype Props = {|\n+parentThreadInfo: ThreadInfo,\n@@ -16,10 +18,15 @@ type Props = {|\nfunction ParentThreadHeader(props: Props): React.Node {\nconst colors = useColors();\nconst threadVisibilityColor = colors.modalForegroundLabel;\n-\nconst styles = useStyles(unboundStyles);\nconst { parentThreadInfo, childThreadType } = props;\n+\n+ const navigateToThread = useNavigateToThread();\n+ const onPressParentThread = React.useCallback(() => {\n+ navigateToThread({ threadInfo: parentThreadInfo });\n+ }, [parentThreadInfo, navigateToThread]);\n+\nreturn (\n<View style={styles.parentThreadRow}>\n<ThreadVisibility\n@@ -27,7 +34,9 @@ function ParentThreadHeader(props: Props): React.Node {\ncolor={threadVisibilityColor}\n/>\n<Text style={styles.parentThreadLabel}>within</Text>\n+ <Button onPress={onPressParentThread}>\n<CommunityPill community={parentThreadInfo} />\n+ </Button>\n</View>\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Make ParentThreadHeader pressable
Test Plan: Press it
Reviewers: atul, palys-swm
Reviewed By: atul, palys-swm
Subscribers: KatPo, Adrian
Differential Revision: https://phabricator.ashoat.com/D1527 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.