Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33062097
D6595.1768434642.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D6595.1768434642.diff
View Options
diff --git a/native/chat/settings/delete-thread.react.js b/native/chat/settings/delete-thread.react.js
--- a/native/chat/settings/delete-thread.react.js
+++ b/native/chat/settings/delete-thread.react.js
@@ -49,7 +49,7 @@
type Props = {
...BaseProps,
// Redux state
- +threadInfo: ?ThreadInfo,
+ +threadInfo: ThreadInfo,
+loadingStatus: LoadingStatus,
+activeTheme: ?GlobalTheme,
+colors: Colors,
@@ -65,14 +65,6 @@
mounted = false;
passwordInput: ?React.ElementRef<typeof BaseTextInput>;
- static getThreadInfo(props: Props): ThreadInfo {
- const { threadInfo } = props;
- if (threadInfo) {
- return threadInfo;
- }
- return props.route.params.threadInfo;
- }
-
componentDidMount() {
this.mounted = true;
}
@@ -87,14 +79,6 @@
}
}
- componentDidUpdate(prevProps: Props) {
- const oldReduxThreadInfo = prevProps.threadInfo;
- const newReduxThreadInfo = this.props.threadInfo;
- if (newReduxThreadInfo && newReduxThreadInfo !== oldReduxThreadInfo) {
- this.props.navigation.setParams({ threadInfo: newReduxThreadInfo });
- }
- }
-
render() {
const buttonContent =
this.props.loadingStatus === 'loading' ? (
@@ -102,7 +86,7 @@
) : (
<Text style={this.props.styles.deleteText}>Delete chat</Text>
);
- const threadInfo = DeleteThread.getThreadInfo(this.props);
+ const { threadInfo } = this.props;
return (
<ScrollView
contentContainerStyle={this.props.styles.scrollViewContentContainer}
@@ -143,8 +127,7 @@
};
async deleteThread() {
- const threadInfo = DeleteThread.getThreadInfo(this.props);
- const { navDispatch } = this.props;
+ const { threadInfo, navDispatch } = this.props;
navDispatch({
type: clearThreadsActionType,
payload: { threadIDs: [threadInfo.id] },
@@ -238,10 +221,19 @@
const ConnectedDeleteThread: React.ComponentType<BaseProps> = React.memo<BaseProps>(
function ConnectedDeleteThread(props: BaseProps) {
const threadID = props.route.params.threadInfo.id;
- const threadInfo = useSelector(
+ const reduxThreadInfo = useSelector(
state => threadInfoSelector(state)[threadID],
);
+ const { setParams } = props.navigation;
+ React.useEffect(() => {
+ if (reduxThreadInfo) {
+ setParams({ threadInfo: reduxThreadInfo });
+ }
+ }, [reduxThreadInfo, setParams]);
+ const threadInfo: ThreadInfo =
+ reduxThreadInfo ?? props.route.params.threadInfo;
+
const loadingStatus = useSelector(loadingStatusSelector);
const activeTheme = useSelector(state => state.globalThemeInfo.activeTheme);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 14, 11:50 PM (17 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5934719
Default Alt Text
D6595.1768434642.diff (2 KB)
Attached To
Mode
D6595: [native] Move DeleteThread logic for determining ThreadInfo to hook
Attached
Detach File
Event Timeline
Log In to Comment