@planningcenter/chat-react-native 3.20.2 → 3.21.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/conversation/message_reaction.d.ts +0 -1
- package/build/components/conversation/message_reaction.d.ts.map +1 -1
- package/build/components/conversation/message_reaction.js +1 -7
- package/build/components/conversation/message_reaction.js.map +1 -1
- package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +29 -6
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/hooks/use_conversations_actions.js +1 -1
- package/build/hooks/use_conversations_actions.js.map +1 -1
- package/build/hooks/use_mark_latest_message_read.d.ts.map +1 -1
- package/build/hooks/use_mark_latest_message_read.js +10 -21
- package/build/hooks/use_mark_latest_message_read.js.map +1 -1
- package/build/hooks/use_message_reaction_toggle.d.ts +1 -1
- package/build/hooks/use_message_reaction_toggle.d.ts.map +1 -1
- package/build/hooks/use_message_reaction_toggle.js +44 -14
- package/build/hooks/use_message_reaction_toggle.js.map +1 -1
- package/build/screens/message_actions_screen.d.ts.map +1 -1
- package/build/screens/message_actions_screen.js +3 -2
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/screens/reactions_screen.d.ts.map +1 -1
- package/build/screens/reactions_screen.js +1 -2
- package/build/screens/reactions_screen.js.map +1 -1
- package/build/types/resources/conversation.d.ts +1 -0
- package/build/types/resources/conversation.d.ts.map +1 -1
- package/build/types/resources/conversation.js.map +1 -1
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/reaction_constants.d.ts +3 -0
- package/build/utils/reaction_constants.d.ts.map +1 -0
- package/build/utils/reaction_constants.js +8 -0
- package/build/utils/reaction_constants.js.map +1 -0
- package/package.json +2 -2
- package/src/components/conversation/message_reaction.tsx +1 -8
- package/src/hooks/use_conversation_jolt_events.ts +36 -8
- package/src/hooks/use_conversations_actions.ts +1 -1
- package/src/hooks/use_mark_latest_message_read.ts +15 -30
- package/src/hooks/use_message_reaction_toggle.ts +62 -16
- package/src/screens/message_actions_screen.tsx +3 -2
- package/src/screens/reactions_screen.tsx +1 -2
- package/src/types/resources/conversation.ts +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/reaction_constants.ts +9 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ReactionCountResource } from '../../types/resources/reaction';
|
|
3
3
|
import { MessageResource } from '../../types';
|
|
4
|
-
export declare const REACTION_EMOJIS: Record<ReactionCountResource['value'], string>;
|
|
5
4
|
export declare function MessageReaction({ reaction, onLongPress, message, conversationId, }: {
|
|
6
5
|
reaction: ReactionCountResource;
|
|
7
6
|
onLongPress: (_reaction: ReactionCountResource) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_reaction.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_reaction.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAKtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"message_reaction.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_reaction.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAKtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAK7C,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,WAAW,EACX,OAAO,EACP,cAAc,GACf,EAAE;IACD,QAAQ,EAAE,qBAAqB,CAAA;IAC/B,WAAW,EAAE,CAAC,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAA;IACvD,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;CACvB,4BA+BA;AAED,eAAO,MAAM,iBAAiB,aAAc;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;CA0B3D,CAAA"}
|
|
@@ -7,13 +7,7 @@ import { useInteractionGhostBackgroundColor, useTheme } from '../../hooks';
|
|
|
7
7
|
import { useMessageReactionToggle } from '../../hooks/use_message_reaction_toggle';
|
|
8
8
|
import { useCreateAndroidRippleColor } from '../../hooks/use_create_android_ripple_color';
|
|
9
9
|
import { Haptic } from '../../utils/native_adapters';
|
|
10
|
-
|
|
11
|
-
thumbs_up: '👍',
|
|
12
|
-
thumbs_down: '👎',
|
|
13
|
-
pray: '🙏',
|
|
14
|
-
laugh: '😂',
|
|
15
|
-
heart: '❤️',
|
|
16
|
-
};
|
|
10
|
+
import { REACTION_EMOJIS } from '../../utils';
|
|
17
11
|
export function MessageReaction({ reaction, onLongPress, message, conversationId, }) {
|
|
18
12
|
const styles = useReactionStyles(reaction);
|
|
19
13
|
const { handleReactionToggle } = useMessageReactionToggle({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_reaction.js","sourceRoot":"","sources":["../../../src/components/conversation/message_reaction.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAC/C,OAAO,EAAE,kCAAkC,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAGlF,OAAO,EAAE,2BAA2B,EAAE,MAAM,6CAA6C,CAAA;AACzF,OAAO,EAAE,MAA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AAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC3C,MAAM,EAAE,CAAA;IACb,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IACrC,MAAM,qBAAqB,GAAG,kCAAkC,EAAE,CAAA;IAElE,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,QAAQ,EAAE;YACR,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa;YACrD,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB;YAC1E,YAAY,EAAE,EAAE;YAChB,QAAQ,EAAE,QAAQ;YAClB,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;YACpB,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;SACP;QACD,aAAa,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE;QAC9C,YAAY,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,uBAAuB,EAAE;KACtE,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport colorFunction from 'color'\nimport React, { useMemo } from 'react'\nimport { StyleSheet } from 'react-native'\nimport { Text } from '../../components/display'\nimport { useInteractionGhostBackgroundColor, useTheme } from '../../hooks'\nimport { useMessageReactionToggle } from '../../hooks/use_message_reaction_toggle'\nimport { ReactionCountResource } from '../../types/resources/reaction'\nimport { MessageResource } from '../../types'\nimport { useCreateAndroidRippleColor } from '../../hooks/use_create_android_ripple_color'\nimport { Haptic } from '../../utils/native_adapters'\nimport { REACTION_EMOJIS } from '../../utils'\n\nexport function MessageReaction({\n reaction,\n onLongPress,\n message,\n conversationId,\n}: {\n reaction: ReactionCountResource\n onLongPress: (_reaction: ReactionCountResource) => void\n message: MessageResource\n conversationId: number\n}) {\n const styles = useReactionStyles(reaction)\n const { handleReactionToggle } = useMessageReactionToggle({\n conversation_id: conversationId,\n message,\n })\n\n const { colors } = useTheme()\n const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060\n const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })\n\n if (!reaction.count) return null\n if (!REACTION_EMOJIS[reaction.value]) return null\n\n const handlePress = () => {\n Haptic.impactLight()\n handleReactionToggle({ value: reaction.value, mine: !!reaction.mine })\n }\n\n return (\n <PlatformPressable\n key={reaction.value}\n style={styles.reaction}\n onLongPress={() => onLongPress(reaction)}\n onPress={handlePress}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n >\n <Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={styles.reactionText}>{reaction.count}</Text>\n </PlatformPressable>\n )\n}\n\nexport const useReactionStyles = ({ mine }: { mine: number }) => {\n const { colors } = useTheme()\n const activeBorderColor = useMemo(() => {\n return colorFunction(colors.interaction)\n .hsl()\n .lightness(colors.name === 'dark' ? 20 : 80)\n .string()\n }, [colors.interaction, colors.name])\n const activeBackgroundColor = useInteractionGhostBackgroundColor()\n\n return StyleSheet.create({\n reaction: {\n borderWidth: 1,\n borderColor: mine ? activeBorderColor : 'transparent',\n backgroundColor: mine ? activeBackgroundColor : colors.fillColorNeutral060,\n borderRadius: 16,\n overflow: 'hidden',\n paddingVertical: 4,\n paddingHorizontal: 8,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 2,\n },\n reactionEmoji: { fontSize: 12, paddingTop: 0 },\n reactionText: { fontSize: 12, color: colors.textColorDefaultPrimary },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_conversation_jolt_events.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation_jolt_events.ts"],"names":[],"mappings":"AAWA,UAAU,KAAK;IACb,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,yBAAyB,CAAC,EAAE,cAAc,EAAE,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"use_conversation_jolt_events.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation_jolt_events.ts"],"names":[],"mappings":"AAWA,UAAU,KAAK;IACb,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,yBAAyB,CAAC,EAAE,cAAc,EAAE,EAAE,KAAK,QA8FlE"}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { useJoltChannel, useJoltEvent } from './use_jolt';
|
|
2
|
-
import { getConversationRequestArgs } from './use_conversation';
|
|
3
1
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { getRequestQueryKey } from './use_suspense_api';
|
|
5
2
|
import { useCallback, useMemo } from 'react';
|
|
6
3
|
import { completeMessageCreationConversationTracking } from '../utils/performance_tracking';
|
|
7
|
-
import { useCurrentPerson } from './use_current_person';
|
|
8
4
|
import { useApiClient } from './use_api_client';
|
|
5
|
+
import { getConversationRequestArgs } from './use_conversation';
|
|
6
|
+
import { useCurrentPerson } from './use_current_person';
|
|
7
|
+
import { useJoltChannel, useJoltEvent } from './use_jolt';
|
|
8
|
+
import { getRequestQueryKey } from './use_suspense_api';
|
|
9
9
|
export function useConversationJoltEvents({ conversationId }) {
|
|
10
10
|
const joltChannel = useJoltChannel(`chat.conversations.${conversationId}`);
|
|
11
11
|
const queryClient = useQueryClient();
|
|
12
12
|
const currentPerson = useCurrentPerson();
|
|
13
|
+
const currentPersonId = currentPerson?.id;
|
|
13
14
|
const apiClient = useApiClient();
|
|
14
15
|
const queryKey = useMemo(() => getRequestQueryKey(getConversationRequestArgs({ conversation_id: conversationId })), [conversationId]);
|
|
15
16
|
const handleUpdatedConversation = useCallback((e) => {
|
|
16
17
|
const { last_message_idempotent_key, last_message_author_id } = e.data.data;
|
|
17
|
-
if (last_message_idempotent_key && last_message_author_id ===
|
|
18
|
+
if (last_message_idempotent_key && last_message_author_id === currentPersonId) {
|
|
18
19
|
completeMessageCreationConversationTracking({
|
|
19
20
|
apiClient,
|
|
20
21
|
idempotentKey: last_message_idempotent_key,
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
queryClient.invalidateQueries({ queryKey });
|
|
24
|
-
}, [queryClient, queryKey,
|
|
25
|
+
}, [queryClient, queryKey, currentPersonId, apiClient]);
|
|
25
26
|
const handleConversationRead = useCallback((e) => {
|
|
26
27
|
const { latest_read_message_sort_key } = e.data.data;
|
|
27
28
|
queryClient.setQueryData(queryKey, prev => {
|
|
@@ -36,6 +37,7 @@ export function useConversationJoltEvents({ conversationId }) {
|
|
|
36
37
|
data: {
|
|
37
38
|
...prev.data,
|
|
38
39
|
latestReadMessageSortKey: latest_read_message_sort_key,
|
|
40
|
+
unreadReactionCount: 0,
|
|
39
41
|
},
|
|
40
42
|
};
|
|
41
43
|
});
|
|
@@ -53,8 +55,29 @@ export function useConversationJoltEvents({ conversationId }) {
|
|
|
53
55
|
};
|
|
54
56
|
});
|
|
55
57
|
}, [queryClient, queryKey]);
|
|
58
|
+
const handleReactionJoltEvent = useCallback((event) => {
|
|
59
|
+
queryClient.setQueryData(queryKey, prev => {
|
|
60
|
+
if (!prev?.data)
|
|
61
|
+
return prev;
|
|
62
|
+
if (event.data.data.author_id === currentPersonId) {
|
|
63
|
+
return prev;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...prev,
|
|
67
|
+
data: {
|
|
68
|
+
...prev.data,
|
|
69
|
+
// Not a real count, just a derived value from Jolt events so we can
|
|
70
|
+
// determine if we should mark the conversation as read
|
|
71
|
+
unreadReactionCount: prev.data.unreadReactionCount
|
|
72
|
+
? prev.data.unreadReactionCount + 1
|
|
73
|
+
: 1,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}, [queryClient, queryKey, currentPersonId]);
|
|
56
78
|
useJoltEvent(joltChannel, 'conversation.updated', handleUpdatedConversation);
|
|
57
79
|
useJoltEvent(joltChannel, 'conversation.read', handleConversationRead);
|
|
58
80
|
useJoltEvent(joltChannel, 'conversation.destroyed', handleConversationDestroyed);
|
|
81
|
+
useJoltEvent(joltChannel, 'reaction.*', handleReactionJoltEvent);
|
|
59
82
|
}
|
|
60
83
|
//# sourceMappingURL=use_conversation_jolt_events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_conversation_jolt_events.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_jolt_events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use_conversation_jolt_events.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_jolt_events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAG5C,OAAO,EAAE,2CAA2C,EAAE,MAAM,+BAA+B,CAAA;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAMvD,MAAM,UAAU,yBAAyB,CAAC,EAAE,cAAc,EAAS;IACjE,MAAM,WAAW,GAAG,cAAc,CAAC,sBAAsB,cAAc,EAAE,CAAC,CAAA;IAC1E,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IACxC,MAAM,eAAe,GAAG,aAAa,EAAE,EAAE,CAAA;IACzC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC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ACtE,YAAY,CAAC,WAAW,EAAE,wBAAwB,EAAE,2BAA2B,CAAC,CAAA;IAChF,YAAY,CAAC,WAAW,EAAE,YAAY,EAAE,uBAAuB,CAAC,CAAA;AAClE,CAAC","sourcesContent":["import { useQueryClient } from '@tanstack/react-query'\nimport { useCallback, useMemo } from 'react'\nimport { ApiResource, ConversationResource } from '../types'\nimport { JoltConversationEvent, JoltReactionEvent } from '../types/jolt_events'\nimport { completeMessageCreationConversationTracking } from '../utils/performance_tracking'\nimport { useApiClient } from './use_api_client'\nimport { getConversationRequestArgs } from './use_conversation'\nimport { useCurrentPerson } from './use_current_person'\nimport { useJoltChannel, useJoltEvent } from './use_jolt'\nimport { getRequestQueryKey } from './use_suspense_api'\n\ninterface Props {\n conversationId: number\n}\n\nexport function useConversationJoltEvents({ conversationId }: Props) {\n const joltChannel = useJoltChannel(`chat.conversations.${conversationId}`)\n const queryClient = useQueryClient()\n const currentPerson = useCurrentPerson()\n const currentPersonId = currentPerson?.id\n const apiClient = useApiClient()\n const queryKey = useMemo(\n () => getRequestQueryKey(getConversationRequestArgs({ conversation_id: conversationId })),\n [conversationId]\n )\n\n const handleUpdatedConversation = useCallback(\n (e: JoltConversationEvent) => {\n const { last_message_idempotent_key, last_message_author_id } = e.data.data\n\n if (last_message_idempotent_key && last_message_author_id === currentPersonId) {\n completeMessageCreationConversationTracking({\n apiClient,\n idempotentKey: last_message_idempotent_key,\n })\n }\n queryClient.invalidateQueries({ queryKey })\n },\n [queryClient, queryKey, currentPersonId, apiClient]\n )\n\n const handleConversationRead = useCallback(\n (e: JoltConversationEvent) => {\n const { latest_read_message_sort_key } = e.data.data\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data || !latest_read_message_sort_key) return prev\n if (\n prev.data.latestReadMessageSortKey &&\n prev.data.latestReadMessageSortKey >= latest_read_message_sort_key\n ) {\n return prev\n }\n\n return {\n ...prev,\n data: {\n ...prev.data,\n latestReadMessageSortKey: latest_read_message_sort_key,\n unreadReactionCount: 0,\n },\n }\n })\n },\n [queryClient, queryKey]\n )\n\n const handleConversationDestroyed = useCallback(() => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n return {\n ...prev,\n data: {\n ...prev.data,\n deleted: true,\n },\n }\n })\n }, [queryClient, queryKey])\n\n const handleReactionJoltEvent = useCallback(\n (event: JoltReactionEvent) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n if (event.data.data.author_id === currentPersonId) {\n return prev\n }\n\n return {\n ...prev,\n data: {\n ...prev.data,\n // Not a real count, just a derived value from Jolt events so we can\n // determine if we should mark the conversation as read\n unreadReactionCount: prev.data.unreadReactionCount\n ? prev.data.unreadReactionCount + 1\n : 1,\n },\n }\n })\n },\n [queryClient, queryKey, currentPersonId]\n )\n\n useJoltEvent(joltChannel, 'conversation.updated', handleUpdatedConversation)\n useJoltEvent(joltChannel, 'conversation.read', handleConversationRead)\n useJoltEvent(joltChannel, 'conversation.destroyed', handleConversationDestroyed)\n useJoltEvent(joltChannel, 'reaction.*', handleReactionJoltEvent)\n}\n"]}
|
|
@@ -13,7 +13,7 @@ export const useConversationsMarkRead = ({ conversation, }) => {
|
|
|
13
13
|
currentPersonCache.update({}, person => {
|
|
14
14
|
const currentUnread = person.unreadCount;
|
|
15
15
|
const updatedUnread = read ? Math.max(currentUnread - 1, 0) : currentUnread + 1;
|
|
16
|
-
return { ...person, unreadCount: updatedUnread };
|
|
16
|
+
return { ...person, unreadCount: updatedUnread, unreadReactionCount: 0 };
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
const { mutate: handleMarkRead, ...mutation } = useMutation({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_conversations_actions.js","sourceRoot":"","sources":["../../src/hooks/use_conversations_actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA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ACJ,CAAC;QACD,WAAW,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC;QAClC,UAAU,EAAE,GAAG,EAAE,CACf,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YAClB,GAAG,EAAE,mBAAmB;SACzB,CAAC;QACJ,SAAS,EAAE,UAAU;KACtB,CAAC,CAAA;IAEF,OAAO;QACL,WAAW;QACX,GAAG,KAAK;KACT,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { useMutation } from '@tanstack/react-query'\nimport { Alert } from 'react-native'\nimport { useConversationsContext } from '../contexts/conversations_context'\nimport { ApiResource, ConversationResource } from '../types'\nimport { useApiClient } from './use_api_client'\nimport { useConversationsCache } from './use_conversations_cache'\nimport { useCurrentPersonCache } from './use_current_person'\n\nexport const useConversationsMarkRead = ({\n conversation,\n}: {\n conversation: ConversationResource\n}) => {\n const apiClient = useApiClient()\n const { args } = useConversationsContext()\n const currentPersonCache = useCurrentPersonCache()\n const { update, invalidate, fetchUpdate } = useConversationsCache(args)\n\n function handlePersonUnreadCount(read: boolean) {\n currentPersonCache.update({}, person => {\n const currentUnread = person.unreadCount\n const updatedUnread = read ? Math.max(currentUnread - 1, 0) : currentUnread + 1\n return { ...person, unreadCount: updatedUnread, unreadReactionCount: 0 }\n })\n }\n\n const { mutate: handleMarkRead, ...mutation } = useMutation({\n onMutate: async (read: boolean) => {\n update({\n ...conversation,\n unreadCount: read ? 0 : 1,\n })\n handlePersonUnreadCount(read)\n },\n mutationKey: ['markRead', conversation.id],\n mutationFn: async (read: boolean) => {\n const action = read ? 'mark_read' : 'mark_unread'\n\n return apiClient.chat.post({\n url: `/me/conversations/${conversation.id}/${action}`,\n data: { data: { type: '', attributes: {} }, fields: { Conversation: 'unread_count,id' } },\n })\n },\n onSuccess: () => {\n fetchUpdate(conversation)\n },\n onError: () => {\n Alert.alert('Oops', 'Something went wrong updating this conversation, please try again')\n invalidate()\n },\n })\n\n return {\n read: conversation.unreadCount < 1, // prefer cache\n markRead: handleMarkRead,\n ...mutation,\n }\n}\n\nexport const useConversationsMute = ({ conversation }: { conversation: ConversationResource }) => {\n const apiClient = useApiClient()\n const { args } = useConversationsContext()\n const { update, invalidate } = useConversationsCache(args)\n\n const { mutate: setMuted, ...mutation } = useMutation({\n onMutate: async (muted: boolean) => {\n update({\n ...conversation,\n muted,\n })\n },\n mutationKey: ['muteConversation'],\n mutationFn: async (muted: boolean) => {\n const action = muted ? 'mute' : 'unmute'\n\n return apiClient.chat.post<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation.id}/${action}`,\n data: { data: { type: '', attributes: {} }, fields: { Conversation: 'muted' } },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n update(response.data)\n },\n onError: () => {\n Alert.alert('Oops', 'Something went wrong muting this conversation, please try again')\n invalidate()\n },\n })\n\n return {\n muted: conversation.muted, // prefer cache\n setMuted,\n ...mutation,\n }\n}\n\nexport const useMarkAllRead = () => {\n const apiClient = useApiClient()\n const { args } = useConversationsContext()\n const { invalidate, updateAll } = useConversationsCache(args)\n const { mutate: markAllRead, ...query } = useMutation({\n onMutate: () => {\n updateAll({\n unreadCount: 0,\n })\n },\n mutationKey: ['markAllRead', args],\n mutationFn: () =>\n apiClient.chat.post({\n url: '/me/mark_all_read',\n }),\n onSettled: invalidate,\n })\n\n return {\n markAllRead,\n ...query,\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_mark_latest_message_read.d.ts","sourceRoot":"","sources":["../../src/hooks/use_mark_latest_message_read.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use_mark_latest_message_read.d.ts","sourceRoot":"","sources":["../../src/hooks/use_mark_latest_message_read.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAIhE,UAAU,KAAK;IACb,YAAY,EAAE,oBAAoB,CAAA;IAClC,QAAQ,EAAE,eAAe,EAAE,CAAA;CAC5B;AAED,wBAAgB,wBAAwB,CAAC,EAAE,YAAY,EAAE,EAAE,KAAK,QAsB/D"}
|
|
@@ -1,33 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debounce } from 'lodash';
|
|
2
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
2
3
|
import { useAppState } from './use_app_state';
|
|
3
4
|
import { useConversationsMarkRead } from './use_conversations_actions';
|
|
4
5
|
export function useMarkLatestMessageRead({ conversation }) {
|
|
6
|
+
const firedOnce = useRef(false);
|
|
5
7
|
const { markRead } = useConversationsMarkRead({ conversation });
|
|
6
|
-
const debouncedMarkRead =
|
|
8
|
+
const debouncedMarkRead = useMemo(() => debounce(markRead, 1000, { leading: true, trailing: true }), [markRead]);
|
|
7
9
|
const unreadCount = conversation.unreadCount;
|
|
10
|
+
const unreadReactionCount = conversation.unreadReactionCount || 0;
|
|
11
|
+
const shouldMarkRead = Boolean(unreadCount >= 1 || unreadReactionCount > 0);
|
|
8
12
|
const appState = useAppState();
|
|
9
13
|
const isActive = appState === 'active';
|
|
10
|
-
/**
|
|
11
|
-
* Handle marking the conversation as read.
|
|
12
|
-
* * The app needs to be active
|
|
13
|
-
* * The latest message from someone else is newer than the last read message
|
|
14
|
-
*/
|
|
15
14
|
useEffect(() => {
|
|
16
|
-
if (!isActive ||
|
|
15
|
+
if (!isActive || !shouldMarkRead)
|
|
17
16
|
return;
|
|
17
|
+
firedOnce.current = true;
|
|
18
18
|
debouncedMarkRead(true);
|
|
19
|
-
|
|
19
|
+
// keeping unreadReactionCount in the dependency array to watch for changes
|
|
20
|
+
}, [debouncedMarkRead, isActive, shouldMarkRead, unreadReactionCount]);
|
|
20
21
|
}
|
|
21
|
-
const useDebounce = (fn, delay) => {
|
|
22
|
-
const lastBroadcastTime = useRef(0);
|
|
23
|
-
const action = useCallback((...args) => {
|
|
24
|
-
const now = Date.now();
|
|
25
|
-
if (now - lastBroadcastTime.current < delay) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
lastBroadcastTime.current = now;
|
|
29
|
-
fn(...args);
|
|
30
|
-
}, [delay, fn]);
|
|
31
|
-
return action;
|
|
32
|
-
};
|
|
33
22
|
//# sourceMappingURL=use_mark_latest_message_read.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_mark_latest_message_read.js","sourceRoot":"","sources":["../../src/hooks/use_mark_latest_message_read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use_mark_latest_message_read.js","sourceRoot":"","sources":["../../src/hooks/use_mark_latest_message_read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AAOtE,MAAM,UAAU,wBAAwB,CAAC,EAAE,YAAY,EAAS;IAC9D,MAAM,SAAS,GAAG,MAAM,CAAU,KAAK,CAAC,CAAA;IACxC,MAAM,EAAE,QAAQ,EAAE,GAAG,wBAAwB,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;IAC/D,MAAM,iBAAiB,GAAG,OAAO,CAC/B,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EACjE,CAAC,QAAQ,CAAC,CACX,CAAA;IACD,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAA;IAC5C,MAAM,mBAAmB,GAAG,YAAY,CAAC,mBAAmB,IAAI,CAAC,CAAA;IAEjE,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,IAAI,mBAAmB,GAAG,CAAC,CAAC,CAAA;IAC3E,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,MAAM,QAAQ,GAAG,QAAQ,KAAK,QAAQ,CAAA;IAEtC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,QAAQ,IAAI,CAAC,cAAc;YAAE,OAAM;QAExC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAA;QAExB,iBAAiB,CAAC,IAAI,CAAC,CAAA;QACvB,2EAA2E;IAC7E,CAAC,EAAE,CAAC,iBAAiB,EAAE,QAAQ,EAAE,cAAc,EAAE,mBAAmB,CAAC,CAAC,CAAA;AACxE,CAAC","sourcesContent":["import { debounce } from 'lodash'\nimport { useEffect, useMemo, useRef } from 'react'\nimport { ConversationResource, MessageResource } from '../types'\nimport { useAppState } from './use_app_state'\nimport { useConversationsMarkRead } from './use_conversations_actions'\n\ninterface Props {\n conversation: ConversationResource\n messages: MessageResource[]\n}\n\nexport function useMarkLatestMessageRead({ conversation }: Props) {\n const firedOnce = useRef<boolean>(false)\n const { markRead } = useConversationsMarkRead({ conversation })\n const debouncedMarkRead = useMemo(\n () => debounce(markRead, 1000, { leading: true, trailing: true }),\n [markRead]\n )\n const unreadCount = conversation.unreadCount\n const unreadReactionCount = conversation.unreadReactionCount || 0\n\n const shouldMarkRead = Boolean(unreadCount >= 1 || unreadReactionCount > 0)\n const appState = useAppState()\n const isActive = appState === 'active'\n\n useEffect(() => {\n if (!isActive || !shouldMarkRead) return\n\n firedOnce.current = true\n\n debouncedMarkRead(true)\n // keeping unreadReactionCount in the dependency array to watch for changes\n }, [debouncedMarkRead, isActive, shouldMarkRead, unreadReactionCount])\n}\n"]}
|
|
@@ -8,7 +8,7 @@ type UseMessageReactionToggleProps = {
|
|
|
8
8
|
};
|
|
9
9
|
type ToggleReactionParams = {
|
|
10
10
|
value: ReactionCountResource['value'];
|
|
11
|
-
mine
|
|
11
|
+
mine: boolean;
|
|
12
12
|
};
|
|
13
13
|
type QueryData = InfiniteData<ApiCollection<MessageResource>>;
|
|
14
14
|
export declare function useMessageReactionToggle({ conversation_id, message, onSuccess, }: UseMessageReactionToggleProps): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_message_reaction_toggle.d.ts","sourceRoot":"","sources":["../../src/hooks/use_message_reaction_toggle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA+B,MAAM,uBAAuB,CAAA;AAKjF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"use_message_reaction_toggle.d.ts","sourceRoot":"","sources":["../../src/hooks/use_message_reaction_toggle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA+B,MAAM,uBAAuB,CAAA;AAKjF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAMnE,KAAK,6BAA6B,GAAG;IACnC,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB,CAAA;AAED,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAA;IACrC,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,KAAK,SAAS,GAAG,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAA;AAE7D,wBAAgB,wBAAwB,CAAC,EACvC,eAAe,EACf,OAAO,EACP,SAAS,GACV,EAAE,6BAA6B;;;;;EA0E/B"}
|
|
@@ -3,7 +3,9 @@ import { useCallback } from 'react';
|
|
|
3
3
|
import { Alert } from 'react-native';
|
|
4
4
|
import { useApiClient } from './use_api_client';
|
|
5
5
|
import { getMessagesQueryKey, getMessagesRequestArgs } from '../utils/request/get_messages';
|
|
6
|
-
import { updateRecordInPagesData } from '../utils';
|
|
6
|
+
import { updateRecordInPagesData, REACTION_EMOJIS } from '../utils';
|
|
7
|
+
const REACT = 1;
|
|
8
|
+
const UNREACT = -1;
|
|
7
9
|
export function useMessageReactionToggle({ conversation_id, message, onSuccess, }) {
|
|
8
10
|
const apiClient = useApiClient();
|
|
9
11
|
const queryClient = useQueryClient();
|
|
@@ -12,7 +14,7 @@ export function useMessageReactionToggle({ conversation_id, message, onSuccess,
|
|
|
12
14
|
const toggleReaction = useCallback(({ value, mine }) => {
|
|
13
15
|
const requestParams = getMessagesRequestArgs({ conversation_id });
|
|
14
16
|
// If already reacted, unreact; otherwise react
|
|
15
|
-
const endpoint =
|
|
17
|
+
const endpoint = mine ? 'unreact' : 'react';
|
|
16
18
|
const url = `/me/conversations/${conversation_id}/messages/${message_id}/${endpoint}`;
|
|
17
19
|
const fieldsWithValueJoined = Object.fromEntries(Object.entries(requestParams.data.fields).map(([k, v]) => [k, v.join(',')]));
|
|
18
20
|
return apiClient.chat.post({
|
|
@@ -36,7 +38,7 @@ export function useMessageReactionToggle({ conversation_id, message, onSuccess,
|
|
|
36
38
|
message,
|
|
37
39
|
data,
|
|
38
40
|
value: variables.value,
|
|
39
|
-
|
|
41
|
+
mine: variables.mine,
|
|
40
42
|
}));
|
|
41
43
|
}
|
|
42
44
|
return { previousData };
|
|
@@ -63,19 +65,18 @@ export function useMessageReactionToggle({ conversation_id, message, onSuccess,
|
|
|
63
65
|
isPending,
|
|
64
66
|
};
|
|
65
67
|
}
|
|
66
|
-
const optimisticUpdate = ({ message, data, value,
|
|
68
|
+
const optimisticUpdate = ({ message, data, value, mine, }) => {
|
|
67
69
|
if (!data)
|
|
68
70
|
return data;
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
71
|
+
const hasExistingReaction = message.reactionCounts.some(r => r.value === value);
|
|
72
|
+
let updatedReactionCounts;
|
|
73
|
+
if (hasExistingReaction) {
|
|
74
|
+
const delta = mine ? UNREACT : REACT;
|
|
75
|
+
updatedReactionCounts = updateCount(message.reactionCounts, value, delta);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
updatedReactionCounts = createCount(message.reactionCounts, value, message.id);
|
|
79
|
+
}
|
|
79
80
|
const updatedMessage = {
|
|
80
81
|
...message,
|
|
81
82
|
reactionCounts: updatedReactionCounts,
|
|
@@ -85,4 +86,33 @@ const optimisticUpdate = ({ message, data, value, state, }) => {
|
|
|
85
86
|
record: updatedMessage,
|
|
86
87
|
});
|
|
87
88
|
};
|
|
89
|
+
const updateCount = (reactionCounts, value, delta) => {
|
|
90
|
+
return reactionCounts.map(reaction => {
|
|
91
|
+
if (reaction.value === value) {
|
|
92
|
+
return {
|
|
93
|
+
...reaction,
|
|
94
|
+
mine: delta > 0 ? 1 : 0,
|
|
95
|
+
count: reaction.count + delta,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return reaction;
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
const createCount = (reactionCounts, value, messageId) => {
|
|
102
|
+
const reactionOrder = Object.keys(REACTION_EMOJIS);
|
|
103
|
+
const newReactionIndex = reactionOrder.indexOf(value);
|
|
104
|
+
const insertIndex = reactionCounts.findIndex(r => reactionOrder.indexOf(r.value) > newReactionIndex);
|
|
105
|
+
const newReaction = {
|
|
106
|
+
type: 'ReactionCount',
|
|
107
|
+
id: `${messageId}/${value}`,
|
|
108
|
+
value,
|
|
109
|
+
count: 1,
|
|
110
|
+
mine: 1,
|
|
111
|
+
messageId,
|
|
112
|
+
authorIds: [],
|
|
113
|
+
};
|
|
114
|
+
return insertIndex === -1
|
|
115
|
+
? [...reactionCounts, newReaction]
|
|
116
|
+
: [...reactionCounts.slice(0, insertIndex), newReaction, ...reactionCounts.slice(insertIndex)];
|
|
117
|
+
};
|
|
88
118
|
//# sourceMappingURL=use_message_reaction_toggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_message_reaction_toggle.js","sourceRoot":"","sources":["../../src/hooks/use_message_reaction_toggle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAG3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"use_message_reaction_toggle.js","sourceRoot":"","sources":["../../src/hooks/use_message_reaction_toggle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAG3F,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEnE,MAAM,KAAK,GAAG,CAAC,CAAA;AACf,MAAM,OAAO,GAAG,CAAC,CAAC,CAAA;AAelB,MAAM,UAAU,wBAAwB,CAAC,EACvC,eAAe,EACf,OAAO,EACP,SAAS,GACqB;IAC9B,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAA;IACzD,MAAM,UAAU,GAAG,O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gB,CACvD,CAAA;IAED,MAAM,WAAW,GAA0B;QACzC,IAAI,EAAE,eAAe;QACrB,EAAE,EAAE,GAAG,SAAS,IAAI,KAAK,EAAE;QAC3B,KAAK;QACL,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;QACP,SAAS;QACT,SAAS,EAAE,EAAE;KACd,CAAA;IAED,OAAO,WAAW,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC,GAAG,cAAc,EAAE,WAAW,CAAC;QAClC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;AAClG,CAAC,CAAA","sourcesContent":["import { InfiniteData, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useCallback } from 'react'\nimport { Alert } from 'react-native'\nimport { useApiClient } from './use_api_client'\nimport { getMessagesQueryKey, getMessagesRequestArgs } from '../utils/request/get_messages'\nimport { ApiCollection, ApiResource, MessageResource } from '../types'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { updateRecordInPagesData, REACTION_EMOJIS } from '../utils'\n\nconst REACT = 1\nconst UNREACT = -1\n\ntype UseMessageReactionToggleProps = {\n conversation_id: number\n message: MessageResource\n onSuccess?: () => void\n}\n\ntype ToggleReactionParams = {\n value: ReactionCountResource['value']\n mine: boolean\n}\n\ntype QueryData = InfiniteData<ApiCollection<MessageResource>>\n\nexport function useMessageReactionToggle({\n conversation_id,\n message,\n onSuccess,\n}: UseMessageReactionToggleProps) {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const queryKey = getMessagesQueryKey({ conversation_id })\n const message_id = message.id\n\n const toggleReaction = useCallback(\n ({ value, mine }: ToggleReactionParams) => {\n const requestParams = getMessagesRequestArgs({ conversation_id })\n\n // If already reacted, unreact; otherwise react\n const endpoint = mine ? 'unreact' : 'react'\n const url = `/me/conversations/${conversation_id}/messages/${message_id}/${endpoint}`\n const fieldsWithValueJoined = Object.fromEntries(\n Object.entries(requestParams.data.fields).map(([k, v]) => [k, v.join(',')])\n )\n\n return apiClient.chat.post<ApiResource<MessageResource>>({\n url,\n data: {\n ...requestParams.data,\n data: {\n type: 'Message',\n attributes: { value: value },\n },\n fields: fieldsWithValueJoined,\n },\n })\n },\n [apiClient, conversation_id, message_id]\n )\n\n const { mutate: handleReactionToggle, isPending } = useMutation({\n mutationFn: toggleReaction,\n onMutate: variables => {\n const previousData = queryClient.getQueryData<QueryData>(queryKey)\n if (previousData) {\n queryClient.setQueryData<QueryData>(queryKey, data =>\n optimisticUpdate({\n message,\n data,\n value: variables.value,\n mine: variables.mine,\n })\n )\n }\n return { previousData }\n },\n onSuccess: result => {\n const updatedMessage = result.data\n\n queryClient.setQueryData<QueryData>(queryKey, data =>\n updateRecordInPagesData({\n data,\n record: updatedMessage,\n })\n )\n\n if (onSuccess) {\n onSuccess()\n }\n },\n onError: (_data, _variables, context) => {\n if (context?.previousData) {\n queryClient.setQueryData<QueryData>(queryKey, context.previousData)\n }\n Alert.alert('Oops', 'We were unable to react to this message. Please try again.')\n },\n })\n\n return {\n handleReactionToggle,\n isPending,\n }\n}\n\nconst optimisticUpdate = ({\n message,\n data,\n value,\n mine,\n}: {\n message: MessageResource\n data: QueryData | undefined\n value: ReactionCountResource['value']\n mine: boolean\n}) => {\n if (!data) return data\n\n const hasExistingReaction = message.reactionCounts.some(r => r.value === value)\n\n let updatedReactionCounts: ReactionCountResource[]\n\n if (hasExistingReaction) {\n const delta = mine ? UNREACT : REACT\n updatedReactionCounts = updateCount(message.reactionCounts, value, delta)\n } else {\n updatedReactionCounts = createCount(message.reactionCounts, value, message.id)\n }\n\n const updatedMessage: MessageResource = {\n ...message,\n reactionCounts: updatedReactionCounts,\n }\n\n return updateRecordInPagesData({\n data,\n record: updatedMessage,\n })\n}\n\nconst updateCount = (\n reactionCounts: ReactionCountResource[],\n value: ReactionCountResource['value'],\n delta: typeof REACT | typeof UNREACT\n): ReactionCountResource[] => {\n return reactionCounts.map(reaction => {\n if (reaction.value === value) {\n return {\n ...reaction,\n mine: delta > 0 ? 1 : 0,\n count: reaction.count + delta,\n } as ReactionCountResource\n }\n return reaction\n })\n}\n\nconst createCount = (\n reactionCounts: ReactionCountResource[],\n value: ReactionCountResource['value'],\n messageId: string\n): ReactionCountResource[] => {\n const reactionOrder = Object.keys(REACTION_EMOJIS) as ReactionCountResource['value'][]\n const newReactionIndex = reactionOrder.indexOf(value)\n const insertIndex = reactionCounts.findIndex(\n r => reactionOrder.indexOf(r.value) > newReactionIndex\n )\n\n const newReaction: ReactionCountResource = {\n type: 'ReactionCount',\n id: `${messageId}/${value}`,\n value,\n count: 1,\n mine: 1,\n messageId,\n authorIds: [],\n }\n\n return insertIndex === -1\n ? [...reactionCounts, newReaction]\n : [...reactionCounts.slice(0, insertIndex), newReaction, ...reactionCounts.slice(insertIndex)]\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_actions_screen.d.ts","sourceRoot":"","sources":["../../src/screens/message_actions_screen.tsx"],"names":[],"mappings":"AACA,OAAO,EAAgB,iBAAiB,EAAiB,MAAM,0BAA0B,CAAA;AAGzF,OAAO,KAAsB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"message_actions_screen.d.ts","sourceRoot":"","sources":["../../src/screens/message_actions_screen.tsx"],"names":[],"mappings":"AACA,OAAO,EAAgB,iBAAiB,EAAiB,MAAM,0BAA0B,CAAA;AAGzF,OAAO,KAAsB,MAAM,OAAO,CAAA;AAe1C,eAAO,MAAM,2BAA2B,uEAGtC,CAAA;AAEF,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;IACxD,UAAU,EAAE,MAAM,CAAA;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,eAAe,EAAE,MAAM,CAAA;IACvB,4BAA4B,CAAC,EAAE,OAAO,CAAA;IACtC,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAC,CAAA;AAEF,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,EAAE,yBAAyB,4BA2BxE"}
|
|
@@ -5,7 +5,8 @@ import { isNil, omitBy } from 'lodash';
|
|
|
5
5
|
import React, { useCallback } from 'react';
|
|
6
6
|
import { Alert, Platform, StyleSheet, View } from 'react-native';
|
|
7
7
|
import { Text } from '../components';
|
|
8
|
-
import {
|
|
8
|
+
import { useReactionStyles } from '../components/conversation/message_reaction';
|
|
9
|
+
import { REACTION_EMOJIS } from '../utils';
|
|
9
10
|
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet';
|
|
10
11
|
import { useCreateAndroidRippleColor, useFontScale, useTheme } from '../hooks';
|
|
11
12
|
import { useApiClient } from '../hooks/use_api_client';
|
|
@@ -67,7 +68,6 @@ function MessageActionsScreenContent({ message, conversation_id, canDeleteNonAut
|
|
|
67
68
|
const { handleReactionToggle, isPending } = useMessageReactionToggle({
|
|
68
69
|
conversation_id,
|
|
69
70
|
message,
|
|
70
|
-
onSuccess: () => navigation.goBack(),
|
|
71
71
|
});
|
|
72
72
|
const deleteMessage = useCallback(() => {
|
|
73
73
|
const url = `/me/conversations/${conversation_id}/messages/${message.id}/`;
|
|
@@ -141,6 +141,7 @@ function MessageActionsScreenContent({ message, conversation_id, canDeleteNonAut
|
|
|
141
141
|
value: reaction.value,
|
|
142
142
|
mine: reaction.mine,
|
|
143
143
|
});
|
|
144
|
+
navigation.goBack();
|
|
144
145
|
}}/>))}
|
|
145
146
|
</View>
|
|
146
147
|
<View style={styles.actions}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_actions_screen.js","sourceRoot":"","sources":["../../src/screens/message_actions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACzF,OAAO,EAAE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,EAAE;YACP,UAAU,EAAE,CAAC;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport { StackActions, StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport { useMutation } from '@tanstack/react-query'\nimport { isNil, omitBy } from 'lodash'\nimport React, { useCallback } from 'react'\nimport { Alert, Platform, StyleSheet, View } from 'react-native'\nimport { Text } from '../components'\nimport { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { useCreateAndroidRippleColor, useFontScale, useTheme } from '../hooks'\nimport { useApiClient } from '../hooks/use_api_client'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { Clipboard, Haptic } from '../utils/native_adapters'\nimport { MessageResource } from '../types'\nimport { availableFeatures, useFeatures } from '../hooks/use_features'\n\nexport const MessageActionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: [0.5],\n headerTitle: 'Message actions',\n})\n\nexport type MessageActionsScreenProps = StaticScreenProps<{\n message_id: string\n reply_root_author_name?: string\n conversation_id: number\n canDeleteNonAuthoredMessages?: boolean\n inReplyScreen?: boolean\n}>\n\nexport function MessageActionsScreen({ route }: MessageActionsScreenProps) {\n const {\n conversation_id,\n message_id,\n canDeleteNonAuthoredMessages,\n inReplyScreen,\n reply_root_author_name,\n } = route.params\n\n const { messages, refetch } = useConversationMessages(\n { conversation_id },\n { refetchOnMount: false }\n )\n const message = messages.find(m => m.id === message_id)\n\n if (!message) return null\n\n return (\n <MessageActionsScreenContent\n message={message}\n conversation_id={conversation_id}\n canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages || false}\n refetchMessages={refetch}\n inReplyScreen={inReplyScreen}\n replyRootAuthorName={reply_root_author_name}\n />\n )\n}\n\nfunction MessageActionsScreenContent({\n message,\n conversation_id,\n canDeleteNonAuthoredMessages,\n refetchMessages,\n inReplyScreen,\n replyRootAuthorName,\n}: {\n message: MessageResource\n conversation_id: number\n canDeleteNonAuthoredMessages: boolean\n refetchMessages: () => void\n inReplyScreen?: boolean\n replyRootAuthorName?: string\n}) {\n const navigation = useNavigation()\n const apiClient = useApiClient()\n const styles = useStyles()\n const { featureEnabled } = useFeatures()\n const repliesEnabled = featureEnabled(availableFeatures.threaded_replies)\n const expandedLink = message.attachments.find(attachment => attachment.type === 'ExpandedLink')\n const hasExpandedLink = !!expandedLink\n\n const myReactions = message?.reactionCounts\n .filter(reaction => reaction.mine)\n .map(reaction => reaction.value)\n\n const availableReactions = Object.entries(REACTION_EMOJIS).map(([value, emoji]) => {\n return {\n value: value as ReactionCountResource['value'],\n emoji,\n mine: myReactions?.includes(value as ReactionCountResource['value']),\n }\n })\n\n const attachmentForCopy = (): string => {\n const giphyTitleLink = message?.attachments.find(\n attachment => attachment.type === 'giphy'\n )?.titleLink\n\n if (giphyTitleLink) return giphyTitleLink\n return ''\n }\n\n const handleReplyPress = useCallback(() => {\n navigation.goBack()\n // Waits for the modal to be dismissed before pushing the reply screen\n requestAnimationFrame(() => {\n navigation.navigate('ConversationReply', {\n conversation_id,\n reply_root_id: message.replyRootId || message.id,\n reply_root_author_name: replyRootAuthorName,\n })\n })\n }, [navigation, conversation_id, message.id, message.replyRootId, replyRootAuthorName])\n\n const handleCopyPress = () => {\n Clipboard.setStringAsync(message?.text || attachmentForCopy() || '')\n navigation.goBack()\n }\n\n const { handleReactionToggle, isPending } = useMessageReactionToggle({\n conversation_id,\n message,\n onSuccess: () => navigation.goBack(),\n })\n\n const deleteMessage = useCallback(() => {\n const url = `/me/conversations/${conversation_id}/messages/${message.id}/`\n\n return apiClient.chat.delete({ url })\n }, [apiClient, conversation_id, message.id])\n\n const { mutate: handleDeleteMessage } = useMutation({\n mutationFn: deleteMessage,\n onSuccess: () => {\n refetchMessages()\n Haptic.notificationSuccess()\n navigation.goBack()\n },\n onError: () => {\n Alert.alert('Oops', 'We were unable to delete this message. Please try again.')\n },\n })\n\n const handleDeleteConfirm = useCallback(() => {\n Alert.alert('Delete message', 'Are you sure you want to permanently delete this message?', [\n { text: 'Cancel', style: 'cancel' },\n { text: 'Delete', style: 'destructive', onPress: () => handleDeleteMessage() },\n ])\n }, [handleDeleteMessage])\n\n const handleEditPress = useCallback(() => {\n const state = navigation.getState?.()\n const targetRouteName = inReplyScreen ? 'ConversationReply' : 'Conversation'\n const targetRoute = state?.routes?.find(r => r.name === targetRouteName)\n const params = omitBy(\n {\n ...(targetRoute?.params || {}),\n conversation_id,\n editing_message_id: message.id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo(targetRouteName, params))\n }, [navigation, conversation_id, message.id, inReplyScreen])\n\n const handleViewReadReceiptsPress = useCallback(() => {\n Haptic.impactLight()\n const params = omitBy(\n {\n conversation_id,\n message_id: message.id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo('MessageReadReceipts', params))\n }, [navigation, conversation_id, message.id])\n\n const removeLinkPreview = useCallback(() => {\n const url = `/me/conversations/${conversation_id}/messages/${message.id}/remove_expanded_link`\n const data = {\n data: { type: 'ExpandedLink', attributes: { expanded_link_id: expandedLink?.id } },\n }\n\n return apiClient.chat.post({ url, data })\n }, [apiClient, conversation_id, message.id, expandedLink])\n\n const { mutate: handleRemoveLinkPreview } = useMutation({\n mutationFn: removeLinkPreview,\n onSuccess: () => {\n refetchMessages()\n Haptic.notificationSuccess()\n navigation.goBack()\n },\n onError: () => {\n Alert.alert('Oops', 'We were unable to remove the preview. Please try again.')\n },\n })\n\n const handleRemoveLinkPreviewConfirm = useCallback(() => {\n Alert.alert('Remove link preview?', 'This will remove the image preview but retain the link', [\n { text: 'Cancel', style: 'cancel' },\n { text: 'Remove', style: 'destructive', onPress: () => handleRemoveLinkPreview() },\n ])\n }, [handleRemoveLinkPreview])\n\n return (\n <FormSheet.Root style={styles.formSheetContent}>\n <View style={styles.reactionList}>\n {availableReactions.map((reaction, index) => (\n <Reaction\n key={index}\n reaction={reaction}\n onPress={() => {\n Haptic.impactLight()\n handleReactionToggle({\n value: reaction.value,\n mine: reaction.mine,\n })\n }}\n />\n ))}\n </View>\n <View style={styles.actions}>\n {repliesEnabled && !inReplyScreen && (\n <FormSheet.Action\n onPress={handleReplyPress}\n title=\"Reply to message\"\n iconName=\"registrations.undo\"\n accessibilityHint=\"Navigates to the reply screen\"\n accessibilityRole=\"link\"\n />\n )}\n <FormSheet.Action\n onPress={handleCopyPress}\n title=\"Copy text\"\n iconName=\"services.fileCopy\"\n accessibilityHint=\"Copies text and links to clipboard\"\n />\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleEditPress()}\n title=\"Edit message\"\n iconName=\"accounts.editor\"\n accessibilityHint=\"Opens existing text in the message form input.\"\n />\n )}\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleViewReadReceiptsPress()}\n title=\"View read receipts\"\n iconName=\"general.checkPerson\"\n accessibilityHint=\"Opens a modal with a list of people who read your message.\"\n />\n )}\n {message?.mine && hasExpandedLink && (\n <FormSheet.Action\n onPress={() => handleRemoveLinkPreviewConfirm()}\n title=\"Remove link preview\"\n iconName=\"general.brokenLink\"\n accessibilityHint=\"Removes an expanded link preview from the message.\"\n />\n )}\n {(message?.mine || canDeleteNonAuthoredMessages) && (\n <FormSheet.Action\n onPress={() => handleDeleteConfirm()}\n title=\"Delete message\"\n iconName=\"publishing.trash\"\n appearance=\"danger\"\n disabled={isPending}\n accessibilityHint=\"Opens a confirmation alert to delete this message permanently.\"\n />\n )}\n </View>\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n onPress,\n}: {\n reaction: { value: ReactionCountResource['value']; emoji: string; mine: boolean | undefined }\n onPress: () => void\n}) => {\n const styles = useStyles()\n const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })\n\n const { colors } = useTheme()\n const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060\n const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })\n\n return (\n <PlatformPressable\n key={reaction.value}\n style={[reactionStyles.reaction, styles.reaction]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n onPress={onPress}\n >\n <Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })\n\n const btnBorderWidth = 1\n const baseSize = 46 * fontScale\n const reactionBtnSize = Platform.select({\n ios: baseSize,\n android: baseSize + btnBorderWidth * 2,\n })\n\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: 16,\n },\n reactionList: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n gap: 16,\n paddingTop: 8,\n paddingBottom: 16,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n reaction: {\n height: reactionBtnSize,\n width: reactionBtnSize,\n borderWidth: btnBorderWidth,\n borderRadius: 32,\n justifyContent: 'center',\n overflow: 'hidden',\n },\n reactionEmoji: {\n fontSize: 24,\n },\n actions: {\n paddingTop: 4,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message_actions_screen.js","sourceRoot":"","sources":["../../src/screens/message_actions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAA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5E;IAAA,EAAE,iBAAiB,CAAC,CACrB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC7B,MAAM,SAAS,GAAG,YAAY,CAAC,EAAE,qBAAqB,EAAE,GAAG,EAAE,CAAC,CAAA;IAE9D,MAAM,cAAc,GAAG,CAAC,CAAA;IACxB,MAAM,QAAQ,GAAG,EAAE,GAAG,SAAS,CAAA;IAC/B,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC;QACtC,GAAG,EAAE,QAAQ;QACb,OAAO,EAAE,QAAQ,GAAG,cAAc,GAAG,CAAC;KACvC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE;YAChB,UAAU,EAAE,EAAE;SACf;QACD,YAAY,EAAE;YACZ,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;YACP,UAAU,EAAE,CAAC;YACb,aAAa,EAAE,EAAE;YACjB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;YAChD,iBAAiB,EAAE,CAAC;SACrB;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,eAAe;YACvB,KAAK,EAAE,eAAe;YACtB,WAAW,EAAE,cAAc;YAC3B,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,QAAQ;YACxB,QAAQ,EAAE,QAAQ;SACnB;QACD,aAAa,EAAE;YACb,QAAQ,EAAE,EAAE;SACb;QACD,OAAO,EAAE;YACP,UAAU,EAAE,CAAC;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport { StackActions, StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport { useMutation } from '@tanstack/react-query'\nimport { isNil, omitBy } from 'lodash'\nimport React, { useCallback } from 'react'\nimport { Alert, Platform, StyleSheet, View } from 'react-native'\nimport { Text } from '../components'\nimport { useReactionStyles } from '../components/conversation/message_reaction'\nimport { REACTION_EMOJIS } from '../utils'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { useCreateAndroidRippleColor, useFontScale, useTheme } from '../hooks'\nimport { useApiClient } from '../hooks/use_api_client'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { Clipboard, Haptic } from '../utils/native_adapters'\nimport { MessageResource } from '../types'\nimport { availableFeatures, useFeatures } from '../hooks/use_features'\n\nexport const MessageActionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: [0.5],\n headerTitle: 'Message actions',\n})\n\nexport type MessageActionsScreenProps = StaticScreenProps<{\n message_id: string\n reply_root_author_name?: string\n conversation_id: number\n canDeleteNonAuthoredMessages?: boolean\n inReplyScreen?: boolean\n}>\n\nexport function MessageActionsScreen({ route }: MessageActionsScreenProps) {\n const {\n conversation_id,\n message_id,\n canDeleteNonAuthoredMessages,\n inReplyScreen,\n reply_root_author_name,\n } = route.params\n\n const { messages, refetch } = useConversationMessages(\n { conversation_id },\n { refetchOnMount: false }\n )\n const message = messages.find(m => m.id === message_id)\n\n if (!message) return null\n\n return (\n <MessageActionsScreenContent\n message={message}\n conversation_id={conversation_id}\n canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages || false}\n refetchMessages={refetch}\n inReplyScreen={inReplyScreen}\n replyRootAuthorName={reply_root_author_name}\n />\n )\n}\n\nfunction MessageActionsScreenContent({\n message,\n conversation_id,\n canDeleteNonAuthoredMessages,\n refetchMessages,\n inReplyScreen,\n replyRootAuthorName,\n}: {\n message: MessageResource\n conversation_id: number\n canDeleteNonAuthoredMessages: boolean\n refetchMessages: () => void\n inReplyScreen?: boolean\n replyRootAuthorName?: string\n}) {\n const navigation = useNavigation()\n const apiClient = useApiClient()\n const styles = useStyles()\n const { featureEnabled } = useFeatures()\n const repliesEnabled = featureEnabled(availableFeatures.threaded_replies)\n const expandedLink = message.attachments.find(attachment => attachment.type === 'ExpandedLink')\n const hasExpandedLink = !!expandedLink\n\n const myReactions = message?.reactionCounts\n .filter(reaction => reaction.mine)\n .map(reaction => reaction.value)\n\n const availableReactions = Object.entries(REACTION_EMOJIS).map(([value, emoji]) => {\n return {\n value: value as ReactionCountResource['value'],\n emoji,\n mine: myReactions?.includes(value as ReactionCountResource['value']),\n }\n })\n\n const attachmentForCopy = (): string => {\n const giphyTitleLink = message?.attachments.find(\n attachment => attachment.type === 'giphy'\n )?.titleLink\n\n if (giphyTitleLink) return giphyTitleLink\n return ''\n }\n\n const handleReplyPress = useCallback(() => {\n navigation.goBack()\n // Waits for the modal to be dismissed before pushing the reply screen\n requestAnimationFrame(() => {\n navigation.navigate('ConversationReply', {\n conversation_id,\n reply_root_id: message.replyRootId || message.id,\n reply_root_author_name: replyRootAuthorName,\n })\n })\n }, [navigation, conversation_id, message.id, message.replyRootId, replyRootAuthorName])\n\n const handleCopyPress = () => {\n Clipboard.setStringAsync(message?.text || attachmentForCopy() || '')\n navigation.goBack()\n }\n\n const { handleReactionToggle, isPending } = useMessageReactionToggle({\n conversation_id,\n message,\n })\n\n const deleteMessage = useCallback(() => {\n const url = `/me/conversations/${conversation_id}/messages/${message.id}/`\n\n return apiClient.chat.delete({ url })\n }, [apiClient, conversation_id, message.id])\n\n const { mutate: handleDeleteMessage } = useMutation({\n mutationFn: deleteMessage,\n onSuccess: () => {\n refetchMessages()\n Haptic.notificationSuccess()\n navigation.goBack()\n },\n onError: () => {\n Alert.alert('Oops', 'We were unable to delete this message. Please try again.')\n },\n })\n\n const handleDeleteConfirm = useCallback(() => {\n Alert.alert('Delete message', 'Are you sure you want to permanently delete this message?', [\n { text: 'Cancel', style: 'cancel' },\n { text: 'Delete', style: 'destructive', onPress: () => handleDeleteMessage() },\n ])\n }, [handleDeleteMessage])\n\n const handleEditPress = useCallback(() => {\n const state = navigation.getState?.()\n const targetRouteName = inReplyScreen ? 'ConversationReply' : 'Conversation'\n const targetRoute = state?.routes?.find(r => r.name === targetRouteName)\n const params = omitBy(\n {\n ...(targetRoute?.params || {}),\n conversation_id,\n editing_message_id: message.id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo(targetRouteName, params))\n }, [navigation, conversation_id, message.id, inReplyScreen])\n\n const handleViewReadReceiptsPress = useCallback(() => {\n Haptic.impactLight()\n const params = omitBy(\n {\n conversation_id,\n message_id: message.id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo('MessageReadReceipts', params))\n }, [navigation, conversation_id, message.id])\n\n const removeLinkPreview = useCallback(() => {\n const url = `/me/conversations/${conversation_id}/messages/${message.id}/remove_expanded_link`\n const data = {\n data: { type: 'ExpandedLink', attributes: { expanded_link_id: expandedLink?.id } },\n }\n\n return apiClient.chat.post({ url, data })\n }, [apiClient, conversation_id, message.id, expandedLink])\n\n const { mutate: handleRemoveLinkPreview } = useMutation({\n mutationFn: removeLinkPreview,\n onSuccess: () => {\n refetchMessages()\n Haptic.notificationSuccess()\n navigation.goBack()\n },\n onError: () => {\n Alert.alert('Oops', 'We were unable to remove the preview. Please try again.')\n },\n })\n\n const handleRemoveLinkPreviewConfirm = useCallback(() => {\n Alert.alert('Remove link preview?', 'This will remove the image preview but retain the link', [\n { text: 'Cancel', style: 'cancel' },\n { text: 'Remove', style: 'destructive', onPress: () => handleRemoveLinkPreview() },\n ])\n }, [handleRemoveLinkPreview])\n\n return (\n <FormSheet.Root style={styles.formSheetContent}>\n <View style={styles.reactionList}>\n {availableReactions.map((reaction, index) => (\n <Reaction\n key={index}\n reaction={reaction}\n onPress={() => {\n Haptic.impactLight()\n handleReactionToggle({\n value: reaction.value,\n mine: reaction.mine,\n })\n navigation.goBack()\n }}\n />\n ))}\n </View>\n <View style={styles.actions}>\n {repliesEnabled && !inReplyScreen && (\n <FormSheet.Action\n onPress={handleReplyPress}\n title=\"Reply to message\"\n iconName=\"registrations.undo\"\n accessibilityHint=\"Navigates to the reply screen\"\n accessibilityRole=\"link\"\n />\n )}\n <FormSheet.Action\n onPress={handleCopyPress}\n title=\"Copy text\"\n iconName=\"services.fileCopy\"\n accessibilityHint=\"Copies text and links to clipboard\"\n />\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleEditPress()}\n title=\"Edit message\"\n iconName=\"accounts.editor\"\n accessibilityHint=\"Opens existing text in the message form input.\"\n />\n )}\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleViewReadReceiptsPress()}\n title=\"View read receipts\"\n iconName=\"general.checkPerson\"\n accessibilityHint=\"Opens a modal with a list of people who read your message.\"\n />\n )}\n {message?.mine && hasExpandedLink && (\n <FormSheet.Action\n onPress={() => handleRemoveLinkPreviewConfirm()}\n title=\"Remove link preview\"\n iconName=\"general.brokenLink\"\n accessibilityHint=\"Removes an expanded link preview from the message.\"\n />\n )}\n {(message?.mine || canDeleteNonAuthoredMessages) && (\n <FormSheet.Action\n onPress={() => handleDeleteConfirm()}\n title=\"Delete message\"\n iconName=\"publishing.trash\"\n appearance=\"danger\"\n disabled={isPending}\n accessibilityHint=\"Opens a confirmation alert to delete this message permanently.\"\n />\n )}\n </View>\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n onPress,\n}: {\n reaction: { value: ReactionCountResource['value']; emoji: string; mine: boolean | undefined }\n onPress: () => void\n}) => {\n const styles = useStyles()\n const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })\n\n const { colors } = useTheme()\n const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060\n const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })\n\n return (\n <PlatformPressable\n key={reaction.value}\n style={[reactionStyles.reaction, styles.reaction]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n onPress={onPress}\n >\n <Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })\n\n const btnBorderWidth = 1\n const baseSize = 46 * fontScale\n const reactionBtnSize = Platform.select({\n ios: baseSize,\n android: baseSize + btnBorderWidth * 2,\n })\n\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: 16,\n },\n reactionList: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n gap: 16,\n paddingTop: 8,\n paddingBottom: 16,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n reaction: {\n height: reactionBtnSize,\n width: reactionBtnSize,\n borderWidth: btnBorderWidth,\n borderRadius: 32,\n justifyContent: 'center',\n overflow: 'hidden',\n },\n reactionEmoji: {\n fontSize: 24,\n },\n actions: {\n paddingTop: 4,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions_screen.d.ts","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAe,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"reactions_screen.d.ts","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAe,MAAM,OAAO,CAAA;AAcnC,eAAO,MAAM,sBAAsB,uEAMjC,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;IAClD,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC,CAAA;AAEF,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,EAAE,mBAAmB,qBAkE7D"}
|
|
@@ -3,13 +3,12 @@ import { Platform, StyleSheet, View } from 'react-native';
|
|
|
3
3
|
import { FlatList } from 'react-native-gesture-handler';
|
|
4
4
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
5
5
|
import { Avatar, Text } from '../components';
|
|
6
|
-
import { REACTION_EMOJIS } from '../components/conversation/message_reaction';
|
|
7
6
|
import { Tabs } from '../components/display/tabs';
|
|
8
7
|
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet';
|
|
9
8
|
import { useSuspenseGet, useTheme } from '../hooks';
|
|
10
9
|
import { useConversationMessages } from '../hooks/use_conversation_messages';
|
|
11
10
|
import { useFontScale } from '../hooks/use_font_scale';
|
|
12
|
-
import { platformFontWeightMedium } from '../utils';
|
|
11
|
+
import { platformFontWeightMedium, REACTION_EMOJIS } from '../utils';
|
|
13
12
|
export const ReactionsScreenOptions = getFormSheetScreenOptions({
|
|
14
13
|
sheetAllowedDetents: Platform.select({
|
|
15
14
|
android: [0.5, 0.94], // Going straight to full 0.94 preserves height of screen on Android
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions_screen.js","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AACjD,OAAO,SAAS,EAAE,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAA;AACzF,OAAO,EAAE,cAAc,EAAE,Q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E,EAAE;YACrB,IAAI,EAAE,CAAC;SACR;QACD,UAAU,EAAE;YACV,IAAI,EAAE,CAAC;SACR;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,CAAC;YACpB,eAAe,EAAE,EAAE;YACnB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;SACP;QACD,eAAe,EAAE;YACf,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,wBAAwB;SACrC;QACD,OAAO,EAAE;YACP,SAAS,EAAE,EAAE,GAAG,SAAS;YACzB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;YAChD,iBAAiB,EAAE,CAAC;SACrB;QACD,cAAc,EAAE;YACd,IAAI,EAAE,CAAC;YACP,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StaticScreenProps } from '@react-navigation/native'\nimport React, { memo } from 'react'\nimport { Platform, StyleSheet, View } from 'react-native'\nimport { FlatList } from 'react-native-gesture-handler'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Avatar, Text } from '../components'\nimport { REACTION_EMOJIS } from '../components/conversation/message_reaction'\nimport { Tabs } from '../components/display/tabs'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { useSuspenseGet, useTheme } from '../hooks'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useFontScale } from '../hooks/use_font_scale'\nimport { MemberResource } from '../types'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { platformFontWeightMedium } from '../utils'\n\nexport const ReactionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: Platform.select({\n android: [0.5, 0.94], // Going straight to full 0.94 preserves height of screen on Android\n default: [0.5, 1],\n }),\n headerTitle: 'Reactions',\n})\n\nexport type ReactionScreenProps = StaticScreenProps<{\n message_id: string\n conversation_id: number\n reaction_value?: string\n}>\n\nexport function ReactionsScreen({ route }: ReactionScreenProps) {\n const { conversation_id, message_id, reaction_value } = route.params\n const styles = useStyles()\n\n const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false })\n\n const message = messages.find(m => m.id === message_id)\n const reactionCounts = message?.reactionCounts || []\n const initialReactionCount =\n reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0]\n const [reactionCountValue, setReactionCountValue] = React.useState<\n ReactionCountResource['value']\n >(initialReactionCount?.value)\n const reactionCount = reactionCounts.find(r => r.value === reactionCountValue)\n\n // Get author IDs for the API call, ensuring we have a valid array\n const authorIds = reactionCount?.authorIds || []\n\n const { data: members } = useSuspenseGet<MemberResource[]>({\n url: `/me/conversations/${conversation_id}/members`,\n data: {\n fields: {\n Member: ['id', 'name', 'avatar', 'badges', 'child', 'role'],\n },\n where: {\n id: authorIds,\n },\n limit: authorIds.length,\n },\n })\n\n if (!reactionCount) {\n return (\n <View style={styles.errorContainer}>\n <Text>No reactions found for this message.</Text>\n </View>\n )\n }\n\n const authors = members.filter(member => authorIds.includes(member.id))\n\n return (\n <FormSheet.Root contentStyle={styles.formSheetContent}>\n <Tabs\n data={reactionCounts}\n activeTab={reactionCount}\n onTabPress={item => {\n setReactionCountValue(item.value)\n }}\n renderItem={({ item }) => (\n <Reaction\n active={reactionCount.id === item.id}\n reaction={item}\n onPress={() => setReactionCountValue(item.value)}\n />\n )}\n style={styles.actions}\n />\n <FlatList\n data={authors}\n contentContainerStyle={styles.contentContainer}\n keyExtractor={item => item.id.toString()}\n renderItem={({ item: author }) => <Author author={author} key={author.id} />}\n />\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n}: {\n active: boolean\n reaction: ReactionCountResource\n onPress: () => void\n}) => {\n const styles = useStyles()\n\n return (\n <View key={reaction.value} style={styles.reaction}>\n <Text style={styles.reactionContent}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={styles.reactionContent}>{reaction.count}</Text>\n </View>\n )\n}\n\ntype AuthorProps = Pick<MemberResource, 'id' | 'name' | 'avatar'>\n\nconst Author = memo(({ author }: { author: AuthorProps }) => {\n const styles = useStyles()\n\n return (\n <View style={styles.authorRow}>\n <Avatar sourceUri={author.avatar} size=\"sm\" />\n <Text variant=\"tertiary\" numberOfLines={2} style={styles.authorName}>\n {author.name}\n </Text>\n </View>\n )\n})\n\nconst TABS_HEIGHT = 67\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const { bottom } = useSafeAreaInsets()\n const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })\n\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: 16,\n },\n contentContainer: {\n paddingTop: 8,\n paddingBottom: bottom + Platform.select({ android: 24, default: TABS_HEIGHT + 24 }),\n },\n authorRow: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n paddingVertical: 8,\n paddingHorizontal: 16,\n flex: 1,\n },\n authorName: {\n flex: 1,\n },\n reaction: {\n paddingHorizontal: 8,\n paddingVertical: 16,\n flexDirection: 'row',\n gap: 4,\n },\n reactionContent: {\n fontSize: 18,\n fontWeight: platformFontWeightMedium,\n },\n actions: {\n minHeight: 68 * fontScale,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n errorContainer: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n padding: 16,\n marginTop: 30,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reactions_screen.js","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE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,OAAO,EAAE,WAAW,GAAG,EAAE,EAAE,CAAC;SACpF;QACD,SAAS,EAAE;YACT,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;YACN,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,EAAE;YACrB,IAAI,EAAE,CAAC;SACR;QACD,UAAU,EAAE;YACV,IAAI,EAAE,CAAC;SACR;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,CAAC;YACpB,eAAe,EAAE,EAAE;YACnB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;SACP;QACD,eAAe,EAAE;YACf,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,wBAAwB;SACrC;QACD,OAAO,EAAE;YACP,SAAS,EAAE,EAAE,GAAG,SAAS;YACzB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;YAChD,iBAAiB,EAAE,CAAC;SACrB;QACD,cAAc,EAAE;YACd,IAAI,EAAE,CAAC;YACP,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StaticScreenProps } from '@react-navigation/native'\nimport React, { memo } from 'react'\nimport { Platform, StyleSheet, View } from 'react-native'\nimport { FlatList } from 'react-native-gesture-handler'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Avatar, Text } from '../components'\nimport { Tabs } from '../components/display/tabs'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { useSuspenseGet, useTheme } from '../hooks'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useFontScale } from '../hooks/use_font_scale'\nimport { MemberResource } from '../types'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { platformFontWeightMedium, REACTION_EMOJIS } from '../utils'\n\nexport const ReactionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: Platform.select({\n android: [0.5, 0.94], // Going straight to full 0.94 preserves height of screen on Android\n default: [0.5, 1],\n }),\n headerTitle: 'Reactions',\n})\n\nexport type ReactionScreenProps = StaticScreenProps<{\n message_id: string\n conversation_id: number\n reaction_value?: string\n}>\n\nexport function ReactionsScreen({ route }: ReactionScreenProps) {\n const { conversation_id, message_id, reaction_value } = route.params\n const styles = useStyles()\n\n const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false })\n\n const message = messages.find(m => m.id === message_id)\n const reactionCounts = message?.reactionCounts || []\n const initialReactionCount =\n reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0]\n const [reactionCountValue, setReactionCountValue] = React.useState<\n ReactionCountResource['value']\n >(initialReactionCount?.value)\n const reactionCount = reactionCounts.find(r => r.value === reactionCountValue)\n\n // Get author IDs for the API call, ensuring we have a valid array\n const authorIds = reactionCount?.authorIds || []\n\n const { data: members } = useSuspenseGet<MemberResource[]>({\n url: `/me/conversations/${conversation_id}/members`,\n data: {\n fields: {\n Member: ['id', 'name', 'avatar', 'badges', 'child', 'role'],\n },\n where: {\n id: authorIds,\n },\n limit: authorIds.length,\n },\n })\n\n if (!reactionCount) {\n return (\n <View style={styles.errorContainer}>\n <Text>No reactions found for this message.</Text>\n </View>\n )\n }\n\n const authors = members.filter(member => authorIds.includes(member.id))\n\n return (\n <FormSheet.Root contentStyle={styles.formSheetContent}>\n <Tabs\n data={reactionCounts}\n activeTab={reactionCount}\n onTabPress={item => {\n setReactionCountValue(item.value)\n }}\n renderItem={({ item }) => (\n <Reaction\n active={reactionCount.id === item.id}\n reaction={item}\n onPress={() => setReactionCountValue(item.value)}\n />\n )}\n style={styles.actions}\n />\n <FlatList\n data={authors}\n contentContainerStyle={styles.contentContainer}\n keyExtractor={item => item.id.toString()}\n renderItem={({ item: author }) => <Author author={author} key={author.id} />}\n />\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n}: {\n active: boolean\n reaction: ReactionCountResource\n onPress: () => void\n}) => {\n const styles = useStyles()\n\n return (\n <View key={reaction.value} style={styles.reaction}>\n <Text style={styles.reactionContent}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={styles.reactionContent}>{reaction.count}</Text>\n </View>\n )\n}\n\ntype AuthorProps = Pick<MemberResource, 'id' | 'name' | 'avatar'>\n\nconst Author = memo(({ author }: { author: AuthorProps }) => {\n const styles = useStyles()\n\n return (\n <View style={styles.authorRow}>\n <Avatar sourceUri={author.avatar} size=\"sm\" />\n <Text variant=\"tertiary\" numberOfLines={2} style={styles.authorName}>\n {author.name}\n </Text>\n </View>\n )\n})\n\nconst TABS_HEIGHT = 67\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const { bottom } = useSafeAreaInsets()\n const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })\n\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: 16,\n },\n contentContainer: {\n paddingTop: 8,\n paddingBottom: bottom + Platform.select({ android: 24, default: TABS_HEIGHT + 24 }),\n },\n authorRow: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n paddingVertical: 8,\n paddingHorizontal: 16,\n flex: 1,\n },\n authorName: {\n flex: 1,\n },\n reaction: {\n paddingHorizontal: 8,\n paddingVertical: 16,\n flexDirection: 'row',\n gap: 4,\n },\n reactionContent: {\n fontSize: 18,\n fontWeight: platformFontWeightMedium,\n },\n actions: {\n minHeight: 68 * fontScale,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n errorContainer: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n padding: 16,\n marginTop: 30,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAA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nC,IAAI,EAAE,cAAc,CAAA;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,yBAAyB,EAAE,CAAA;IACpC,iBAAiB,CAAC,EAAE,yBAAyB,CAAA;IAC7C,sBAAsB,CAAC,EAAE;QACvB,sBAAsB,EAAE,MAAM,CAAA;KAC/B,CAAA;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,aAAa,CAAC,EAAE,qBAAqB,CAAA;IACrC,KAAK,EAAE,OAAO,CAAA;IACd,eAAe,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnalyticsMetadataResource } from './analytics_metadata'\nimport { ConversationBadgeResource } from './conversation_badge'\nimport { GroupResource } from './group_resource'\nimport { MemberAbilityResource } from './member_ability'\n\nexport interface ConversationResource {\n type: 'Conversation'\n id: number\n badges?: ConversationBadgeResource[]\n analyticsMetadata?: AnalyticsMetadataResource\n conversationMembership?: {\n lastReadMessageSortKey: string\n }\n createdAt: string\n deleted?: boolean\n groups?: GroupResource[]\n previewAvatarUrls?: string[]\n lastMessageAuthorId?: string\n lastMessageAuthorName?: string\n lastMessageCreatedAt?: string\n lastMessageTextPreview?: string\n latestReadMessageSortKey?: string\n memberAbility?: MemberAbilityResource\n muted: boolean\n repliesDisabled: boolean\n title: string\n unreadCount: number\n updatedAt: string\n}\n"]}
|
|
1
|
+
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnalyticsMetadataResource } from './analytics_metadata'\nimport { ConversationBadgeResource } from './conversation_badge'\nimport { GroupResource } from './group_resource'\nimport { MemberAbilityResource } from './member_ability'\n\nexport interface ConversationResource {\n type: 'Conversation'\n id: number\n badges?: ConversationBadgeResource[]\n analyticsMetadata?: AnalyticsMetadataResource\n conversationMembership?: {\n lastReadMessageSortKey: string\n }\n createdAt: string\n deleted?: boolean\n groups?: GroupResource[]\n previewAvatarUrls?: string[]\n lastMessageAuthorId?: string\n lastMessageAuthorName?: string\n lastMessageCreatedAt?: string\n lastMessageTextPreview?: string\n latestReadMessageSortKey?: string\n memberAbility?: MemberAbilityResource\n muted: boolean\n repliesDisabled: boolean\n title: string\n unreadCount: number\n unreadReactionCount?: number // Derived from Jolt events\n updatedAt: string\n}\n"]}
|
package/build/utils/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './uri';
|
|
|
6
6
|
export * from './cache';
|
|
7
7
|
export * from './native_adapters';
|
|
8
8
|
export * from './pluralize';
|
|
9
|
+
export * from './reaction_constants';
|
|
9
10
|
export * from './destructure_chat_group_graph_id';
|
|
10
11
|
export * from './convert_attachments_for_create';
|
|
11
12
|
export * from './assert_keys_are_numbers';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA"}
|
package/build/utils/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from './uri';
|
|
|
6
6
|
export * from './cache';
|
|
7
7
|
export * from './native_adapters';
|
|
8
8
|
export * from './pluralize';
|
|
9
|
+
export * from './reaction_constants';
|
|
9
10
|
export * from './destructure_chat_group_graph_id';
|
|
10
11
|
export * from './convert_attachments_for_create';
|
|
11
12
|
export * from './assert_keys_are_numbers';
|
package/build/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA","sourcesContent":["export * from './session'\nexport * from './theme'\nexport * from './styles'\nexport * from './client'\nexport * from './uri'\nexport * from './cache'\nexport * from './native_adapters'\nexport * from './pluralize'\nexport * from './destructure_chat_group_graph_id'\nexport * from './convert_attachments_for_create'\nexport * from './assert_keys_are_numbers'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA","sourcesContent":["export * from './session'\nexport * from './theme'\nexport * from './styles'\nexport * from './client'\nexport * from './uri'\nexport * from './cache'\nexport * from './native_adapters'\nexport * from './pluralize'\nexport * from './reaction_constants'\nexport * from './destructure_chat_group_graph_id'\nexport * from './convert_attachments_for_create'\nexport * from './assert_keys_are_numbers'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reaction_constants.d.ts","sourceRoot":"","sources":["../../src/utils/reaction_constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,CAM1E,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reaction_constants.js","sourceRoot":"","sources":["../../src/utils/reaction_constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAmD;IAC7E,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;CACZ,CAAA","sourcesContent":["import { ReactionCountResource } from '../types/resources/reaction'\n\nexport const REACTION_EMOJIS: Record<ReactionCountResource['value'], string> = {\n thumbs_up: '👍',\n thumbs_down: '👎',\n pray: '🙏',\n laugh: '😂',\n heart: '❤️',\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.0-rc.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"react-native-url-polyfill": "^2.0.0",
|
|
59
59
|
"typescript": "<5.6.0"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "4a2f7c817762a0edc53f592b180374019ed2dc57"
|
|
62
62
|
}
|
|
@@ -9,14 +9,7 @@ import { ReactionCountResource } from '../../types/resources/reaction'
|
|
|
9
9
|
import { MessageResource } from '../../types'
|
|
10
10
|
import { useCreateAndroidRippleColor } from '../../hooks/use_create_android_ripple_color'
|
|
11
11
|
import { Haptic } from '../../utils/native_adapters'
|
|
12
|
-
|
|
13
|
-
export const REACTION_EMOJIS: Record<ReactionCountResource['value'], string> = {
|
|
14
|
-
thumbs_up: '👍',
|
|
15
|
-
thumbs_down: '👎',
|
|
16
|
-
pray: '🙏',
|
|
17
|
-
laugh: '😂',
|
|
18
|
-
heart: '❤️',
|
|
19
|
-
}
|
|
12
|
+
import { REACTION_EMOJIS } from '../../utils'
|
|
20
13
|
|
|
21
14
|
export function MessageReaction({
|
|
22
15
|
reaction,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { JoltConversationEvent } from '../types/jolt_events'
|
|
2
|
-
import { useJoltChannel, useJoltEvent } from './use_jolt'
|
|
3
|
-
import { getConversationRequestArgs } from './use_conversation'
|
|
4
1
|
import { useQueryClient } from '@tanstack/react-query'
|
|
5
|
-
import { ApiResource, ConversationResource } from '../types'
|
|
6
|
-
import { getRequestQueryKey } from './use_suspense_api'
|
|
7
2
|
import { useCallback, useMemo } from 'react'
|
|
3
|
+
import { ApiResource, ConversationResource } from '../types'
|
|
4
|
+
import { JoltConversationEvent, JoltReactionEvent } from '../types/jolt_events'
|
|
8
5
|
import { completeMessageCreationConversationTracking } from '../utils/performance_tracking'
|
|
9
|
-
import { useCurrentPerson } from './use_current_person'
|
|
10
6
|
import { useApiClient } from './use_api_client'
|
|
7
|
+
import { getConversationRequestArgs } from './use_conversation'
|
|
8
|
+
import { useCurrentPerson } from './use_current_person'
|
|
9
|
+
import { useJoltChannel, useJoltEvent } from './use_jolt'
|
|
10
|
+
import { getRequestQueryKey } from './use_suspense_api'
|
|
11
11
|
|
|
12
12
|
interface Props {
|
|
13
13
|
conversationId: number
|
|
@@ -17,6 +17,7 @@ export function useConversationJoltEvents({ conversationId }: Props) {
|
|
|
17
17
|
const joltChannel = useJoltChannel(`chat.conversations.${conversationId}`)
|
|
18
18
|
const queryClient = useQueryClient()
|
|
19
19
|
const currentPerson = useCurrentPerson()
|
|
20
|
+
const currentPersonId = currentPerson?.id
|
|
20
21
|
const apiClient = useApiClient()
|
|
21
22
|
const queryKey = useMemo(
|
|
22
23
|
() => getRequestQueryKey(getConversationRequestArgs({ conversation_id: conversationId })),
|
|
@@ -27,7 +28,7 @@ export function useConversationJoltEvents({ conversationId }: Props) {
|
|
|
27
28
|
(e: JoltConversationEvent) => {
|
|
28
29
|
const { last_message_idempotent_key, last_message_author_id } = e.data.data
|
|
29
30
|
|
|
30
|
-
if (last_message_idempotent_key && last_message_author_id ===
|
|
31
|
+
if (last_message_idempotent_key && last_message_author_id === currentPersonId) {
|
|
31
32
|
completeMessageCreationConversationTracking({
|
|
32
33
|
apiClient,
|
|
33
34
|
idempotentKey: last_message_idempotent_key,
|
|
@@ -35,7 +36,7 @@ export function useConversationJoltEvents({ conversationId }: Props) {
|
|
|
35
36
|
}
|
|
36
37
|
queryClient.invalidateQueries({ queryKey })
|
|
37
38
|
},
|
|
38
|
-
[queryClient, queryKey,
|
|
39
|
+
[queryClient, queryKey, currentPersonId, apiClient]
|
|
39
40
|
)
|
|
40
41
|
|
|
41
42
|
const handleConversationRead = useCallback(
|
|
@@ -55,6 +56,7 @@ export function useConversationJoltEvents({ conversationId }: Props) {
|
|
|
55
56
|
data: {
|
|
56
57
|
...prev.data,
|
|
57
58
|
latestReadMessageSortKey: latest_read_message_sort_key,
|
|
59
|
+
unreadReactionCount: 0,
|
|
58
60
|
},
|
|
59
61
|
}
|
|
60
62
|
})
|
|
@@ -76,7 +78,33 @@ export function useConversationJoltEvents({ conversationId }: Props) {
|
|
|
76
78
|
})
|
|
77
79
|
}, [queryClient, queryKey])
|
|
78
80
|
|
|
81
|
+
const handleReactionJoltEvent = useCallback(
|
|
82
|
+
(event: JoltReactionEvent) => {
|
|
83
|
+
queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {
|
|
84
|
+
if (!prev?.data) return prev
|
|
85
|
+
|
|
86
|
+
if (event.data.data.author_id === currentPersonId) {
|
|
87
|
+
return prev
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
...prev,
|
|
92
|
+
data: {
|
|
93
|
+
...prev.data,
|
|
94
|
+
// Not a real count, just a derived value from Jolt events so we can
|
|
95
|
+
// determine if we should mark the conversation as read
|
|
96
|
+
unreadReactionCount: prev.data.unreadReactionCount
|
|
97
|
+
? prev.data.unreadReactionCount + 1
|
|
98
|
+
: 1,
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
},
|
|
103
|
+
[queryClient, queryKey, currentPersonId]
|
|
104
|
+
)
|
|
105
|
+
|
|
79
106
|
useJoltEvent(joltChannel, 'conversation.updated', handleUpdatedConversation)
|
|
80
107
|
useJoltEvent(joltChannel, 'conversation.read', handleConversationRead)
|
|
81
108
|
useJoltEvent(joltChannel, 'conversation.destroyed', handleConversationDestroyed)
|
|
109
|
+
useJoltEvent(joltChannel, 'reaction.*', handleReactionJoltEvent)
|
|
82
110
|
}
|
|
@@ -20,7 +20,7 @@ export const useConversationsMarkRead = ({
|
|
|
20
20
|
currentPersonCache.update({}, person => {
|
|
21
21
|
const currentUnread = person.unreadCount
|
|
22
22
|
const updatedUnread = read ? Math.max(currentUnread - 1, 0) : currentUnread + 1
|
|
23
|
-
return { ...person, unreadCount: updatedUnread }
|
|
23
|
+
return { ...person, unreadCount: updatedUnread, unreadReactionCount: 0 }
|
|
24
24
|
})
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debounce } from 'lodash'
|
|
2
|
+
import { useEffect, useMemo, useRef } from 'react'
|
|
2
3
|
import { ConversationResource, MessageResource } from '../types'
|
|
3
4
|
import { useAppState } from './use_app_state'
|
|
4
5
|
import { useConversationsMarkRead } from './use_conversations_actions'
|
|
@@ -9,41 +10,25 @@ interface Props {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export function useMarkLatestMessageRead({ conversation }: Props) {
|
|
13
|
+
const firedOnce = useRef<boolean>(false)
|
|
12
14
|
const { markRead } = useConversationsMarkRead({ conversation })
|
|
13
|
-
const debouncedMarkRead =
|
|
15
|
+
const debouncedMarkRead = useMemo(
|
|
16
|
+
() => debounce(markRead, 1000, { leading: true, trailing: true }),
|
|
17
|
+
[markRead]
|
|
18
|
+
)
|
|
14
19
|
const unreadCount = conversation.unreadCount
|
|
20
|
+
const unreadReactionCount = conversation.unreadReactionCount || 0
|
|
21
|
+
|
|
22
|
+
const shouldMarkRead = Boolean(unreadCount >= 1 || unreadReactionCount > 0)
|
|
15
23
|
const appState = useAppState()
|
|
16
24
|
const isActive = appState === 'active'
|
|
17
25
|
|
|
18
|
-
/**
|
|
19
|
-
* Handle marking the conversation as read.
|
|
20
|
-
* * The app needs to be active
|
|
21
|
-
* * The latest message from someone else is newer than the last read message
|
|
22
|
-
*/
|
|
23
26
|
useEffect(() => {
|
|
24
|
-
if (!isActive ||
|
|
25
|
-
|
|
26
|
-
debouncedMarkRead(true)
|
|
27
|
-
}, [debouncedMarkRead, isActive, unreadCount])
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const useDebounce = (fn: (...args: any[]) => void, delay: number) => {
|
|
31
|
-
const lastBroadcastTime = useRef<number>(0)
|
|
27
|
+
if (!isActive || !shouldMarkRead) return
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
(...args: any[]) => {
|
|
35
|
-
const now = Date.now()
|
|
29
|
+
firedOnce.current = true
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
lastBroadcastTime.current = now
|
|
42
|
-
|
|
43
|
-
fn(...args)
|
|
44
|
-
},
|
|
45
|
-
[delay, fn]
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
return action
|
|
31
|
+
debouncedMarkRead(true)
|
|
32
|
+
// keeping unreadReactionCount in the dependency array to watch for changes
|
|
33
|
+
}, [debouncedMarkRead, isActive, shouldMarkRead, unreadReactionCount])
|
|
49
34
|
}
|
|
@@ -5,7 +5,10 @@ import { useApiClient } from './use_api_client'
|
|
|
5
5
|
import { getMessagesQueryKey, getMessagesRequestArgs } from '../utils/request/get_messages'
|
|
6
6
|
import { ApiCollection, ApiResource, MessageResource } from '../types'
|
|
7
7
|
import { ReactionCountResource } from '../types/resources/reaction'
|
|
8
|
-
import { updateRecordInPagesData } from '../utils'
|
|
8
|
+
import { updateRecordInPagesData, REACTION_EMOJIS } from '../utils'
|
|
9
|
+
|
|
10
|
+
const REACT = 1
|
|
11
|
+
const UNREACT = -1
|
|
9
12
|
|
|
10
13
|
type UseMessageReactionToggleProps = {
|
|
11
14
|
conversation_id: number
|
|
@@ -15,7 +18,7 @@ type UseMessageReactionToggleProps = {
|
|
|
15
18
|
|
|
16
19
|
type ToggleReactionParams = {
|
|
17
20
|
value: ReactionCountResource['value']
|
|
18
|
-
mine
|
|
21
|
+
mine: boolean
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
type QueryData = InfiniteData<ApiCollection<MessageResource>>
|
|
@@ -35,7 +38,7 @@ export function useMessageReactionToggle({
|
|
|
35
38
|
const requestParams = getMessagesRequestArgs({ conversation_id })
|
|
36
39
|
|
|
37
40
|
// If already reacted, unreact; otherwise react
|
|
38
|
-
const endpoint =
|
|
41
|
+
const endpoint = mine ? 'unreact' : 'react'
|
|
39
42
|
const url = `/me/conversations/${conversation_id}/messages/${message_id}/${endpoint}`
|
|
40
43
|
const fieldsWithValueJoined = Object.fromEntries(
|
|
41
44
|
Object.entries(requestParams.data.fields).map(([k, v]) => [k, v.join(',')])
|
|
@@ -66,7 +69,7 @@ export function useMessageReactionToggle({
|
|
|
66
69
|
message,
|
|
67
70
|
data,
|
|
68
71
|
value: variables.value,
|
|
69
|
-
|
|
72
|
+
mine: variables.mine,
|
|
70
73
|
})
|
|
71
74
|
)
|
|
72
75
|
}
|
|
@@ -104,25 +107,25 @@ const optimisticUpdate = ({
|
|
|
104
107
|
message,
|
|
105
108
|
data,
|
|
106
109
|
value,
|
|
107
|
-
|
|
110
|
+
mine,
|
|
108
111
|
}: {
|
|
109
112
|
message: MessageResource
|
|
110
113
|
data: QueryData | undefined
|
|
111
114
|
value: ReactionCountResource['value']
|
|
112
|
-
|
|
115
|
+
mine: boolean
|
|
113
116
|
}) => {
|
|
114
117
|
if (!data) return data
|
|
115
118
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
119
|
+
const hasExistingReaction = message.reactionCounts.some(r => r.value === value)
|
|
120
|
+
|
|
121
|
+
let updatedReactionCounts: ReactionCountResource[]
|
|
122
|
+
|
|
123
|
+
if (hasExistingReaction) {
|
|
124
|
+
const delta = mine ? UNREACT : REACT
|
|
125
|
+
updatedReactionCounts = updateCount(message.reactionCounts, value, delta)
|
|
126
|
+
} else {
|
|
127
|
+
updatedReactionCounts = createCount(message.reactionCounts, value, message.id)
|
|
128
|
+
}
|
|
126
129
|
|
|
127
130
|
const updatedMessage: MessageResource = {
|
|
128
131
|
...message,
|
|
@@ -134,3 +137,46 @@ const optimisticUpdate = ({
|
|
|
134
137
|
record: updatedMessage,
|
|
135
138
|
})
|
|
136
139
|
}
|
|
140
|
+
|
|
141
|
+
const updateCount = (
|
|
142
|
+
reactionCounts: ReactionCountResource[],
|
|
143
|
+
value: ReactionCountResource['value'],
|
|
144
|
+
delta: typeof REACT | typeof UNREACT
|
|
145
|
+
): ReactionCountResource[] => {
|
|
146
|
+
return reactionCounts.map(reaction => {
|
|
147
|
+
if (reaction.value === value) {
|
|
148
|
+
return {
|
|
149
|
+
...reaction,
|
|
150
|
+
mine: delta > 0 ? 1 : 0,
|
|
151
|
+
count: reaction.count + delta,
|
|
152
|
+
} as ReactionCountResource
|
|
153
|
+
}
|
|
154
|
+
return reaction
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const createCount = (
|
|
159
|
+
reactionCounts: ReactionCountResource[],
|
|
160
|
+
value: ReactionCountResource['value'],
|
|
161
|
+
messageId: string
|
|
162
|
+
): ReactionCountResource[] => {
|
|
163
|
+
const reactionOrder = Object.keys(REACTION_EMOJIS) as ReactionCountResource['value'][]
|
|
164
|
+
const newReactionIndex = reactionOrder.indexOf(value)
|
|
165
|
+
const insertIndex = reactionCounts.findIndex(
|
|
166
|
+
r => reactionOrder.indexOf(r.value) > newReactionIndex
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
const newReaction: ReactionCountResource = {
|
|
170
|
+
type: 'ReactionCount',
|
|
171
|
+
id: `${messageId}/${value}`,
|
|
172
|
+
value,
|
|
173
|
+
count: 1,
|
|
174
|
+
mine: 1,
|
|
175
|
+
messageId,
|
|
176
|
+
authorIds: [],
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return insertIndex === -1
|
|
180
|
+
? [...reactionCounts, newReaction]
|
|
181
|
+
: [...reactionCounts.slice(0, insertIndex), newReaction, ...reactionCounts.slice(insertIndex)]
|
|
182
|
+
}
|
|
@@ -5,7 +5,8 @@ import { isNil, omitBy } from 'lodash'
|
|
|
5
5
|
import React, { useCallback } from 'react'
|
|
6
6
|
import { Alert, Platform, StyleSheet, View } from 'react-native'
|
|
7
7
|
import { Text } from '../components'
|
|
8
|
-
import {
|
|
8
|
+
import { useReactionStyles } from '../components/conversation/message_reaction'
|
|
9
|
+
import { REACTION_EMOJIS } from '../utils'
|
|
9
10
|
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'
|
|
10
11
|
import { useCreateAndroidRippleColor, useFontScale, useTheme } from '../hooks'
|
|
11
12
|
import { useApiClient } from '../hooks/use_api_client'
|
|
@@ -122,7 +123,6 @@ function MessageActionsScreenContent({
|
|
|
122
123
|
const { handleReactionToggle, isPending } = useMessageReactionToggle({
|
|
123
124
|
conversation_id,
|
|
124
125
|
message,
|
|
125
|
-
onSuccess: () => navigation.goBack(),
|
|
126
126
|
})
|
|
127
127
|
|
|
128
128
|
const deleteMessage = useCallback(() => {
|
|
@@ -218,6 +218,7 @@ function MessageActionsScreenContent({
|
|
|
218
218
|
value: reaction.value,
|
|
219
219
|
mine: reaction.mine,
|
|
220
220
|
})
|
|
221
|
+
navigation.goBack()
|
|
221
222
|
}}
|
|
222
223
|
/>
|
|
223
224
|
))}
|
|
@@ -4,7 +4,6 @@ import { Platform, StyleSheet, View } from 'react-native'
|
|
|
4
4
|
import { FlatList } from 'react-native-gesture-handler'
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
6
6
|
import { Avatar, Text } from '../components'
|
|
7
|
-
import { REACTION_EMOJIS } from '../components/conversation/message_reaction'
|
|
8
7
|
import { Tabs } from '../components/display/tabs'
|
|
9
8
|
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'
|
|
10
9
|
import { useSuspenseGet, useTheme } from '../hooks'
|
|
@@ -12,7 +11,7 @@ import { useConversationMessages } from '../hooks/use_conversation_messages'
|
|
|
12
11
|
import { useFontScale } from '../hooks/use_font_scale'
|
|
13
12
|
import { MemberResource } from '../types'
|
|
14
13
|
import { ReactionCountResource } from '../types/resources/reaction'
|
|
15
|
-
import { platformFontWeightMedium } from '../utils'
|
|
14
|
+
import { platformFontWeightMedium, REACTION_EMOJIS } from '../utils'
|
|
16
15
|
|
|
17
16
|
export const ReactionsScreenOptions = getFormSheetScreenOptions({
|
|
18
17
|
sheetAllowedDetents: Platform.select({
|
package/src/utils/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './uri'
|
|
|
6
6
|
export * from './cache'
|
|
7
7
|
export * from './native_adapters'
|
|
8
8
|
export * from './pluralize'
|
|
9
|
+
export * from './reaction_constants'
|
|
9
10
|
export * from './destructure_chat_group_graph_id'
|
|
10
11
|
export * from './convert_attachments_for_create'
|
|
11
12
|
export * from './assert_keys_are_numbers'
|