@planningcenter/chat-react-native 3.42.2-rc.0 → 3.42.2
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/conversations/conversation_preview.d.ts.map +1 -1
- package/build/components/conversations/conversation_preview.js +46 -12
- package/build/components/conversations/conversation_preview.js.map +1 -1
- package/build/components/conversations/unread_count_badge.d.ts +2 -1
- package/build/components/conversations/unread_count_badge.d.ts.map +1 -1
- package/build/components/conversations/unread_count_badge.js +5 -4
- package/build/components/conversations/unread_count_badge.js.map +1 -1
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +2 -0
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +8 -15
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/hooks/use_conversations_actions.d.ts.map +1 -1
- package/build/hooks/use_conversations_actions.js +15 -2
- 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 +3 -4
- package/build/hooks/use_mark_latest_message_read.js.map +1 -1
- package/build/hooks/use_suspense_api.d.ts.map +1 -1
- package/build/hooks/use_suspense_api.js +1 -7
- package/build/hooks/use_suspense_api.js.map +1 -1
- package/build/types/jolt_events/reaction_events.d.ts +1 -0
- package/build/types/jolt_events/reaction_events.d.ts.map +1 -1
- package/build/types/jolt_events/reaction_events.js.map +1 -1
- package/build/types/resources/conversation.d.ts +10 -1
- package/build/types/resources/conversation.d.ts.map +1 -1
- package/build/types/resources/conversation.js.map +1 -1
- package/build/utils/client/client.d.ts.map +1 -1
- package/build/utils/client/client.js +2 -1
- package/build/utils/client/client.js.map +1 -1
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +2 -0
- package/build/utils/request/conversation.js.map +1 -1
- package/build/utils/response_error.d.ts +1 -0
- package/build/utils/response_error.d.ts.map +1 -1
- package/build/utils/response_error.js +20 -1
- package/build/utils/response_error.js.map +1 -1
- package/package.json +3 -3
- package/src/components/conversations/conversation_preview.tsx +58 -23
- package/src/components/conversations/unread_count_badge.tsx +13 -4
- package/src/hooks/use_conversation.ts +2 -0
- package/src/hooks/use_conversation_jolt_events.ts +6 -17
- package/src/hooks/use_conversations_actions.ts +16 -2
- package/src/hooks/use_mark_latest_message_read.ts +3 -4
- package/src/hooks/use_suspense_api.ts +1 -9
- package/src/types/jolt_events/reaction_events.ts +1 -0
- package/src/types/resources/conversation.ts +11 -1
- package/src/utils/__tests__/response_error.test.ts +47 -0
- package/src/utils/client/client.ts +2 -1
- package/src/utils/request/conversation.ts +2 -0
- package/src/utils/response_error.ts +23 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useSuspenseInfiniteQuery, useSuspenseQuery, } from '@tanstack/react-query';
|
|
2
2
|
import { Log } from '../utils';
|
|
3
|
-
import {
|
|
3
|
+
import { throwResponseError } from '../utils/response_error';
|
|
4
4
|
import { getNextPageParamFromMeta } from './paginator_meta';
|
|
5
5
|
import { useApiClient } from './use_api_client';
|
|
6
6
|
export const useSuspenseGet = (args, options) => {
|
|
@@ -44,12 +44,6 @@ export const useSuspensePaginator = (args, opts) => {
|
|
|
44
44
|
const totalCount = query.data?.pages[0]?.meta?.totalCount || data.length;
|
|
45
45
|
return { ...query, data, totalCount };
|
|
46
46
|
};
|
|
47
|
-
const throwResponseError = (error) => {
|
|
48
|
-
if (error instanceof Response) {
|
|
49
|
-
throw new ResponseError(error);
|
|
50
|
-
}
|
|
51
|
-
return Promise.reject(error);
|
|
52
|
-
};
|
|
53
47
|
export const getRequestQueryKey = (args) => [
|
|
54
48
|
args.url,
|
|
55
49
|
args.data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_suspense_api.js","sourceRoot":"","sources":["../../src/hooks/use_suspense_api.ts"],"names":[],"mappings":"AAAA,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,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,IAAI,IAAI,CAAC,MAAM,CAAA;IAExE,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;AACvC,CAAC,CAAA;AASD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAwB,EAAmB,EAAE,CAAC;IAC/E,IAAI,CAAC,GAAG;IACR,IAAI,CAAC,IAAI;IACT,IAAI,CAAC,OAAO;IACZ,IAAI,CAAC,GAAG,IAAI,MAAM;IAClB,IAAI,CAAC,aAAa;CACnB,CAAA","sourcesContent":["import {\n AnyUseSuspenseInfiniteQueryOptions,\n InfiniteData,\n useSuspenseInfiniteQuery,\n useSuspenseQuery,\n UseSuspenseQueryOptions,\n} from '@tanstack/react-query'\nimport { ApiCollection, ApiResource, ResourceObject } from '../types'\nimport { FailedResponse } from '../types/api_primitives'\nimport { Log } from '../utils'\nimport { GetRequest, RequestData } from '../utils/client'\nimport { throwResponseError } from '../utils/response_error'\nimport { getNextPageParamFromMeta } from './paginator_meta'\nimport { App, useApiClient } from './use_api_client'\n\ninterface SuspenseGetOptions extends GetRequest {\n app?: App\n reply_root_id?: string | null\n}\n\nexport type SuspenseGetQueryOptions<T extends ResourceObject | ResourceObject[]> = Omit<\n UseSuspenseQueryOptions<ApiResource<T>, FailedResponse>,\n 'queryKey' | 'queryFn'\n>\n\nexport const useSuspenseGet = <T extends ResourceObject | ResourceObject[]>(\n args: SuspenseGetOptions,\n options?: SuspenseGetQueryOptions<T>\n) => {\n type Resource = ApiResource<T>\n const apiClient = useApiClient()\n\n const { data, ...query } = useSuspenseQuery<Resource, FailedResponse>({\n queryKey: getRequestQueryKey(args),\n queryFn: ({ queryKey }) => {\n const [url, d, headers, app = 'chat'] = queryKey as RequestQueryKey\n return apiClient[app]\n .get({ url, data: d, headers })\n .catch(throwResponseError) as Promise<Resource>\n },\n ...options,\n })\n\n return { ...data, ...query }\n}\n\nexport type SuspensePaginatorOptions = Omit<\n AnyUseSuspenseInfiniteQueryOptions,\n 'getNextPageParam' | 'initialPageParam' | 'queryFn' | 'queryKey'\n>\n\nexport const useSuspensePaginator = <T extends ResourceObject>(\n args: SuspenseGetOptions,\n opts?: SuspensePaginatorOptions\n) => {\n const apiClient = useApiClient()\n const query = useSuspenseInfiniteQuery<\n ApiCollection<T>,\n Response,\n InfiniteData<ApiCollection<T>>,\n any,\n Partial<RequestData> | undefined\n >({\n queryKey: getRequestQueryKey(args),\n queryFn: ({ pageParam }) => {\n Log.info('useSuspenseGet', { pageParam })\n\n const pageParmWhere = pageParam?.where || {}\n const argsWhere = args.data.where || {}\n const where = { ...argsWhere, ...pageParmWhere }\n const app = args.app || 'chat'\n const offset = pageParam?.offset || args.data.offset\n const data = { ...args.data, where, offset }\n\n return apiClient[app]\n .get<ApiCollection<T>>({\n url: args.url,\n data,\n })\n .catch(throwResponseError)\n },\n initialPageParam: {} as Partial<RequestData>,\n getNextPageParam: lastPage => getNextPageParamFromMeta(lastPage.meta?.next),\n ...(opts || {}),\n })\n\n const data: T[] = query.data?.pages.flatMap(page => page.data) || []\n const totalCount = query.data?.pages[0]?.meta?.totalCount || data.length\n\n return { ...query, data, totalCount }\n}\n\nexport type RequestQueryKey = [\n SuspenseGetOptions['url'],\n SuspenseGetOptions['data'],\n SuspenseGetOptions['headers'],\n SuspenseGetOptions['app'],\n SuspenseGetOptions['reply_root_id'],\n]\nexport const getRequestQueryKey = (args: SuspenseGetOptions): RequestQueryKey => [\n args.url,\n args.data,\n args.headers,\n args.app || 'chat',\n args.reply_root_id,\n]\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reaction_events.d.ts","sourceRoot":"","sources":["../../../src/types/jolt_events/reaction_events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uDAAuD,CAAA;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAA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BAAqB,CAAC,OAAO,CAAC,CAAA;QACrC,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;CACF;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,KAAK,EAAE,kBAAkB,CAAA;IACzB,IAAI,EAAE,qBAAqB,CAAA;CAC5B;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,KAAK,EAAE,oBAAoB,CAAA;IAC3B,IAAI,EAAE,qBAAqB,CAAA;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reaction_events.js","sourceRoot":"","sources":["../../../src/types/jolt_events/reaction_events.ts"],"names":[],"mappings":"","sourcesContent":["import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'\nimport { ReactionCountResource } from '../resources/reaction'\n\ninterface BaseReactionEventData extends Record<string, unknown> {\n data: {\n author_id: number\n conversation_id: number\n message_sort_key: string\n reply_root_id?: string | null\n created_at: string\n organization_id: number\n value: ReactionCountResource['value']\n author_name?: string\n author_avatar?: string\n count: number\n }\n}\n\nexport interface ReactionCreatedEvent extends CustomMessage {\n event: 'reaction.created'\n data: BaseReactionEventData\n}\n\nexport interface ReactionDeletedEvent extends CustomMessage {\n event: 'reaction.destroyed'\n data: BaseReactionEventData\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reaction_events.js","sourceRoot":"","sources":["../../../src/types/jolt_events/reaction_events.ts"],"names":[],"mappings":"","sourcesContent":["import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'\nimport { ReactionCountResource } from '../resources/reaction'\n\ninterface BaseReactionEventData extends Record<string, unknown> {\n data: {\n author_id: number\n conversation_id: number\n message_sort_key: string\n message_author_id: number\n reply_root_id?: string | null\n created_at: string\n organization_id: number\n value: ReactionCountResource['value']\n author_name?: string\n author_avatar?: string\n count: number\n }\n}\n\nexport interface ReactionCreatedEvent extends CustomMessage {\n event: 'reaction.created'\n data: BaseReactionEventData\n}\n\nexport interface ReactionDeletedEvent extends CustomMessage {\n event: 'reaction.destroyed'\n data: BaseReactionEventData\n}\n"]}
|
|
@@ -3,13 +3,22 @@ import { ConversationBadgeResource } from './conversation_badge';
|
|
|
3
3
|
import { ConversationMembershipResource } from './conversation_membership';
|
|
4
4
|
import { GroupResource } from './group_resource';
|
|
5
5
|
import { MemberAbilityResource } from './member_ability';
|
|
6
|
+
import { ReactionCountResource } from './reaction';
|
|
6
7
|
export type ConversationDisabledReason = 'safety_check' | 'direct_messages_disabled';
|
|
8
|
+
export interface ConversationPreviewData {
|
|
9
|
+
kind: 'reaction' | 'message';
|
|
10
|
+
authorName: string;
|
|
11
|
+
value: ReactionCountResource['value'] | null;
|
|
12
|
+
text: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}
|
|
7
15
|
export interface ConversationResource {
|
|
8
16
|
type: 'Conversation';
|
|
9
17
|
id: number;
|
|
10
18
|
badges?: ConversationBadgeResource[];
|
|
11
19
|
analyticsMetadata?: AnalyticsMetadataResource;
|
|
12
20
|
conversationMembership?: Partial<ConversationMembershipResource>;
|
|
21
|
+
conversationPreview: ConversationPreviewData | null;
|
|
13
22
|
createdAt: string;
|
|
14
23
|
deleted?: boolean;
|
|
15
24
|
directMessage?: boolean;
|
|
@@ -32,7 +41,7 @@ export interface ConversationResource {
|
|
|
32
41
|
repliesDisabled: boolean;
|
|
33
42
|
title: string;
|
|
34
43
|
unreadCount: number;
|
|
35
|
-
|
|
44
|
+
unreadReaction: boolean;
|
|
36
45
|
updatedAt: string;
|
|
37
46
|
}
|
|
38
47
|
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -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,OA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AO,CAAA;IACjB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,0BAA0B,CAAA;IAC3C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;IACpD,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,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,cAAc,EAAE,OAAO,CAAA;IACvB,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 { ConversationMembershipResource } from './conversation_membership'\nimport { GroupResource } from './group_resource'\nimport { MemberAbilityResource } from './member_ability'\n\nexport type ConversationDisabledReason = 'safety_check' | 'direct_messages_disabled'\n\nexport interface ConversationResource {\n type: 'Conversation'\n id: number\n badges?: ConversationBadgeResource[]\n analyticsMetadata?: AnalyticsMetadataResource\n conversationMembership?: Partial<ConversationMembershipResource>\n createdAt: string\n deleted?: boolean\n directMessage?: boolean\n disabled?: boolean\n disabledReason?: ConversationDisabledReason\n genderOption?: string | null\n groups?: GroupResource[]\n previewAvatarUrls?: string[]\n customAvatarType?: 'image' | 'icon' | 'emoji' | null\n customAvatarKey?: string | null\n customAvatarColor?: string | null\n customAvatarImageUrl?: string | null\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
|
|
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 { ConversationMembershipResource } from './conversation_membership'\nimport { GroupResource } from './group_resource'\nimport { MemberAbilityResource } from './member_ability'\nimport { ReactionCountResource } from './reaction'\n\nexport type ConversationDisabledReason = 'safety_check' | 'direct_messages_disabled'\n\nexport interface ConversationPreviewData {\n kind: 'reaction' | 'message'\n authorName: string\n value: ReactionCountResource['value'] | null\n text: string\n createdAt: string\n}\n\nexport interface ConversationResource {\n type: 'Conversation'\n id: number\n badges?: ConversationBadgeResource[]\n analyticsMetadata?: AnalyticsMetadataResource\n conversationMembership?: Partial<ConversationMembershipResource>\n conversationPreview: ConversationPreviewData | null\n createdAt: string\n deleted?: boolean\n directMessage?: boolean\n disabled?: boolean\n disabledReason?: ConversationDisabledReason\n genderOption?: string | null\n groups?: GroupResource[]\n previewAvatarUrls?: string[]\n customAvatarType?: 'image' | 'icon' | 'emoji' | null\n customAvatarKey?: string | null\n customAvatarColor?: string | null\n customAvatarImageUrl?: string | null\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 unreadReaction: boolean\n updatedAt: string\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/utils/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/utils/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAUxE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAe,MAAM,SAAS,CAAA;AAE3F,MAAM,MAAM,sBAAsB,GAAG,CAAC,SAAS,EAAE,cAAc,KAAK,IAAI,CAAA;AAExE,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,qBAAa,MAAM;IACjB,OAAO,EAAE,MAAM,CAAK;IACpB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IAC3C,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;gBAED,EAAE,OAAO,EAAE,cAAmB,EAAE,sBAAsB,EAAE,IAAI,EAAE,EAAE,UAAU;IAOhF,GAAG,CAAC,CAAC,SAAS,aAAa,GAAG,WAAW,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC;IA2CxE,KAAK,CAAC,CAAC,SAAS,aAAa,GAAG,WAAW,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC;IAW5E,IAAI,CAAC,CAAC,SAAS,aAAa,GAAG,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAW1E,MAAM,CAAC,IAAI,EAAE,aAAa;IAShC,WAAW,GAAU,UAAU,QAAQ,GAAG,KAAK,oBAY9C;IAED,kBAAkB,GAAU,UAAU,QAAQ,KAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAMhF;IAED,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,IAAI,OAAO;;;;MAOV;CACF;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isResponseLike } from '../response_error';
|
|
1
2
|
import { concatRecords, ensureNoQueryParamsInDev, makeRequest, throwErrorIfFieldsMissing, throwErrorIfQueryParams, } from './request_helpers';
|
|
2
3
|
export class Client {
|
|
3
4
|
version = '';
|
|
@@ -65,7 +66,7 @@ export class Client {
|
|
|
65
66
|
return makeRequest(requestArgs).catch(this.handleNotOk);
|
|
66
67
|
}
|
|
67
68
|
handleNotOk = async (response) => {
|
|
68
|
-
if (!(response
|
|
69
|
+
if (!isResponseLike(response))
|
|
69
70
|
return Promise.reject(response);
|
|
70
71
|
const errorData = await this.parseErrorResponse(response);
|
|
71
72
|
const notOkResponse = response.clone();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/utils/client/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,WAAW,EAEX,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,mBAAmB,CAAA;AAY1B,MAAM,OAAO,MAAM;IACjB,OAAO,GAAW,EAAE,CAAA;IACpB,cAAc,GAA2B,EAAE,CAAA;IAC3C,sBAAsB,CAAyB;IA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AAC,WAAW,CAAC,CAAA;IACzD,CAAC;IAED,WAAW,GAAG,KAAK,EAAE,QAA0B,EAAE,EAAE;QACjD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;YAAE,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAE9D,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACzD,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,EAAoB,CAAA;QACxD,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,EAAE,CAAA;QAE7C,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,sBAAsB,EAAE,CAAC,aAAa,CAAC,CAAA;QAC9C,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IACtC,CAAC,CAAA;IAED,kBAAkB,GAAG,KAAK,EAAE,QAAkB,EAAoC,EAAE;QAClF,IAAI,CAAC;YACH,OAAO,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAmB,CAAA;QAC1D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAA;QACX,CAAC;IACH,CAAC,CAAA;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE,CAAA;IAC7B,CAAC;IAED,IAAI,OAAO;QACT,OAAO;YACL,MAAM,EAAE,0BAA0B;YAClC,cAAc,EAAE,kBAAkB;YAClC,mBAAmB,EAAE,IAAI,CAAC,OAAO;YACjC,GAAG,IAAI,CAAC,cAAc;SACvB,CAAA;IACH,CAAC;CACF;AAED,eAAe,MAAM,CAAA","sourcesContent":["import { ApiCollection, ApiResource, FailedResponse } from '../../types'\nimport { isResponseLike } from '../response_error'\nimport {\n concatRecords,\n ensureNoQueryParamsInDev,\n makeRequest,\n MakeRequestArgs,\n throwErrorIfFieldsMissing,\n throwErrorIfQueryParams,\n} from './request_helpers'\nimport { DeleteRequest, GetRequest, PatchRequest, PostRequest, WalkRequest } from './types'\n\nexport type OnUnauthorizedResponse = (_response: FailedResponse) => void\n\ntype ClientArgs = {\n version: string\n defaultHeaders?: Record<string, string>\n onUnauthorizedResponse?: OnUnauthorizedResponse\n root?: string\n}\n\nexport class Client {\n version: string = ''\n defaultHeaders: Record<string, string> = {}\n onUnauthorizedResponse?: OnUnauthorizedResponse\n root?: string\n\n constructor({ version, defaultHeaders = {}, onUnauthorizedResponse, root }: ClientArgs) {\n this.version = version\n this.defaultHeaders = defaultHeaders\n this.onUnauthorizedResponse = onUnauthorizedResponse\n this.root = root\n }\n\n async get<T extends ApiCollection | ApiResource>(args: GetRequest): Promise<T> {\n const { walk, ...data } = args.data\n const isWalking = Boolean(walk)\n const headers = { ...this.headers, ...args.headers }\n const url = this.appUrl(args.url)\n\n await throwErrorIfQueryParams(url)\n\n const requestArgs: MakeRequestArgs = { data, url, action: 'GET', headers }\n\n const walkRequest = ({\n url: requestUrl,\n data: d = { fields: {} },\n acc = { data: [], included: [], meta: {}, links: {} },\n ...options\n }: WalkRequest): Promise<T> => {\n return makeRequest({\n action: 'GET',\n data: d,\n url: requestUrl,\n ...options,\n headers,\n }).then(({ links, ...rest }) => {\n const records = Array.isArray(rest.data) ? concatRecords(acc, rest) : rest\n\n // `next` will have our params in the link so we do not want to pass them back in\n if (links?.next) {\n return walkRequest({ ...options, data: d, url: links.next, acc: records })\n } else {\n return records\n }\n })\n }\n\n const handler = isWalking\n ? (a: MakeRequestArgs | WalkRequest) => walkRequest(a as WalkRequest)\n : (a: MakeRequestArgs | WalkRequest) => makeRequest(a as MakeRequestArgs)\n\n return throwErrorIfFieldsMissing(handler, requestArgs)\n .then(response => response as T)\n .catch(this.handleNotOk)\n }\n\n async patch<T extends ApiCollection | ApiResource>(args: PatchRequest): Promise<T> {\n const headers = { ...this.headers, ...args.headers }\n const url = this.appUrl(args.url)\n\n const requestArgs: MakeRequestArgs = { data: args.data, url, action: 'PATCH', headers }\n\n return ensureNoQueryParamsInDev(makeRequest, requestArgs)\n .then(response => response as T)\n .catch(this.handleNotOk)\n }\n\n async post<T extends ApiCollection | ApiResource>(args: PostRequest): Promise<T> {\n const headers = { ...this.headers, ...args.headers }\n const url = this.appUrl(args.url)\n\n const requestArgs: MakeRequestArgs = { ...args, data: args.data, url, action: 'POST', headers }\n\n return ensureNoQueryParamsInDev(makeRequest, requestArgs)\n .then(response => response as T)\n .catch(this.handleNotOk)\n }\n\n async delete(args: DeleteRequest) {\n const headers = { ...this.headers, ...args.headers }\n const url = this.appUrl(args.url)\n\n const requestArgs: MakeRequestArgs = { url, action: 'DELETE', headers }\n\n return makeRequest(requestArgs).catch(this.handleNotOk)\n }\n\n handleNotOk = async (response: Response | Error) => {\n if (!isResponseLike(response)) return Promise.reject(response)\n\n const errorData = await this.parseErrorResponse(response)\n const notOkResponse = response.clone() as FailedResponse\n notOkResponse.errors = errorData.errors || []\n\n if (response.status === 401) {\n this.onUnauthorizedResponse?.(notOkResponse)\n }\n\n return Promise.reject(notOkResponse)\n }\n\n parseErrorResponse = async (response: Response): Promise<Partial<FailedResponse>> => {\n try {\n return (await response.clone().json()) as FailedResponse\n } catch {\n return {}\n }\n }\n\n appUrl(url: string) {\n return `${this.root}${url}`\n }\n\n get headers() {\n return {\n Accept: 'application/vnd.api+json',\n 'Content-Type': 'application/json',\n 'X-PCO-API-Version': this.version,\n ...this.defaultHeaders,\n }\n }\n}\n\nexport default Client\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/utils/request/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,eAAO,MAAM,2BAA2B,GAAI,8EAKzC,OAAO,CAAC,uBAAuB,CAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/utils/request/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,eAAO,MAAM,2BAA2B,GAAI,8EAKzC,OAAO,CAAC,uBAAuB,CAAM,KAAG,UAoD1C,CAAA"}
|
|
@@ -25,6 +25,7 @@ export const getConversationsRequestArgs = ({ gids, chat_group_graph_id, group_s
|
|
|
25
25
|
Conversation: [
|
|
26
26
|
'created_at',
|
|
27
27
|
'badges',
|
|
28
|
+
'conversation_preview',
|
|
28
29
|
'disabled',
|
|
29
30
|
'disabled_reason',
|
|
30
31
|
'groups',
|
|
@@ -42,6 +43,7 @@ export const getConversationsRequestArgs = ({ gids, chat_group_graph_id, group_s
|
|
|
42
43
|
'replies_disabled',
|
|
43
44
|
'title',
|
|
44
45
|
'unread_count',
|
|
46
|
+
'unread_reaction',
|
|
45
47
|
'updated_at',
|
|
46
48
|
],
|
|
47
49
|
AnalyticsMetadata: ['metadata'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/utils/request/conversation.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,EAC1C,IAAI,EACJ,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,MACgB,EAAE,EAAc,EAAE;IACtD,IAAI,MAAc,CAAA;IAClB,IAAI,mBAAmB,EAAE,CAAC;QACxB,MAAM,GAAG,yBAAyB,CAAA;IACpC,CAAC;SAAM,IAAI,oBAAoB,EAAE,CAAC;QAChC,MAAM,GAAG,kCAAkC,CAAA;IAC7C,CAAC;SAAM,IAAI,qBAAqB,EAAE,CAAC;QACjC,MAAM,GAAG,yCAAyC,CAAA;IACpD,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,mBAAmB,CAAA;IAC9B,CAAC;IAED,OAAO;QACL,GAAG,EAAE,mBAAmB;QACxB,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,eAAe;YACtB,MAAM;YACN,IAAI;YACJ,KAAK,EAAE,mBAAmB;YAC1B,qBAAqB;YACrB,MAAM,EAAE;gBACN,YAAY,EAAE;oBACZ,YAAY;oBACZ,QAAQ;oBACR,UAAU;oBACV,iBAAiB;oBACjB,QAAQ;oBACR,wBAAwB;oBACxB,0BAA0B;oBAC1B,yBAAyB;oBACzB,2BAA2B;oBAC3B,qBAAqB;oBACrB,oBAAoB;oBACpB,mBAAmB;oBACnB,qBAAqB;oBACrB,yBAAyB;oBACzB,gBAAgB;oBAChB,OAAO;oBACP,kBAAkB;oBAClB,OAAO;oBACP,cAAc;oBACd,YAAY;iBACb;gBACD,iBAAiB,EAAE,CAAC,UAAU,CAAC;gBAC/B,iBAAiB,EAAE,CAAC,UAAU,EAAE,mBAAmB,EAAE,MAAM,CAAC;aAC7D;YACD,OAAO,EAAE,CAAC,QAAQ,EAAE,oBAAoB,CAAC;SAC1C;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { GraphId } from '../../types/resources/group_resource'\nimport { GetRequest } from '../client/types'\n\nexport interface ConversationRequestArgs {\n gids: string\n chat_group_graph_id?: GraphId\n group_source_app_name?: string\n show_direct_messages?: boolean\n}\n\nexport const getConversationsRequestArgs = ({\n gids,\n chat_group_graph_id,\n group_source_app_name,\n show_direct_messages,\n}: Partial<ConversationRequestArgs> = {}): GetRequest => {\n let filter: string\n if (chat_group_graph_id) {\n filter = 'mine_or_not_empty,group'\n } else if (show_direct_messages) {\n filter = 'mine_or_not_empty,direct_message'\n } else if (group_source_app_name) {\n filter = 'mine_or_not_empty,group_source_app_name'\n } else {\n filter = 'mine_or_not_empty'\n }\n\n return {\n url: '/me/conversations',\n data: {\n perPage: 20,\n order: '-last_message',\n filter,\n gids,\n group: chat_group_graph_id,\n group_source_app_name,\n fields: {\n Conversation: [\n 'created_at',\n 'badges',\n 'disabled',\n 'disabled_reason',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'preview_avatar_urls',\n 'custom_avatar_type',\n 'custom_avatar_key',\n 'custom_avatar_color',\n 'custom_avatar_image_url',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'updated_at',\n ],\n AnalyticsMetadata: ['metadata'],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n },\n include: ['badges', 'analytics_metadata'],\n },\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/utils/request/conversation.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,EAC1C,IAAI,EACJ,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,MACgB,EAAE,EAAc,EAAE;IACtD,IAAI,MAAc,CAAA;IAClB,IAAI,mBAAmB,EAAE,CAAC;QACxB,MAAM,GAAG,yBAAyB,CAAA;IACpC,CAAC;SAAM,IAAI,oBAAoB,EAAE,CAAC;QAChC,MAAM,GAAG,kCAAkC,CAAA;IAC7C,CAAC;SAAM,IAAI,qBAAqB,EAAE,CAAC;QACjC,MAAM,GAAG,yCAAyC,CAAA;IACpD,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,mBAAmB,CAAA;IAC9B,CAAC;IAED,OAAO;QACL,GAAG,EAAE,mBAAmB;QACxB,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,eAAe;YACtB,MAAM;YACN,IAAI;YACJ,KAAK,EAAE,mBAAmB;YAC1B,qBAAqB;YACrB,MAAM,EAAE;gBACN,YAAY,EAAE;oBACZ,YAAY;oBACZ,QAAQ;oBACR,sBAAsB;oBACtB,UAAU;oBACV,iBAAiB;oBACjB,QAAQ;oBACR,wBAAwB;oBACxB,0BAA0B;oBAC1B,yBAAyB;oBACzB,2BAA2B;oBAC3B,qBAAqB;oBACrB,oBAAoB;oBACpB,mBAAmB;oBACnB,qBAAqB;oBACrB,yBAAyB;oBACzB,gBAAgB;oBAChB,OAAO;oBACP,kBAAkB;oBAClB,OAAO;oBACP,cAAc;oBACd,iBAAiB;oBACjB,YAAY;iBACb;gBACD,iBAAiB,EAAE,CAAC,UAAU,CAAC;gBAC/B,iBAAiB,EAAE,CAAC,UAAU,EAAE,mBAAmB,EAAE,MAAM,CAAC;aAC7D;YACD,OAAO,EAAE,CAAC,QAAQ,EAAE,oBAAoB,CAAC;SAC1C;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { GraphId } from '../../types/resources/group_resource'\nimport { GetRequest } from '../client/types'\n\nexport interface ConversationRequestArgs {\n gids: string\n chat_group_graph_id?: GraphId\n group_source_app_name?: string\n show_direct_messages?: boolean\n}\n\nexport const getConversationsRequestArgs = ({\n gids,\n chat_group_graph_id,\n group_source_app_name,\n show_direct_messages,\n}: Partial<ConversationRequestArgs> = {}): GetRequest => {\n let filter: string\n if (chat_group_graph_id) {\n filter = 'mine_or_not_empty,group'\n } else if (show_direct_messages) {\n filter = 'mine_or_not_empty,direct_message'\n } else if (group_source_app_name) {\n filter = 'mine_or_not_empty,group_source_app_name'\n } else {\n filter = 'mine_or_not_empty'\n }\n\n return {\n url: '/me/conversations',\n data: {\n perPage: 20,\n order: '-last_message',\n filter,\n gids,\n group: chat_group_graph_id,\n group_source_app_name,\n fields: {\n Conversation: [\n 'created_at',\n 'badges',\n 'conversation_preview',\n 'disabled',\n 'disabled_reason',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'preview_avatar_urls',\n 'custom_avatar_type',\n 'custom_avatar_key',\n 'custom_avatar_color',\n 'custom_avatar_image_url',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'unread_reaction',\n 'updated_at',\n ],\n AnalyticsMetadata: ['metadata'],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n },\n include: ['badges', 'analytics_metadata'],\n },\n }\n}\n"]}
|
|
@@ -6,5 +6,6 @@ export declare class ResponseError extends Error {
|
|
|
6
6
|
response: FailedResponse;
|
|
7
7
|
constructor(response: FailedResponse);
|
|
8
8
|
}
|
|
9
|
+
export declare const isResponseLike: (value: unknown) => value is Response;
|
|
9
10
|
export declare const throwResponseError: (error: unknown) => Promise<never>;
|
|
10
11
|
//# sourceMappingURL=response_error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response_error.d.ts","sourceRoot":"","sources":["../../src/utils/response_error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,qBAAa,aAAc,SAAQ,KAAK;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;IAChC,QAAQ,EAAE,cAAc,CAAA;gBAEZ,QAAQ,EAAE,cAAc;CAQrC;AAED,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,mBAMhD,CAAA"}
|
|
1
|
+
{"version":3,"file":"response_error.d.ts","sourceRoot":"","sources":["../../src/utils/response_error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,qBAAa,aAAc,SAAQ,KAAK;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;IAChC,QAAQ,EAAE,cAAc,CAAA;gBAEZ,QAAQ,EAAE,cAAc;CAQrC;AAKD,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,QAiBxD,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,mBAMhD,CAAA"}
|
|
@@ -12,8 +12,27 @@ export class ResponseError extends Error {
|
|
|
12
12
|
this.response = response;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
// Detect a fetch Response by shape, not `instanceof`: Expo's winter runtime
|
|
16
|
+
// swaps in a `fetch` whose `FetchResponse` isn't an instance of the global
|
|
17
|
+
// `Response`, so `instanceof` silently misses it under Expo.
|
|
18
|
+
export const isResponseLike = (value) => {
|
|
19
|
+
if (typeof value !== 'object' || value === null)
|
|
20
|
+
return false;
|
|
21
|
+
const candidate = value;
|
|
22
|
+
return (typeof candidate.status === 'number' &&
|
|
23
|
+
typeof candidate.statusText === 'string' &&
|
|
24
|
+
typeof candidate.ok === 'boolean' &&
|
|
25
|
+
typeof candidate.redirected === 'boolean' &&
|
|
26
|
+
typeof candidate.url === 'string' &&
|
|
27
|
+
typeof candidate.headers === 'object' &&
|
|
28
|
+
candidate.headers !== null &&
|
|
29
|
+
typeof candidate.clone === 'function' &&
|
|
30
|
+
typeof candidate.json === 'function' &&
|
|
31
|
+
typeof candidate.text === 'function' &&
|
|
32
|
+
typeof candidate.arrayBuffer === 'function');
|
|
33
|
+
};
|
|
15
34
|
export const throwResponseError = (error) => {
|
|
16
|
-
if (error
|
|
35
|
+
if (isResponseLike(error)) {
|
|
17
36
|
throw new ResponseError(error);
|
|
18
37
|
}
|
|
19
38
|
return Promise.reject(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response_error.js","sourceRoot":"","sources":["../../src/utils/response_error.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,MAAM,CAAQ;IACd,UAAU,CAAQ;IAClB,MAAM,CAA0B;IAChC,QAAQ,CAAgB;IAExB,YAAY,QAAwB;QAClC,KAAK,CAAC,kBAAkB,QAAQ,EAAE,MAAM,IAAI,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;QACnE,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,MAAM,CAAA;QAC9B,IAAI,CAAC,UAAU,GAAG,QAAQ,EAAE,UAAU,CAAA;QACtC,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAA;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAE,EAAE;IACnD,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"response_error.js","sourceRoot":"","sources":["../../src/utils/response_error.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,MAAM,CAAQ;IACd,UAAU,CAAQ;IAClB,MAAM,CAA0B;IAChC,QAAQ,CAAgB;IAExB,YAAY,QAAwB;QAClC,KAAK,CAAC,kBAAkB,QAAQ,EAAE,MAAM,IAAI,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;QACnE,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,MAAM,CAAA;QAC9B,IAAI,CAAC,UAAU,GAAG,QAAQ,EAAE,UAAU,CAAA;QACtC,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAA;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AAED,4EAA4E;AAC5E,2EAA2E;AAC3E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAqB,EAAE;IAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAE7D,MAAM,SAAS,GAAG,KAAgC,CAAA;IAClD,OAAO,CACL,OAAO,SAAS,CAAC,MAAM,KAAK,QAAQ;QACpC,OAAO,SAAS,CAAC,UAAU,KAAK,QAAQ;QACxC,OAAO,SAAS,CAAC,EAAE,KAAK,SAAS;QACjC,OAAO,SAAS,CAAC,UAAU,KAAK,SAAS;QACzC,OAAO,SAAS,CAAC,GAAG,KAAK,QAAQ;QACjC,OAAO,SAAS,CAAC,OAAO,KAAK,QAAQ;QACrC,SAAS,CAAC,OAAO,KAAK,IAAI;QAC1B,OAAO,SAAS,CAAC,KAAK,KAAK,UAAU;QACrC,OAAO,SAAS,CAAC,IAAI,KAAK,UAAU;QACpC,OAAO,SAAS,CAAC,IAAI,KAAK,UAAU;QACpC,OAAO,SAAS,CAAC,WAAW,KAAK,UAAU,CAC5C,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAE,EAAE;IACnD,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,aAAa,CAAC,KAAuB,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { FailedResponse } from '../types/api_primitives'\n\nexport class ResponseError extends Error {\n status: number\n statusText: string\n errors: FailedResponse['errors']\n response: FailedResponse\n\n constructor(response: FailedResponse) {\n super(`ResponseError: ${response?.status} ${response?.statusText}`)\n this.name = 'ResponseError'\n this.status = response?.status\n this.statusText = response?.statusText\n this.errors = response?.errors || []\n this.response = response\n }\n}\n\n// Detect a fetch Response by shape, not `instanceof`: Expo's winter runtime\n// swaps in a `fetch` whose `FetchResponse` isn't an instance of the global\n// `Response`, so `instanceof` silently misses it under Expo.\nexport const isResponseLike = (value: unknown): value is Response => {\n if (typeof value !== 'object' || value === null) return false\n\n const candidate = value as Record<string, unknown>\n return (\n typeof candidate.status === 'number' &&\n typeof candidate.statusText === 'string' &&\n typeof candidate.ok === 'boolean' &&\n typeof candidate.redirected === 'boolean' &&\n typeof candidate.url === 'string' &&\n typeof candidate.headers === 'object' &&\n candidate.headers !== null &&\n typeof candidate.clone === 'function' &&\n typeof candidate.json === 'function' &&\n typeof candidate.text === 'function' &&\n typeof candidate.arrayBuffer === 'function'\n )\n}\n\nexport const throwResponseError = (error: unknown) => {\n if (isResponseLike(error)) {\n throw new ResponseError(error as FailedResponse)\n }\n\n return Promise.reject(error)\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "3.42.2
|
|
3
|
+
"version": "3.42.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"react-native": "./src/index.tsx",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@fortawesome/fontawesome-svg-core": "^7.2.0",
|
|
28
28
|
"@fortawesome/react-native-fontawesome": "^0.3.2",
|
|
29
|
-
"@planningcenter/emoji-keyboard": "3.
|
|
29
|
+
"@planningcenter/emoji-keyboard": "3.42.2",
|
|
30
30
|
"lodash-inflection": "^1.5.0",
|
|
31
31
|
"react-compiler-runtime": "^1.0.0"
|
|
32
32
|
},
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"react-native-url-polyfill": "^2.0.0",
|
|
73
73
|
"typescript": "~5.9.2"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "c67ad284f4c7047831a37cc7826ff827e0637f2d"
|
|
76
76
|
}
|
|
@@ -6,8 +6,10 @@ import {
|
|
|
6
6
|
useFontScale,
|
|
7
7
|
useScalableNumberOfLines,
|
|
8
8
|
} from '../../hooks'
|
|
9
|
-
import { ConversationResource } from '../../types'
|
|
9
|
+
import { ConversationPreviewData, ConversationResource } from '../../types'
|
|
10
|
+
import { REACTION_EMOJIS, platformFontWeightBold } from '../../utils'
|
|
10
11
|
import { formatDatePreview } from '../../utils/date'
|
|
12
|
+
import { tokens } from '../../vendor/tapestry/tokens'
|
|
11
13
|
import { AvatarGroup, ConversationAvatar, Heading, Text, Badge, type BadgeProps } from '../display'
|
|
12
14
|
import { ConversationActions } from './conversation_actions'
|
|
13
15
|
import { MuteIndicator } from './mute_indicator'
|
|
@@ -30,25 +32,26 @@ export const ConversationPreview = ({
|
|
|
30
32
|
}: ConversationPreviewProps) => {
|
|
31
33
|
const styles = useStyles()
|
|
32
34
|
const {
|
|
33
|
-
|
|
35
|
+
conversationPreview,
|
|
34
36
|
lastMessageCreatedAt,
|
|
35
|
-
lastMessageTextPreview,
|
|
36
37
|
title,
|
|
37
38
|
unreadCount,
|
|
38
39
|
badges,
|
|
39
40
|
muted,
|
|
40
41
|
disabled,
|
|
42
|
+
unreadReaction,
|
|
41
43
|
} = conversation
|
|
42
44
|
|
|
43
45
|
const emptyConversation = !lastMessageCreatedAt
|
|
44
46
|
const fallbackIconName = emptyConversation ? 'people.noTextMessage' : 'general.person'
|
|
45
47
|
const hasMetaContent = lastMessageCreatedAt || unreadCount > 0 || muted
|
|
48
|
+
const isUnread = unreadCount > 0 || unreadReaction
|
|
46
49
|
|
|
47
50
|
const numberOfLinesScaledTitle = useScalableNumberOfLines(1)
|
|
48
51
|
const numberOfLinesScaledPreviewText = useScalableNumberOfLines(2)
|
|
49
52
|
|
|
50
|
-
const conversationPreviewText =
|
|
51
|
-
?
|
|
53
|
+
const conversationPreviewText = conversationPreview
|
|
54
|
+
? formatConversationPreviewText(conversationPreview)
|
|
52
55
|
: EMPTY_CONVERSATION_PREVIEW_TEXT
|
|
53
56
|
|
|
54
57
|
const conversationAccessibilityLabel = getConversationAccessibilityLabel({
|
|
@@ -69,13 +72,20 @@ export const ConversationPreview = ({
|
|
|
69
72
|
fallbackIconName={fallbackIconName}
|
|
70
73
|
/>
|
|
71
74
|
<View style={styles.conversationBody}>
|
|
72
|
-
<Heading
|
|
75
|
+
<Heading
|
|
76
|
+
numberOfLines={numberOfLinesScaledTitle}
|
|
77
|
+
variant="h3"
|
|
78
|
+
style={[styles.title, isUnread && styles.unreadTitle]}
|
|
79
|
+
>
|
|
73
80
|
{title}
|
|
74
81
|
</Heading>
|
|
75
82
|
<Text
|
|
76
83
|
variant="tertiary"
|
|
77
84
|
numberOfLines={numberOfLinesScaledPreviewText}
|
|
78
|
-
style={
|
|
85
|
+
style={[
|
|
86
|
+
emptyConversation && styles.emptyConversationPreviewText,
|
|
87
|
+
isUnread && styles.unreadText,
|
|
88
|
+
]}
|
|
79
89
|
>
|
|
80
90
|
{conversationPreviewText}
|
|
81
91
|
</Text>
|
|
@@ -83,9 +93,9 @@ export const ConversationPreview = ({
|
|
|
83
93
|
</View>
|
|
84
94
|
{hasMetaContent && (
|
|
85
95
|
<View style={styles.metaContainer}>
|
|
86
|
-
<Text variant="tertiary">{formatDatePreview(
|
|
96
|
+
<Text variant="tertiary">{formatDatePreview(conversationPreview?.createdAt)}</Text>
|
|
87
97
|
<View style={styles.statusContainer}>
|
|
88
|
-
<UnreadCountBadge count={unreadCount} showDot={muted} />
|
|
98
|
+
<UnreadCountBadge count={unreadCount} unreadReaction={unreadReaction} showDot={muted} />
|
|
89
99
|
<MuteIndicator muted={muted} />
|
|
90
100
|
</View>
|
|
91
101
|
</View>
|
|
@@ -152,6 +162,30 @@ export const ConversationPreviewSkeleton = () => {
|
|
|
152
162
|
)
|
|
153
163
|
}
|
|
154
164
|
|
|
165
|
+
function reactionEmoji(value: ConversationPreviewData['value']): string | null {
|
|
166
|
+
if (!value) return null
|
|
167
|
+
return REACTION_EMOJIS[value] ?? null
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function formatConversationPreviewText(preview: ConversationPreviewData) {
|
|
171
|
+
if (preview.kind === 'reaction') {
|
|
172
|
+
const emoji = reactionEmoji(preview.value)
|
|
173
|
+
return `${preview.authorName}${emoji ? ` ${emoji}` : ' reacted'} to: "${preview.text}"`
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return `${preview.authorName}: ${preview.text}`
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function formatConversationPreviewAccessibilityLabel(preview: ConversationPreviewData) {
|
|
180
|
+
const date = formatDatePreview(preview.createdAt)
|
|
181
|
+
|
|
182
|
+
if (preview.kind === 'reaction') {
|
|
183
|
+
return `${preview.authorName} reacted to your message sent ${date} and says ${preview.text}`
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return `Last message sent ${date} from ${preview.authorName} and says ${preview.text}`
|
|
187
|
+
}
|
|
188
|
+
|
|
155
189
|
interface GetConversationAccessibilityLabelProps {
|
|
156
190
|
conversation: ConversationResource
|
|
157
191
|
showBadges: boolean
|
|
@@ -160,29 +194,24 @@ const getConversationAccessibilityLabel = ({
|
|
|
160
194
|
conversation,
|
|
161
195
|
showBadges,
|
|
162
196
|
}: GetConversationAccessibilityLabelProps) => {
|
|
163
|
-
const {
|
|
164
|
-
|
|
165
|
-
title,
|
|
166
|
-
lastMessageAuthorName,
|
|
167
|
-
lastMessageTextPreview,
|
|
168
|
-
muted,
|
|
169
|
-
disabled,
|
|
170
|
-
unreadCount,
|
|
171
|
-
lastMessageCreatedAt,
|
|
172
|
-
} = conversation
|
|
197
|
+
const { badges, title, conversationPreview, muted, disabled, unreadCount, unreadReaction } =
|
|
198
|
+
conversation
|
|
173
199
|
|
|
174
200
|
const hasBadges = badges && showBadges
|
|
175
201
|
const hasUnreadMessages = unreadCount > 0
|
|
176
|
-
const hasLastMessage = lastMessageCreatedAt
|
|
177
202
|
|
|
178
203
|
const label = {
|
|
179
204
|
title,
|
|
180
205
|
badge: hasBadges ? `for ${badges[0]?.pcoResourceType} ${badges[0]?.text || ''}` : '',
|
|
181
206
|
disabled: disabled ? 'Disabled' : '',
|
|
182
207
|
muted: muted ? 'Muted' : '',
|
|
183
|
-
readStatus: hasUnreadMessages
|
|
184
|
-
|
|
185
|
-
|
|
208
|
+
readStatus: hasUnreadMessages
|
|
209
|
+
? `${unreadCount} unread messages`
|
|
210
|
+
: unreadReaction
|
|
211
|
+
? 'unread reaction'
|
|
212
|
+
: '',
|
|
213
|
+
lastMessage: conversationPreview
|
|
214
|
+
? formatConversationPreviewAccessibilityLabel(conversationPreview)
|
|
186
215
|
: EMPTY_CONVERSATION_PREVIEW_TEXT,
|
|
187
216
|
}
|
|
188
217
|
|
|
@@ -222,6 +251,12 @@ const useStyles = () => {
|
|
|
222
251
|
fontSize: 16,
|
|
223
252
|
color: colors.textColorDefaultPrimary,
|
|
224
253
|
},
|
|
254
|
+
unreadTitle: {
|
|
255
|
+
fontWeight: tokens.fontWeightBold,
|
|
256
|
+
},
|
|
257
|
+
unreadText: {
|
|
258
|
+
fontWeight: platformFontWeightBold,
|
|
259
|
+
},
|
|
225
260
|
titleLoading: {
|
|
226
261
|
width: 120,
|
|
227
262
|
height: 20,
|
|
@@ -4,12 +4,21 @@ import { useFontScale, useTheme } from '../../hooks'
|
|
|
4
4
|
import { MAX_FONT_SIZE_MULTIPLIER, platformFontWeightBold } from '../../utils'
|
|
5
5
|
import { Text } from '../display'
|
|
6
6
|
|
|
7
|
-
export const UnreadCountBadge = ({
|
|
7
|
+
export const UnreadCountBadge = ({
|
|
8
|
+
count,
|
|
9
|
+
unreadReaction,
|
|
10
|
+
showDot,
|
|
11
|
+
}: {
|
|
12
|
+
count: number
|
|
13
|
+
unreadReaction: boolean
|
|
14
|
+
showDot: boolean
|
|
15
|
+
}) => {
|
|
8
16
|
const styles = useStyles()
|
|
9
17
|
const displayCount = count > 99 ? '99+' : count
|
|
18
|
+
const isUnread = count > 0 || unreadReaction
|
|
10
19
|
|
|
11
|
-
if (
|
|
12
|
-
if (showDot) return <View style={styles.dot} />
|
|
20
|
+
if (!isUnread) return null
|
|
21
|
+
if (showDot || count === 0) return <View style={styles.dot} />
|
|
13
22
|
|
|
14
23
|
return (
|
|
15
24
|
<View style={styles.badge}>
|
|
@@ -24,7 +33,7 @@ const useStyles = () => {
|
|
|
24
33
|
const { colors } = useTheme()
|
|
25
34
|
const dotScaleLimit = MAX_FONT_SIZE_MULTIPLIER * 1.5
|
|
26
35
|
const fontScale = useFontScale({ maxFontSizeMultiplier: dotScaleLimit })
|
|
27
|
-
const size =
|
|
36
|
+
const size = 10 * fontScale
|
|
28
37
|
|
|
29
38
|
return StyleSheet.create({
|
|
30
39
|
badge: {
|
|
@@ -16,6 +16,7 @@ export const getConversationRequestArgs = ({ conversation_id }: { conversation_i
|
|
|
16
16
|
'created_at',
|
|
17
17
|
'badges',
|
|
18
18
|
'conversation_membership',
|
|
19
|
+
'conversation_preview',
|
|
19
20
|
'gender_option',
|
|
20
21
|
'groups',
|
|
21
22
|
'last_message_author_id',
|
|
@@ -36,6 +37,7 @@ export const getConversationRequestArgs = ({ conversation_id }: { conversation_i
|
|
|
36
37
|
'replies_disabled',
|
|
37
38
|
'title',
|
|
38
39
|
'unread_count',
|
|
40
|
+
'unread_reaction',
|
|
39
41
|
'updated_at',
|
|
40
42
|
],
|
|
41
43
|
AnalyticsMetadata: ['metadata'],
|
|
@@ -63,7 +63,7 @@ export function useConversationJoltEvents({ conversationId }: Props) {
|
|
|
63
63
|
data: {
|
|
64
64
|
...prev.data,
|
|
65
65
|
latestReadMessageSortKey: latest_read_message_sort_key,
|
|
66
|
-
|
|
66
|
+
unreadReaction: false,
|
|
67
67
|
},
|
|
68
68
|
}
|
|
69
69
|
})
|
|
@@ -87,24 +87,13 @@ export function useConversationJoltEvents({ conversationId }: Props) {
|
|
|
87
87
|
|
|
88
88
|
const handleReactionJoltEvent = useCallback(
|
|
89
89
|
(event: JoltReactionEvent) => {
|
|
90
|
+
if (event.event !== 'reaction.created') return
|
|
91
|
+
if (event.data.data.author_id === currentPersonId) return
|
|
92
|
+
if (event.data.data.message_author_id !== currentPersonId) return
|
|
93
|
+
|
|
90
94
|
queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {
|
|
91
95
|
if (!prev?.data) return prev
|
|
92
|
-
|
|
93
|
-
if (event.data.data.author_id === currentPersonId) {
|
|
94
|
-
return prev
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
...prev,
|
|
99
|
-
data: {
|
|
100
|
-
...prev.data,
|
|
101
|
-
// Not a real count, just a derived value from Jolt events so we can
|
|
102
|
-
// determine if we should mark the conversation as read
|
|
103
|
-
unreadReactionCount: prev.data.unreadReactionCount
|
|
104
|
-
? prev.data.unreadReactionCount + 1
|
|
105
|
-
: 1,
|
|
106
|
-
},
|
|
107
|
-
}
|
|
96
|
+
return { ...prev, data: { ...prev.data, unreadReaction: true } }
|
|
108
97
|
})
|
|
109
98
|
},
|
|
110
99
|
[queryClient, queryKey, currentPersonId]
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { useMutation } from '@tanstack/react-query'
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
2
2
|
import { Alert } from 'react-native'
|
|
3
3
|
import { useConversationsContext } from '../contexts/conversations_context'
|
|
4
4
|
import { ApiResource, ConversationResource } from '../types'
|
|
5
5
|
import { useApiClient } from './use_api_client'
|
|
6
|
+
import { getConversationRequestArgs } from './use_conversation'
|
|
6
7
|
import { useConversationsCache } from './use_conversations_cache'
|
|
7
8
|
import { useCurrentPersonCache } from './use_current_person'
|
|
9
|
+
import { getRequestQueryKey } from './use_suspense_api'
|
|
8
10
|
|
|
9
11
|
export const useConversationsMarkRead = ({
|
|
10
12
|
conversation,
|
|
@@ -12,15 +14,19 @@ export const useConversationsMarkRead = ({
|
|
|
12
14
|
conversation: ConversationResource
|
|
13
15
|
}) => {
|
|
14
16
|
const apiClient = useApiClient()
|
|
17
|
+
const queryClient = useQueryClient()
|
|
15
18
|
const { args } = useConversationsContext()
|
|
16
19
|
const currentPersonCache = useCurrentPersonCache()
|
|
17
20
|
const { update, invalidate, fetchUpdate } = useConversationsCache(args)
|
|
21
|
+
const conversationQueryKey = getRequestQueryKey(
|
|
22
|
+
getConversationRequestArgs({ conversation_id: conversation.id })
|
|
23
|
+
)
|
|
18
24
|
|
|
19
25
|
function handlePersonUnreadCount(read: boolean) {
|
|
20
26
|
currentPersonCache.update({}, person => {
|
|
21
27
|
const currentUnread = person.unreadCount
|
|
22
28
|
const updatedUnread = read ? Math.max(currentUnread - 1, 0) : currentUnread + 1
|
|
23
|
-
return { ...person, unreadCount: updatedUnread
|
|
29
|
+
return { ...person, unreadCount: updatedUnread }
|
|
24
30
|
})
|
|
25
31
|
}
|
|
26
32
|
|
|
@@ -29,7 +35,14 @@ export const useConversationsMarkRead = ({
|
|
|
29
35
|
update({
|
|
30
36
|
...conversation,
|
|
31
37
|
unreadCount: read ? 0 : 1,
|
|
38
|
+
...(read ? { unreadReaction: false } : {}),
|
|
32
39
|
})
|
|
40
|
+
if (read) {
|
|
41
|
+
queryClient.setQueryData<ApiResource<ConversationResource>>(conversationQueryKey, prev => {
|
|
42
|
+
if (!prev?.data) return prev
|
|
43
|
+
return { ...prev, data: { ...prev.data, unreadReaction: false } }
|
|
44
|
+
})
|
|
45
|
+
}
|
|
33
46
|
handlePersonUnreadCount(read)
|
|
34
47
|
},
|
|
35
48
|
mutationKey: ['markRead', conversation.id],
|
|
@@ -106,6 +119,7 @@ export const useMarkAllRead = () => {
|
|
|
106
119
|
onMutate: () => {
|
|
107
120
|
updateAll({
|
|
108
121
|
unreadCount: 0,
|
|
122
|
+
unreadReaction: false,
|
|
109
123
|
})
|
|
110
124
|
},
|
|
111
125
|
mutationKey: ['markAllRead', args],
|