@planningcenter/chat-react-native 4.6.4-qa-staging.4 → 4.6.4-rc.0
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_list.d.ts.map +1 -1
- package/build/components/conversation/message_list.js +0 -7
- package/build/components/conversation/message_list.js.map +1 -1
- package/build/contexts/api_provider.d.ts +0 -1
- package/build/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +38 -50
- package/build/contexts/api_provider.js.map +1 -1
- package/build/contexts/chat_context.d.ts +0 -1
- package/build/contexts/chat_context.d.ts.map +1 -1
- package/build/contexts/chat_context.js +25 -28
- package/build/contexts/chat_context.js.map +1 -1
- package/build/contexts/session_context.d.ts +1 -2
- package/build/contexts/session_context.d.ts.map +1 -1
- package/build/contexts/session_context.js +6 -10
- package/build/contexts/session_context.js.map +1 -1
- package/build/hooks/index.d.ts +0 -1
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/index.js.map +1 -1
- package/build/screens/system_message_people_screen.d.ts.map +1 -1
- package/build/screens/system_message_people_screen.js +96 -33
- package/build/screens/system_message_people_screen.js.map +1 -1
- package/build/types/jolt_events/message_events.d.ts +0 -3
- package/build/types/jolt_events/message_events.d.ts.map +1 -1
- package/build/types/jolt_events/message_events.js.map +1 -1
- package/build/types/resources/message.d.ts +0 -3
- package/build/types/resources/message.d.ts.map +1 -1
- package/build/types/resources/message.js.map +1 -1
- package/build/utils/jolt/transform_message_event_data_to_message_resource.d.ts.map +1 -1
- package/build/utils/jolt/transform_message_event_data_to_message_resource.js +0 -2
- package/build/utils/jolt/transform_message_event_data_to_message_resource.js.map +1 -1
- package/build/utils/request/messages_data_options.d.ts.map +1 -1
- package/build/utils/request/messages_data_options.js +1 -1
- package/build/utils/request/messages_data_options.js.map +1 -1
- package/build/utils/session.d.ts +1 -3
- package/build/utils/session.d.ts.map +1 -1
- package/build/utils/session.js +0 -3
- package/build/utils/session.js.map +1 -1
- package/build/utils/session_manager.d.ts +1 -1
- package/build/utils/session_manager.d.ts.map +1 -1
- package/build/utils/session_manager.js +1 -2
- package/build/utils/session_manager.js.map +1 -1
- package/build/utils/upload_uri.d.ts.map +1 -1
- package/build/utils/upload_uri.js +0 -3
- package/build/utils/upload_uri.js.map +1 -1
- package/build/utils/uri.d.ts.map +1 -1
- package/build/utils/uri.js +0 -4
- package/build/utils/uri.js.map +1 -1
- package/package.json +3 -3
- package/src/components/conversation/__tests__/message_list.test.tsx +1 -1
- package/src/components/conversation/message_list.tsx +0 -6
- package/src/contexts/__tests__/api_provider.test.tsx +4 -17
- package/src/contexts/api_provider.tsx +11 -25
- package/src/contexts/chat_context.tsx +2 -4
- package/src/contexts/session_context.tsx +10 -18
- package/src/hooks/index.ts +0 -1
- package/src/screens/system_message_people_screen.tsx +20 -6
- package/src/types/jolt_events/message_events.ts +0 -3
- package/src/types/resources/message.ts +0 -5
- package/src/utils/__tests__/session_manager.test.ts +0 -12
- package/src/utils/jolt/__tests__/transform_message_event_data_to_message_resource.test.ts +0 -10
- package/src/utils/jolt/transform_message_event_data_to_message_resource.ts +0 -2
- package/src/utils/request/messages_data_options.ts +0 -1
- package/src/utils/session.ts +3 -11
- package/src/utils/session_manager.ts +1 -2
- package/src/utils/upload_uri.ts +0 -4
- package/src/utils/uri.ts +0 -5
- package/build/components/conversation/unsupported_message.d.ts +0 -15
- package/build/components/conversation/unsupported_message.d.ts.map +0 -1
- package/build/components/conversation/unsupported_message.js +0 -415
- package/build/components/conversation/unsupported_message.js.map +0 -1
- package/build/hooks/use_system_message_people.d.ts +0 -14
- package/build/hooks/use_system_message_people.d.ts.map +0 -1
- package/build/hooks/use_system_message_people.js +0 -101
- package/build/hooks/use_system_message_people.js.map +0 -1
- package/build/types/resources/fallback_content.d.ts +0 -20
- package/build/types/resources/fallback_content.d.ts.map +0 -1
- package/build/types/resources/fallback_content.js +0 -2
- package/build/types/resources/fallback_content.js.map +0 -1
- package/build/utils/message_types.d.ts +0 -5
- package/build/utils/message_types.d.ts.map +0 -1
- package/build/utils/message_types.js +0 -10
- package/build/utils/message_types.js.map +0 -1
- package/src/components/conversation/__tests__/unsupported_message.test.tsx +0 -109
- package/src/components/conversation/unsupported_message.tsx +0 -202
- package/src/contexts/__tests__/configured_retry.test.ts +0 -39
- package/src/hooks/__tests__/use_system_message_people.test.tsx +0 -79
- package/src/hooks/use_system_message_people.ts +0 -55
- package/src/types/resources/fallback_content.ts +0 -20
- package/src/utils/__tests__/message_types.test.ts +0 -22
- package/src/utils/__tests__/uri.test.ts +0 -26
- package/src/utils/message_types.ts +0 -22
package/build/utils/session.js
CHANGED
|
@@ -7,13 +7,11 @@ export class Session {
|
|
|
7
7
|
constructor(props) {
|
|
8
8
|
const {
|
|
9
9
|
env = 'production',
|
|
10
|
-
prototypeName,
|
|
11
10
|
token,
|
|
12
11
|
type,
|
|
13
12
|
meta
|
|
14
13
|
} = props || {};
|
|
15
14
|
this.env = env;
|
|
16
|
-
this.prototypeName = env === 'prototype' ? prototypeName : undefined;
|
|
17
15
|
this.token = token;
|
|
18
16
|
this.type = type || 'OAuth';
|
|
19
17
|
this.meta = meta || {};
|
|
@@ -34,7 +32,6 @@ export class Session {
|
|
|
34
32
|
toString() {
|
|
35
33
|
return JSON.stringify({
|
|
36
34
|
env: this.env,
|
|
37
|
-
prototypeName: this.prototypeName,
|
|
38
35
|
token: this.token,
|
|
39
36
|
meta: this.meta
|
|
40
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","names":["UNAUTHENTICATED_SESSION_ID","Session","constructor","props","env","
|
|
1
|
+
{"version":3,"file":"session.js","names":["UNAUTHENTICATED_SESSION_ID","Session","constructor","props","env","token","type","meta","isAuthenticated","Boolean","access_token","isChurchCenterToken","id","tokenStr","slice","toString","JSON","stringify","setPerson","person","setOrganization","organization","hydrate","sessionString","parse","_error"],"sources":["../../src/utils/session.ts"],"sourcesContent":["import { OAuthToken, OrganizationResource, PersonResource } from '../types'\n\nexport type ENV = 'production' | 'staging' | 'development'\nexport type OauthType = 'OAuth' | 'ChurchCenterOauth'\nexport type PartialToken = Pick<OAuthToken, 'access_token'> & Partial<OAuthToken>\nexport type SessionMeta = {\n [key: string]: {\n person: PersonResource\n organization: OrganizationResource\n }\n}\nexport type SessionProps<T extends PartialToken> = {\n env?: ENV\n token?: T\n type?: OauthType\n meta?: SessionMeta\n}\n\nexport const UNAUTHENTICATED_SESSION_ID = 'unauthenticated' as const\ntype SessionId = string | typeof UNAUTHENTICATED_SESSION_ID\n\n/**\n * Session class to track the environment and token\n * Not intended to make network requests or handle authentication\n */\nexport class Session<T extends PartialToken = PartialToken> {\n env: ENV\n token: T | undefined\n type: OauthType\n meta: Record<string, any>\n\n constructor(props?: SessionProps<T>) {\n const { env = 'production', token, type, meta } = props || {}\n this.env = env\n this.token = token\n this.type = type || 'OAuth'\n this.meta = meta || {}\n }\n\n get isAuthenticated() {\n return Boolean(this.token?.access_token)\n }\n\n get isChurchCenterToken() {\n return this.type === 'ChurchCenterOauth'\n }\n\n get id(): SessionId {\n if (!this.isAuthenticated || !this.token?.access_token) {\n return UNAUTHENTICATED_SESSION_ID\n }\n const tokenStr = this.token.access_token\n return tokenStr.slice(-8)\n }\n\n toString() {\n return JSON.stringify({ env: this.env, token: this.token, meta: this.meta })\n }\n\n // Convenience methods to set the person and organization\n setPerson(person: PersonResource) {\n this.meta.person = person\n }\n\n setOrganization(organization: OrganizationResource) {\n this.meta.organization = organization\n }\n\n static hydrate<T extends PartialToken>(sessionString: string) {\n try {\n const props = JSON.parse(sessionString)\n return new Session<T>(props)\n } catch (_error) {\n return new Session<T>()\n }\n }\n}\n"],"mappings":"AAkBA,OAAO,MAAMA,0BAA0B,GAAG,iBAA0B;AAGpE;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,CAAwC;EAM1DC,WAAWA,CAACC,KAAuB,EAAE;IACnC,MAAM;MAAEC,GAAG,GAAG,YAAY;MA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ItB,OAAO,CAAIE,KAAK,CAAC;IAC9B,CAAC,CAAC,OAAOsB,MAAM,EAAE;MACf,OAAO,IAAIxB,OAAO,CAAI,CAAC;IACzB;EACF;AACF","ignoreList":[]}
|
|
@@ -10,7 +10,7 @@ export declare class SessionManager {
|
|
|
10
10
|
constructor(props?: SessionManagerProps);
|
|
11
11
|
static hydrate(sessionManagerString: string): SessionManager;
|
|
12
12
|
get currentSession(): Session<OAuthToken>;
|
|
13
|
-
setEnv(env: ENV
|
|
13
|
+
setEnv(env: ENV): void;
|
|
14
14
|
toString(): string;
|
|
15
15
|
removeSession(sessionId: string): void;
|
|
16
16
|
switchSession(sessionId: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session_manager.d.ts","sourceRoot":"","sources":["../../src/utils/session_manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,OAAO,EAA8B,MAAM,WAAW,CAAA;AAEpE,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,qBAAa,cAAc;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,gBAAgB,EAAE,MAAM,CAAA;gBAEZ,KAAK,CAAC,EAAE,mBAAmB;IAMvC,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM;IAS3C,IAAI,cAAc,wBAIjB;IAED,MAAM,CAAC,GAAG,EAAE,GAAG
|
|
1
|
+
{"version":3,"file":"session_manager.d.ts","sourceRoot":"","sources":["../../src/utils/session_manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,OAAO,EAA8B,MAAM,WAAW,CAAA;AAEpE,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,qBAAa,cAAc;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,gBAAgB,EAAE,MAAM,CAAA;gBAEZ,KAAK,CAAC,EAAE,mBAAmB;IAMvC,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM;IAS3C,IAAI,cAAc,wBAIjB;IAED,MAAM,CAAC,GAAG,EAAE,GAAG;IAQf,QAAQ;IAIR,aAAa,CAAC,SAAS,EAAE,MAAM;IAQ/B,aAAa,CAAC,SAAS,EAAE,MAAM;IAQ/B,aAAa,CAAC,OAAO,EAAE,OAAO;IAK9B,kBAAkB,CAAC,KAAK,EAAE,UAAU;CAMrC"}
|
|
@@ -20,11 +20,10 @@ export class SessionManager {
|
|
|
20
20
|
get currentSession() {
|
|
21
21
|
return Session.hydrate(this.sessions[this.currentSessionId] || new Session({}).toString());
|
|
22
22
|
}
|
|
23
|
-
setEnv(env
|
|
23
|
+
setEnv(env) {
|
|
24
24
|
// Get the current session (handles case where it doesn't exist)
|
|
25
25
|
const session = this.currentSession;
|
|
26
26
|
session.env = env;
|
|
27
|
-
session.prototypeName = prototypeName;
|
|
28
27
|
// Store the session with its ID
|
|
29
28
|
this.upsertSession(session);
|
|
30
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session_manager.js","names":["omit","Session","UNAUTHENTICATED_SESSION_ID","SessionManager","constructor","props","sessions","currentSessionId","hydrate","sessionManagerString","JSON","parse","_error","currentSession","toString","setEnv","env","
|
|
1
|
+
{"version":3,"file":"session_manager.js","names":["omit","Session","UNAUTHENTICATED_SESSION_ID","SessionManager","constructor","props","sessions","currentSessionId","hydrate","sessionManagerString","JSON","parse","_error","currentSession","toString","setEnv","env","session","upsertSession","stringify","removeSession","sessionId","switchSession","sessionPresent","Error","id","updateCurrentToken","token"],"sources":["../../src/utils/session_manager.ts"],"sourcesContent":["import { omit } from 'lodash'\nimport { OAuthToken } from '../types'\nimport { ENV, Session, UNAUTHENTICATED_SESSION_ID } from './session'\n\ntype SessionManagerProps = {\n sessions?: Record<string, string>\n currentSessionId?: string\n}\n\nexport class SessionManager {\n sessions: Record<string, string>\n currentSessionId: string\n\n constructor(props?: SessionManagerProps) {\n const { sessions, currentSessionId } = props || {}\n this.sessions = sessions || {}\n this.currentSessionId = currentSessionId || UNAUTHENTICATED_SESSION_ID\n }\n\n static hydrate(sessionManagerString: string) {\n try {\n const props = JSON.parse(sessionManagerString)\n return new SessionManager(props)\n } catch (_error) {\n return new SessionManager()\n }\n }\n\n get currentSession() {\n return Session.hydrate<OAuthToken>(\n this.sessions[this.currentSessionId] || new Session<OAuthToken>({}).toString()\n )\n }\n\n setEnv(env: ENV) {\n // Get the current session (handles case where it doesn't exist)\n const session = this.currentSession\n session.env = env\n // Store the session with its ID\n this.upsertSession(session)\n }\n\n toString() {\n return JSON.stringify({ sessions: this.sessions, currentSessionId: this.currentSessionId })\n }\n\n removeSession(sessionId: string) {\n // if unauthenticated, this is a no-op\n this.sessions = omit(this.sessions, sessionId)\n if (this.currentSessionId === sessionId) {\n this.currentSessionId = UNAUTHENTICATED_SESSION_ID\n }\n }\n\n switchSession(sessionId: string) {\n const sessionPresent = this.sessions[sessionId]\n if (!sessionPresent) {\n throw new Error(`Session ${sessionId} not found`)\n }\n this.currentSessionId = sessionId\n }\n\n upsertSession(session: Session) {\n this.sessions[session.id] = session.toString()\n this.currentSessionId = session.id\n }\n\n updateCurrentToken(token: OAuthToken) {\n const session = this.currentSession\n this.removeSession(session.id)\n session.token = token\n this.upsertSession(session)\n }\n}\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,QAAQ;AAE7B,SAAcC,OAAO,EAAEC,0BAA0B,QAAQ,WAAW;AAOpE,OAAO,MA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AACd,gBAAgB,GAAGL,0BAA0B;IACpD;EACF;EAEAoB,aAAaA,CAACD,SAAiB,EAAE;IAC/B,MAAME,cAAc,GAAG,IAAI,CAACjB,QAAQ,CAACe,SAAS,CAAC;IAC/C,IAAI,CAACE,cAAc,EAAE;MACnB,MAAM,IAAIC,KAAK,CAAC,WAAWH,SAAS,YAAY,CAAC;IACnD;IACA,IAAI,CAACd,gBAAgB,GAAGc,SAAS;EACnC;EAEAH,aAAaA,CAACD,OAAgB,EAAE;IAC9B,IAAI,CAACX,QAAQ,CAACW,OAAO,CAACQ,EAAE,CAAC,GAAGR,OAAO,CAACH,QAAQ,CAAC,CAAC;IAC9C,IAAI,CAACP,gBAAgB,GAAGU,OAAO,CAACQ,EAAE;EACpC;EAEAC,kBAAkBA,CAACC,KAAiB,EAAE;IACpC,MAAMV,OAAO,GAAG,IAAI,CAACJ,cAAc;IACnC,IAAI,CAACO,aAAa,CAACH,OAAO,CAACQ,EAAE,CAAC;IAC9BR,OAAO,CAACU,KAAK,GAAGA,KAAK;IACrB,IAAI,CAACT,aAAa,CAACD,OAAO,CAAC;EAC7B;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload_uri.d.ts","sourceRoot":"","sources":["../../src/utils/upload_uri.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;gBAEA,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE;IAI7C,IAAI,MAAM,WAET;IAED,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"upload_uri.d.ts","sourceRoot":"","sources":["../../src/utils/upload_uri.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;gBAEA,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE;IAI7C,IAAI,MAAM,WAET;IAED,IAAI,IAAI,WAEP;IAED,IAAI,SAAS,gCAOZ;IAED,IAAI,MAAM,IAAI,KAAK,GAAG,sBAAsB,CAE3C;IAED,IAAI,GAAG,mBAON;IAED,IAAI,GAAG,4BAEN;IAED,IAAI,OAAO,WAEV;IAED,IAAI,OAAO;;;;MAMV;CACF"}
|
|
@@ -19,9 +19,6 @@ export class UploadUri {
|
|
|
19
19
|
return 'https';
|
|
20
20
|
}
|
|
21
21
|
get host() {
|
|
22
|
-
if (this.env === 'prototype') {
|
|
23
|
-
return `${this.session.prototypeName}.upload.planningcenter.ninja`;
|
|
24
|
-
}
|
|
25
22
|
return `${this.subdomain}.${this.domain}.${this.tld}`;
|
|
26
23
|
}
|
|
27
24
|
get subdomain() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload_uri.js","names":["DeviceInfo","brand","getBrand","model","getModel","systemName","getSystemName","systemVersion","getSystemVersion","readableVersion","getReadableVersion","appName","getApplicationName","UploadUri","constructor","session","schema","host","
|
|
1
|
+
{"version":3,"file":"upload_uri.js","names":["DeviceInfo","brand","getBrand","model","getModel","systemName","getSystemName","systemVersion","getSystemVersion","readableVersion","getReadableVersion","appName","getApplicationName","UploadUri","constructor","session","schema","host","subdomain","domain","tld","env","baseUrl","headers","Authorization","token","access_token"],"sources":["../../src/utils/upload_uri.ts"],"sourcesContent":["import DeviceInfo from 'react-native-device-info'\nimport { Session } from './session'\nconst brand = DeviceInfo.getBrand()\nconst model = DeviceInfo.getModel()\nconst systemName = DeviceInfo.getSystemName()\nconst systemVersion = DeviceInfo.getSystemVersion()\nconst readableVersion = DeviceInfo.getReadableVersion()\nconst appName = DeviceInfo.getApplicationName()\n\n/**\n * This is for accessing https://github.com/planningcenter/upload\n */\nexport class UploadUri {\n session: Session\n app?: string\n\n constructor({ session }: { session: Session }) {\n this.session = session\n }\n\n get schema() {\n return 'https'\n }\n\n get host() {\n return `${this.subdomain}.${this.domain}.${this.tld}`\n }\n\n get subdomain() {\n switch (this.env) {\n case 'staging':\n return 'upload-staging'\n default:\n return 'upload'\n }\n }\n\n get domain(): 'pco' | 'planningcenteronline' {\n return this.env === 'development' ? 'pco' : 'planningcenteronline'\n }\n\n get tld() {\n switch (this.env) {\n case 'development':\n return 'test'\n default:\n return 'com'\n }\n }\n\n get env() {\n return this.session?.env || 'production'\n }\n\n get baseUrl() {\n return `${this.schema}://${this.host}`\n }\n\n get headers() {\n return {\n 'User-Agent': `${appName}/${readableVersion} (${brand}, ${model}, ${systemName}, ${systemVersion})`,\n Authorization: `Bearer ${this.session.token?.access_token}`,\n 'X-PCO-Moderate-Image': 'true',\n }\n }\n}\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,0BAA0B;AAEjD,MAAMC,KAAK,GAAGD,UAAU,CAACE,QAAQ,CAAC,CAAC;AACnC,MAAMC,KAAK,GAAGH,UAAU,CAACI,QAAQ,CAAC,CAAC;AACnC,MAAMC,UAAU,GAAGL,UAAU,CAACM,aAAa,CAAC,CAAC;AAC7C,MAAMC,aAAa,GAAGP,UAAU,CAACQ,gBAAgB,CAAC,CAAC;AACnD,MAAMC,eAAe,GAAGT,UAAU,CAACU,kBAAkB,CAAC,CAAC;AACvD,MAAMC,OAAO,GAAGX,UAAU,CAACY,kBAAkB,CAAC,CAAC;;AAE/C;AACA;AACA;AACA,OAAO,MAAMC,SAAS,CAAC;EAIrBC,WAAWA,CAAC;IAAEC;EAA8B,CAAC,EAAE;IAC7C,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;EAEA,IAAIC,MAAMA,CAAA,EAAG;IACX,OAAO,OAAO;EAChB;EAEA,IAAIC,IAAIA,CAAA,EAAG;IACT,OAAO,GAAG,IAAI,CAACC,SAAS,IAAI,IAAI,CAACC,MAAM,IAAI,IAAI,CAACC,GAAG,EAAE;EACvD;EAEA,IAAIF,SAASA,CAAA,EAAG;IACd,QAAQ,IAAI,CAACG,GAAG;MACd,KAAK,SAAS;QACZ,OAAO,gBAAgB;MACzB;QACE,OAAO,QAAQ;IACnB;EACF;EAEA,IAAIF,MAAMA,CAAA,EAAmC;IAC3C,OAAO,IAAI,CAACE,GAAG,KAAK,aAAa,GAAG,KAAK,GAAG,sBAAsB;EACpE;EAEA,IAAID,GAAGA,CAAA,EAAG;IACR,QAAQ,IAAI,CAACC,GAAG;MACd,KAAK,aAAa;QAChB,OAAO,MAAM;MACf;QACE,OAAO,KAAK;IAChB;EACF;EAEA,IAAIA,GAAGA,CAAA,EAAG;IACR,OAAO,IAAI,CAACN,OAAO,EAAEM,GAAG,IAAI,YAAY;EAC1C;EAEA,IAAIC,OAAOA,CAAA,EAAG;IACZ,OAAO,GAAG,IAAI,CAACN,MAAM,MAAM,IAAI,CAACC,IAAI,EAAE;EACxC;EAEA,IAAIM,OAAOA,CAAA,EAAG;IACZ,OAAO;MACL,YAAY,EAAE,GAAGZ,OAAO,IAAIF,eAAe,KAAKR,KAAK,KAAKE,KAAK,KAAKE,UAAU,KAAKE,aAAa,GAAG;MACnGiB,aAAa,EAAE,UAAU,IAAI,CAACT,OAAO,CAACU,KAAK,EAAEC,YAAY,EAAE;MAC3D,sBAAsB,EAAE;IAC1B,CAAC;EACH;AACF","ignoreList":[]}
|
package/build/utils/uri.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uri.d.ts","sourceRoot":"","sources":["../../src/utils/uri.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,KAAK,KAAK,GAAG,cAAc,GAAG,gBAAgB,CAAA;AAC9C,qBAAa,GAAG;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,CAAmB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAA;gBAEA,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;IAMtF,IAAI,MAAM,WAET;IAED,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"uri.d.ts","sourceRoot":"","sources":["../../src/utils/uri.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,KAAK,KAAK,GAAG,cAAc,GAAG,gBAAgB,CAAA;AAC9C,qBAAa,GAAG;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,CAAmB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAA;gBAEA,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;IAMtF,IAAI,MAAM,WAET;IAED,IAAI,IAAI,WAEP;IAED,IAAI,SAAS,0CAOZ;IAED,IAAI,MAAM,IAAI,KAAK,GAAG,sBAAsB,GAAG,cAAc,CAM5D;IAED,IAAI,GAAG,mBAON;IAED,IAAI,cAAc,YAEjB;IAED,IAAI,GAAG,4BAEN;IAED,IAAI,OAAO,WAEV;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,OAAO;;;MAKV;IAED,MAAM,GAAI,MAAM,MAAM,YAIrB;IAED,GAAG,GAAI,MAAM,MAAM,YAIlB;CACF"}
|
package/build/utils/uri.js
CHANGED
|
@@ -20,10 +20,6 @@ export class Uri {
|
|
|
20
20
|
return 'https';
|
|
21
21
|
}
|
|
22
22
|
get host() {
|
|
23
|
-
if (this.env === 'prototype') {
|
|
24
|
-
const graphDomain = this.isChurchCenter ? 'churchcenter' : 'planningcenter';
|
|
25
|
-
return `${this.session.prototypeName}.api.${graphDomain}.ninja`;
|
|
26
|
-
}
|
|
27
23
|
return `${this.subdomain}.${this.domain}.${this.tld}`;
|
|
28
24
|
}
|
|
29
25
|
get subdomain() {
|
package/build/utils/uri.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uri.js","names":["DeviceInfo","brand","getBrand","model","getModel","systemName","getSystemName","systemVersion","getSystemVersion","readableVersion","getReadableVersion","appName","getApplicationName","Uri","graph","constructor","session","app","schema","host","
|
|
1
|
+
{"version":3,"file":"uri.js","names":["DeviceInfo","brand","getBrand","model","getModel","systemName","getSystemName","systemVersion","getSystemVersion","readableVersion","getReadableVersion","appName","getApplicationName","Uri","graph","constructor","session","app","schema","host","subdomain","domain","tld","env","isChurchCenter","isChurchCenterToken","baseUrl","directory","headers","Authorization","token","access_token","appUrl","path","startsWith","api"],"sources":["../../src/utils/uri.ts"],"sourcesContent":["import DeviceInfo from 'react-native-device-info'\nimport { Session } from './session'\nconst brand = DeviceInfo.getBrand()\nconst model = DeviceInfo.getModel()\nconst systemName = DeviceInfo.getSystemName()\nconst systemVersion = DeviceInfo.getSystemVersion()\nconst readableVersion = DeviceInfo.getReadableVersion()\nconst appName = DeviceInfo.getApplicationName()\n\ntype Graph = 'churchcenter' | 'planningcenter'\nexport class Uri {\n session: Session\n graph: Graph = 'planningcenter'\n app?: string\n\n constructor({ session, app, graph }: { session: Session; app?: string; graph?: Graph }) {\n this.session = session\n this.app = app\n this.graph = graph || 'planningcenter'\n }\n\n get schema() {\n return 'https'\n }\n\n get host() {\n return `${this.subdomain}.${this.domain}.${this.tld}`\n }\n\n get subdomain() {\n switch (this.env) {\n case 'staging':\n return this.isChurchCenter ? 'api.staging' : 'api-staging'\n default:\n return 'api'\n }\n }\n\n get domain(): 'pco' | 'planningcenteronline' | 'churchcenter' {\n if (this.isChurchCenter) {\n return 'churchcenter'\n }\n\n return this.env === 'development' ? 'pco' : 'planningcenteronline'\n }\n\n get tld() {\n switch (this.env) {\n case 'development':\n return 'test'\n default:\n return 'com'\n }\n }\n\n get isChurchCenter() {\n return this.session.isChurchCenterToken\n }\n\n get env() {\n return this.session?.env || 'production'\n }\n\n get baseUrl() {\n return `${this.schema}://${this.host}`\n }\n\n get directory() {\n return this.app ? `/${this.app}/v2` : ''\n }\n\n get headers() {\n return {\n 'User-Agent': `${appName}/${readableVersion} (${brand}, ${model}, ${systemName}, ${systemVersion})`,\n Authorization: `Bearer ${this.session.token?.access_token}`,\n }\n }\n\n appUrl = (path: string) => {\n if (path.startsWith(`${this.schema}://`)) return path\n\n return `${this.baseUrl}${this.directory}${path || '/'}`\n }\n\n api = (path: string) => {\n if (path.startsWith(`${this.schema}://`)) return path\n\n return `${this.baseUrl}${path || '/'}`\n }\n}\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,0BAA0B;AAEjD,MAAMC,KAAK,GAAGD,UAAU,CAACE,QAAQ,CAAC,CAAC;AACnC,MAAMC,KAAK,GAAGH,UAAU,CAACI,QAAQ,CAAC,CAAC;AACnC,MAAMC,UAAU,GAAGL,UAAU,CAACM,aAAa,CAAC,CAAC;AAC7C,MAAMC,aAAa,GAAGP,UAAU,CAACQ,gBAAgB,CAAC,CAAC;AACnD,MAAMC,eAAe,GAAGT,UAAU,CAACU,kBAAkB,CAAC,CAAC;AACvD,MAAMC,OAAO,GAAGX,UAAU,CAACY,kBAAkB,CAAC,CAAC;AAG/C,OAAO,MAAMC,GAAG,CAAC;EAEfC,KAAK,GAAU,gBAAgB;EAG/BC,WAAWA,CAAC;IAAEC,OAAO;IAAEC,GAAG;IAAEH;EAAyD,CAAC,EAAE;IACtF,IAAI,CAACE,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,GAAG,GAAGA,GAAG;IACd,IAAI,CAACH,KAAK,GAAGA,KAAK,IAAI,gBAAgB;EACxC;EAEA,IAAII,MAAMA,CAAA,EAAG;IACX,OAAO,OAAO;EAChB;EAEA,IAAIC,IAAIA,C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IAAK;IACzB,IAAIA,IAAI,CAACC,UAAU,CAAC,GAAG,IAAI,CAAChB,MAAM,KAAK,CAAC,EAAE,OAAOe,IAAI;IAErD,OAAO,GAAG,IAAI,CAACP,OAAO,GAAG,IAAI,CAACC,SAAS,GAAGM,IAAI,IAAI,GAAG,EAAE;EACzD,CAAC;EAEDE,GAAG,GAAIF,IAAY,IAAK;IACtB,IAAIA,IAAI,CAACC,UAAU,CAAC,GAAG,IAAI,CAAChB,MAAM,KAAK,CAAC,EAAE,OAAOe,IAAI;IAErD,OAAO,GAAG,IAAI,CAACP,OAAO,GAAGO,IAAI,IAAI,GAAG,EAAE;EACxC,CAAC;AACH","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "4.6.4-
|
|
3
|
+
"version": "4.6.4-rc.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@fortawesome/fontawesome-svg-core": "^7.2.0",
|
|
35
35
|
"@fortawesome/react-native-fontawesome": "^0.3.2",
|
|
36
|
-
"@planningcenter/emoji-keyboard": "4.6.
|
|
36
|
+
"@planningcenter/emoji-keyboard": "4.6.0",
|
|
37
37
|
"lodash-inflection": "^1.5.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"sf-symbols-typescript": "^2.2.0",
|
|
85
85
|
"typescript": "~6.0.3"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "5b0d4594b5ae704c9543fa2d771025adba33310c"
|
|
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: '
|
|
93
|
+
messageType: 'message',
|
|
94
94
|
...overrides,
|
|
95
95
|
}
|
|
96
96
|
idByCreatedAt.set(message.createdAt, message.id)
|
|
@@ -9,7 +9,6 @@ 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'
|
|
13
12
|
import { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../../utils/styles'
|
|
14
13
|
import { isSystemMessage } from '../../utils/system_messages'
|
|
15
14
|
import { Text } from '../display'
|
|
@@ -18,7 +17,6 @@ import { Message } from './message'
|
|
|
18
17
|
import { MissingMessage } from './missing_message'
|
|
19
18
|
import { ReplyShadowMessage } from './reply_shadow_message'
|
|
20
19
|
import { SystemMessage } from './system_message'
|
|
21
|
-
import { UnsupportedMessage } from './unsupported_message'
|
|
22
20
|
|
|
23
21
|
// While behind, the bottom of the window isn't the live edge. Following there pulls
|
|
24
22
|
// each newly paged-in page into view and chains the next fetch.
|
|
@@ -201,10 +199,6 @@ export function MessageList({
|
|
|
201
199
|
)
|
|
202
200
|
}
|
|
203
201
|
|
|
204
|
-
if (isUnsupportedMessage(item)) {
|
|
205
|
-
return <UnsupportedMessage message={item} />
|
|
206
|
-
}
|
|
207
|
-
|
|
208
202
|
if (isSystemMessage(item)) {
|
|
209
203
|
return (
|
|
210
204
|
<SystemMessage
|
|
@@ -37,18 +37,16 @@ const Probe = () => {
|
|
|
37
37
|
return <Text>{`${status}:${fetchStatus}:${data?.id ?? ''}`}</Text>
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const Tree = ({ accessToken
|
|
40
|
+
const Tree = ({ accessToken }: { accessToken: string }) => {
|
|
41
41
|
const value = useMemo(() => {
|
|
42
|
-
const
|
|
43
|
-
const session = new Session({ token: { access_token: accessToken }, env, prototypeName })
|
|
42
|
+
const session = new Session({ token: { access_token: accessToken } })
|
|
44
43
|
return {
|
|
45
44
|
session,
|
|
46
45
|
token: session.token,
|
|
47
|
-
env,
|
|
48
|
-
prototypeName,
|
|
46
|
+
env: 'production',
|
|
49
47
|
onUnauthorizedResponse: () => {},
|
|
50
48
|
} as unknown as ChatContextValue
|
|
51
|
-
}, [accessToken
|
|
49
|
+
}, [accessToken])
|
|
52
50
|
|
|
53
51
|
return (
|
|
54
52
|
<ChatContext.Provider value={value}>
|
|
@@ -106,14 +104,3 @@ describe('ApiProvider on access token change', () => {
|
|
|
106
104
|
expect(await screen.findByText('success:idle:42')).toBeTruthy()
|
|
107
105
|
})
|
|
108
106
|
})
|
|
109
|
-
|
|
110
|
-
describe('ApiProvider on Protonova environment change', () => {
|
|
111
|
-
it("drops the old environment's data and refetches", async () => {
|
|
112
|
-
const { rerender } = render(<Tree accessToken="fresh" prototypeName="chat-1" />)
|
|
113
|
-
expect(await screen.findByText('success:idle:42')).toBeTruthy()
|
|
114
|
-
|
|
115
|
-
rerender(<Tree accessToken="fresh" prototypeName="chat-2" />)
|
|
116
|
-
|
|
117
|
-
await waitFor(() => expect(meRequests()).toEqual(['fresh', 'fresh']))
|
|
118
|
-
})
|
|
119
|
-
})
|
|
@@ -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 {
|
|
17
|
+
import { ResponseError } from '../utils/response_error'
|
|
18
18
|
import { ChatContext, ChatContextValue } from './chat_context'
|
|
19
19
|
|
|
20
20
|
let apiClient: ApiClient | undefined
|
|
@@ -29,21 +29,14 @@ const defaultQueryFn = ({ queryKey }: { queryKey: QueryKey }) => {
|
|
|
29
29
|
return apiClient[app].get({ url, data, headers })
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
if (
|
|
32
|
+
const configuredRetry = (failureCount: number, error: any) => {
|
|
33
|
+
if (is429Error(error)) return false
|
|
34
34
|
|
|
35
35
|
return failureCount < 3
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const
|
|
39
|
-
|
|
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
|
|
38
|
+
const is429Error = (error: any): boolean => {
|
|
39
|
+
return error instanceof ResponseError && error.status === 429
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
export const chatQueryClient = new QueryClient({
|
|
@@ -56,8 +49,8 @@ export const chatQueryClient = new QueryClient({
|
|
|
56
49
|
})
|
|
57
50
|
|
|
58
51
|
export function ApiProvider({ children }: ViewProps) {
|
|
59
|
-
const { token, env,
|
|
60
|
-
const sessionChanged = useSessionChanged({ token, env
|
|
52
|
+
const { token, env, session } = useContext(ChatContext)
|
|
53
|
+
const sessionChanged = useSessionChanged({ token, env })
|
|
61
54
|
|
|
62
55
|
const client = useApiClient()
|
|
63
56
|
|
|
@@ -115,15 +108,9 @@ export function useFocusManager() {
|
|
|
115
108
|
return appState
|
|
116
109
|
}
|
|
117
110
|
|
|
118
|
-
function useSessionChanged(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const { token: newToken, env: newEnv, prototypeName: newPrototypeName } = value
|
|
122
|
-
const {
|
|
123
|
-
token: prevToken,
|
|
124
|
-
env: prevEnv,
|
|
125
|
-
prototypeName: prevPrototypeName,
|
|
126
|
-
} = usePrevious<typeof value>(value)
|
|
111
|
+
function useSessionChanged(value: Pick<ChatContextValue, 'token' | 'env'>): boolean {
|
|
112
|
+
const { token: newToken, env: newEnv } = value
|
|
113
|
+
const { token: prevToken, env: prevEnv } = usePrevious<typeof value>(value)
|
|
127
114
|
|
|
128
115
|
const isInitialLogin = !prevToken && !!newToken
|
|
129
116
|
if (isInitialLogin) return false
|
|
@@ -133,9 +120,8 @@ function useSessionChanged(
|
|
|
133
120
|
)
|
|
134
121
|
|
|
135
122
|
const envChanged = Boolean(prevEnv && newEnv !== prevEnv)
|
|
136
|
-
const prototypeChanged = Boolean(prevEnv && newPrototypeName !== prevPrototypeName)
|
|
137
123
|
|
|
138
|
-
return tokenChanged || envChanged
|
|
124
|
+
return tokenChanged || envChanged
|
|
139
125
|
}
|
|
140
126
|
|
|
141
127
|
function usePrevious<T>(value: T): T {
|
|
@@ -12,7 +12,6 @@ import { ChatTheme, defaultTheme, DefaultTheme } from '../utils/theme'
|
|
|
12
12
|
|
|
13
13
|
export interface ChatProviderProps {
|
|
14
14
|
env?: ENV
|
|
15
|
-
prototypeName?: string
|
|
16
15
|
giphyApiKey?: string
|
|
17
16
|
onAgeDisqualification?: (params: AgeCheckContactInfo) => void
|
|
18
17
|
onUnauthorizedResponse: (_response: FailedResponse) => void
|
|
@@ -46,7 +45,6 @@ export const ChatContext = createContext<ChatContextValue>({
|
|
|
46
45
|
export function ChatProvider({ children, value }: { children: any; value: ChatProviderProps }) {
|
|
47
46
|
const {
|
|
48
47
|
env,
|
|
49
|
-
prototypeName,
|
|
50
48
|
token,
|
|
51
49
|
onAgeDisqualification = (_params: AgeCheckContactInfo) => {},
|
|
52
50
|
onUnauthorizedResponse,
|
|
@@ -60,8 +58,8 @@ export function ChatProvider({ children, value }: { children: any; value: ChatPr
|
|
|
60
58
|
setLiquidGlassCapability(liquidGlassEnabled)
|
|
61
59
|
const theme = useCreateChatTheme(value.theme || {})
|
|
62
60
|
const session = useMemo(
|
|
63
|
-
() => new Session({ token, env,
|
|
64
|
-
[env,
|
|
61
|
+
() => new Session({ token, env, type: tokenType }),
|
|
62
|
+
[env, token, tokenType]
|
|
65
63
|
)
|
|
66
64
|
|
|
67
65
|
const productAnalyticsConfig = useProductAnalyticsConfig(session)
|
|
@@ -23,7 +23,7 @@ type Sessions = Record<string, string> // Key is session ID
|
|
|
23
23
|
|
|
24
24
|
export type SessionContextValue = {
|
|
25
25
|
env: ENV
|
|
26
|
-
setEnv: (_env: ENV
|
|
26
|
+
setEnv: (_env: ENV) => void
|
|
27
27
|
session: Session
|
|
28
28
|
sessions: Sessions
|
|
29
29
|
token: OAuthToken | undefined
|
|
@@ -52,11 +52,7 @@ export type SessionContextConfig = {
|
|
|
52
52
|
secureStorage: StorageAdapter // For sensitive data (tokens/sessions)
|
|
53
53
|
|
|
54
54
|
// Functional callbacks
|
|
55
|
-
refreshTokenFn: (params: {
|
|
56
|
-
refresh_token: string
|
|
57
|
-
env: ENV
|
|
58
|
-
prototypeName?: string
|
|
59
|
-
}) => Promise<OAuthToken>
|
|
55
|
+
refreshTokenFn: (params: { refresh_token: string; env: ENV }) => Promise<OAuthToken>
|
|
60
56
|
onLogout: () => void | Promise<void>
|
|
61
57
|
|
|
62
58
|
// Optional configuration
|
|
@@ -131,11 +127,9 @@ export function SessionContextProvider({
|
|
|
131
127
|
if (!token?.refresh_token) {
|
|
132
128
|
return Promise.reject(new Error('Refresh token is required'))
|
|
133
129
|
}
|
|
134
|
-
return refreshTokenFn({
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
prototypeName: currentSession.prototypeName,
|
|
138
|
-
}).then(handleTokenUpdate)
|
|
130
|
+
return refreshTokenFn({ refresh_token: token.refresh_token, env: currentSession.env }).then(
|
|
131
|
+
handleTokenUpdate
|
|
132
|
+
)
|
|
139
133
|
},
|
|
140
134
|
onError: (t: Partial<FailedResponse>) => {
|
|
141
135
|
handleRefreshFailed(t)
|
|
@@ -148,24 +142,22 @@ export function SessionContextProvider({
|
|
|
148
142
|
}, [queryClient])
|
|
149
143
|
|
|
150
144
|
const handleSetEnv = useCallback(
|
|
151
|
-
async (_env: ENV
|
|
145
|
+
async (_env: ENV) => {
|
|
152
146
|
const updatedManager = SessionManager.hydrate(managerString)
|
|
153
147
|
const session = updatedManager.currentSession
|
|
154
|
-
|
|
155
|
-
if (sameEnvironment) return
|
|
148
|
+
if (_env === session.env) return
|
|
156
149
|
|
|
157
150
|
const productionEnvironments = ['production', 'staging']
|
|
158
151
|
const switchingToDevelopment =
|
|
159
152
|
_env === 'development' && productionEnvironments.includes(session.env)
|
|
160
153
|
const switchingToProduction = _env === 'production' && session.env === 'development'
|
|
161
|
-
const switchingPrototype = _env === 'prototype' || session.env === 'prototype'
|
|
162
154
|
|
|
163
|
-
if (switchingToDevelopment || switchingToProduction
|
|
164
|
-
const newSession = new Session({ env: _env
|
|
155
|
+
if (switchingToDevelopment || switchingToProduction) {
|
|
156
|
+
const newSession = new Session({ env: _env })
|
|
165
157
|
updatedManager.upsertSession(newSession)
|
|
166
158
|
}
|
|
167
159
|
|
|
168
|
-
updatedManager.setEnv(_env
|
|
160
|
+
updatedManager.setEnv(_env)
|
|
169
161
|
await setManagerString(updatedManager.toString())
|
|
170
162
|
},
|
|
171
163
|
[managerString, setManagerString]
|
package/src/hooks/index.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { FlatList } from 'react-native-gesture-handler'
|
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
6
6
|
import { Avatar, Text } from '../components'
|
|
7
7
|
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'
|
|
8
|
-
import {
|
|
8
|
+
import { useSuspenseGet } from '../hooks'
|
|
9
|
+
import { MemberResource } from '../types'
|
|
9
10
|
|
|
10
11
|
export const SystemMessagePeopleScreenOptions = getFormSheetScreenOptions({
|
|
11
12
|
sheetAllowedDetents: Platform.select({
|
|
@@ -24,15 +25,26 @@ export function SystemMessagePeopleScreen({ route }: SystemMessagePeopleScreenPr
|
|
|
24
25
|
const { conversation_id, person_ids } = route.params
|
|
25
26
|
const styles = useStyles()
|
|
26
27
|
|
|
27
|
-
const { data:
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const { data: members } = useSuspenseGet<MemberResource[]>({
|
|
29
|
+
url: `/me/conversations/${conversation_id}/members`,
|
|
30
|
+
data: {
|
|
31
|
+
fields: {
|
|
32
|
+
Member: ['id', 'name', 'avatar'],
|
|
33
|
+
},
|
|
34
|
+
where: {
|
|
35
|
+
id: person_ids,
|
|
36
|
+
},
|
|
37
|
+
limit: person_ids.length,
|
|
38
|
+
},
|
|
30
39
|
})
|
|
31
40
|
|
|
41
|
+
const orderById = Object.fromEntries(person_ids.map((id, i) => [id, i]))
|
|
42
|
+
const sortedMembers = [...members].sort((a, b) => (orderById[a.id] ?? 0) - (orderById[b.id] ?? 0))
|
|
43
|
+
|
|
32
44
|
return (
|
|
33
45
|
<FormSheet.Root contentStyle={styles.formSheetContent}>
|
|
34
46
|
<FlatList
|
|
35
|
-
data={
|
|
47
|
+
data={sortedMembers}
|
|
36
48
|
contentContainerStyle={styles.contentContainer}
|
|
37
49
|
keyExtractor={item => item.id.toString()}
|
|
38
50
|
renderItem={({ item }) => <Person person={item} />}
|
|
@@ -41,7 +53,9 @@ export function SystemMessagePeopleScreen({ route }: SystemMessagePeopleScreenPr
|
|
|
41
53
|
)
|
|
42
54
|
}
|
|
43
55
|
|
|
44
|
-
|
|
56
|
+
type PersonProps = Pick<MemberResource, 'id' | 'name' | 'avatar'>
|
|
57
|
+
|
|
58
|
+
const Person = memo(({ person }: { person: PersonProps }) => {
|
|
45
59
|
const styles = useStyles()
|
|
46
60
|
|
|
47
61
|
return (
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'
|
|
2
2
|
import { DenormalizedAttachmentResource } from '../resources/denormalized_attachment_resource'
|
|
3
|
-
import type { FallbackContent } from '../resources/fallback_content'
|
|
4
3
|
import type { SystemTextFormat } from '../resources/message'
|
|
5
4
|
|
|
6
5
|
interface BaseMessageEventData extends Record<string, unknown> {
|
|
@@ -21,8 +20,6 @@ interface BaseMessageEventData extends Record<string, unknown> {
|
|
|
21
20
|
reply_count: number
|
|
22
21
|
reply_root_id: string | null
|
|
23
22
|
message_type: string
|
|
24
|
-
unsupported_message_type?: string | null
|
|
25
|
-
fallback_content?: FallbackContent | null
|
|
26
23
|
system_event_person_ids: number[] | null
|
|
27
24
|
system_text_parts: { names: string[]; overflow_count: number; action: string } | null
|
|
28
25
|
system_text_format: SystemTextFormat | null
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DenormalizedAttachmentResource } from './denormalized_attachment_resource'
|
|
2
2
|
import { DenormalizedAttachmentResourceForCreate } from './denormalized_attachment_resource_for_create'
|
|
3
|
-
import type { FallbackContent } from './fallback_content'
|
|
4
3
|
import type { PersonResource } from './person'
|
|
5
4
|
import type { ReactionCountResource } from './reaction'
|
|
6
5
|
|
|
@@ -23,10 +22,6 @@ export interface MessageResource {
|
|
|
23
22
|
replyRoot?: MessageResource | null
|
|
24
23
|
idempotentKey?: string | null
|
|
25
24
|
messageType: string
|
|
26
|
-
// Set when messageType is 'unsupported': the type the server would have sent a newer client.
|
|
27
|
-
unsupportedMessageType?: string | null
|
|
28
|
-
// Set when messageType is 'unsupported': what to show read-only in place of the type.
|
|
29
|
-
fallbackContent?: FallbackContent | null
|
|
30
25
|
personIdsForSystemEvent?: number[] | null
|
|
31
26
|
systemTextParts?: { names: string[]; overflowCount: number; action: string } | null
|
|
32
27
|
systemTextFormat?: SystemTextFormat | null
|
|
@@ -110,18 +110,6 @@ describe('SessionManager', () => {
|
|
|
110
110
|
expect(manager.currentSession.id).toBe(UNAUTHENTICATED_SESSION_ID)
|
|
111
111
|
expect(manager.sessions).toHaveProperty(UNAUTHENTICATED_SESSION_ID)
|
|
112
112
|
})
|
|
113
|
-
|
|
114
|
-
it('keeps the Protonova environment name only while on Protonova', () => {
|
|
115
|
-
const manager = new SessionManager()
|
|
116
|
-
|
|
117
|
-
manager.setEnv('prototype', 'chat-812')
|
|
118
|
-
expect(SessionManager.hydrate(manager.toString()).currentSession.prototypeName).toBe(
|
|
119
|
-
'chat-812'
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
manager.setEnv('production', 'chat-812')
|
|
123
|
-
expect(manager.currentSession.prototypeName).toBeUndefined()
|
|
124
|
-
})
|
|
125
113
|
})
|
|
126
114
|
|
|
127
115
|
describe('upsertSession', () => {
|
|
@@ -32,14 +32,4 @@ describe('transformMessageEventDataToMessageResource', () => {
|
|
|
32
32
|
|
|
33
33
|
expect(isSystemMessage(message)).toBe(true)
|
|
34
34
|
})
|
|
35
|
-
|
|
36
|
-
it('carries the fallback content through so unsupported types render read-only in realtime', () => {
|
|
37
|
-
const fallback = { kind: 'poll', title: 'Lunch?', items: [{ label: 'Tacos', detail: '2' }] }
|
|
38
|
-
const message = transformMessageEventDataToMessageResource({
|
|
39
|
-
data: { ...archivedEventData, message_type: 'poll', fallback_content: fallback },
|
|
40
|
-
currentPersonId: 2,
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
expect(message.fallbackContent).toEqual(fallback)
|
|
44
|
-
})
|
|
45
35
|
})
|
|
@@ -31,8 +31,6 @@ export function transformMessageEventDataToMessageResource({
|
|
|
31
31
|
replyRootId: data.reply_root_id || null,
|
|
32
32
|
idempotentKey: data.idempotent_key ?? null,
|
|
33
33
|
messageType: data.message_type,
|
|
34
|
-
unsupportedMessageType: data.unsupported_message_type ?? null,
|
|
35
|
-
fallbackContent: data.fallback_content ?? null,
|
|
36
34
|
personIdsForSystemEvent: data.system_event_person_ids,
|
|
37
35
|
systemTextParts: data.system_text_parts
|
|
38
36
|
? {
|