@planningcenter/chat-react-native 4.2.0-rc.1 → 4.2.0-rc.3
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/display/index.d.ts +1 -0
- package/build/components/display/index.d.ts.map +1 -1
- package/build/components/display/index.js +1 -0
- package/build/components/display/index.js.map +1 -1
- package/build/components/display/version_footer.d.ts +2 -0
- package/build/components/display/version_footer.d.ts.map +1 -0
- package/build/components/display/version_footer.js +36 -0
- package/build/components/display/version_footer.js.map +1 -0
- package/build/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +12 -1
- package/build/contexts/api_provider.js.map +1 -1
- package/build/hooks/use_features.d.ts +16 -0
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +43 -47
- package/build/hooks/use_features.js.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.d.ts +2 -0
- package/build/screens/conversations/components/search_list_header_component.d.ts.map +1 -0
- package/build/screens/conversations/components/search_list_header_component.js +496 -0
- package/build/screens/conversations/components/search_list_header_component.js.map +1 -0
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +28 -16
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/screens/settings_screen.d.ts.map +1 -1
- package/build/screens/settings_screen.js +41 -14
- package/build/screens/settings_screen.js.map +1 -1
- package/build/utils/package_version.d.ts +2 -0
- package/build/utils/package_version.d.ts.map +1 -0
- package/build/utils/package_version.js +5 -0
- package/build/utils/package_version.js.map +1 -0
- package/build/utils/time.d.ts +1 -0
- package/build/utils/time.d.ts.map +1 -1
- package/build/utils/time.js +1 -0
- package/build/utils/time.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/hooks/use_features.test.ts +61 -0
- package/src/components/display/__tests__/version_footer.test.tsx +48 -0
- package/src/components/display/index.ts +1 -0
- package/src/components/display/version_footer.tsx +26 -0
- package/src/contexts/api_provider.tsx +4 -0
- package/src/hooks/use_features.ts +26 -14
- package/src/screens/conversations/components/search_list_header_component.tsx +291 -0
- package/src/screens/conversations/conversations_screen.tsx +6 -1
- package/src/screens/settings_screen.tsx +11 -1
- package/src/utils/package_version.ts +3 -0
- package/src/utils/time.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/display/index.ts"],"sourcesContent":["export * from './avatar_group'\nexport * from './avatar'\nexport * from './badge'\nexport * from './conversation_avatar'\nexport * from './emoji_avatar'\nexport * from './icon_avatar'\nexport * from './banner_collapsible'\nexport * from './banner'\nexport * from './button'\nexport * from './adult_requirement_notice'\nexport * from './child_notice'\nexport * from './heading'\nexport * from './icon_button'\nexport * from './icon'\nexport * from './image'\nexport * from './file_attachment_preview'\nexport * from './image_attachment_preview'\nexport * from './video_attachment_preview'\nexport * from './person'\nexport * from './spinner'\nexport * from './switch'\nexport * from './text_button'\nexport * from './text_inline_button'\nexport * from './text'\nexport * from './toggle_button'\nexport * from './keyboard_scroll_view'\nexport * from './keyboard_view'\nexport * from './platform_modal_header_buttons'\nexport * from './pressable_row'\n"],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,uBAAuB;AACrC,cAAc,gBAAgB;AAC9B,cAAc,eAAe;AAC7B,cAAc,sBAAsB;AACpC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,4BAA4B;AAC1C,cAAc,gBAAgB;AAC9B,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,2BAA2B;AACzC,cAAc,4BAA4B;AAC1C,cAAc,4BAA4B;AAC1C,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,sBAAsB;AACpC,cAAc,QAAQ;AACtB,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,iBAAiB;AAC/B,cAAc,iCAAiC;AAC/C,cAAc,iBAAiB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/display/index.ts"],"sourcesContent":["export * from './avatar_group'\nexport * from './avatar'\nexport * from './badge'\nexport * from './conversation_avatar'\nexport * from './emoji_avatar'\nexport * from './icon_avatar'\nexport * from './banner_collapsible'\nexport * from './banner'\nexport * from './button'\nexport * from './adult_requirement_notice'\nexport * from './child_notice'\nexport * from './heading'\nexport * from './icon_button'\nexport * from './icon'\nexport * from './image'\nexport * from './file_attachment_preview'\nexport * from './image_attachment_preview'\nexport * from './video_attachment_preview'\nexport * from './person'\nexport * from './spinner'\nexport * from './switch'\nexport * from './text_button'\nexport * from './text_inline_button'\nexport * from './text'\nexport * from './toggle_button'\nexport * from './keyboard_scroll_view'\nexport * from './keyboard_view'\nexport * from './platform_modal_header_buttons'\nexport * from './pressable_row'\nexport * from './version_footer'\n"],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,uBAAuB;AACrC,cAAc,gBAAgB;AAC9B,cAAc,eAAe;AAC7B,cAAc,sBAAsB;AACpC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,4BAA4B;AAC1C,cAAc,gBAAgB;AAC9B,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,2BAA2B;AACzC,cAAc,4BAA4B;AAC1C,cAAc,4BAA4B;AAC1C,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,sBAAsB;AACpC,cAAc,QAAQ;AACtB,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,iBAAiB;AAC/B,cAAc,iCAAiC;AAC/C,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version_footer.d.ts","sourceRoot":"","sources":["../../../src/components/display/version_footer.tsx"],"names":[],"mappings":"AAKA,wBAAgB,aAAa,4CAQ5B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { StyleSheet, View } from 'react-native';
|
|
4
|
+
import { chatReactNativeVersion } from '../../utils/package_version';
|
|
5
|
+
import { Text } from './text';
|
|
6
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export function VersionFooter() {
|
|
8
|
+
const $ = _c(1);
|
|
9
|
+
let t0;
|
|
10
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
11
|
+
t0 = /*#__PURE__*/_jsx(View, {
|
|
12
|
+
style: styles.container,
|
|
13
|
+
children: /*#__PURE__*/_jsxs(Text, {
|
|
14
|
+
variant: "footnote",
|
|
15
|
+
style: styles.text,
|
|
16
|
+
children: ["Chat v", chatReactNativeVersion]
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
$[0] = t0;
|
|
20
|
+
} else {
|
|
21
|
+
t0 = $[0];
|
|
22
|
+
}
|
|
23
|
+
return t0;
|
|
24
|
+
}
|
|
25
|
+
const styles = StyleSheet.create({
|
|
26
|
+
container: {
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
paddingTop: 24,
|
|
29
|
+
paddingBottom: 8,
|
|
30
|
+
paddingHorizontal: 16
|
|
31
|
+
},
|
|
32
|
+
text: {
|
|
33
|
+
textAlign: 'center'
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=version_footer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version_footer.js","names":["React","StyleSheet","View","chatReactNativeVersion","Text","jsxs","_jsxs","jsx","_jsx","VersionFooter","$","_c","t0","Symbol","for","style","styles","container","children","variant","text","create","alignItems","paddingTop","paddingBottom","paddingHorizontal","textAlign"],"sources":["../../../src/components/display/version_footer.tsx"],"sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { chatReactNativeVersion } from '../../utils/package_version'\nimport { Text } from './text'\n\nexport function VersionFooter() {\n return (\n <View style={styles.container}>\n <Text variant=\"footnote\" style={styles.text}>\n Chat v{chatReactNativeVersion}\n </Text>\n </View>\n )\n}\n\nconst styles = StyleSheet.create({\n container: {\n alignItems: 'center',\n paddingTop: 24,\n paddingBottom: 8,\n paddingHorizontal: 16,\n },\n text: {\n textAlign: 'center',\n },\n})\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC/C,SAASC,sBAAsB,QAAQ,6BAA6B;AACpE,SAASC,IAAI,QAAQ,QAAQ;AAAA,SAAAC,IAAA,IAAAC,KAAA,EAAAC,GAAA,IAAAC,IAAA;AAE7B,OAAO,SAAAC,cAAA;EAAA,MAAAC,CAAA,GAAAC,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAF,CAAA,QAAAG,MAAA,CAAAC,GAAA;IAEHF,EAAA,gBAAAJ,IAAA,CAACN,IAAI;MAAQa,KAAgB,EAAhBC,MAAM,CAAAC,SAAU;MAAAC,QAAA,eAC3BZ,KAAA,CAACF,IAAI;QAASe,OAAU,EAAV,UAAU;QAAQJ,KAAW,EAAXC,MAAM,CAAAI,IAAK;QAAAF,QAAA,GAAE,QACrC,EAACf,sBAAsB;MAAA,CACzB;IAAC,CACH,CAAC;IAAAO,CAAA,MAAAE,EAAA;EAAA;IAAAA,EAAA,GAAAF,CAAA;EAAA;EAAA,OAJPE,EAIO;AAAA;AAIX,MAAMI,MAAM,GAAGf,UAAU,CAACoB,MAAM,CAAC;EAC/BJ,SAAS,EAAE;IACTK,UAAU,EAAE,QAAQ;IACpBC,UAAU,EAAE,EAAE;IACdC,aAAa,EAAE,CAAC;IAChBC,iBAAiB,EAAE;EACrB,CAAC;EACDL,IAAI,EAAE;IACJM,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_provider.d.ts","sourceRoot":"","sources":["../../src/contexts/api_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAIZ,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"api_provider.d.ts","sourceRoot":"","sources":["../../src/contexts/api_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAIZ,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAgCxC,eAAO,MAAM,eAAe,aAO1B,CAAA;AAEF,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,SAAS,2CA6BlD;AAiBD,wBAAgB,eAAe,WAQ9B"}
|
|
@@ -4,6 +4,7 @@ import React, { useContext, useEffect, useRef } from 'react';
|
|
|
4
4
|
import { useApiClient } from '../hooks/use_api_client';
|
|
5
5
|
import { useAppState } from '../hooks/use_app_state';
|
|
6
6
|
import { appGrantsRequestArgs } from '../hooks/use_chat_permissions';
|
|
7
|
+
import { featuresQueryOptions } from '../hooks/use_features';
|
|
7
8
|
import { getRequestQueryKey } from '../hooks/use_suspense_api';
|
|
8
9
|
import { emitAuthRefresh } from '../utils/auth_events';
|
|
9
10
|
import { ResponseError } from '../utils/response_error';
|
|
@@ -124,7 +125,8 @@ export function ApiProvider(t0) {
|
|
|
124
125
|
// This needs to live in the provider so that it can access the api client
|
|
125
126
|
// and the chat query client
|
|
126
127
|
const PrefetchQueries = () => {
|
|
127
|
-
const $ = _c(
|
|
128
|
+
const $ = _c(3);
|
|
129
|
+
const client = useApiClient();
|
|
128
130
|
let t0;
|
|
129
131
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
130
132
|
t0 = {
|
|
@@ -136,6 +138,15 @@ const PrefetchQueries = () => {
|
|
|
136
138
|
t0 = $[0];
|
|
137
139
|
}
|
|
138
140
|
usePrefetchQuery(t0);
|
|
141
|
+
let t1;
|
|
142
|
+
if ($[1] !== client) {
|
|
143
|
+
t1 = featuresQueryOptions(client);
|
|
144
|
+
$[1] = client;
|
|
145
|
+
$[2] = t1;
|
|
146
|
+
} else {
|
|
147
|
+
t1 = $[2];
|
|
148
|
+
}
|
|
149
|
+
usePrefetchQuery(t1);
|
|
139
150
|
return null;
|
|
140
151
|
};
|
|
141
152
|
export function useFocusManager() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_provider.js","names":["focusManager","QueryClient","QueryClientProvider","usePrefetchQuery","React","useContext","useEffect","useRef","useApiClient","useAppState","appGrantsRequestArgs","getRequestQueryKey","emitAuthRefresh","ResponseError","ChatContext","jsx","_jsx","jsxs","_jsxs","apiClient","defaultQueryFn","queryKey","Error","url","data","headers","app","get","configuredRetry","failureCount","error","is429Error","status","chatQueryClient","defaultOptions","queries","queryFn","retry","ApiProvider","t0","$","_c","children","token","env","t1","sessionChanged","useSessionChanged","client","t2","t3","isFetching","invalidateQueries","clear","t4","t5","t6","Symbol","for","PrefetchQueries","t7","useFocusManager","appState","setFocused","value","newToken","newEnv","prevToken","prevEnv","usePrevious","isInitialLogin","tokenChanged","Boolean","access_token","envChanged","ref","current"],"sources":["../../src/contexts/api_provider.tsx"],"sourcesContent":["import {\n focusManager,\n QueryClient,\n QueryClientProvider,\n QueryKey,\n usePrefetchQuery,\n} from '@tanstack/react-query'\nimport React, { useContext, useEffect, useRef } from 'react'\nimport { ViewProps } from 'react-native'\nimport { ApiClient, useApiClient } from '../hooks/use_api_client'\nimport { useAppState } from '../hooks/use_app_state'\nimport { appGrantsRequestArgs } from '../hooks/use_chat_permissions'\nimport { getRequestQueryKey, RequestQueryKey } from '../hooks/use_suspense_api'\nimport { emitAuthRefresh } from '../utils/auth_events'\nimport { ResponseError } from '../utils/response_error'\nimport { ChatContext, ChatContextValue } from './chat_context'\n\nlet apiClient: ApiClient | undefined\n\nconst defaultQueryFn = ({ queryKey }: { queryKey: QueryKey }) => {\n if (!apiClient) {\n throw new Error('No token present')\n }\n\n const [url, data, headers, app = 'chat'] = queryKey as RequestQueryKey\n\n return apiClient[app].get({ url, data, headers })\n}\n\nconst configuredRetry = (failureCount: number, error: any) => {\n if (is429Error(error)) return false\n\n return failureCount < 3\n}\n\nconst is429Error = (error: any): boolean => {\n return error instanceof ResponseError && error.status === 429\n}\n\nexport const chatQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n queryFn: defaultQueryFn,\n retry: configuredRetry,\n },\n },\n})\n\nexport function ApiProvider({ children }: ViewProps) {\n const { token, env } = useContext(ChatContext)\n const sessionChanged = useSessionChanged({ token, env })\n\n const client = useApiClient()\n\n useEffect(() => {\n if (!sessionChanged) return\n\n emitAuthRefresh()\n\n if (chatQueryClient.isFetching()) {\n chatQueryClient.invalidateQueries()\n return\n }\n\n chatQueryClient.clear()\n }, [sessionChanged])\n\n useEffect(() => {\n apiClient = client\n }, [client])\n\n return (\n <QueryClientProvider client={chatQueryClient}>\n <PrefetchQueries />\n {children}\n </QueryClientProvider>\n )\n}\n\n// Component to prefetch queries when the app is focused\n// This needs to live in the provider so that it can access the api client\n// and the chat query client\nconst PrefetchQueries = () => {\n usePrefetchQuery({\n queryKey: getRequestQueryKey(appGrantsRequestArgs),\n queryFn: defaultQueryFn,\n })\n\n return null\n}\n\nexport function useFocusManager() {\n const appState = useAppState()\n\n useEffect(() => {\n focusManager.setFocused(appState === 'active')\n }, [appState])\n\n return appState\n}\n\nfunction useSessionChanged(value: Pick<ChatContextValue, 'token' | 'env'>): boolean {\n const { token: newToken, env: newEnv } = value\n const { token: prevToken, env: prevEnv } = usePrevious<typeof value>(value)\n\n const isInitialLogin = !prevToken && !!newToken\n if (isInitialLogin) return false\n\n const tokenChanged = Boolean(\n prevToken?.access_token && newToken?.access_token !== prevToken?.access_token\n )\n\n const envChanged = Boolean(prevEnv && newEnv !== prevEnv)\n\n return tokenChanged || envChanged\n}\n\nfunction usePrevious<T>(value: T): T {\n const ref = useRef<T>(value)\n\n useEffect(() => {\n ref.current = value\n }, [value])\n\n return ref.current\n}\n"],"mappings":";AAAA,SACEA,YAAY,EACZC,WAAW,EACXC,mBAAmB,EAEnBC,gBAAgB,QACX,uBAAuB;AAC9B,OAAOC,KAAK,IAAIC,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAE5D,SAAoBC,YAAY,QAAQ,yBAAyB;AACjE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,oBAAoB,QAAQ,+BAA+B;AACpE,SAASC,kBAAkB,QAAyB,2BAA2B;AAC/E,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,WAAW,QAA0B,gBAAgB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9D,IAAIC,SAAgC;AAEpC,MAAMC,cAAc,GAAGA,CAAC;EAAEC;AAAiC,CAAC,KAAK;EAC/D,IAAI,CAACF,SAAS,EAAE;IACd,MAAM,IAAIG,KAAK,CAAC,kBAAkB,CAAC;EACrC;EAEA,MAAM,CAACC,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,GAAG,GAAG,MAAM,CAAC,GAAGL,QAA2B;EAEtE,OAAOF,SAAS,CAACO,GAAG,CAAC,CAACC,GAAG,CAAC;IAAEJ,GAAG;IAAEC,IAAI;IAAEC;EAAQ,CAAC,CAAC;AACnD,CAAC;AAED,MAAMG,eAAe,GAAGA,CAACC,YAAoB,EAAEC,KAAU,KAAK;EAC5D,IAAIC,UAAU,CAACD,KAAK,CAAC,EAAE,OAAO,KAAK;EAEnC,OAAOD,YAAY,GAAG,CAAC;AACzB,CAAC;AAED,MAAME,UAAU,GAAID,KAAU,IAAc;EAC1C,OAAOA,KAAK,YAAYjB,aAAa,IAAIiB,KAAK,CAACE,MAAM,KAAK,GAAG;AAC/D,CAAC;AAED,OAAO,MAAMC,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"api_provider.js","names":["focusManager","QueryClient","QueryClientProvider","usePrefetchQuery","React","useContext","useEffect","useRef","useApiClient","useAppState","appGrantsRequestArgs","featuresQueryOptions","getRequestQueryKey","emitAuthRefresh","ResponseError","ChatContext","jsx","_jsx","jsxs","_jsxs","apiClient","defaultQueryFn","queryKey","Error","url","data","headers","app","get","configuredRetry","failureCount","error","is429Error","status","chatQueryClient","defaultOptions","queries","queryFn","retry","ApiProvider","t0","$","_c","children","token","env","t1","sessionChanged","useSessionChanged","client","t2","t3","isFetching","invalidateQueries","clear","t4","t5","t6","Symbol","for","PrefetchQueries","t7","useFocusManager","appState","setFocused","value","newToken","newEnv","prevToken","prevEnv","usePrevious","isInitialLogin","tokenChanged","Boolean","access_token","envChanged","ref","current"],"sources":["../../src/contexts/api_provider.tsx"],"sourcesContent":["import {\n focusManager,\n QueryClient,\n QueryClientProvider,\n QueryKey,\n usePrefetchQuery,\n} from '@tanstack/react-query'\nimport React, { useContext, useEffect, useRef } from 'react'\nimport { ViewProps } from 'react-native'\nimport { ApiClient, useApiClient } from '../hooks/use_api_client'\nimport { useAppState } from '../hooks/use_app_state'\nimport { appGrantsRequestArgs } from '../hooks/use_chat_permissions'\nimport { featuresQueryOptions } from '../hooks/use_features'\nimport { getRequestQueryKey, RequestQueryKey } from '../hooks/use_suspense_api'\nimport { emitAuthRefresh } from '../utils/auth_events'\nimport { ResponseError } from '../utils/response_error'\nimport { ChatContext, ChatContextValue } from './chat_context'\n\nlet apiClient: ApiClient | undefined\n\nconst defaultQueryFn = ({ queryKey }: { queryKey: QueryKey }) => {\n if (!apiClient) {\n throw new Error('No token present')\n }\n\n const [url, data, headers, app = 'chat'] = queryKey as RequestQueryKey\n\n return apiClient[app].get({ url, data, headers })\n}\n\nconst configuredRetry = (failureCount: number, error: any) => {\n if (is429Error(error)) return false\n\n return failureCount < 3\n}\n\nconst is429Error = (error: any): boolean => {\n return error instanceof ResponseError && error.status === 429\n}\n\nexport const chatQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n queryFn: defaultQueryFn,\n retry: configuredRetry,\n },\n },\n})\n\nexport function ApiProvider({ children }: ViewProps) {\n const { token, env } = useContext(ChatContext)\n const sessionChanged = useSessionChanged({ token, env })\n\n const client = useApiClient()\n\n useEffect(() => {\n if (!sessionChanged) return\n\n emitAuthRefresh()\n\n if (chatQueryClient.isFetching()) {\n chatQueryClient.invalidateQueries()\n return\n }\n\n chatQueryClient.clear()\n }, [sessionChanged])\n\n useEffect(() => {\n apiClient = client\n }, [client])\n\n return (\n <QueryClientProvider client={chatQueryClient}>\n <PrefetchQueries />\n {children}\n </QueryClientProvider>\n )\n}\n\n// Component to prefetch queries when the app is focused\n// This needs to live in the provider so that it can access the api client\n// and the chat query client\nconst PrefetchQueries = () => {\n const client = useApiClient()\n\n usePrefetchQuery({\n queryKey: getRequestQueryKey(appGrantsRequestArgs),\n queryFn: defaultQueryFn,\n })\n usePrefetchQuery(featuresQueryOptions(client))\n\n return null\n}\n\nexport function useFocusManager() {\n const appState = useAppState()\n\n useEffect(() => {\n focusManager.setFocused(appState === 'active')\n }, [appState])\n\n return appState\n}\n\nfunction useSessionChanged(value: Pick<ChatContextValue, 'token' | 'env'>): boolean {\n const { token: newToken, env: newEnv } = value\n const { token: prevToken, env: prevEnv } = usePrevious<typeof value>(value)\n\n const isInitialLogin = !prevToken && !!newToken\n if (isInitialLogin) return false\n\n const tokenChanged = Boolean(\n prevToken?.access_token && newToken?.access_token !== prevToken?.access_token\n )\n\n const envChanged = Boolean(prevEnv && newEnv !== prevEnv)\n\n return tokenChanged || envChanged\n}\n\nfunction usePrevious<T>(value: T): T {\n const ref = useRef<T>(value)\n\n useEffect(() => {\n ref.current = value\n }, [value])\n\n return ref.current\n}\n"],"mappings":";AAAA,SACEA,YAAY,EACZC,WAAW,EACXC,mBAAmB,EAEnBC,gBAAgB,QACX,uBAAuB;AAC9B,OAAOC,KAAK,IAAIC,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAE5D,SAAoBC,YAAY,QAAQ,yBAAyB;AACjE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,oBAAoB,QAAQ,+BAA+B;AACpE,SAASC,oBAAoB,QAAQ,uBAAuB;AAC5D,SAASC,kBAAkB,QAAyB,2BAA2B;AAC/E,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,WAAW,QAA0B,gBAAgB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9D,IAAIC,SAAgC;AAEpC,MAAMC,cAAc,GAAGA,CAAC;EAAEC;AAAiC,CAAC,KAAK;EAC/D,IAAI,CAACF,SAAS,EAAE;IACd,MAAM,IAAIG,KAAK,CAAC,kBAAkB,CAAC;EACrC;EAEA,MAAM,CAACC,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,GAAG,GAAG,MAAM,CAAC,GAAGL,QAA2B;EAEtE,OAAOF,SA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BAAAiB,KAAA;EACE;IAAArB,KAAA,EAAAsB,QAAA;IAAArB,GAAA,EAAAsB;EAAA,IAAyCF,KAAK;EAC9C;IAAArB,KAAA,EAAAwB,SAAA;IAAAvB,GAAA,EAAAwB;EAAA,IAA2CC,WAAW,CAAeL,KAAK,CAAC;EAE3E,MAAAM,cAAA,GAAuB,CAACH,SAAuB,IAAxB,CAAe,CAACF,QAAQ;EAC/C,IAAIK,cAAc;IAAA,OAAS,KAAK;EAAA;EAEhC,MAAAC,YAAA,GAAqBC,OAAO,CAC1BL,SAAS,EAAAM,YAAoE,IAAlDR,QAAQ,EAAAQ,YAAc,KAAKN,SAAS,EAAAM,YACjE,CAAC;EAED,MAAAC,UAAA,GAAmBF,OAAO,CAACJ,OAA6B,IAAlBF,MAAM,KAAKE,OAAO,CAAC;EAAA,OAElDG,YAA0B,IAA1BG,UAA0B;AAAA;AAGnC,SAASL,WAAWA,CAAIL,KAAQ,EAAK;EACnC,MAAMW,GAAG,GAAGrE,MAAM,CAAI0D,KAAK,CAAC;EAE5B3D,SAAS,CAAC,MAAM;IACdsE,GAAG,CAACC,OAAO,GAAGZ,KAAK;EACrB,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,OAAOW,GAAG,CAACC,OAAO;AACpB","ignoreList":[]}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import { ApiCollection } from '../types';
|
|
1
2
|
import type { FeatureResource } from '../types/resources/feature_resource';
|
|
3
|
+
import { ApiClient } from './use_api_client';
|
|
2
4
|
type FeatureName = (typeof availableFeatures)[keyof typeof availableFeatures];
|
|
5
|
+
type FeaturesCollection = ApiCollection<FeatureResource> & {
|
|
6
|
+
failure?: {
|
|
7
|
+
status?: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
3
10
|
export declare function useFeatures(): {
|
|
4
11
|
features: FeatureResource[];
|
|
5
12
|
featureEnabled: (featureName: FeatureName) => boolean;
|
|
6
13
|
};
|
|
14
|
+
export declare const featuresQueryOptions: (apiClient: ApiClient) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<FeaturesCollection, Error, FeaturesCollection, import("./use_suspense_api").RequestQueryKey>, "queryFn"> & {
|
|
15
|
+
queryFn?: import("@tanstack/query-core").QueryFunction<FeaturesCollection, import("./use_suspense_api").RequestQueryKey, never> | undefined;
|
|
16
|
+
} & {
|
|
17
|
+
queryKey: import("./use_suspense_api").RequestQueryKey & {
|
|
18
|
+
[dataTagSymbol]: FeaturesCollection;
|
|
19
|
+
[dataTagErrorSymbol]: Error;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
7
22
|
export declare const availableFeatures: {
|
|
8
23
|
readonly gender_specific_conversations: "ROLLOUT_gender_specific_conversations";
|
|
9
24
|
readonly message_reporting: "ROLLOUT_MOBILE_message_reporting";
|
|
@@ -12,6 +27,7 @@ export declare const availableFeatures: {
|
|
|
12
27
|
readonly conversation_safety_lock: "ROLLOUT_conversation_safety_lock";
|
|
13
28
|
readonly video_moderation: "ROLLOUT_MOBILE_video_moderation";
|
|
14
29
|
readonly dm_search_clear_fix: "ROLLOUT_MOBILE_dm_search_clear_fix";
|
|
30
|
+
readonly search: "ROLLOUT_search";
|
|
15
31
|
};
|
|
16
32
|
export {};
|
|
17
33
|
//# sourceMappingURL=use_features.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_features.d.ts","sourceRoot":"","sources":["../../src/hooks/use_features.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use_features.d.ts","sourceRoot":"","sources":["../../src/hooks/use_features.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAG1E,OAAO,EAAE,SAAS,EAAgB,MAAM,kBAAkB,CAAA;AAE1D,KAAK,WAAW,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAA;AAE7E,KAAK,kBAAkB,GAAG,aAAa,CAAC,eAAe,CAAC,GAAG;IACzD,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAC9B,CAAA;AAED,wBAAgB,WAAW;;kCAOT,WAAW;EAS5B;AAED,eAAO,MAAM,oBAAoB,GAAI,WAAW,SAAS;;;;;;;CAerD,CAAA;AAEJ,eAAO,MAAM,iBAAiB;;;;;;;;;CAS0B,CAAA"}
|
|
@@ -1,69 +1,64 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
-
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
2
|
+
import { queryOptions, useSuspenseQuery } from '@tanstack/react-query';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import { getFeaturesRequestArgs, getFeaturesQueryKey } from '../utils/request/get_features';
|
|
5
|
-
import { FIVE_MINUTES } from '../utils/time';
|
|
5
|
+
import { FIVE_MINUTES, ONE_MINUTE } from '../utils/time';
|
|
6
6
|
import { useApiClient } from './use_api_client';
|
|
7
7
|
export function useFeatures() {
|
|
8
|
-
const $ = _c(
|
|
8
|
+
const $ = _c(7);
|
|
9
9
|
const apiClient = useApiClient();
|
|
10
10
|
let t0;
|
|
11
|
-
if ($[0]
|
|
12
|
-
t0 =
|
|
13
|
-
$[0] =
|
|
11
|
+
if ($[0] !== apiClient) {
|
|
12
|
+
t0 = featuresQueryOptions(apiClient);
|
|
13
|
+
$[0] = apiClient;
|
|
14
|
+
$[1] = t0;
|
|
14
15
|
} else {
|
|
15
|
-
t0 = $[
|
|
16
|
-
}
|
|
17
|
-
const requestArgs = t0;
|
|
18
|
-
let t1;
|
|
19
|
-
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
20
|
-
t1 = getFeaturesQueryKey();
|
|
21
|
-
$[1] = t1;
|
|
22
|
-
} else {
|
|
23
|
-
t1 = $[1];
|
|
24
|
-
}
|
|
25
|
-
let t2;
|
|
26
|
-
if ($[2] !== apiClient) {
|
|
27
|
-
t2 = {
|
|
28
|
-
queryKey: t1,
|
|
29
|
-
queryFn: () => apiClient.chat.get(requestArgs).catch(_temp),
|
|
30
|
-
staleTime: FIVE_MINUTES
|
|
31
|
-
};
|
|
32
|
-
$[2] = apiClient;
|
|
33
|
-
$[3] = t2;
|
|
34
|
-
} else {
|
|
35
|
-
t2 = $[3];
|
|
16
|
+
t0 = $[1];
|
|
36
17
|
}
|
|
37
18
|
const {
|
|
38
19
|
data
|
|
39
|
-
} = useSuspenseQuery(
|
|
20
|
+
} = useSuspenseQuery(t0);
|
|
40
21
|
const features = data.data;
|
|
41
|
-
let
|
|
42
|
-
if ($[
|
|
43
|
-
|
|
44
|
-
$[
|
|
45
|
-
$[
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[2] !== features) {
|
|
24
|
+
t1 = featureName => features.some(feature => feature.name === featureName && feature.enabled);
|
|
25
|
+
$[2] = features;
|
|
26
|
+
$[3] = t1;
|
|
46
27
|
} else {
|
|
47
|
-
|
|
28
|
+
t1 = $[3];
|
|
48
29
|
}
|
|
49
|
-
const featureEnabled =
|
|
50
|
-
let
|
|
51
|
-
if ($[
|
|
52
|
-
|
|
30
|
+
const featureEnabled = t1;
|
|
31
|
+
let t2;
|
|
32
|
+
if ($[4] !== featureEnabled || $[5] !== features) {
|
|
33
|
+
t2 = {
|
|
53
34
|
features,
|
|
54
35
|
featureEnabled
|
|
55
36
|
};
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
37
|
+
$[4] = featureEnabled;
|
|
38
|
+
$[5] = features;
|
|
39
|
+
$[6] = t2;
|
|
59
40
|
} else {
|
|
60
|
-
|
|
41
|
+
t2 = $[6];
|
|
61
42
|
}
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
function _temp() {
|
|
65
|
-
return stableEmptyFeatures;
|
|
43
|
+
return t2;
|
|
66
44
|
}
|
|
45
|
+
export const featuresQueryOptions = apiClient => queryOptions({
|
|
46
|
+
queryKey: getFeaturesQueryKey(),
|
|
47
|
+
queryFn: () => {
|
|
48
|
+
return apiClient.chat.get(getFeaturesRequestArgs()).catch(error => ({
|
|
49
|
+
...stableEmptyFeatures,
|
|
50
|
+
failure: {
|
|
51
|
+
status: error?.status
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
},
|
|
55
|
+
staleTime: query => {
|
|
56
|
+
const failure = query.state.data?.failure;
|
|
57
|
+
if (!failure) return FIVE_MINUTES;
|
|
58
|
+
return failure.status === 429 ? ONE_MINUTE : 0;
|
|
59
|
+
},
|
|
60
|
+
gcTime: Infinity
|
|
61
|
+
});
|
|
67
62
|
export const availableFeatures = {
|
|
68
63
|
gender_specific_conversations: 'ROLLOUT_gender_specific_conversations',
|
|
69
64
|
message_reporting: 'ROLLOUT_MOBILE_message_reporting',
|
|
@@ -71,7 +66,8 @@ export const availableFeatures = {
|
|
|
71
66
|
custom_conversation_avatars: 'ROLLOUT_custom_conversation_avatars',
|
|
72
67
|
conversation_safety_lock: 'ROLLOUT_conversation_safety_lock',
|
|
73
68
|
video_moderation: 'ROLLOUT_MOBILE_video_moderation',
|
|
74
|
-
dm_search_clear_fix: 'ROLLOUT_MOBILE_dm_search_clear_fix'
|
|
69
|
+
dm_search_clear_fix: 'ROLLOUT_MOBILE_dm_search_clear_fix',
|
|
70
|
+
search: 'ROLLOUT_search'
|
|
75
71
|
};
|
|
76
72
|
const stableEmptyFeatures = {
|
|
77
73
|
data: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_features.js","names":["useSuspenseQuery","useCallback","getFeaturesRequestArgs","getFeaturesQueryKey","FIVE_MINUTES","useApiClient","useFeatures","$","_c","apiClient","t0","
|
|
1
|
+
{"version":3,"file":"use_features.js","names":["queryOptions","useSuspenseQuery","useCallback","getFeaturesRequestArgs","getFeaturesQueryKey","FIVE_MINUTES","ONE_MINUTE","useApiClient","useFeatures","$","_c","apiClient","t0","featuresQueryOptions","data","features","t1","featureName","some","feature","name","enabled","featureEnabled","t2","queryKey","queryFn","chat","get","catch","error","stableEmptyFeatures","failure","status","staleTime","query","state","gcTime","Infinity","availableFeatures","gender_specific_conversations","message_reporting","granular_notifications_ui","custom_conversation_avatars","conversation_safety_lock","video_moderation","dm_search_clear_fix","search","links","meta","count","totalCount"],"sources":["../../src/hooks/use_features.ts"],"sourcesContent":["import { queryOptions, useSuspenseQuery } from '@tanstack/react-query'\nimport { useCallback } from 'react'\nimport { ApiCollection } from '../types'\nimport type { FeatureResource } from '../types/resources/feature_resource'\nimport { getFeaturesRequestArgs, getFeaturesQueryKey } from '../utils/request/get_features'\nimport { FIVE_MINUTES, ONE_MINUTE } from '../utils/time'\nimport { ApiClient, useApiClient } from './use_api_client'\n\ntype FeatureName = (typeof availableFeatures)[keyof typeof availableFeatures]\n\ntype FeaturesCollection = ApiCollection<FeatureResource> & {\n failure?: { status?: number }\n}\n\nexport function useFeatures() {\n const apiClient = useApiClient()\n const { data } = useSuspenseQuery(featuresQueryOptions(apiClient))\n\n const features = data.data\n\n const featureEnabled = useCallback(\n (featureName: FeatureName) =>\n features.some(feature => feature.name === featureName && feature.enabled),\n [features]\n )\n\n return {\n features,\n featureEnabled,\n }\n}\n\nexport const featuresQueryOptions = (apiClient: ApiClient) =>\n queryOptions({\n queryKey: getFeaturesQueryKey(),\n queryFn: (): Promise<FeaturesCollection> => {\n return apiClient.chat\n .get<ApiCollection<FeatureResource>>(getFeaturesRequestArgs())\n .catch(error => ({ ...stableEmptyFeatures, failure: { status: error?.status } }))\n },\n staleTime: query => {\n const failure = query.state.data?.failure\n if (!failure) return FIVE_MINUTES\n\n return failure.status === 429 ? ONE_MINUTE : 0\n },\n gcTime: Infinity,\n })\n\nexport const availableFeatures = {\n gender_specific_conversations: 'ROLLOUT_gender_specific_conversations',\n message_reporting: 'ROLLOUT_MOBILE_message_reporting',\n granular_notifications_ui: 'ROLLOUT_granular_notification_preferences_ui',\n custom_conversation_avatars: 'ROLLOUT_custom_conversation_avatars',\n conversation_safety_lock: 'ROLLOUT_conversation_safety_lock',\n video_moderation: 'ROLLOUT_MOBILE_video_moderation',\n dm_search_clear_fix: 'ROLLOUT_MOBILE_dm_search_clear_fix',\n search: 'ROLLOUT_search',\n} as const satisfies Record<string, `ROLLOUT_${string}`>\n\nconst stableEmptyFeatures: ApiCollection<FeatureResource> = {\n data: [],\n links: {},\n meta: {\n count: 0,\n totalCount: 0,\n },\n}\n"],"mappings":";AAAA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,uBAAuB;AACtE,SAASC,WAAW,QAAQ,OAAO;AAGnC,SAASC,sBAAsB,EAAEC,mBAAmB,QAAQ,+BAA+B;AAC3F,SAASC,YAAY,EAAEC,UAAU,QAAQ,eAAe;AACxD,SAAoBC,YAAY,QAAQ,kBAAkB;AAQ1D,OAAO,SAAAC,YAAA;EAAA,MAAAC,CAAA,GAAAC,EAAA;EACL,MAAAC,SAAA,GAAkBJ,YAAY,CAAC,CAAC;EAAA,IAAAK,EAAA;EAAA,IAAAH,CAAA,QAAAE,SAAA;IACEC,EAAA,GAAAC,oBAAoB,CAACF,SAAS,CAAC;IAAAF,CAAA,MAAAE,SAAA;IAAAF,CAAA,MAAAG,EAAA;EAAA;IAAAA,EAAA,GAAAH,CAAA;EAAA;EAAjE;IAAAK;EAAA,IAAiBb,gBAAgB,CAACW,EAA+B,CAAC;EAElE,MAAAG,QAAA,GAAiBD,IAAI,CAAAA,IAAK;EAAA,IAAAE,EAAA;EAAA,IAAAP,CAAA,QAAAM,QAAA;IAGxBC,EAAA,GAAAC,WAAA,IACEF,QAAQ,CAAAG,IAAK,CAACC,OAAA,IAAWA,OAAO,CAAAC,IAAK,KAAKH,WAA8B,IAAfE,OAAO,CAAAE,OAAQ,CAAC;IAAAZ,CAAA,MAAAM,QAAA;IAAAN,CAAA,MAAAO,EAAA;EAAA;IAAAA,EAAA,GAAAP,CAAA;EAAA;EAF7E,MAAAa,cAAA,GAAu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1DhB,IAAI,EAAE,EAAE;EACRiC,KAAK,EAAE,CAAC,CAAC;EACTC,IAAI,EAAE;IACJC,KAAK,EAAE,CAAC;IACRC,UAAU,EAAE;EACd;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search_list_header_component.d.ts","sourceRoot":"","sources":["../../../../src/screens/conversations/components/search_list_header_component.tsx"],"names":[],"mappings":"AAkCA,eAAO,MAAM,yBAAyB,+CA8MrC,CAAA"}
|