@planningcenter/chat-react-native 4.3.0-rc.1 → 4.3.0-rc.11
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_form.d.ts +2 -1
- package/build/components/conversation/message_form.d.ts.map +1 -1
- package/build/components/conversation/message_form.js +167 -370
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/conversation/message_list.d.ts +5 -2
- package/build/components/conversation/message_list.d.ts.map +1 -1
- package/build/components/conversation/message_list.js +187 -67
- package/build/components/conversation/message_list.js.map +1 -1
- package/build/components/conversation/missing_message.d.ts +2 -0
- package/build/components/conversation/missing_message.d.ts.map +1 -0
- package/build/components/conversation/missing_message.js +139 -0
- package/build/components/conversation/missing_message.js.map +1 -0
- package/build/components/display/conversation_avatar.d.ts +1 -2
- package/build/components/display/conversation_avatar.d.ts.map +1 -1
- package/build/components/display/conversation_avatar.js.map +1 -1
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +4 -3
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation_messages.d.ts +14 -5
- package/build/hooks/use_conversation_messages.d.ts.map +1 -1
- package/build/hooks/use_conversation_messages.js +218 -42
- package/build/hooks/use_conversation_messages.js.map +1 -1
- package/build/hooks/use_conversation_messages_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_messages_jolt_events.js +58 -42
- package/build/hooks/use_conversation_messages_jolt_events.js.map +1 -1
- package/build/hooks/use_features.d.ts +2 -1
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +2 -1
- package/build/hooks/use_features.js.map +1 -1
- package/build/hooks/use_mark_latest_message_read.d.ts +2 -1
- package/build/hooks/use_mark_latest_message_read.d.ts.map +1 -1
- package/build/hooks/use_mark_latest_message_read.js +4 -3
- package/build/hooks/use_mark_latest_message_read.js.map +1 -1
- package/build/hooks/use_read_receipts.d.ts +4 -3
- package/build/hooks/use_read_receipts.d.ts.map +1 -1
- package/build/hooks/use_search_results.d.ts +19 -0
- package/build/hooks/use_search_results.d.ts.map +1 -0
- package/build/hooks/use_search_results.js +145 -0
- package/build/hooks/use_search_results.js.map +1 -0
- package/build/hooks/use_suspense_api.d.ts +10 -6
- package/build/hooks/use_suspense_api.d.ts.map +1 -1
- package/build/hooks/use_suspense_api.js +83 -63
- package/build/hooks/use_suspense_api.js.map +1 -1
- package/build/navigation/index.d.ts +5 -0
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +5 -0
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_screen.d.ts +1 -0
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +305 -203
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/components/view_more_link_row.d.ts +2 -1
- package/build/screens/conversation_select_recipients/components/view_more_link_row.d.ts.map +1 -1
- package/build/screens/conversation_select_recipients/components/view_more_link_row.js +39 -24
- package/build/screens/conversation_select_recipients/components/view_more_link_row.js.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.js +159 -133
- package/build/screens/conversations/components/search_list_header_component.js.map +1 -1
- package/build/screens/message_actions_screen.d.ts.map +1 -1
- package/build/screens/message_actions_screen.js +103 -92
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/screens/notification_settings/hooks/groups.d.ts +4 -3
- package/build/screens/notification_settings/hooks/groups.d.ts.map +1 -1
- package/build/screens/search/components/conversation_result_row.d.ts +8 -0
- package/build/screens/search/components/conversation_result_row.d.ts.map +1 -0
- package/build/screens/search/components/conversation_result_row.js +80 -0
- package/build/screens/search/components/conversation_result_row.js.map +1 -0
- package/build/screens/search/components/conversation_results.d.ts +8 -0
- package/build/screens/search/components/conversation_results.d.ts.map +1 -0
- package/build/screens/search/components/conversation_results.js +77 -0
- package/build/screens/search/components/conversation_results.js.map +1 -0
- package/build/screens/search/components/message_result_row.d.ts +8 -0
- package/build/screens/search/components/message_result_row.d.ts.map +1 -0
- package/build/screens/search/components/message_result_row.js +152 -0
- package/build/screens/search/components/message_result_row.js.map +1 -0
- package/build/screens/search/components/result_row.d.ts +10 -0
- package/build/screens/search/components/result_row.d.ts.map +1 -0
- package/build/screens/search/components/result_row.js +102 -0
- package/build/screens/search/components/result_row.js.map +1 -0
- package/build/screens/search/components/results_section.d.ts +9 -0
- package/build/screens/search/components/results_section.d.ts.map +1 -0
- package/build/screens/search/components/results_section.js +51 -0
- package/build/screens/search/components/results_section.js.map +1 -0
- package/build/screens/search/components/search_blank_states.d.ts +7 -0
- package/build/screens/search/components/search_blank_states.d.ts.map +1 -0
- package/build/screens/search/components/search_blank_states.js +72 -0
- package/build/screens/search/components/search_blank_states.js.map +1 -0
- package/build/screens/search/components/search_field.d.ts +7 -0
- package/build/screens/search/components/search_field.d.ts.map +1 -0
- package/build/screens/search/components/search_field.js +152 -0
- package/build/screens/search/components/search_field.js.map +1 -0
- package/build/screens/search/components/snippet.d.ts +8 -0
- package/build/screens/search/components/snippet.d.ts.map +1 -0
- package/build/screens/search/components/snippet.js +68 -0
- package/build/screens/search/components/snippet.js.map +1 -0
- package/build/screens/search/search_screen.d.ts +5 -0
- package/build/screens/search/search_screen.d.ts.map +1 -0
- package/build/screens/search/search_screen.js +59 -0
- package/build/screens/search/search_screen.js.map +1 -0
- package/build/types/api_primitives.d.ts +1 -0
- package/build/types/api_primitives.d.ts.map +1 -1
- package/build/types/api_primitives.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/types/resources/index.d.ts +1 -0
- package/build/types/resources/index.d.ts.map +1 -1
- package/build/types/resources/index.js +1 -0
- package/build/types/resources/index.js.map +1 -1
- package/build/types/resources/search_result.d.ts +29 -0
- package/build/types/resources/search_result.d.ts.map +1 -0
- package/build/types/resources/search_result.js +2 -0
- package/build/types/resources/search_result.js.map +1 -0
- package/build/utils/cache/messages_cache.d.ts +1 -0
- package/build/utils/cache/messages_cache.d.ts.map +1 -1
- package/build/utils/cache/messages_cache.js +37 -1
- package/build/utils/cache/messages_cache.js.map +1 -1
- package/build/utils/cache/messages_window.d.ts +11 -0
- package/build/utils/cache/messages_window.d.ts.map +1 -0
- package/build/utils/cache/messages_window.js +51 -0
- package/build/utils/cache/messages_window.js.map +1 -0
- package/build/utils/client/types.d.ts +1 -0
- package/build/utils/client/types.d.ts.map +1 -1
- package/build/utils/client/types.js.map +1 -1
- package/build/utils/request/get_search_results.d.ts +13 -0
- package/build/utils/request/get_search_results.d.ts.map +1 -0
- package/build/utils/request/get_search_results.js +20 -0
- package/build/utils/request/get_search_results.js.map +1 -0
- package/package.json +2 -2
- package/src/__tests__/hooks/use_features.test.ts +10 -2
- package/src/__utils__/query_client.ts +3 -0
- package/src/components/conversation/message_form.tsx +31 -3
- package/src/components/conversation/message_list.tsx +88 -4
- package/src/components/conversation/missing_message.tsx +66 -0
- package/src/components/display/conversation_avatar.tsx +1 -10
- package/src/hooks/__tests__/use_conversation_messages.test.tsx +333 -0
- package/src/hooks/__tests__/use_conversation_messages_jolt_events.test.tsx +87 -0
- package/src/hooks/__tests__/use_mark_latest_message_read.test.tsx +33 -0
- package/src/hooks/__tests__/use_message_create_or_update.test.tsx +2 -7
- package/src/hooks/__tests__/use_search_results.test.tsx +76 -0
- package/src/hooks/use_conversation_messages.ts +103 -17
- package/src/hooks/use_conversation_messages_jolt_events.ts +12 -2
- package/src/hooks/use_features.ts +3 -2
- package/src/hooks/use_mark_latest_message_read.ts +4 -3
- package/src/hooks/use_search_results.ts +77 -0
- package/src/hooks/use_suspense_api.ts +14 -6
- package/src/navigation/index.tsx +5 -0
- package/src/screens/conversation_screen.tsx +62 -13
- package/src/screens/conversation_select_recipients/components/view_more_link_row.tsx +12 -3
- package/src/screens/conversations/components/__tests__/search_list_header_component.test.tsx +62 -0
- package/src/screens/conversations/components/search_list_header_component.tsx +11 -0
- package/src/screens/message_actions_screen.tsx +12 -1
- package/src/screens/search/components/__tests__/conversation_results.test.tsx +55 -0
- package/src/screens/search/components/__tests__/message_result_row.test.tsx +65 -0
- package/src/screens/search/components/__tests__/result_row.test.tsx +33 -0
- package/src/screens/search/components/__tests__/search_blank_states.test.tsx +20 -0
- package/src/screens/search/components/__tests__/search_field.test.tsx +29 -0
- package/src/screens/search/components/conversation_result_row.tsx +36 -0
- package/src/screens/search/components/conversation_results.tsx +39 -0
- package/src/screens/search/components/message_result_row.tsx +48 -0
- package/src/screens/search/components/result_row.tsx +58 -0
- package/src/screens/search/components/results_section.tsx +34 -0
- package/src/screens/search/components/search_blank_states.tsx +34 -0
- package/src/screens/search/components/search_field.tsx +81 -0
- package/src/screens/search/components/snippet.tsx +37 -0
- package/src/screens/search/search_screen.tsx +41 -0
- package/src/types/api_primitives.ts +1 -0
- package/src/types/resources/conversation.ts +9 -0
- package/src/types/resources/index.ts +1 -0
- package/src/types/resources/search_result.ts +32 -0
- package/src/utils/__tests__/get_search_results.test.ts +24 -0
- package/src/utils/cache/__tests__/messages_cache.test.ts +2 -1
- package/src/utils/cache/__tests__/messages_cache_deletion.test.ts +97 -0
- package/src/utils/cache/__tests__/messages_cache_reply_roots.test.ts +3 -2
- package/src/utils/cache/__tests__/messages_window.test.ts +78 -0
- package/src/utils/cache/messages_cache.ts +45 -1
- package/src/utils/cache/messages_window.ts +55 -0
- package/src/utils/client/types.ts +1 -0
- package/src/utils/request/get_search_results.ts +23 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InfiniteData } from '@tanstack/react-query';
|
|
2
|
+
import { ApiCollection, MessageResource } from '../../types';
|
|
3
|
+
import { RequestData } from '../client';
|
|
4
|
+
export type MessagesWindow = InfiniteData<ApiCollection<MessageResource>, Partial<RequestData> | undefined>;
|
|
5
|
+
export declare const livePageParam: Partial<RequestData>;
|
|
6
|
+
export declare const anchoredPageParam: (anchor: string) => Partial<RequestData>;
|
|
7
|
+
export declare function isBehindLiveEdge(data: MessagesWindow | undefined): boolean;
|
|
8
|
+
export declare function newerPageParam(firstPage: ApiCollection<MessageResource>): Partial<RequestData> | undefined;
|
|
9
|
+
export declare function newestFirst<Page extends ApiCollection<MessageResource>>(page: Page, pageParam: Partial<RequestData> | undefined): Page;
|
|
10
|
+
export declare function markLiveIfCaughtUp(data: MessagesWindow | undefined): MessagesWindow | undefined;
|
|
11
|
+
//# sourceMappingURL=messages_window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages_window.d.ts","sourceRoot":"","sources":["../../../src/utils/cache/messages_window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,MAAM,cAAc,GAAG,YAAY,CACvC,aAAa,CAAC,eAAe,CAAC,EAC9B,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,CACjC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,WAAW,CAAM,CAAA;AAErD,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,OAAO,CAAC,WAAW,CAEpE,CAAA;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAE1E;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,aAAa,CAAC,eAAe,CAAC,GACxC,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,CAMlC;AAKD,wBAAgB,WAAW,CAAC,IAAI,SAAS,aAAa,CAAC,eAAe,CAAC,EACrE,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,GAC1C,IAAI,CAUN;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAO/F"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export const livePageParam = {};
|
|
2
|
+
export const anchoredPageParam = anchor => ({
|
|
3
|
+
where: {
|
|
4
|
+
id_around: anchor
|
|
5
|
+
}
|
|
6
|
+
});
|
|
7
|
+
export function isBehindLiveEdge(data) {
|
|
8
|
+
return !!data?.pages[0]?.meta?.prev;
|
|
9
|
+
}
|
|
10
|
+
export function newerPageParam(firstPage) {
|
|
11
|
+
const newestId = firstPage.meta?.prev?.idGt;
|
|
12
|
+
if (!newestId) return undefined;
|
|
13
|
+
|
|
14
|
+
// Without asc the server hands back the newest page instead, leaving a gap.
|
|
15
|
+
return {
|
|
16
|
+
where: {
|
|
17
|
+
id_gt: newestId
|
|
18
|
+
},
|
|
19
|
+
order: 'asc'
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// The server returns newer pages oldest first, linking only to the next newer page.
|
|
24
|
+
// Storing them newest first with an older link lets a refetch replay the window
|
|
25
|
+
// forward from its top page like any other.
|
|
26
|
+
export function newestFirst(page, pageParam) {
|
|
27
|
+
if (pageParam?.order !== 'asc') return page;
|
|
28
|
+
const data = [...page.data].reverse();
|
|
29
|
+
const oldest = data[data.length - 1];
|
|
30
|
+
return {
|
|
31
|
+
...page,
|
|
32
|
+
data,
|
|
33
|
+
meta: {
|
|
34
|
+
...page.meta,
|
|
35
|
+
prev: page.meta?.next,
|
|
36
|
+
next: oldest && {
|
|
37
|
+
idLt: oldest.id
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function markLiveIfCaughtUp(data) {
|
|
43
|
+
if (!data) return data;
|
|
44
|
+
const topIsLive = !data.pageParams[0]?.where;
|
|
45
|
+
if (topIsLive || isBehindLiveEdge(data)) return data;
|
|
46
|
+
return {
|
|
47
|
+
...data,
|
|
48
|
+
pageParams: [livePageParam, ...data.pageParams.slice(1)]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=messages_window.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages_window.js","names":["livePageParam","anchoredPageParam","anchor","where","id_around","isBehindLiveEdge","data","pages","meta","prev","newerPageParam","firstPage","newestId","idGt","undefined","id_gt","order","newestFirst","page","pageParam","reverse","oldest","length","next","idLt","id","markLiveIfCaughtUp","topIsLive","pageParams","slice"],"sources":["../../../src/utils/cache/messages_window.ts"],"sourcesContent":["import { InfiniteData } from '@tanstack/react-query'\nimport { ApiCollection, MessageResource } from '../../types'\nimport { RequestData } from '../client'\n\nexport type MessagesWindow = InfiniteData<\n ApiCollection<MessageResource>,\n Partial<RequestData> | undefined\n>\n\nexport const livePageParam: Partial<RequestData> = {}\n\nexport const anchoredPageParam = (anchor: string): Partial<RequestData> => ({\n where: { id_around: anchor },\n})\n\nexport function isBehindLiveEdge(data: MessagesWindow | undefined): boolean {\n return !!data?.pages[0]?.meta?.prev\n}\n\nexport function newerPageParam(\n firstPage: ApiCollection<MessageResource>\n): Partial<RequestData> | undefined {\n const newestId = firstPage.meta?.prev?.idGt\n if (!newestId) return undefined\n\n // Without asc the server hands back the newest page instead, leaving a gap.\n return { where: { id_gt: newestId }, order: 'asc' }\n}\n\n// The server returns newer pages oldest first, linking only to the next newer page.\n// Storing them newest first with an older link lets a refetch replay the window\n// forward from its top page like any other.\nexport function newestFirst<Page extends ApiCollection<MessageResource>>(\n page: Page,\n pageParam: Partial<RequestData> | undefined\n): Page {\n if (pageParam?.order !== 'asc') return page\n\n const data = [...page.data].reverse()\n const oldest = data[data.length - 1]\n return {\n ...page,\n data,\n meta: { ...page.meta, prev: page.meta?.next, next: oldest && { idLt: oldest.id } },\n }\n}\n\nexport function markLiveIfCaughtUp(data: MessagesWindow | undefined): MessagesWindow | undefined {\n if (!data) return data\n\n const topIsLive = !data.pageParams[0]?.where\n if (topIsLive || isBehindLiveEdge(data)) return data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;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,CAAA;IACzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CAAA;IAC5D,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/client/types.ts"],"sourcesContent":["export interface Accumulator {\n data: Record<string, unknown>[]\n included: Record<string, unknown>[]\n meta: Record<string, unknown>\n links: Record<string, unknown>\n}\n\nexport interface WalkRequest extends GetRequest {\n acc?: Accumulator\n}\n\nexport interface GenericRequest {\n headers?: Record<string, string>\n url: string\n}\n\nexport interface GetRequest extends GenericRequest {\n data: {\n filter?: string\n fields: Record<string, string[]>\n where?: Record<string, string | number | (string | number)[]>\n include?: string[]\n order?: string\n perPage?: number\n offset?: number\n walk?: boolean\n } & Record<string, unknown>\n}\n\nexport interface Relationship {\n data: {\n type: string\n id: string\n }\n}\n\nexport type Relationships = Record<string, Relationship | Relationship[]>\nexport interface PostRequest extends GenericRequest {\n data?: {\n fields?: Record<string, string> // value should be comma separated string\n include?: string[]\n data?: {\n type: string\n attributes: Record<string, unknown>\n relationships?: Relationships\n }\n }\n}\n\nexport type PatchRequest = PostRequest\n\nexport interface DeleteRequest extends GenericRequest {}\n\nexport interface ApiClient<T = unknown> {\n get(_request: GetRequest): Promise<T>\n post(_request: PostRequest): Promise<T>\n patch(_request: PatchRequest): Promise<T>\n delete(_request: DeleteRequest): Promise<T>\n}\n\nexport type RequestData = {\n fields: Record<string, string[] | string>\n where: Record<string, string | number | (string | number)[]>\n include: string[]\n data: Record<string, unknown>\n perPage: number\n offset: number\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/client/types.ts"],"sourcesContent":["export interface Accumulator {\n data: Record<string, unknown>[]\n included: Record<string, unknown>[]\n meta: Record<string, unknown>\n links: Record<string, unknown>\n}\n\nexport interface WalkRequest extends GetRequest {\n acc?: Accumulator\n}\n\nexport interface GenericRequest {\n headers?: Record<string, string>\n url: string\n}\n\nexport interface GetRequest extends GenericRequest {\n data: {\n filter?: string\n fields: Record<string, string[]>\n where?: Record<string, string | number | (string | number)[]>\n include?: string[]\n order?: string\n perPage?: number\n offset?: number\n walk?: boolean\n } & Record<string, unknown>\n}\n\nexport interface Relationship {\n data: {\n type: string\n id: string\n }\n}\n\nexport type Relationships = Record<string, Relationship | Relationship[]>\nexport interface PostRequest extends GenericRequest {\n data?: {\n fields?: Record<string, string> // value should be comma separated string\n include?: string[]\n data?: {\n type: string\n attributes: Record<string, unknown>\n relationships?: Relationships\n }\n }\n}\n\nexport type PatchRequest = PostRequest\n\nexport interface DeleteRequest extends GenericRequest {}\n\nexport interface ApiClient<T = unknown> {\n get(_request: GetRequest): Promise<T>\n post(_request: PostRequest): Promise<T>\n patch(_request: PatchRequest): Promise<T>\n delete(_request: DeleteRequest): Promise<T>\n}\n\nexport type RequestData = {\n fields: Record<string, string[] | string>\n where: Record<string, string | number | (string | number)[]>\n include: string[]\n data: Record<string, unknown>\n perPage: number\n offset: number\n order: string\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const SEARCH_RESULTS_PAGE_SIZE = 20;
|
|
2
|
+
export declare const getSearchResultsRequestArgs: (term: string) => {
|
|
3
|
+
url: string;
|
|
4
|
+
data: {
|
|
5
|
+
q: string;
|
|
6
|
+
perPage: number;
|
|
7
|
+
fields: {
|
|
8
|
+
SearchResult: string[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const getSearchResultsQueryKey: (term: string) => import("../..").RequestQueryKey;
|
|
13
|
+
//# sourceMappingURL=get_search_results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_search_results.d.ts","sourceRoot":"","sources":["../../../src/utils/request/get_search_results.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAE1C,eAAO,MAAM,2BAA2B,GAAI,MAAM,MAAM;;;;;;;;;CAavD,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,MAAM,MAAM,oCAGpD,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getRequestQueryKey } from '../../hooks/use_suspense_api';
|
|
2
|
+
export const SEARCH_RESULTS_PAGE_SIZE = 20;
|
|
3
|
+
export const getSearchResultsRequestArgs = term => {
|
|
4
|
+
const url = '/search_results';
|
|
5
|
+
return {
|
|
6
|
+
url,
|
|
7
|
+
data: {
|
|
8
|
+
q: term,
|
|
9
|
+
perPage: SEARCH_RESULTS_PAGE_SIZE,
|
|
10
|
+
fields: {
|
|
11
|
+
SearchResult: ['type', 'title', 'url', 'extra']
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export const getSearchResultsQueryKey = term => {
|
|
17
|
+
const requestArgs = getSearchResultsRequestArgs(term);
|
|
18
|
+
return getRequestQueryKey(requestArgs);
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=get_search_results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_search_results.js","names":["getRequestQueryKey","SEARCH_RESULTS_PAGE_SIZE","getSearchResultsRequestArgs","term","url","data","q","perPage","fields","SearchResult","getSearchResultsQueryKey","requestArgs"],"sources":["../../../src/utils/request/get_search_results.ts"],"sourcesContent":["import { getRequestQueryKey } from '../../hooks/use_suspense_api'\n\nexport const SEARCH_RESULTS_PAGE_SIZE = 20\n\nexport const getSearchResultsRequestArgs = (term: string) => {\n const url = '/search_results'\n\n return {\n url,\n data: {\n q: term,\n perPage: SEARCH_RESULTS_PAGE_SIZE,\n fields: {\n SearchResult: ['type', 'title', 'url', 'extra'],\n },\n },\n }\n}\n\nexport const getSearchResultsQueryKey = (term: string) => {\n const requestArgs = getSearchResultsRequestArgs(term)\n return getRequestQueryKey(requestArgs)\n}\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,8BAA8B;AAEjE,OAAO,MAAMC,wBAAwB,GAAG,EAAE;AAE1C,OAAO,MAAMC,2BAA2B,GAAIC,IAAY,IAAK;EAC3D,MAAMC,GAAG,GAAG,iBAAiB;EAE7B,OAAO;IACLA,GAAG;IACHC,IAAI,EAAE;MACJC,CAAC,EAAEH,IAAI;MACPI,OAAO,EAAEN,wBAAwB;MACjCO,MAAM,EAAE;QACNC,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;MAChD;IACF;EACF,CAAC;AACH,CAAC;AAED,OAAO,MAAMC,wBAAwB,GAAIP,IAAY,IAAK;EACxD,MAAMQ,WAAW,GAAGT,2BAA2B,CAACC,IAAI,CAAC;EACrD,OAAOH,kBAAkB,CAACW,WAAW,CAAC;AACxC,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "4.3.0-rc.
|
|
3
|
+
"version": "4.3.0-rc.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"sf-symbols-typescript": "^2.2.0",
|
|
85
85
|
"typescript": "~6.0.3"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "4bf514fb42cdbc7a6bc0cb8fd3b1cee9432acae8"
|
|
88
88
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { buildTestQueryClient } from '../../__utils__/query_client'
|
|
2
2
|
import type { ApiClient } from '../../hooks/use_api_client'
|
|
3
|
-
import { featuresQueryOptions } from '../../hooks/use_features'
|
|
3
|
+
import { availableFeatures, featuresQueryOptions } from '../../hooks/use_features'
|
|
4
4
|
|
|
5
5
|
const features = {
|
|
6
|
-
data: [{ type: 'Feature', id: '1', name: '
|
|
6
|
+
data: [{ type: 'Feature', id: '1', name: 'QA_MOBILE_search', enabled: true }],
|
|
7
7
|
links: {},
|
|
8
8
|
meta: { count: 1, totalCount: 1 },
|
|
9
9
|
}
|
|
@@ -19,6 +19,14 @@ const fetchTwice = async (get: jest.Mock, secondsBetween: number) => {
|
|
|
19
19
|
await queryClient.fetchQuery(options)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
describe('availableFeatures', () => {
|
|
23
|
+
it('never reads a web-only flag', () => {
|
|
24
|
+
Object.values(availableFeatures).forEach(name => {
|
|
25
|
+
expect(name).not.toMatch(/_WEB_/)
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
22
30
|
describe('featuresQueryOptions', () => {
|
|
23
31
|
beforeEach(() => {
|
|
24
32
|
jest.useFakeTimers()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native'
|
|
2
|
-
import React, { useCallback, useContext, useEffect, useState } from 'react'
|
|
2
|
+
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'
|
|
3
3
|
import {
|
|
4
4
|
Linking,
|
|
5
5
|
Platform,
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
FileAttachment,
|
|
35
35
|
} from '../../types/resources/denormalized_attachment_resource_for_create'
|
|
36
36
|
import {
|
|
37
|
+
Log,
|
|
37
38
|
MAX_FONT_SIZE_MULTIPLIER_LANDMARK,
|
|
38
39
|
platformFontWeightMedium,
|
|
39
40
|
platformPressedOpacityStyle,
|
|
@@ -71,6 +72,7 @@ interface MessagesFormRootProps extends ViewProps {
|
|
|
71
72
|
replyRootId?: string | null
|
|
72
73
|
replyRootAuthorFirstName?: string | null
|
|
73
74
|
onFlaggedInMessageForm?: (id: string) => void
|
|
75
|
+
onBeforeSubmit?: () => void | Promise<void>
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
const MessageFormContext = React.createContext<{
|
|
@@ -113,6 +115,7 @@ function MessageFormRoot({
|
|
|
113
115
|
replyRootId,
|
|
114
116
|
replyRootAuthorFirstName,
|
|
115
117
|
onFlaggedInMessageForm,
|
|
118
|
+
onBeforeSubmit,
|
|
116
119
|
}: MessagesFormRootProps) {
|
|
117
120
|
const { giphyApiKey } = useContext(ChatContext)
|
|
118
121
|
const canGiphy = !!giphyApiKey && !currentlyEditingMessage
|
|
@@ -224,10 +227,31 @@ function MessageFormRoot({
|
|
|
224
227
|
}
|
|
225
228
|
}, [conversation.id, navigation, text])
|
|
226
229
|
|
|
227
|
-
const
|
|
230
|
+
const catchingUp = useRef(false)
|
|
231
|
+
|
|
232
|
+
// A send from a window behind the live edge would leave a gap above it, so a failed
|
|
233
|
+
// catch-up stops the send and keeps what was typed.
|
|
234
|
+
const catchUpBeforeSend = async () => {
|
|
235
|
+
if (catchingUp.current) return false
|
|
236
|
+
|
|
237
|
+
catchingUp.current = true
|
|
238
|
+
try {
|
|
239
|
+
await onBeforeSubmit?.()
|
|
240
|
+
return true
|
|
241
|
+
} catch (error) {
|
|
242
|
+
Log.error('send stopped: live window fetch failed', error)
|
|
243
|
+
return false
|
|
244
|
+
} finally {
|
|
245
|
+
catchingUp.current = false
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const handleSubmit = async () => {
|
|
228
250
|
if (!canSubmit) return
|
|
229
251
|
|
|
230
252
|
if (canGiphy && usingGiphy) {
|
|
253
|
+
if (!(await catchUpBeforeSend())) return
|
|
254
|
+
|
|
231
255
|
TextInput.State.blurTextInput(TextInput.State.currentlyFocusedInput())
|
|
232
256
|
Haptic.impactLight()
|
|
233
257
|
navigateToSendGiphyAfterKeyboardHides()
|
|
@@ -248,8 +272,12 @@ function MessageFormRoot({
|
|
|
248
272
|
mutateAsync({ text: messageText })
|
|
249
273
|
reset()
|
|
250
274
|
} else {
|
|
251
|
-
|
|
275
|
+
// The live-window fetch replaces the cache, which would wipe an optimistic row
|
|
276
|
+
// added earlier.
|
|
277
|
+
if (!(await catchUpBeforeSend())) return
|
|
278
|
+
|
|
252
279
|
reset()
|
|
280
|
+
mutateAsync({ text: messageText, attachments: attachmentsForSubmit })
|
|
253
281
|
}
|
|
254
282
|
}
|
|
255
283
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { date as formatDate } from '@planningcenter/datetime-fmt'
|
|
2
|
-
import
|
|
2
|
+
import { noop } from 'lodash'
|
|
3
|
+
import React, { RefObject, useRef } from 'react'
|
|
3
4
|
import { FlatList, FlatListProps, StyleSheet, View } from 'react-native'
|
|
4
5
|
import { useTheme } from '../../hooks'
|
|
5
6
|
import { ConversationResource } from '../../types/resources/conversation'
|
|
@@ -11,12 +12,23 @@ import { isSystemMessage } from '../../utils/system_messages'
|
|
|
11
12
|
import { Text } from '../display'
|
|
12
13
|
import { ConversationStartBanner } from './conversation_start_banner'
|
|
13
14
|
import { Message } from './message'
|
|
15
|
+
import { MissingMessage } from './missing_message'
|
|
14
16
|
import { ReplyShadowMessage } from './reply_shadow_message'
|
|
15
17
|
import { SystemMessage } from './system_message'
|
|
16
18
|
|
|
19
|
+
// While behind, the bottom of the window isn't the live edge. Following there pulls
|
|
20
|
+
// each newly paged-in page into view and chains the next fetch.
|
|
21
|
+
const HOLD_AND_FOLLOW = { minIndexForVisible: 0, autoscrollToTopThreshold: 100 }
|
|
22
|
+
const HOLD_ONLY = { minIndexForVisible: 0 }
|
|
23
|
+
|
|
17
24
|
type ScrollHandlers = Pick<
|
|
18
25
|
FlatListProps<EnrichedMessage>,
|
|
19
|
-
|
|
26
|
+
| 'onScroll'
|
|
27
|
+
| 'onLayout'
|
|
28
|
+
| 'onContentSizeChange'
|
|
29
|
+
| 'onScrollBeginDrag'
|
|
30
|
+
| 'onScrollEndDrag'
|
|
31
|
+
| 'onMomentumScrollEnd'
|
|
20
32
|
>
|
|
21
33
|
|
|
22
34
|
interface MessageListProps extends ScrollHandlers {
|
|
@@ -25,10 +37,15 @@ interface MessageListProps extends ScrollHandlers {
|
|
|
25
37
|
conversationId: number
|
|
26
38
|
messages: MessageResource[]
|
|
27
39
|
replyRootId?: string | null
|
|
40
|
+
anchorMessageId?: string | null
|
|
41
|
+
behind?: boolean
|
|
28
42
|
hasNextPage: boolean
|
|
29
43
|
onEndReached: () => void
|
|
44
|
+
onStartReached?: () => void
|
|
30
45
|
}
|
|
31
46
|
|
|
47
|
+
const ANCHOR_CLEARS_JUMP_BUTTON = 56
|
|
48
|
+
|
|
32
49
|
/** MessageList
|
|
33
50
|
* The inverted list of messages, reply previews, and date separators for a conversation
|
|
34
51
|
*/
|
|
@@ -38,11 +55,15 @@ export function MessageList({
|
|
|
38
55
|
conversationId,
|
|
39
56
|
messages,
|
|
40
57
|
replyRootId,
|
|
58
|
+
anchorMessageId,
|
|
59
|
+
behind = false,
|
|
41
60
|
hasNextPage,
|
|
42
61
|
onEndReached,
|
|
62
|
+
onStartReached,
|
|
43
63
|
onScroll,
|
|
44
64
|
onLayout,
|
|
45
65
|
onContentSizeChange,
|
|
66
|
+
onScrollBeginDrag,
|
|
46
67
|
onScrollEndDrag,
|
|
47
68
|
onMomentumScrollEnd,
|
|
48
69
|
}: MessageListProps) {
|
|
@@ -52,6 +73,60 @@ export function MessageList({
|
|
|
52
73
|
conversation.memberAbility?.canDeleteNonAuthoredMessages ?? false
|
|
53
74
|
const latestRead = conversation.latestReadMessageSortKey
|
|
54
75
|
const messagesWithSeparators = groupMessages({ ms: messages, inReplyScreen })
|
|
76
|
+
const anchorIndex = anchorMessageId
|
|
77
|
+
? messagesWithSeparators.findIndex(item => item.id === anchorMessageId)
|
|
78
|
+
: -1
|
|
79
|
+
const layoutHeight = useRef(0)
|
|
80
|
+
const contentHeight = useRef(0)
|
|
81
|
+
const userHasScrolled = useRef(false)
|
|
82
|
+
const draggedSinceStartReached = useRef(false)
|
|
83
|
+
|
|
84
|
+
// Row heights keep settling after the first layout (images, attachments), so we
|
|
85
|
+
// re-pin on every layout pass until the reader takes over with a drag.
|
|
86
|
+
const pinAnchorToBottomEdge = () => {
|
|
87
|
+
const anchorIsLoaded = anchorIndex >= 0
|
|
88
|
+
if (!anchorIsLoaded || userHasScrolled.current) return
|
|
89
|
+
|
|
90
|
+
const scrollable = layoutHeight.current > 0 && contentHeight.current > layoutHeight.current
|
|
91
|
+
if (!scrollable) return
|
|
92
|
+
|
|
93
|
+
listRef.current?.scrollToIndex({
|
|
94
|
+
index: anchorIndex,
|
|
95
|
+
viewPosition: 0,
|
|
96
|
+
viewOffset: ANCHOR_CLEARS_JUMP_BUTTON,
|
|
97
|
+
animated: false,
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const handleLayout: FlatListProps<EnrichedMessage>['onLayout'] = event => {
|
|
102
|
+
onLayout?.(event)
|
|
103
|
+
layoutHeight.current = event.nativeEvent.layout.height
|
|
104
|
+
pinAnchorToBottomEdge()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const handleContentSizeChange: FlatListProps<EnrichedMessage>['onContentSizeChange'] = (
|
|
108
|
+
width,
|
|
109
|
+
height
|
|
110
|
+
) => {
|
|
111
|
+
onContentSizeChange?.(width, height)
|
|
112
|
+
contentHeight.current = height
|
|
113
|
+
pinAnchorToBottomEdge()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const handleScrollBeginDrag: FlatListProps<EnrichedMessage>['onScrollBeginDrag'] = event => {
|
|
117
|
+
userHasScrolled.current = true
|
|
118
|
+
draggedSinceStartReached.current = true
|
|
119
|
+
onScrollBeginDrag?.(event)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// VirtualizedList re-checks its edges on every content size change using a JS offset
|
|
123
|
+
// the native hold never updates, so without this each merged page re-fires it.
|
|
124
|
+
const handleStartReached = () => {
|
|
125
|
+
if (!draggedSinceStartReached.current) return
|
|
126
|
+
|
|
127
|
+
draggedSinceStartReached.current = false
|
|
128
|
+
onStartReached?.()
|
|
129
|
+
}
|
|
55
130
|
|
|
56
131
|
return (
|
|
57
132
|
<FlatList
|
|
@@ -61,11 +136,15 @@ export function MessageList({
|
|
|
61
136
|
data={messagesWithSeparators}
|
|
62
137
|
keyExtractor={item => item.id}
|
|
63
138
|
onScroll={onScroll}
|
|
64
|
-
onLayout={
|
|
65
|
-
onContentSizeChange={
|
|
139
|
+
onLayout={handleLayout}
|
|
140
|
+
onContentSizeChange={handleContentSizeChange}
|
|
141
|
+
onScrollBeginDrag={handleScrollBeginDrag}
|
|
142
|
+
// Expected while rows are still measuring; the next layout pass pins again.
|
|
143
|
+
onScrollToIndexFailed={noop}
|
|
66
144
|
onScrollEndDrag={onScrollEndDrag}
|
|
67
145
|
onMomentumScrollEnd={onMomentumScrollEnd}
|
|
68
146
|
scrollEventThrottle={10}
|
|
147
|
+
maintainVisibleContentPosition={behind ? HOLD_ONLY : HOLD_AND_FOLLOW}
|
|
69
148
|
ListFooterComponent={
|
|
70
149
|
hasNextPage ? null : (
|
|
71
150
|
<ConversationStartBanner conversation={conversation} hasMessages={true} />
|
|
@@ -76,6 +155,10 @@ export function MessageList({
|
|
|
76
155
|
return <InlineDateSeparator {...item} />
|
|
77
156
|
}
|
|
78
157
|
|
|
158
|
+
if (item.type === 'Message' && item.deletedAt && !item.replyRootId) {
|
|
159
|
+
return <MissingMessage />
|
|
160
|
+
}
|
|
161
|
+
|
|
79
162
|
if (item.type === 'ReplyShadowMessage') {
|
|
80
163
|
return (
|
|
81
164
|
<ReplyShadowMessage
|
|
@@ -102,6 +185,7 @@ export function MessageList({
|
|
|
102
185
|
)
|
|
103
186
|
}}
|
|
104
187
|
onEndReached={onEndReached}
|
|
188
|
+
onStartReached={handleStartReached}
|
|
105
189
|
ListHeaderComponent={<View style={styles.listHeader} />}
|
|
106
190
|
/>
|
|
107
191
|
)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, useWindowDimensions, View } from 'react-native'
|
|
3
|
+
import { useTheme } from '../../hooks'
|
|
4
|
+
import { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../../utils/styles'
|
|
5
|
+
import { Avatar, Text } from '../display'
|
|
6
|
+
import { AVATAR_CONNECTOR_SPACING } from './reply_connectors'
|
|
7
|
+
|
|
8
|
+
export function MissingMessage() {
|
|
9
|
+
const styles = useStyles()
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<View style={styles.message} accessibilityLabel="Message deleted">
|
|
13
|
+
<Avatar
|
|
14
|
+
size="md"
|
|
15
|
+
sourceUri=""
|
|
16
|
+
style={styles.avatar}
|
|
17
|
+
maxFontSizeMultiplier={1}
|
|
18
|
+
minFontSizeMultiplier={1}
|
|
19
|
+
fallbackIconName="publishing.trash"
|
|
20
|
+
showFallback
|
|
21
|
+
/>
|
|
22
|
+
<View style={styles.messageContent}>
|
|
23
|
+
<View style={styles.messageBubble}>
|
|
24
|
+
<View style={styles.messageText}>
|
|
25
|
+
<Text style={styles.deletedText}>Message deleted</Text>
|
|
26
|
+
</View>
|
|
27
|
+
</View>
|
|
28
|
+
</View>
|
|
29
|
+
</View>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const useStyles = () => {
|
|
34
|
+
const { colors } = useTheme()
|
|
35
|
+
const { width } = useWindowDimensions()
|
|
36
|
+
const tabletWidth = width >= 744
|
|
37
|
+
|
|
38
|
+
return StyleSheet.create({
|
|
39
|
+
message: {
|
|
40
|
+
gap: 8,
|
|
41
|
+
flexDirection: 'row',
|
|
42
|
+
paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,
|
|
43
|
+
},
|
|
44
|
+
avatar: {
|
|
45
|
+
marginBottom: AVATAR_CONNECTOR_SPACING,
|
|
46
|
+
},
|
|
47
|
+
messageContent: {
|
|
48
|
+
flex: 1,
|
|
49
|
+
marginBottom: 16,
|
|
50
|
+
},
|
|
51
|
+
messageBubble: {
|
|
52
|
+
backgroundColor: colors.fillColorNeutral070,
|
|
53
|
+
borderRadius: 8,
|
|
54
|
+
maxWidth: tabletWidth ? 360 : '80%',
|
|
55
|
+
alignSelf: 'flex-start',
|
|
56
|
+
},
|
|
57
|
+
messageText: {
|
|
58
|
+
paddingVertical: 6,
|
|
59
|
+
paddingHorizontal: 8,
|
|
60
|
+
},
|
|
61
|
+
deletedText: {
|
|
62
|
+
color: colors.textColorDefaultSecondary,
|
|
63
|
+
fontStyle: 'italic',
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { ViewStyle } from 'react-native'
|
|
3
|
-
import type {
|
|
3
|
+
import type { ConversationAvatarData } from '../../types'
|
|
4
4
|
import AvatarPrimitive, { type AvatarRootProps } from '../primitive/avatar_primitive'
|
|
5
5
|
import { AvatarGroup } from './avatar_group'
|
|
6
6
|
import { EmojiAvatar } from './emoji_avatar'
|
|
7
7
|
import { type IconString } from './icon'
|
|
8
8
|
import { IconAvatar } from './icon_avatar'
|
|
9
9
|
|
|
10
|
-
type ConversationAvatarData = Pick<
|
|
11
|
-
ConversationResource,
|
|
12
|
-
| 'customAvatarType'
|
|
13
|
-
| 'customAvatarKey'
|
|
14
|
-
| 'customAvatarColor'
|
|
15
|
-
| 'customAvatarImageUrl'
|
|
16
|
-
| 'previewAvatarUrls'
|
|
17
|
-
>
|
|
18
|
-
|
|
19
10
|
type ResolvedAvatar =
|
|
20
11
|
| { kind: 'image'; url: string }
|
|
21
12
|
| { kind: 'icon'; iconKey: string; color: string | null }
|