@planningcenter/chat-react-native 4.7.0-rc.0 → 4.7.0-rc.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.
Files changed (61) hide show
  1. package/build/components/conversation/message_list.d.ts.map +1 -1
  2. package/build/components/conversation/message_list.js +7 -0
  3. package/build/components/conversation/message_list.js.map +1 -1
  4. package/build/components/conversation/unsupported_message.d.ts +15 -0
  5. package/build/components/conversation/unsupported_message.d.ts.map +1 -0
  6. package/build/components/conversation/unsupported_message.js +415 -0
  7. package/build/components/conversation/unsupported_message.js.map +1 -0
  8. package/build/contexts/api_provider.d.ts +1 -0
  9. package/build/contexts/api_provider.d.ts.map +1 -1
  10. package/build/contexts/api_provider.js +11 -5
  11. package/build/contexts/api_provider.js.map +1 -1
  12. package/build/hooks/index.d.ts +1 -0
  13. package/build/hooks/index.d.ts.map +1 -1
  14. package/build/hooks/index.js +1 -0
  15. package/build/hooks/index.js.map +1 -1
  16. package/build/hooks/use_system_message_people.d.ts +14 -0
  17. package/build/hooks/use_system_message_people.d.ts.map +1 -0
  18. package/build/hooks/use_system_message_people.js +101 -0
  19. package/build/hooks/use_system_message_people.js.map +1 -0
  20. package/build/screens/system_message_people_screen.d.ts.map +1 -1
  21. package/build/screens/system_message_people_screen.js +33 -96
  22. package/build/screens/system_message_people_screen.js.map +1 -1
  23. package/build/types/jolt_events/message_events.d.ts +3 -0
  24. package/build/types/jolt_events/message_events.d.ts.map +1 -1
  25. package/build/types/jolt_events/message_events.js.map +1 -1
  26. package/build/types/resources/fallback_content.d.ts +20 -0
  27. package/build/types/resources/fallback_content.d.ts.map +1 -0
  28. package/build/types/resources/fallback_content.js +2 -0
  29. package/build/types/resources/fallback_content.js.map +1 -0
  30. package/build/types/resources/message.d.ts +3 -0
  31. package/build/types/resources/message.d.ts.map +1 -1
  32. package/build/types/resources/message.js.map +1 -1
  33. package/build/utils/jolt/transform_message_event_data_to_message_resource.d.ts.map +1 -1
  34. package/build/utils/jolt/transform_message_event_data_to_message_resource.js +2 -0
  35. package/build/utils/jolt/transform_message_event_data_to_message_resource.js.map +1 -1
  36. package/build/utils/message_types.d.ts +5 -0
  37. package/build/utils/message_types.d.ts.map +1 -0
  38. package/build/utils/message_types.js +10 -0
  39. package/build/utils/message_types.js.map +1 -0
  40. package/build/utils/request/messages_data_options.d.ts.map +1 -1
  41. package/build/utils/request/messages_data_options.js +1 -1
  42. package/build/utils/request/messages_data_options.js.map +1 -1
  43. package/package.json +2 -2
  44. package/src/components/conversation/__tests__/message_list.test.tsx +1 -1
  45. package/src/components/conversation/__tests__/unsupported_message.test.tsx +109 -0
  46. package/src/components/conversation/message_list.tsx +6 -0
  47. package/src/components/conversation/unsupported_message.tsx +202 -0
  48. package/src/contexts/__tests__/configured_retry.test.ts +39 -0
  49. package/src/contexts/api_provider.tsx +12 -5
  50. package/src/hooks/__tests__/use_system_message_people.test.tsx +79 -0
  51. package/src/hooks/index.ts +1 -0
  52. package/src/hooks/use_system_message_people.ts +55 -0
  53. package/src/screens/system_message_people_screen.tsx +6 -20
  54. package/src/types/jolt_events/message_events.ts +3 -0
  55. package/src/types/resources/fallback_content.ts +20 -0
  56. package/src/types/resources/message.ts +5 -0
  57. package/src/utils/__tests__/message_types.test.ts +22 -0
  58. package/src/utils/jolt/__tests__/transform_message_event_data_to_message_resource.test.ts +10 -0
  59. package/src/utils/jolt/transform_message_event_data_to_message_resource.ts +2 -0
  60. package/src/utils/message_types.ts +22 -0
  61. package/src/utils/request/messages_data_options.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"transform_message_event_data_to_message_resource.js","names":["deepCamelCaseKeys","transformMessageEventDataToMessageResource","data","currentPersonId","type","id","sort_key","text","html","createdAt","created_at","deletedAt","deleted_at","textEditedAt","text_edited_at","mine","author_id","attachments","author","name","author_name","avatar","author_avatar","reactionCounts","replyCount","reply_count","replyRootId","reply_root_id","idempotentKey","idempotent_key","messageType","message_type","personIdsForSystemEvent","system_event_person_ids","systemTextParts","system_text_parts","names","overflowCount","overflow_count","action","systemTextFormat","system_text_format"],"sources":["../../../src/utils/jolt/transform_message_event_data_to_message_resource.ts"],"sourcesContent":["import { MessageResource } from '../../types'\nimport { MessageCreatedEvent } from '../../types/jolt_events/message_events'\nimport { DenormalizedAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport { deepCamelCaseKeys } from '../deepCamelCaseKeys'\n\nexport function transformMessageEventDataToMessageResource({\n data,\n currentPersonId,\n}: {\n data: MessageCreatedEvent['data']['data']\n currentPersonId: number\n}): MessageResource {\n return {\n type: 'Message',\n id: data.sort_key,\n text: data.text,\n html: data.html,\n createdAt: data.created_at,\n deletedAt: data.deleted_at,\n textEditedAt: data.text_edited_at,\n mine: data.author_id === currentPersonId,\n attachments: deepCamelCaseKeys<DenormalizedAttachmentResource[]>(data.attachments) || [],\n author: {\n type: 'Person',\n id: data.author_id,\n name: data.author_name,\n avatar: data.author_avatar,\n },\n reactionCounts: [],\n replyCount: data.reply_count || 0,\n replyRootId: data.reply_root_id || null,\n idempotentKey: data.idempotent_key ?? null,\n messageType: data.message_type,\n personIdsForSystemEvent: data.system_event_person_ids,\n systemTextParts: data.system_text_parts\n ? {\n names: data.system_text_parts.names,\n overflowCount: data.system_text_parts.overflow_count,\n action: data.system_text_parts.action,\n }\n : null,\n systemTextFormat: data.system_text_format,\n }\n}\n"],"mappings":"AAGA,SAASA,iBAAiB,QAAQ,sBAAsB;AAExD,OAAO,SAASC,0CAA0CA,CAAC;EACzDC,IAAI;EACJC;AAIF,CAAC,EAAmB;EAClB,OAAO;IACLC,IAAI,EAAE,SAAS;IACfC,EAAE,EAAEH,IAAI,CAACI,QAAQ;IACjBC,IAAI,EAAEL,IAAI,CAACK,IAAI;IACfC,IAAI,EAAEN,IAAI,CAACM,IAAI;IACfC,SAAS,EAAEP,IAAI,CAACQ,UAAU;IAC1BC,SAAS,EAAET,IAAI,CAACU,UAAU;IAC1BC,YAAY,EAAEX,IAAI,CAACY,cAAc;IACjCC,IAAI,EAAEb,IAAI,CAACc,SAAS,KAAKb,eAAe;IACxCc,WAAW,EAAEjB,iBAAiB,CAAmCE,IAAI,CAACe,WAAW,CAAC,IAAI,EAAE;IACxFC,MAAM,EAAE;MACNd,IAAI,EAAE,QAAQ;MACdC,EAAE,EAAEH,IAAI,CAACc,SAAS;MAClBG,IAAI,EAAEjB,IAAI,CAACkB,WAAW;MACtBC,MAAM,EAAEnB,IAAI,CAACoB;IACf,CAAC;IACDC,cAAc,EAAE,EAAE;IAClBC,UAAU,EAAEtB,IAAI,CAACuB,WAAW,IAAI,CAAC;IACjCC,WAAW,EAAExB,IAAI,CAACyB,aAAa,IAAI,IAAI;IACvCC,aAAa,EAAE1B,IAAI,CAAC2B,cAAc,IAAI,IAAI;IAC1CC,WAAW,EAAE5B,IAAI,CAAC6B,YAAY;IAC9BC,uBAAuB,EAAE9B,IAAI,CAAC+B,uBAAuB;IACrDC,eAAe,EAAEhC,IAAI,CAACiC,iBAAiB,GACnC;MACEC,KAAK,EAAElC,IAAI,CAACiC,iBAAiB,CAACC,KAAK;MACnCC,aAAa,EAAEnC,IAAI,CAACiC,iBAAiB,CAACG,cAAc;MACpDC,MAAM,EAAErC,IAAI,CAACiC,iBAAiB,CAACI;IACjC,CAAC,GACD,IAAI;IACRC,gBAAgB,EAAEtC,IAAI,CAACuC;EACzB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"transform_message_event_data_to_message_resource.js","names":["deepCamelCaseKeys","transformMessageEventDataToMessageResource","data","currentPersonId","type","id","sort_key","text","html","createdAt","created_at","deletedAt","deleted_at","textEditedAt","text_edited_at","mine","author_id","attachments","author","name","author_name","avatar","author_avatar","reactionCounts","replyCount","reply_count","replyRootId","reply_root_id","idempotentKey","idempotent_key","messageType","message_type","unsupportedMessageType","unsupported_message_type","fallbackContent","fallback_content","personIdsForSystemEvent","system_event_person_ids","systemTextParts","system_text_parts","names","overflowCount","overflow_count","action","systemTextFormat","system_text_format"],"sources":["../../../src/utils/jolt/transform_message_event_data_to_message_resource.ts"],"sourcesContent":["import { MessageResource } from '../../types'\nimport { MessageCreatedEvent } from '../../types/jolt_events/message_events'\nimport { DenormalizedAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport { deepCamelCaseKeys } from '../deepCamelCaseKeys'\n\nexport function transformMessageEventDataToMessageResource({\n data,\n currentPersonId,\n}: {\n data: MessageCreatedEvent['data']['data']\n currentPersonId: number\n}): MessageResource {\n return {\n type: 'Message',\n id: data.sort_key,\n text: data.text,\n html: data.html,\n createdAt: data.created_at,\n deletedAt: data.deleted_at,\n textEditedAt: data.text_edited_at,\n mine: data.author_id === currentPersonId,\n attachments: deepCamelCaseKeys<DenormalizedAttachmentResource[]>(data.attachments) || [],\n author: {\n type: 'Person',\n id: data.author_id,\n name: data.author_name,\n avatar: data.author_avatar,\n },\n reactionCounts: [],\n replyCount: data.reply_count || 0,\n replyRootId: data.reply_root_id || null,\n idempotentKey: data.idempotent_key ?? null,\n messageType: data.message_type,\n unsupportedMessageType: data.unsupported_message_type ?? null,\n fallbackContent: data.fallback_content ?? null,\n personIdsForSystemEvent: data.system_event_person_ids,\n systemTextParts: data.system_text_parts\n ? {\n names: data.system_text_parts.names,\n overflowCount: data.system_text_parts.overflow_count,\n action: data.system_text_parts.action,\n }\n : null,\n systemTextFormat: data.system_text_format,\n }\n}\n"],"mappings":"AAGA,SAASA,iBAAiB,QAAQ,sBAAsB;AAExD,OAAO,SAASC,0CAA0CA,CAAC;EACzDC,IAAI;EACJC;AAIF,CAAC,EAAmB;EAClB,OAAO;IACLC,IAAI,EAAE,SAAS;IACfC,EAAE,EAAEH,IAAI,CAACI,QAAQ;IACjBC,IAAI,EAAEL,IAAI,CAACK,IAAI;IACfC,IAAI,EAAEN,IAAI,CAACM,IAAI;IACfC,SAAS,EAAEP,IAAI,CAACQ,UAAU;IAC1BC,SAAS,EAAET,IAAI,CAACU,UAAU;IAC1BC,YAAY,EAAEX,IAAI,CAACY,cAAc;IACjCC,IAAI,EAAEb,IAAI,CAACc,SAAS,KAAKb,eAAe;IACxCc,WAAW,EAAEjB,iBAAiB,CAAmCE,IAAI,CAACe,WAAW,CAAC,IAAI,EAAE;IACxFC,MAAM,EAAE;MACNd,IAAI,EAAE,QAAQ;MACdC,EAAE,EAAEH,IAAI,CAACc,SAAS;MAClBG,IAAI,EAAEjB,IAAI,CAACkB,WAAW;MACtBC,MAAM,EAAEnB,IAAI,CAACoB;IACf,CAAC;IACDC,cAAc,EAAE,EAAE;IAClBC,UAAU,EAAEtB,IAAI,CAACuB,WAAW,IAAI,CAAC;IACjCC,WAAW,EAAExB,IAAI,CAACyB,aAAa,IAAI,IAAI;IACvCC,aAAa,EAAE1B,IAAI,CAAC2B,cAAc,IAAI,IAAI;IAC1CC,WAAW,EAAE5B,IAAI,CAAC6B,YAAY;IAC9BC,sBAAsB,EAAE9B,IAAI,CAAC+B,wBAAwB,IAAI,IAAI;IAC7DC,eAAe,EAAEhC,IAAI,CAACiC,gBAAgB,IAAI,IAAI;IAC9CC,uBAAuB,EAAElC,IAAI,CAACmC,uBAAuB;IACrDC,eAAe,EAAEpC,IAAI,CAACqC,iBAAiB,GACnC;MACEC,KAAK,EAAEtC,IAAI,CAACqC,iBAAiB,CAACC,KAAK;MACnCC,aAAa,EAAEvC,IAAI,CAACqC,iBAAiB,CAACG,cAAc;MACpDC,MAAM,EAAEzC,IAAI,CAACqC,iBAAiB,CAACI;IACjC,CAAC,GACD,IAAI;IACRC,gBAAgB,EAAE1C,IAAI,CAAC2C;EACzB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ import type { MessageResource } from '../types/resources/message';
2
+ export declare const UNSUPPORTED_MESSAGE_TYPE = "unsupported";
3
+ export declare const SUPPORTED_MESSAGE_TYPES: readonly ["user", "user_joined", "conversation_archived", "conversation_unarchived"];
4
+ export declare function isUnsupportedMessage(message: Pick<MessageResource, 'messageType'>): boolean;
5
+ //# sourceMappingURL=message_types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_types.d.ts","sourceRoot":"","sources":["../../src/utils/message_types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAKjE,eAAO,MAAM,wBAAwB,gBAAgB,CAAA;AAErD,eAAO,MAAM,uBAAuB,sFAK1B,CAAA;AAEV,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,GAAG,OAAO,CAO3F"}
@@ -0,0 +1,10 @@
1
+ // The server reports a type newer than this build's API version as 'unsupported'. Jolt payloads
2
+ // are not versioned, so a type this build has no code for can still arrive under its real name
3
+ // and gets the same treatment.
4
+ export const UNSUPPORTED_MESSAGE_TYPE = 'unsupported';
5
+ export const SUPPORTED_MESSAGE_TYPES = ['user', 'user_joined', 'conversation_archived', 'conversation_unarchived'];
6
+ export function isUnsupportedMessage(message) {
7
+ if (!message.messageType) return false;
8
+ return message.messageType === UNSUPPORTED_MESSAGE_TYPE || !SUPPORTED_MESSAGE_TYPES.includes(message.messageType);
9
+ }
10
+ //# sourceMappingURL=message_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_types.js","names":["UNSUPPORTED_MESSAGE_TYPE","SUPPORTED_MESSAGE_TYPES","isUnsupportedMessage","message","messageType","includes"],"sources":["../../src/utils/message_types.ts"],"sourcesContent":["import type { MessageResource } from '../types/resources/message'\n\n// The server reports a type newer than this build's API version as 'unsupported'. Jolt payloads\n// are not versioned, so a type this build has no code for can still arrive under its real name\n// and gets the same treatment.\nexport const UNSUPPORTED_MESSAGE_TYPE = 'unsupported'\n\nexport const SUPPORTED_MESSAGE_TYPES = [\n 'user',\n 'user_joined',\n 'conversation_archived',\n 'conversation_unarchived',\n] as const\n\nexport function isUnsupportedMessage(message: Pick<MessageResource, 'messageType'>): boolean {\n if (!message.messageType) return false\n\n return (\n message.messageType === UNSUPPORTED_MESSAGE_TYPE ||\n !(SUPPORTED_MESSAGE_TYPES as readonly string[]).includes(message.messageType)\n )\n}\n"],"mappings":"AAEA;AACA;AACA;AACA,OAAO,MAAMA,wBAAwB,GAAG,aAAa;AAErD,OAAO,MAAMC,uBAAuB,GAAG,CACrC,MAAM,EACN,aAAa,EACb,uBAAuB,EACvB,yBAAyB,CACjB;AAEV,OAAO,SAASC,oBAAoBA,CAACC,OAA6C,EAAW;EAC3F,IAAI,CAACA,OAAO,CAACC,WAAW,EAAE,OAAO,KAAK;EAEtC,OACED,OAAO,CAACC,WAAW,KAAKJ,wBAAwB,IAChD,CAAEC,uBAAuB,CAAuBI,QAAQ,CAACF,OAAO,CAACC,WAAW,CAAC;AAEjF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"messages_data_options.d.ts","sourceRoot":"","sources":["../../../src/utils/request/messages_data_options.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;CAoB5B,CAAA;AAED,eAAO,MAAM,kBAAkB,UAAmE,CAAA"}
1
+ {"version":3,"file":"messages_data_options.d.ts","sourceRoot":"","sources":["../../../src/utils/request/messages_data_options.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;CAqB5B,CAAA;AAED,eAAO,MAAM,kBAAkB,UAAmE,CAAA"}
@@ -1,5 +1,5 @@
1
1
  export const getMessageFields = {
2
- Message: ['text', 'text_edited_at', 'mine', 'attachments', 'created_at', 'deleted_at', 'author', 'reaction_counts', 'reply_count', 'reply_root', 'idempotent_key', 'message_type', 'person_ids_for_system_event', 'system_text_parts', 'system_text_format'],
2
+ Message: ['text', 'text_edited_at', 'mine', 'attachments', 'created_at', 'deleted_at', 'author', 'reaction_counts', 'reply_count', 'reply_root', 'idempotent_key', 'message_type', 'fallback_content', 'person_ids_for_system_event', 'system_text_parts', 'system_text_format'],
3
3
  Person: ['name', 'avatar'],
4
4
  ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids']
5
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"messages_data_options.js","names":["getMessageFields","Message","Person","ReactionCount","getMessagesInclude"],"sources":["../../../src/utils/request/messages_data_options.ts"],"sourcesContent":["export const getMessageFields = {\n Message: [\n 'text',\n 'text_edited_at',\n 'mine',\n 'attachments',\n 'created_at',\n 'deleted_at',\n 'author',\n 'reaction_counts',\n 'reply_count',\n 'reply_root',\n 'idempotent_key',\n 'message_type',\n 'person_ids_for_system_event',\n 'system_text_parts',\n 'system_text_format',\n ],\n Person: ['name', 'avatar'],\n ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],\n}\n\nexport const getMessagesInclude = ['author', 'reaction_counts', 'reply_root', 'reply_root.author']\n"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,GAAG;EAC9BC,OAAO,EAAE,CACP,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,6BAA6B,EAC7B,mBAAmB,EACnB,oBAAoB,CACrB;EACDC,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;EAC1BC,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY;AACtE,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,mBAAmB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"messages_data_options.js","names":["getMessageFields","Message","Person","ReactionCount","getMessagesInclude"],"sources":["../../../src/utils/request/messages_data_options.ts"],"sourcesContent":["export const getMessageFields = {\n Message: [\n 'text',\n 'text_edited_at',\n 'mine',\n 'attachments',\n 'created_at',\n 'deleted_at',\n 'author',\n 'reaction_counts',\n 'reply_count',\n 'reply_root',\n 'idempotent_key',\n 'message_type',\n 'fallback_content',\n 'person_ids_for_system_event',\n 'system_text_parts',\n 'system_text_format',\n ],\n Person: ['name', 'avatar'],\n ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],\n}\n\nexport const getMessagesInclude = ['author', 'reaction_counts', 'reply_root', 'reply_root.author']\n"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,GAAG;EAC9BC,OAAO,EAAE,CACP,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,6BAA6B,EAC7B,mBAAmB,EACnB,oBAAoB,CACrB;EACDC,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;EAC1BC,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY;AACtE,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,mBAAmB,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "4.7.0-rc.0",
3
+ "version": "4.7.0-rc.2",
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": "40ac6f8e91cb71968bce031af578353b233105ec"
87
+ "gitHead": "49bfefc0af6b4acae8c86e2838b57c4c8c5370ce"
88
88
  }
@@ -90,7 +90,7 @@ const buildMessage = (n: number, overrides: Partial<MessageResource> = {}): Mess
90
90
  reactionCounts: [],
91
91
  replyCount: 0,
92
92
  replyRootId: null,
93
- messageType: 'message',
93
+ messageType: 'user',
94
94
  ...overrides,
95
95
  }
96
96
  idByCreatedAt.set(message.createdAt, message.id)
@@ -0,0 +1,109 @@
1
+ import { render, screen } from '@testing-library/react-native'
2
+ import React from 'react'
3
+ import type { MessageResource } from '../../../types/resources/message'
4
+ import type { PersonResource } from '../../../types/resources/person'
5
+ import {
6
+ UNSUPPORTED_MESSAGE_FALLBACK,
7
+ UNSUPPORTED_MESSAGE_HINT,
8
+ UnsupportedMessage,
9
+ } from '../unsupported_message'
10
+
11
+ const author = { id: 1, type: 'Person', name: 'Wes', avatar: null } as unknown as PersonResource
12
+
13
+ const message = (overrides: Partial<MessageResource>): MessageResource => ({
14
+ type: 'Message',
15
+ id: '01',
16
+ text: null,
17
+ html: '',
18
+ createdAt: '2026-02-03T14:18:00',
19
+ deletedAt: null,
20
+ textEditedAt: null,
21
+ mine: false,
22
+ attachments: [],
23
+ author,
24
+ reactionCounts: [],
25
+ replyCount: 0,
26
+ replyRootId: null,
27
+ messageType: 'unsupported',
28
+ ...overrides,
29
+ })
30
+
31
+ describe('UnsupportedMessage', () => {
32
+ it("shows the server's fallback text and the update hint", () => {
33
+ render(
34
+ <UnsupportedMessage
35
+ message={message({ text: '📊 Poll: Lunch? — Update your app to vote' })}
36
+ />
37
+ )
38
+
39
+ expect(screen.getByText('📊 Poll: Lunch? — Update your app to vote')).toBeTruthy()
40
+ expect(screen.getByText(UNSUPPORTED_MESSAGE_HINT)).toBeTruthy()
41
+ })
42
+
43
+ it('falls back to a generic line when the server sent no text', () => {
44
+ render(<UnsupportedMessage message={message({ text: ' ' })} />)
45
+
46
+ expect(screen.getByText(UNSUPPORTED_MESSAGE_FALLBACK)).toBeTruthy()
47
+ })
48
+
49
+ it('names the author when grouping asks for it, so follow-ups stay attributed', () => {
50
+ render(<UnsupportedMessage message={message({ text: 'Poll', renderAuthor: true })} />)
51
+
52
+ expect(screen.getByText('Wes')).toBeTruthy()
53
+ })
54
+
55
+ it('omits the author inside a group and on my own messages', () => {
56
+ const { rerender } = render(
57
+ <UnsupportedMessage message={message({ text: 'Poll', renderAuthor: false })} />
58
+ )
59
+ expect(screen.queryByText('Wes')).toBeNull()
60
+
61
+ rerender(
62
+ <UnsupportedMessage message={message({ text: 'Poll', mine: true, renderAuthor: true })} />
63
+ )
64
+ expect(screen.queryByText('Wes')).toBeNull()
65
+ })
66
+
67
+ it('renders the fallback content read-only: title, items with totals, footer and hint', () => {
68
+ render(
69
+ <UnsupportedMessage
70
+ message={message({
71
+ text: '📊 Poll: Lunch? — Update your app to vote',
72
+ fallbackContent: {
73
+ kind: 'poll',
74
+ title: 'Lunch?',
75
+ subtitle: 'Select one · 3 votes',
76
+ items: [
77
+ { label: 'Tacos', detail: '2', fraction: 0.67, selected: true },
78
+ { label: 'Pizza', detail: '1', fraction: 0.33 },
79
+ ],
80
+ footer: 'Ends Friday',
81
+ hint: 'Update your app to vote',
82
+ },
83
+ })}
84
+ />
85
+ )
86
+
87
+ expect(screen.getByText('Lunch?')).toBeTruthy()
88
+ expect(screen.getByText('Select one · 3 votes')).toBeTruthy()
89
+ expect(screen.getByText('● Tacos')).toBeTruthy()
90
+ expect(screen.getByText('2')).toBeTruthy()
91
+ expect(screen.getByText('Pizza')).toBeTruthy()
92
+ expect(screen.getByText('Ends Friday')).toBeTruthy()
93
+ expect(screen.getByText('Update your app to vote')).toBeTruthy()
94
+ expect(screen.queryByText(/📊 Poll/)).toBeNull()
95
+ expect(screen.queryByRole('button')).toBeNull()
96
+ })
97
+
98
+ it('does not repeat the update hint when the server text already carries it', () => {
99
+ render(
100
+ <UnsupportedMessage
101
+ message={message({
102
+ text: "This message can't be shown here. Update your app to see it.",
103
+ })}
104
+ />
105
+ )
106
+
107
+ expect(screen.getAllByText(/Update your app/)).toHaveLength(1)
108
+ })
109
+ })
@@ -9,6 +9,7 @@ import { MessageResource } from '../../types/resources/message'
9
9
  import { getRelativeDateStatus } from '../../utils/date'
10
10
  import { groupMessages, type DateSeparator, type EnrichedMessage } from '../../utils/group_messages'
11
11
  import { isLiquidGlassEnabled } from '../../utils/liquid_glass'
12
+ import { isUnsupportedMessage } from '../../utils/message_types'
12
13
  import { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../../utils/styles'
13
14
  import { isSystemMessage } from '../../utils/system_messages'
14
15
  import { Text } from '../display'
@@ -17,6 +18,7 @@ import { Message } from './message'
17
18
  import { MissingMessage } from './missing_message'
18
19
  import { ReplyShadowMessage } from './reply_shadow_message'
19
20
  import { SystemMessage } from './system_message'
21
+ import { UnsupportedMessage } from './unsupported_message'
20
22
 
21
23
  // While behind, the bottom of the window isn't the live edge. Following there pulls
22
24
  // each newly paged-in page into view and chains the next fetch.
@@ -199,6 +201,10 @@ export function MessageList({
199
201
  )
200
202
  }
201
203
 
204
+ if (isUnsupportedMessage(item)) {
205
+ return <UnsupportedMessage message={item} />
206
+ }
207
+
202
208
  if (isSystemMessage(item)) {
203
209
  return (
204
210
  <SystemMessage
@@ -0,0 +1,202 @@
1
+ import React from 'react'
2
+ import { StyleSheet, View } from 'react-native'
3
+ import { useTheme } from '../../hooks'
4
+ import type { FallbackContent, FallbackContentItem } from '../../types/resources/fallback_content'
5
+ import type { MessageResource } from '../../types/resources/message'
6
+ import {
7
+ CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,
8
+ MESSAGE_AUTHOR_AVATAR_COLUMN_WIDTH,
9
+ platformFontWeightMedium,
10
+ } from '../../utils/styles'
11
+ import { Avatar, Text } from '../display'
12
+
13
+ export const UNSUPPORTED_MESSAGE_FALLBACK = "This message can't be shown here."
14
+ export const UNSUPPORTED_MESSAGE_HINT = 'Update your app to see it.'
15
+
16
+ interface UnsupportedMessageProps {
17
+ message: MessageResource
18
+ }
19
+
20
+ /** UnsupportedMessage
21
+ * Read-only bubble for a message type this build can't render. With `fallbackContent` it shows
22
+ * the type's title, subtitle, items (label, detail, share) and footer; without it, the server's
23
+ * fallback text or a generic line. Always ends with a hint to update. No actions, no reactions.
24
+ * It keeps the regular message's author column so grouping stays attributed around it.
25
+ */
26
+ export function UnsupportedMessage({ message }: UnsupportedMessageProps) {
27
+ const styles = useStyles(message.mine)
28
+ const content = message.fallbackContent ?? null
29
+ const text = message.text?.trim() || UNSUPPORTED_MESSAGE_FALLBACK
30
+ const hint =
31
+ content?.hint || (text.includes(UNSUPPORTED_MESSAGE_HINT) ? null : UNSUPPORTED_MESSAGE_HINT)
32
+ const renderAuthor = !message.mine && !!message.renderAuthor
33
+ const summary = content ? contentSummary(content) : text
34
+
35
+ return (
36
+ <View
37
+ style={styles.container}
38
+ accessibilityRole="text"
39
+ accessibilityLabel={`${message.author?.name || ''} ${summary} ${hint ?? ''}`}
40
+ testID={`unsupported-message-${message.id}`}
41
+ >
42
+ {!message.mine &&
43
+ (renderAuthor ? (
44
+ <Avatar
45
+ size="md"
46
+ sourceUri={message.author?.avatar}
47
+ maxFontSizeMultiplier={1}
48
+ minFontSizeMultiplier={1}
49
+ />
50
+ ) : (
51
+ <View style={styles.avatarPlaceholder} />
52
+ ))}
53
+ <View style={styles.content}>
54
+ {renderAuthor && (
55
+ <Text variant="footnote" style={styles.authorName}>
56
+ {message.author?.name}
57
+ </Text>
58
+ )}
59
+ <View style={styles.bubble}>
60
+ {content ? (
61
+ <FallbackContentBody content={content} styles={styles} />
62
+ ) : (
63
+ <Text style={styles.text}>{text}</Text>
64
+ )}
65
+ {!!hint && (
66
+ <Text variant="tertiary" style={styles.hint}>
67
+ {hint}
68
+ </Text>
69
+ )}
70
+ </View>
71
+ </View>
72
+ </View>
73
+ )
74
+ }
75
+
76
+ function FallbackContentBody({
77
+ content,
78
+ styles,
79
+ }: {
80
+ content: FallbackContent
81
+ styles: ReturnType<typeof useStyles>
82
+ }) {
83
+ return (
84
+ <>
85
+ <Text style={styles.title}>{content.title}</Text>
86
+ {!!content.subtitle && <Text variant="tertiary">{content.subtitle}</Text>}
87
+ {(content.items ?? []).map((item, index) => (
88
+ <FallbackItem key={`${index}-${item.label}`} item={item} styles={styles} />
89
+ ))}
90
+ {!!content.footer && (
91
+ <Text variant="tertiary" style={styles.footer}>
92
+ {content.footer}
93
+ </Text>
94
+ )}
95
+ </>
96
+ )
97
+ }
98
+
99
+ function FallbackItem({
100
+ item,
101
+ styles,
102
+ }: {
103
+ item: FallbackContentItem
104
+ styles: ReturnType<typeof useStyles>
105
+ }) {
106
+ const fraction =
107
+ typeof item.fraction === 'number' ? Math.min(Math.max(item.fraction, 0), 1) : null
108
+
109
+ return (
110
+ <View style={styles.item}>
111
+ <View style={styles.itemRow}>
112
+ <Text style={[styles.itemLabel, item.selected ? styles.itemSelected : null]}>
113
+ {(item.selected ? '● ' : '') + item.label}
114
+ </Text>
115
+ {!!item.detail && <Text variant="tertiary">{item.detail}</Text>}
116
+ </View>
117
+ {fraction !== null && (
118
+ <View style={styles.track}>
119
+ <View style={[styles.fill, { width: `${Math.round(fraction * 100)}%` }]} />
120
+ </View>
121
+ )}
122
+ </View>
123
+ )
124
+ }
125
+
126
+ function contentSummary(content: FallbackContent): string {
127
+ const items = (content.items ?? [])
128
+ .map(item => (item.detail ? `${item.label} ${item.detail}` : item.label))
129
+ .join(', ')
130
+ return [content.title, content.subtitle, items, content.footer].filter(Boolean).join('. ')
131
+ }
132
+
133
+ const useStyles = (mine: boolean) => {
134
+ const { colors } = useTheme()
135
+ return StyleSheet.create({
136
+ container: {
137
+ gap: 8,
138
+ flexDirection: mine ? 'row-reverse' : 'row',
139
+ paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,
140
+ paddingVertical: 4,
141
+ },
142
+ avatarPlaceholder: {
143
+ width: MESSAGE_AUTHOR_AVATAR_COLUMN_WIDTH,
144
+ },
145
+ content: {
146
+ flex: 1,
147
+ gap: 4,
148
+ },
149
+ authorName: {
150
+ fontWeight: platformFontWeightMedium,
151
+ },
152
+ bubble: {
153
+ maxWidth: '80%',
154
+ minWidth: '60%',
155
+ alignSelf: mine ? 'flex-end' : 'flex-start',
156
+ borderRadius: 8,
157
+ paddingVertical: 6,
158
+ paddingHorizontal: 8,
159
+ gap: 4,
160
+ borderWidth: StyleSheet.hairlineWidth,
161
+ borderColor: colors.textColorDefaultSecondary,
162
+ },
163
+ text: {
164
+ color: colors.textColorDefaultSecondary,
165
+ },
166
+ title: {
167
+ fontWeight: platformFontWeightMedium,
168
+ },
169
+ item: {
170
+ gap: 2,
171
+ marginTop: 2,
172
+ },
173
+ itemRow: {
174
+ flexDirection: 'row',
175
+ justifyContent: 'space-between',
176
+ alignItems: 'center',
177
+ gap: 8,
178
+ },
179
+ itemLabel: {
180
+ flexShrink: 1,
181
+ },
182
+ itemSelected: {
183
+ fontWeight: platformFontWeightMedium,
184
+ },
185
+ track: {
186
+ height: 4,
187
+ borderRadius: 2,
188
+ backgroundColor: colors.fillColorNeutral070,
189
+ overflow: 'hidden',
190
+ },
191
+ fill: {
192
+ height: 4,
193
+ backgroundColor: colors.textColorDefaultSecondary,
194
+ },
195
+ footer: {
196
+ marginTop: 2,
197
+ },
198
+ hint: {
199
+ marginTop: 2,
200
+ },
201
+ })
202
+ }
@@ -0,0 +1,39 @@
1
+ import { ResponseError } from '../../utils/response_error'
2
+ import { configuredRetry } from '../api_provider'
3
+
4
+ jest.mock('../../hooks/use_api_client')
5
+
6
+ const responseWithStatus = (status: number) =>
7
+ ({
8
+ status,
9
+ statusText: 'Error',
10
+ ok: false,
11
+ url: 'https://api.pco.test/chat/v2/me',
12
+ headers: {},
13
+ clone: () => ({}),
14
+ json: () => Promise.resolve({}),
15
+ text: () => Promise.resolve(''),
16
+ arrayBuffer: () => Promise.resolve(new ArrayBuffer(0)),
17
+ errors: [],
18
+ }) as unknown as Response
19
+
20
+ describe('configuredRetry', () => {
21
+ it('does not retry client errors', () => {
22
+ ;[400, 404, 414, 422, 429].forEach(status => {
23
+ expect(configuredRetry(0, new ResponseError(responseWithStatus(status) as any))).toBe(false)
24
+ expect(configuredRetry(0, responseWithStatus(status))).toBe(false)
25
+ })
26
+ })
27
+
28
+ it('retries server errors up to three times', () => {
29
+ const error = new ResponseError(responseWithStatus(503) as any)
30
+
31
+ expect(configuredRetry(0, error)).toBe(true)
32
+ expect(configuredRetry(2, error)).toBe(true)
33
+ expect(configuredRetry(3, error)).toBe(false)
34
+ })
35
+
36
+ it('retries network failures', () => {
37
+ expect(configuredRetry(0, new TypeError('Network request failed'))).toBe(true)
38
+ })
39
+ })
@@ -14,7 +14,7 @@ import { featuresQueryOptions } from '../hooks/use_features'
14
14
  import { useJoltForegroundPing } from '../hooks/use_jolt'
15
15
  import { RequestQueryKey } from '../hooks/use_suspense_api'
16
16
  import { emitAuthRefresh } from '../utils/auth_events'
17
- import { ResponseError } from '../utils/response_error'
17
+ import { isResponseLike, ResponseError } from '../utils/response_error'
18
18
  import { ChatContext, ChatContextValue } from './chat_context'
19
19
 
20
20
  let apiClient: ApiClient | undefined
@@ -29,14 +29,21 @@ const defaultQueryFn = ({ queryKey }: { queryKey: QueryKey }) => {
29
29
  return apiClient[app].get({ url, data, headers })
30
30
  }
31
31
 
32
- const configuredRetry = (failureCount: number, error: any) => {
33
- if (is429Error(error)) return false
32
+ export const configuredRetry = (failureCount: number, error: unknown) => {
33
+ if (isClientError(error)) return false
34
34
 
35
35
  return failureCount < 3
36
36
  }
37
37
 
38
- const is429Error = (error: any): boolean => {
39
- return error instanceof ResponseError && error.status === 429
38
+ const isClientError = (error: unknown): boolean => {
39
+ const status = errorStatus(error)
40
+ return status !== undefined && status >= 400 && status < 500
41
+ }
42
+
43
+ const errorStatus = (error: unknown): number | undefined => {
44
+ if (error instanceof ResponseError) return error.status
45
+ if (isResponseLike(error)) return error.status
46
+ return undefined
40
47
  }
41
48
 
42
49
  export const chatQueryClient = new QueryClient({
@@ -0,0 +1,79 @@
1
+ import { notifyManager, QueryClient, QueryClientProvider } from '@tanstack/react-query'
2
+ import { act, renderHook, waitFor } from '@testing-library/react-native'
3
+ import React, { Suspense } from 'react'
4
+ import { MEMBERS_PER_REQUEST, useSystemMessagePeople } from '../use_system_message_people'
5
+
6
+ const mockGet = jest.fn()
7
+ jest.mock('../use_api_client', () => ({
8
+ useApiClient: () => ({ chat: { get: mockGet } }),
9
+ }))
10
+
11
+ notifyManager.setNotifyFunction(fn => act(fn))
12
+
13
+ const conversationId = 7
14
+
15
+ const member = (id: number) => ({ type: 'Member', id, name: `Person ${id}`, avatar: '' })
16
+
17
+ const membersPage = (ids: number[]) => ({
18
+ data: ids.map(member),
19
+ links: {},
20
+ meta: { count: ids.length, totalCount: ids.length },
21
+ })
22
+
23
+ const requestedIds = () => mockGet.mock.calls.map(([request]) => request.data.where.id as number[])
24
+
25
+ const render = (personIds: number[]) => {
26
+ const queryClient = new QueryClient({
27
+ defaultOptions: { queries: { retry: false, gcTime: 0 } },
28
+ })
29
+ const wrapper = ({ children }: { children: React.ReactNode }) => (
30
+ <QueryClientProvider client={queryClient}>
31
+ <Suspense fallback={null}>{children}</Suspense>
32
+ </QueryClientProvider>
33
+ )
34
+
35
+ return renderHook(() => useSystemMessagePeople({ conversationId, personIds }), { wrapper })
36
+ }
37
+
38
+ beforeEach(() => {
39
+ mockGet.mockReset()
40
+ mockGet.mockImplementation(({ data }) =>
41
+ Promise.resolve(membersPage([...(data.where.id as number[])].reverse()))
42
+ )
43
+ })
44
+
45
+ describe('useSystemMessagePeople', () => {
46
+ it('requests members in batches no larger than a page', async () => {
47
+ const personIds = Array.from({ length: 250 }, (_, i) => i + 1)
48
+
49
+ render(personIds)
50
+
51
+ await waitFor(() => expect(mockGet).toHaveBeenCalledTimes(3))
52
+
53
+ expect(requestedIds().map(ids => ids.length)).toEqual([100, 100, 50])
54
+ expect(requestedIds().flat()).toEqual(personIds)
55
+ mockGet.mock.calls.forEach(([request]) => {
56
+ expect(request.url).toEqual(`/me/conversations/${conversationId}/members`)
57
+ expect(request.data.perPage).toEqual(MEMBERS_PER_REQUEST)
58
+ })
59
+ })
60
+
61
+ it('returns everyone in the order of the system message', async () => {
62
+ const personIds = Array.from({ length: 150 }, (_, i) => 1000 - i)
63
+
64
+ const { result } = render(personIds)
65
+
66
+ await waitFor(() => expect(result.current?.data).toHaveLength(150))
67
+
68
+ expect(result.current.data.map(({ id }) => id)).toEqual(personIds)
69
+ })
70
+
71
+ it('makes a single request for a small list', async () => {
72
+ const { result } = render([3, 1, 2])
73
+
74
+ await waitFor(() => expect(result.current?.data).toHaveLength(3))
75
+
76
+ expect(mockGet).toHaveBeenCalledTimes(1)
77
+ expect(result.current.data.map(({ id }) => id)).toEqual([3, 1, 2])
78
+ })
79
+ })
@@ -29,4 +29,5 @@ export * from './use_reduce_motion'
29
29
  export * from './use_scalable_number_of_lines'
30
30
  export * from './use_submit_age_check'
31
31
  export * from './use_suspense_api'
32
+ export * from './use_system_message_people'
32
33
  export * from './use_theme'
@@ -0,0 +1,55 @@
1
+ import { useSuspenseQueries } from '@tanstack/react-query'
2
+ import { chunk, sortBy } from 'lodash'
3
+ import { ApiCollection, MemberResource } from '../types'
4
+ import { GetRequest } from '../utils/client'
5
+ import { throwResponseError } from '../utils/response_error'
6
+ import { useApiClient } from './use_api_client'
7
+ import { getRequestQueryKey } from './use_suspense_api'
8
+
9
+ export const MEMBERS_PER_REQUEST = 100
10
+
11
+ type SystemMessagePeopleArgs = {
12
+ conversationId: number
13
+ personIds: number[]
14
+ }
15
+
16
+ export type SystemMessagePerson = Pick<MemberResource, 'type' | 'id' | 'name' | 'avatar'>
17
+
18
+ export const systemMessagePeopleRequest = (
19
+ conversationId: number,
20
+ personIds: number[]
21
+ ): GetRequest => ({
22
+ url: `/me/conversations/${conversationId}/members`,
23
+ data: {
24
+ fields: {
25
+ Member: ['id', 'name', 'avatar'],
26
+ },
27
+ where: {
28
+ id: personIds,
29
+ },
30
+ perPage: MEMBERS_PER_REQUEST,
31
+ },
32
+ })
33
+
34
+ export const useSystemMessagePeople = ({ conversationId, personIds }: SystemMessagePeopleArgs) => {
35
+ const apiClient = useApiClient()
36
+ const requests = chunk(personIds, MEMBERS_PER_REQUEST).map(ids =>
37
+ systemMessagePeopleRequest(conversationId, ids)
38
+ )
39
+
40
+ const queries = useSuspenseQueries({
41
+ queries: requests.map(request => ({
42
+ queryKey: getRequestQueryKey(request),
43
+ queryFn: (): Promise<ApiCollection<SystemMessagePerson>> =>
44
+ apiClient.chat.get<ApiCollection<SystemMessagePerson>>(request).catch(throwResponseError),
45
+ })),
46
+ })
47
+
48
+ const orderById = Object.fromEntries(personIds.map((id, index) => [id, index]))
49
+ const people = sortBy(
50
+ queries.flatMap(query => query.data.data),
51
+ person => orderById[person.id] ?? personIds.length
52
+ )
53
+
54
+ return { data: people }
55
+ }