Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3524097
D5143.id16813.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5143.id16813.diff
View Options
diff --git a/native/chat/settings/thread-settings.react.js b/native/chat/settings/thread-settings.react.js
--- a/native/chat/settings/thread-settings.react.js
+++ b/native/chat/settings/thread-settings.react.js
@@ -259,10 +259,6 @@
}
componentDidMount() {
- const threadInfo = this.props.threadInfo;
- if (!threadInChatList(threadInfo)) {
- threadWatcher.watchID(threadInfo.id);
- }
const tabNavigation: ?TabNavigationProp<
'Chat',
> = this.props.navigation.dangerouslyGetParent();
@@ -271,10 +267,6 @@
}
componentWillUnmount() {
- const threadInfo = this.props.threadInfo;
- if (!threadInChatList(threadInfo)) {
- threadWatcher.removeID(threadInfo.id);
- }
const tabNavigation: ?TabNavigationProp<
'Chat',
> = this.props.navigation.dangerouslyGetParent();
@@ -292,19 +284,6 @@
const prevThreadInfo = prevProps.threadInfo;
const newThreadInfo = this.props.threadInfo;
- if (newThreadInfo && newThreadInfo !== prevThreadInfo) {
- this.props.navigation.setParams({ threadInfo: newThreadInfo });
- }
-
- if (prevThreadInfo.id !== newThreadInfo.id) {
- if (!threadInChatList(prevThreadInfo)) {
- threadWatcher.removeID(prevThreadInfo.id);
- }
- if (!threadInChatList(newThreadInfo)) {
- threadWatcher.watchID(newThreadInfo.id);
- }
- }
-
if (
!tinycolor.equals(newThreadInfo.color, prevThreadInfo.color) &&
tinycolor.equals(this.state.colorEditValue, prevThreadInfo.color)
@@ -1081,6 +1060,7 @@
state => state.currentUserInfo && state.currentUserInfo.id,
);
const threadID = props.route.params.threadInfo.id;
+
const reduxThreadInfo: ?ThreadInfo = useSelector(
state => threadInfoSelector(state)[threadID],
);
@@ -1091,8 +1071,27 @@
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
+
+ const { setParams } = props.navigation;
+ React.useEffect(() => {
+ if (reduxThreadInfo) {
+ setParams({ threadInfo: reduxThreadInfo });
+ }
+ }, [reduxThreadInfo, setParams]);
const threadInfo: ThreadInfo =
reduxThreadInfo ?? props.route.params.threadInfo;
+
+ useEffect(() => {
+ if (!threadInChatList(threadInfo)) {
+ threadWatcher.watchID(threadInfo.id);
+ }
+ return () => {
+ if (!threadInChatList(threadInfo)) {
+ threadWatcher.removeID(threadInfo.id);
+ }
+ };
+ }, [threadInfo]);
+
const parentThreadID = threadInfo.parentThreadID;
const parentThreadInfo: ?ThreadInfo = useSelector(state =>
parentThreadID ? threadInfoSelector(state)[parentThreadID] : null,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 11:19 AM (2 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2699808
Default Alt Text
D5143.id16813.diff (2 KB)
Attached To
Mode
D5143: [native] move threadInfo caching logic
Attached
Detach File
Event Timeline
Log In to Comment