Page MenuHomePhabricator

D3419.diff
No OneTemporary

D3419.diff

diff --git a/native/chat/swipeable-thread.react.js b/native/chat/swipeable-thread.react.js
--- a/native/chat/swipeable-thread.react.js
+++ b/native/chat/swipeable-thread.react.js
@@ -4,23 +4,11 @@
import * as React from 'react';
import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
-import {
- setThreadUnreadStatus,
- setThreadUnreadStatusActionTypes,
-} from 'lib/actions/activity-actions';
-import type {
- SetThreadUnreadStatusPayload,
- SetThreadUnreadStatusRequest,
-} from 'lib/types/activity-types';
+import useToggleUnreadStatus from 'lib/hooks/toggle-unread-status';
import type { ThreadInfo } from 'lib/types/thread-types';
-import {
- useDispatchActionPromise,
- useServerCall,
-} from 'lib/utils/action-utils';
import Swipeable from '../components/swipeable';
import { useColors } from '../themes/colors';
-
type Props = {
+threadInfo: ThreadInfo,
+mostRecentNonLocalMessage: ?string,
@@ -54,33 +42,21 @@
const colors = useColors();
const { mostRecentNonLocalMessage, iconSize } = props;
- const updateUnreadStatus: (
- request: SetThreadUnreadStatusRequest,
- ) => Promise<SetThreadUnreadStatusPayload> = useServerCall(
- setThreadUnreadStatus,
+
+ const swipeableClose = React.useCallback(() => {
+ if (swipeable.current) {
+ swipeable.current.close();
+ }
+ }, []);
+
+ const toggleUnreadStatus = useToggleUnreadStatus(
+ threadInfo,
+ mostRecentNonLocalMessage,
+ swipeableClose,
);
- const dispatchActionPromise = useDispatchActionPromise();
+
const swipeableActions = React.useMemo(() => {
const isUnread = threadInfo.currentUser.unread;
- const toggleUnreadStatus = () => {
- const request = {
- unread: !isUnread,
- threadID: threadInfo.id,
- latestMessage: mostRecentNonLocalMessage,
- };
- dispatchActionPromise(
- setThreadUnreadStatusActionTypes,
- updateUnreadStatus(request),
- undefined,
- {
- threadID: threadInfo.id,
- unread: !isUnread,
- },
- );
- if (swipeable.current) {
- swipeable.current.close();
- }
- };
return [
{
key: 'action1',
@@ -96,12 +72,11 @@
},
];
}, [
- colors,
- threadInfo,
- mostRecentNonLocalMessage,
+ threadInfo.currentUser.unread,
+ toggleUnreadStatus,
+ colors.vibrantRedButton,
+ colors.vibrantGreenButton,
iconSize,
- updateUnreadStatus,
- dispatchActionPromise,
]);
return (

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 6:00 PM (21 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2576915
Default Alt Text
D3419.diff (2 KB)

Event Timeline