@sendbird/uikit-utils 2.3.0 → 2.4.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.
Files changed (52) hide show
  1. package/lib/commonjs/hooks/index.js +38 -1
  2. package/lib/commonjs/hooks/index.js.map +1 -1
  3. package/lib/commonjs/hooks/react-native.js +5 -7
  4. package/lib/commonjs/hooks/react-native.js.map +1 -1
  5. package/lib/commonjs/index.js +25 -1
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/sendbird/channel.js +29 -1
  8. package/lib/commonjs/sendbird/channel.js.map +1 -1
  9. package/lib/commonjs/sendbird/message.js +56 -1
  10. package/lib/commonjs/sendbird/message.js.map +1 -1
  11. package/lib/commonjs/sendbird/user.js +0 -6
  12. package/lib/commonjs/sendbird/user.js.map +1 -1
  13. package/lib/commonjs/shared/index.js +12 -0
  14. package/lib/commonjs/shared/index.js.map +1 -1
  15. package/lib/commonjs/types.js.map +1 -1
  16. package/lib/commonjs/ui-format/openChannel.js +22 -0
  17. package/lib/commonjs/ui-format/openChannel.js.map +1 -0
  18. package/lib/module/hooks/index.js +29 -1
  19. package/lib/module/hooks/index.js.map +1 -1
  20. package/lib/module/hooks/react-native.js +6 -8
  21. package/lib/module/hooks/react-native.js.map +1 -1
  22. package/lib/module/index.js +8 -1
  23. package/lib/module/index.js.map +1 -1
  24. package/lib/module/sendbird/channel.js +23 -1
  25. package/lib/module/sendbird/channel.js.map +1 -1
  26. package/lib/module/sendbird/message.js +51 -1
  27. package/lib/module/sendbird/message.js.map +1 -1
  28. package/lib/module/sendbird/user.js +0 -4
  29. package/lib/module/sendbird/user.js.map +1 -1
  30. package/lib/module/shared/index.js +10 -0
  31. package/lib/module/shared/index.js.map +1 -1
  32. package/lib/module/types.js.map +1 -1
  33. package/lib/module/ui-format/openChannel.js +10 -0
  34. package/lib/module/ui-format/openChannel.js.map +1 -0
  35. package/lib/typescript/src/hooks/index.d.ts +3 -0
  36. package/lib/typescript/src/index.d.ts +7 -2
  37. package/lib/typescript/src/sendbird/channel.d.ts +10 -1
  38. package/lib/typescript/src/sendbird/message.d.ts +3 -0
  39. package/lib/typescript/src/sendbird/user.d.ts +0 -2
  40. package/lib/typescript/src/shared/index.d.ts +6 -0
  41. package/lib/typescript/src/types.d.ts +8 -3
  42. package/lib/typescript/src/ui-format/openChannel.d.ts +3 -0
  43. package/package.json +4 -4
  44. package/src/hooks/index.ts +31 -1
  45. package/src/hooks/react-native.ts +6 -8
  46. package/src/index.ts +17 -1
  47. package/src/sendbird/channel.ts +33 -2
  48. package/src/sendbird/message.ts +54 -1
  49. package/src/sendbird/user.ts +0 -7
  50. package/src/shared/index.ts +10 -0
  51. package/src/types.ts +17 -2
  52. package/src/ui-format/openChannel.ts +11 -0
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useUniqId = exports.useIsMountedRef = exports.useIsFirstMount = exports.useIIFE = exports.useFreshCallback = exports.useForceUpdate = exports.useAsyncLayoutEffect = exports.useAsyncEffect = void 0;
6
+ exports.useUniqId = exports.useUniqHandlerId = exports.usePartialState = exports.useIsMountedRef = exports.useIsFirstMount = exports.useIIFE = exports.useFreshCallback = exports.useForceUpdate = exports.useDebounceEffect = exports.useAsyncLayoutEffect = exports.useAsyncEffect = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
@@ -19,6 +19,13 @@ const useUniqId = key => {
19
19
 
20
20
  exports.useUniqId = useUniqId;
21
21
 
22
+ const useUniqHandlerId = name => {
23
+ const id = useUniqId(name);
24
+ return `${name}_${id}`;
25
+ };
26
+
27
+ exports.useUniqHandlerId = useUniqHandlerId;
28
+
22
29
  const useForceUpdate = () => {
23
30
  const [, updater] = (0, _react.useState)(0);
24
31
  return (0, _react.useCallback)(() => updater(prev => prev + 1), []);
@@ -96,4 +103,34 @@ const useFreshCallback = callback => {
96
103
  };
97
104
 
98
105
  exports.useFreshCallback = useFreshCallback;
106
+
107
+ const useDebounceEffect = function (action, delay) {
108
+ let deps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
109
+ const timeoutRef = (0, _react.useRef)();
110
+ (0, _react.useEffect)(() => {
111
+ timeoutRef.current = setTimeout(async () => {
112
+ try {
113
+ await action();
114
+ } finally {
115
+ timeoutRef.current = undefined;
116
+ }
117
+ }, delay);
118
+ return () => {
119
+ if (timeoutRef.current) {
120
+ clearTimeout(timeoutRef.current);
121
+ timeoutRef.current = undefined;
122
+ }
123
+ };
124
+ }, [delay, ...deps]);
125
+ };
126
+
127
+ exports.useDebounceEffect = useDebounceEffect;
128
+
129
+ const usePartialState = initialState => {
130
+ return (0, _react.useReducer)((prev, state) => ({ ...prev,
131
+ ...state
132
+ }), initialState);
133
+ };
134
+
135
+ exports.usePartialState = usePartialState;
99
136
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["idPool","useUniqId","key","useState","useForceUpdate","updater","useCallback","prev","useAsyncEffect","asyncEffect","deps","useEffect","createAsyncEffectCallback","useAsyncLayoutEffect","useLayoutEffect","useIIFE","callback","iife","destructor","Promise","awaitedDestructor","useIsMountedRef","isMounted","useRef","current","useIsFirstMount","isFirstMount","useFreshCallback","ref"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from 'react';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\n\ntype Destructor = () => void;\ntype AsyncEffectCallback = () => void | Destructor | Promise<void> | Promise<Destructor>;\n\nconst idPool: { [key: string]: number } = {};\nexport const useUniqId = (key: string) => {\n return useState(() => {\n if (!idPool[key]) idPool[key] = 1;\n return idPool[key]++;\n })[0];\n};\n\nexport const useForceUpdate = () => {\n const [, updater] = useState(0);\n return useCallback(() => updater((prev) => prev + 1), []);\n};\n\nexport const useAsyncEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useAsyncLayoutEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useLayoutEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useIIFE = <T>(callback: () => T) => {\n return iife(callback);\n};\nconst iife = <T extends (...args: any[]) => any>(callback: T): ReturnType<T> => callback();\nconst createAsyncEffectCallback = (asyncEffect: AsyncEffectCallback) => () => {\n const destructor = iife(asyncEffect);\n return () => {\n if (!destructor) return;\n\n if (destructor instanceof Promise) {\n iife(async () => {\n const awaitedDestructor = await destructor;\n if (awaitedDestructor) awaitedDestructor();\n });\n } else {\n iife(destructor);\n }\n };\n};\n\nexport const useIsMountedRef = () => {\n const isMounted = useRef(true);\n\n useEffect(() => {\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return isMounted;\n};\n\nexport const useIsFirstMount = () => {\n const isFirstMount = useRef(true);\n\n if (isFirstMount.current) {\n isFirstMount.current = false;\n return true;\n }\n\n return isFirstMount.current;\n};\n\nexport const useFreshCallback = <T extends (...args: any[]) => any>(callback: T): T => {\n const ref = useRef<T>(callback);\n ref.current = callback;\n return useCallback(((...args) => ref.current(...args)) as T, []);\n};\n"],"mappings":";;;;;;;AAEA;;AAFA;AAOA,MAAMA,MAAiC,GAAG,EAA1C;;AACO,MAAMC,SAAS,GAAIC,GAAD,IAAiB;EACxC,OAAO,IAAAC,eAAA,EAAS,MAAM;IACpB,IAAI,CAACH,MAAM,CAACE,GAAD,CAAX,EAAkBF,MAAM,CAACE,GAAD,CAAN,GAAc,CAAd;IAClB,OAAOF,MAAM,CAACE,GAAD,CAAN,EAAP;EACD,CAHM,EAGJ,CAHI,CAAP;AAID,CALM;;;;AAOA,MAAME,cAAc,GAAG,MAAM;EAClC,MAAM,GAAGC,OAAH,IAAc,IAAAF,eAAA,EAAS,CAAT,CAApB;EACA,OAAO,IAAAG,kBAAA,EAAY,MAAMD,OAAO,CAAEE,IAAD,IAAUA,IAAI,GAAG,CAAlB,CAAzB,EAA+C,EAA/C,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B;IACxBE,YAAY,CAACF,OAAb,GAAuB,KAAvB;IACA,OAAO,IAAP;EACD;;EAED,OAAOE,YAAY,CAACF,OAApB;AACD,CATM;;;;AAWA,MAAMG,gBAAgB,GAAuCX,QAApC,IAAuD;EACrF,MAAMY,GAAG,GAAG,IAAAL,aAAA,EAAUP,QAAV,CAAZ;EACAY,GAAG,CAACJ,OAAJ,GAAcR,QAAd;EACA,OAAO,IAAAV,kBAAA,EAAa;IAAA,OAAasB,GAAG,CAACJ,OAAJ,CAAY,YAAZ,CAAb;EAAA,CAAb,EAAsD,EAAtD,CAAP;AACD,CAJM"}
1
+ {"version":3,"names":["idPool","useUniqId","key","useState","useUniqHandlerId","name","id","useForceUpdate","updater","useCallback","prev","useAsyncEffect","asyncEffect","deps","useEffect","createAsyncEffectCallback","useAsyncLayoutEffect","useLayoutEffect","useIIFE","callback","iife","destructor","Promise","awaitedDestructor","useIsMountedRef","isMounted","useRef","current","useIsFirstMount","isFirstMount","useFreshCallback","ref","useDebounceEffect","action","delay","timeoutRef","setTimeout","undefined","clearTimeout","usePartialState","initialState","useReducer","state"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from 'react';\nimport { useCallback, useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react';\n\ntype Destructor = () => void;\ntype AsyncEffectCallback = () => void | Destructor | Promise<void> | Promise<Destructor>;\n\nconst idPool: { [key: string]: number } = {};\nexport const useUniqId = (key: string) => {\n return useState(() => {\n if (!idPool[key]) idPool[key] = 1;\n return idPool[key]++;\n })[0];\n};\n\nexport const useUniqHandlerId = (name: string) => {\n const id = useUniqId(name);\n return `${name}_${id}`;\n};\n\nexport const useForceUpdate = () => {\n const [, updater] = useState(0);\n return useCallback(() => updater((prev) => prev + 1), []);\n};\n\nexport const useAsyncEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useAsyncLayoutEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useLayoutEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useIIFE = <T>(callback: () => T) => {\n return iife(callback);\n};\nconst iife = <T extends (...args: any[]) => any>(callback: T): ReturnType<T> => callback();\nconst createAsyncEffectCallback = (asyncEffect: AsyncEffectCallback) => () => {\n const destructor = iife(asyncEffect);\n return () => {\n if (!destructor) return;\n\n if (destructor instanceof Promise) {\n iife(async () => {\n const awaitedDestructor = await destructor;\n if (awaitedDestructor) awaitedDestructor();\n });\n } else {\n iife(destructor);\n }\n };\n};\n\nexport const useIsMountedRef = () => {\n const isMounted = useRef(true);\n\n useEffect(() => {\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return isMounted;\n};\n\nexport const useIsFirstMount = () => {\n const isFirstMount = useRef(true);\n\n if (isFirstMount.current) {\n isFirstMount.current = false;\n return true;\n }\n\n return isFirstMount.current;\n};\n\nexport const useFreshCallback = <T extends (...args: any[]) => any>(callback: T): T => {\n const ref = useRef<T>(callback);\n ref.current = callback;\n return useCallback(((...args) => ref.current(...args)) as T, []);\n};\n\nexport const useDebounceEffect = (action: () => void, delay: number, deps: DependencyList = []) => {\n const timeoutRef = useRef<NodeJS.Timeout>();\n\n useEffect(() => {\n timeoutRef.current = setTimeout(async () => {\n try {\n await action();\n } finally {\n timeoutRef.current = undefined;\n }\n }, delay);\n\n return () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = undefined;\n }\n };\n }, [delay, ...deps]);\n};\n\nexport const usePartialState = <S>(initialState: S) => {\n return useReducer((prev: S, state: Partial<S>) => ({ ...prev, ...state }), initialState);\n};\n"],"mappings":";;;;;;;AAEA;;AAFA;AAOA,MAAMA,MAAiC,GAAG,EAA1C;;AACO,MAAMC,SAAS,GAAIC,GAAD,IAAiB;EACxC,OAAO,IAAAC,eAAA,EAAS,MAAM;IACpB,IAAI,CAACH,MAAM,CAACE,GAAD,CAAX,EAAk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,MAAM;MACX,IAAIC,UAAU,CAACR,OAAf,EAAwB;QACtBW,YAAY,CAACH,UAAU,CAACR,OAAZ,CAAZ;QACAQ,UAAU,CAACR,OAAX,GAAqBU,SAArB;MACD;IACF,CALD;EAMD,CAfD,EAeG,CAACH,KAAD,EAAQ,GAAGrB,IAAX,CAfH;AAgBD,CAnBM;;;;AAqBA,MAAM0B,eAAe,GAAOC,YAAJ,IAAwB;EACrD,OAAO,IAAAC,iBAAA,EAAW,CAAC/B,IAAD,EAAUgC,KAAV,MAAiC,EAAE,GAAGhC,IAAL;IAAW,GAAGgC;EAAd,CAAjC,CAAX,EAAoEF,YAApE,CAAP;AACD,CAFM"}
@@ -20,13 +20,11 @@ const edgePaddingMap = {
20
20
 
21
21
  const useSafeAreaPadding = edges => {
22
22
  const safeAreaInsets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
23
- return (0, _react.useMemo)(() => {
24
- return edges.reduce((map, edge) => {
25
- const paddingKey = edgePaddingMap[edge];
26
- map[paddingKey] = safeAreaInsets[edge];
27
- return map;
28
- }, {});
29
- }, edges);
23
+ return edges.reduce((map, edge) => {
24
+ const paddingKey = edgePaddingMap[edge];
25
+ map[paddingKey] = safeAreaInsets[edge];
26
+ return map;
27
+ }, {});
30
28
  };
31
29
 
32
30
  exports.useSafeAreaPadding = useSafeAreaPadding;
@@ -1 +1 @@
1
- {"version":3,"names":["edgePaddingMap","left","right","top","bottom","useSafeAreaPadding","edges","safeAreaInsets","useSafeAreaInsets","useMemo","reduce","map","edge","paddingKey","useAppState","type","listener","callbackRef","useRef","current","useEffect","eventListener","state","subscriber","AppState","addEventListener","remove","removeEventListener"],"sources":["react-native.ts"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\nimport { AppState, AppStateEvent, AppStateStatus } from 'react-native';\nimport { EdgeInsets, useSafeAreaInsets } from 'react-native-safe-area-context';\n\ntype EdgePaddingMap = {\n left: 'paddingLeft';\n right: 'paddingRight';\n top: 'paddingTop';\n bottom: 'paddingBottom';\n};\nconst edgePaddingMap: EdgePaddingMap = {\n left: 'paddingLeft',\n right: 'paddingRight',\n top: 'paddingTop',\n bottom: 'paddingBottom',\n};\n\nexport const useSafeAreaPadding = <\n T extends keyof EdgeInsets,\n Result extends { [key in EdgePaddingMap[T]]: EdgeInsets[T] },\n>(\n edges: T[],\n): Result => {\n const safeAreaInsets = useSafeAreaInsets();\n return useMemo(() => {\n return edges.reduce((map, edge) => {\n const paddingKey = edgePaddingMap[edge];\n map[paddingKey] = safeAreaInsets[edge];\n return map;\n }, {} as { [key in EdgePaddingMap[T]]: EdgeInsets[T] });\n }, edges) as Result;\n};\n\ntype AppStateListener = (status: AppStateStatus) => void;\n\nexport const useAppState = (type: AppStateEvent, listener: AppStateListener) => {\n const callbackRef = useRef<AppStateListener>(listener);\n callbackRef.current = listener;\n\n useEffect(() => {\n const eventListener = (state: AppStateStatus) => callbackRef.current(state);\n const subscriber = AppState.addEventListener(type, eventListener);\n\n return () => {\n // @ts-ignore\n if (subscriber?.remove) {\n subscriber.remove();\n }\n // @ts-ignore\n else if (AppState.removeEventListener) {\n // @ts-ignore\n AppState.removeEventListener(type, eventListener);\n }\n };\n }, []);\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAQA,MAAMA,cAA8B,GAAG;EACrCC,IAAI,EAAE,aAD+B;EAErCC,KAAK,EAAE,cAF8B;EAGrCC,GAAG,EAAE,YAHgC;EAIrCC,MAAM,EAAE;AAJ6B,CAAvC;;AAOO,MAAMC,kBAAkB,GAI7BC,KAJgC,IAKrB;EACX,MAAMC,cAAc,GAAG,IAAAC,6CAAA,GAAvB;EACA,OAAO,IAAAC,cAAA,EAAQ,MAAM;IACnB,OAAOH,KAAK,CAACI,MAAN,CAAa,CAACC,GAAD,EAAMC,IAAN,KAAe;MACjC,MAAMC,UAAU,GAAGb,cAAc,CAACY,IAAD,CAAjC;MACAD,GAAG,CAACE,UAAD,CAAH,GAAkBN,cAAc,CAACK,IAAD,CAAhC;MACA,OAAOD,GAAP;IACD,CAJM,EAIJ,EAJI,CAAP;EAKD,CANM,EAMJL,KANI,CAAP;AAOD,CAdM;;;;AAkBA,MAAMQ,WAAW,GAAG,CAACC,IAAD,EAAsBC,QAAtB,KAAqD;EAC9E,MAAMC,WAAW,GAAG,IAAAC,aAAA,EAAyBF,QAAzB,CAApB;EACAC,WAAW,CAACE,OAAZ,GAAsBH,QAAtB;EAEA,IAAAI,gBAAA,EAAU,MAAM;IACd,MAAMC,aAAa,GAAIC,KAAD,IAA2BL,WAAW,CAACE,OAAZ,CAAoBG,KAApB,CAAjD;;IACA,MAAMC,UAAU,GAAGC,qBAAA,CAASC,gBAAT,CAA0BV,IAA1B,EAAgCM,aAAhC,CAAnB;;IAEA,OAAO,MAAM;MACX;MACA,IAAIE,UAAJ,aAAIA,UAAJ,eAAIA,UAAU,CAAEG,MAAhB,EAAwB;QACtBH,UAAU,CAACG,MAAX;MACD,CAFD,CAGA;MAHA,KAIK,IAAIF,qBAAA,CAASG,mBAAb,EAAkC;QACrC;QACAH,qBAAA,CAASG,mBAAT,CAA6BZ,IAA7B,EAAmCM,aAAnC;MACD;IACF,CAVD;EAWD,CAfD,EAeG,EAfH;AAgBD,CApBM"}
1
+ {"version":3,"names":["edgePaddingMap","left","right","top","bottom","useSafeAreaPadding","edges","safeAreaInsets","useSafeAreaInsets","reduce","map","edge","paddingKey","useAppState","type","listener","callbackRef","useRef","current","useEffect","eventListener","state","subscriber","AppState","addEventListener","remove","removeEventListener"],"sources":["react-native.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { AppState, AppStateEvent, AppStateStatus } from 'react-native';\nimport { EdgeInsets, useSafeAreaInsets } from 'react-native-safe-area-context';\n\ntype EdgePaddingMap = {\n left: 'paddingLeft';\n right: 'paddingRight';\n top: 'paddingTop';\n bottom: 'paddingBottom';\n};\nconst edgePaddingMap: EdgePaddingMap = {\n left: 'paddingLeft',\n right: 'paddingRight',\n top: 'paddingTop',\n bottom: 'paddingBottom',\n};\n\nexport const useSafeAreaPadding = <\n T extends keyof EdgeInsets,\n Result extends { [key in EdgePaddingMap[T]]: EdgeInsets[T] },\n>(\n edges: T[],\n): Result => {\n const safeAreaInsets = useSafeAreaInsets();\n return edges.reduce((map, edge) => {\n const paddingKey = edgePaddingMap[edge];\n map[paddingKey] = safeAreaInsets[edge];\n return map;\n }, {} as { [key in EdgePaddingMap[T]]: EdgeInsets[T] }) as Result;\n};\n\ntype AppStateListener = (status: AppStateStatus) => void;\n\nexport const useAppState = (type: AppStateEvent, listener: AppStateListener) => {\n const callbackRef = useRef<AppStateListener>(listener);\n callbackRef.current = listener;\n\n useEffect(() => {\n const eventListener = (state: AppStateStatus) => callbackRef.current(state);\n const subscriber = AppState.addEventListener(type, eventListener);\n\n return () => {\n // @ts-ignore\n if (subscriber?.remove) {\n subscriber.remove();\n }\n // @ts-ignore\n else if (AppState.removeEventListener) {\n // @ts-ignore\n AppState.removeEventListener(type, eventListener);\n }\n };\n }, []);\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAQA,MAAMA,cAA8B,GAAG;EACrCC,IAAI,EAAE,aAD+B;EAErCC,KAAK,EAAE,cAF8B;EAGrCC,GAAG,EAAE,YAHgC;EAIrCC,MAAM,EAAE;AAJ6B,CAAvC;;AAOO,MAAMC,kBAAkB,GAI7BC,KAJgC,IAKrB;EACX,MAAMC,cAAc,GAAG,IAAAC,6CAAA,GAAvB;EACA,OAAOF,KAAK,CAACG,MAAN,CAAa,CAACC,GAAD,EAAMC,IAAN,KAAe;IACjC,MAAMC,UAAU,GAAGZ,cAAc,CAACW,IAAD,CAAjC;IACAD,GAAG,CAACE,UAAD,CAAH,GAAkBL,cAAc,CAACI,IAAD,CAAhC;IACA,OAAOD,GAAP;EACD,CAJM,EAIJ,EAJI,CAAP;AAKD,CAZM;;;;AAgBA,MAAMG,WAAW,GAAG,CAACC,IAAD,EAAsBC,QAAtB,KAAqD;EAC9E,MAAMC,WAAW,GAAG,IAAAC,aAAA,EAAyBF,QAAzB,CAApB;EACAC,WAAW,CAACE,OAAZ,GAAsBH,QAAtB;EAEA,IAAAI,gBAAA,EAAU,MAAM;IACd,MAAMC,aAAa,GAAIC,KAAD,IAA2BL,WAAW,CAACE,OAAZ,CAAoBG,KAApB,CAAjD;;IACA,MAAMC,UAAU,GAAGC,qBAAA,CAASC,gBAAT,CAA0BV,IAA1B,EAAgCM,aAAhC,CAAnB;;IAEA,OAAO,MAAM;MACX;MACA,IAAIE,UAAJ,aAAIA,UAAJ,eAAIA,UAAU,CAAEG,MAAhB,EAAwB;QACtBH,UAAU,CAACG,MAAX;MACD,CAFD,CAGA;MAHA,KAIK,IAAIF,qBAAA,CAASG,mBAAb,EAAkC;QACrC;QACAH,qBAAA,CAASG,mBAAT,CAA6BZ,IAA7B,EAAmCM,aAAnC;MACD;IACF,CAVD;EAWD,CAfD,EAeG,EAfH;AAgBD,CApBM"}
@@ -9,6 +9,7 @@ var _exportNames = {
9
9
  PASS: true,
10
10
  toMegabyte: true,
11
11
  isFunction: true,
12
+ ifThenOr: true,
12
13
  SBErrorCode: true,
13
14
  SBErrorMessage: true,
14
15
  Logger: true,
@@ -93,6 +94,7 @@ Object.defineProperty(exports, "getFileType", {
93
94
  return _regex.getFileType;
94
95
  }
95
96
  });
97
+ exports.ifThenOr = ifThenOr;
96
98
  Object.defineProperty(exports, "imageExtRegex", {
97
99
  enumerable: true,
98
100
  get: function () {
@@ -216,6 +218,20 @@ Object.keys(_groupChannel).forEach(function (key) {
216
218
  });
217
219
  });
218
220
 
221
+ var _openChannel = require("./ui-format/openChannel");
222
+
223
+ Object.keys(_openChannel).forEach(function (key) {
224
+ if (key === "default" || key === "__esModule") return;
225
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
226
+ if (key in exports && exports[key] === _openChannel[key]) return;
227
+ Object.defineProperty(exports, key, {
228
+ enumerable: true,
229
+ get: function () {
230
+ return _openChannel[key];
231
+ }
232
+ });
233
+ });
234
+
219
235
  var _common = require("./ui-format/common");
220
236
 
221
237
  Object.keys(_common).forEach(function (key) {
@@ -309,8 +325,16 @@ exports.toMegabyte = toMegabyte;
309
325
  const isFunction = param => typeof param === 'function';
310
326
 
311
327
  exports.isFunction = isFunction;
328
+
329
+ function ifThenOr(cond, then, or) {
330
+ if (cond) return then;
331
+ return or;
332
+ }
333
+
312
334
  const SBErrorCode = {
313
- NON_AUTHORIZED: 400108
335
+ NON_AUTHORIZED: 400108,
336
+ CHANNEL_NOT_FOUND_SERVER: 400201,
337
+ CHANNEL_NOT_FOUND_SDK: 900500
314
338
  };
315
339
  exports.SBErrorCode = SBErrorCode;
316
340
  const SBErrorMessage = {
@@ -1 +1 @@
1
- {"version":3,"names":["NOOP","ASYNC_NOOP","PASS","val","toMegabyte","byte","isFunction","param","SBErrorCode","NON_AUTHORIZED","SBErrorMessage","ACL"],"sources":["index.ts"],"sourcesContent":["export { Logger } from './shared/logger';\nexport { default as arrayToMap, arrayToMapWithGetter } from './shared/arrayToMap';\nexport { createPubSub } from './shared/pubsub';\nexport {\n urlRegexStrict,\n urlRegexRough,\n newLineRegex,\n audioExtRegex,\n videoExtRegex,\n imageExtRegex,\n getFileType,\n getFileExtension,\n replaceUrlAsComponents,\n normalizeFileName,\n emailRegex,\n phoneRegex,\n replaceWithRegex,\n createMentionTemplateRegex,\n} from './shared/regex';\nexport { BufferedRequest } from './shared/bufferedRequest';\n\nexport * from './shared';\n\nexport * from './hooks';\nexport * from './hooks/react-native';\nexport * from './ui-format/groupChannel';\nexport * from './ui-format/common';\nexport * from './sendbird/channel';\nexport * from './sendbird/message';\nexport * from './sendbird/attrs';\nexport * from './sendbird/user';\n\nexport const NOOP: () => void = () => void 0;\nexport const ASYNC_NOOP = async () => void 0;\nexport const PASS = <T>(val: T) => val;\nexport const toMegabyte = (byte: number) => byte / 1024 / 1024;\nexport const isFunction = <T>(param?: T): param is NonNullable<T> => typeof param === 'function';\nexport const SBErrorCode = {\n NON_AUTHORIZED: 400108,\n};\nexport const SBErrorMessage = {\n ACL:\n 'Sendbird provides various access control options when using the Chat SDK.\\n' +\n 'By default, the Allow retrieving user list attribute is turned on to facilitate creating sample apps.\\n' +\n 'However, this may grant access to unwanted data or operations, leading to potential security concerns.\\n' +\n 'To manage your access control settings, you can turn on or off each setting on Sendbird Dashboard.',\n};\n\nexport type {\n UserStruct,\n FilterByValueType,\n UnionToIntersection,\n OmittedValues,\n PartialDeep,\n Optional,\n ContextValue,\n SendbirdMessage,\n SendbirdChatSDK,\n SendbirdChannel,\n SendbirdBaseChannel,\n SendbirdGroupChannel,\n SendbirdOpenChannel,\n SendbirdUser,\n SendbirdMember,\n SendbirdBaseMessage,\n SendbirdUserMessage,\n SendbirdFileMessage,\n SendbirdAdminMessage,\n SendbirdGroupChannelCreateParams,\n SendbirdFileMessageCreateParams,\n SendbirdUserMessageCreateParams,\n SendbirdError,\n SendbirdMessageCollection,\n SendbirdGroupChannelCollection,\n NotificationFiles,\n NotificationMentionedUsers,\n NotificationTranslations,\n PartialNullable,\n SendbirdDataPayload,\n SendbirdPreviousMessageListQuery,\n SendbirdSendableMessage,\n SendbirdGroupChannelListQuery,\n SendbirdGroupChannelUpdateParams,\n SendbirdUserMessageUpdateParams,\n SendbirdFileMessageUpdateParams,\n SendbirdUserUpdateParams,\n SendbirdRestrictedUser,\n SendbirdReaction,\n SendbirdEmojiContainer,\n SendbirdEmoji,\n SendbirdEmojiCategory,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAgBA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;;;AAEO,MAAMA,IAAgB,GAAG,MAAM,KAAK,CAApC;;;;AACA,MAAMC,UAAU,GAAG,YAAY,KAAK,CAApC;;;;AACA,MAAMC,IAAI,GAAOC,GAAJ,IAAeA,GAA5B;;;;AACA,MAAMC,UAAU,GAAIC,IAAD,IAAkBA,IAAI,GAAG,IAAP,GAAc,IAAnD;;;;AACA,MAAMC,UAAU,GAAOC,KAAJ,IAA2C,OAAOA,KAAP,KAAiB,UAA/E;;;AACA,MAAMC,WAAW,GAAG;EACzBC,cAAc,EAAE;AADS,CAApB;;AAGA,MAAMC,cAAc,GAAG;EAC5BC,GAAG,EACD,gFACA,yGADA,GAEA,0GAFA,GAGA;AAL0B,CAAvB"}
1
+ {"version":3,"names":["NOOP","ASYNC_NOOP","PASS","val","toMegabyte","byte","isFunction","param","ifThenOr","cond","then","or","SBErrorCode","NON_AUTHORIZED","CHANNEL_NOT_FOUND_SERVER","CHANNEL_NOT_FOUND_SDK","SBErrorMessage","ACL"],"sources":["index.ts"],"sourcesContent":["export { Logger } from './shared/logger';\nexport { default as arrayToMap, arrayToMapWithGetter } from './shared/arrayToMap';\nexport { createPubSub } from './shared/pubsub';\nexport {\n urlRegexStrict,\n urlRegexRough,\n newLineRegex,\n audioExtRegex,\n videoExtRegex,\n imageExtRegex,\n getFileType,\n getFileExtension,\n replaceUrlAsComponents,\n normalizeFileName,\n emailRegex,\n phoneRegex,\n replaceWithRegex,\n createMentionTemplateRegex,\n} from './shared/regex';\nexport { BufferedRequest } from './shared/bufferedRequest';\n\nexport * from './shared';\n\nexport * from './hooks';\nexport * from './hooks/react-native';\nexport * from './ui-format/groupChannel';\nexport * from './ui-format/openChannel';\nexport * from './ui-format/common';\nexport * from './sendbird/channel';\nexport * from './sendbird/message';\nexport * from './sendbird/attrs';\nexport * from './sendbird/user';\n\nexport const NOOP: () => void = () => void 0;\nexport const ASYNC_NOOP = async () => void 0;\nexport const PASS = <T>(val: T) => val;\nexport const toMegabyte = (byte: number) => byte / 1024 / 1024;\nexport const isFunction = (param?: unknown): param is Function => typeof param === 'function';\n\nexport function ifThenOr<T>(cond: boolean, then: T): T | undefined;\nexport function ifThenOr<T, V>(cond: boolean, then: T, or: V): T | V;\nexport function ifThenOr(cond: boolean, then: unknown, or?: unknown) {\n if (cond) return then;\n return or;\n}\n\nexport const SBErrorCode = {\n NON_AUTHORIZED: 400108,\n CHANNEL_NOT_FOUND_SERVER: 400201,\n CHANNEL_NOT_FOUND_SDK: 900500,\n};\nexport const SBErrorMessage = {\n ACL:\n 'Sendbird provides various access control options when using the Chat SDK.\\n' +\n 'By default, the Allow retrieving user list attribute is turned on to facilitate creating sample apps.\\n' +\n 'However, this may grant access to unwanted data or operations, leading to potential security concerns.\\n' +\n 'To manage your access control settings, you can turn on or off each setting on Sendbird Dashboard.',\n};\n\nexport type {\n UserStruct,\n FilterByValueType,\n UnionToIntersection,\n OmittedValues,\n PartialDeep,\n Optional,\n ContextValue,\n OnBeforeHandler,\n SendbirdMessage,\n SendbirdChatSDK,\n SendbirdChannel,\n SendbirdBaseChannel,\n SendbirdGroupChannel,\n SendbirdOpenChannel,\n SendbirdUser,\n SendbirdMember,\n SendbirdBaseMessage,\n SendbirdUserMessage,\n SendbirdFileMessage,\n SendbirdAdminMessage,\n SendbirdGroupChannelCreateParams,\n SendbirdFileMessageCreateParams,\n SendbirdUserMessageCreateParams,\n SendbirdError,\n SendbirdMessageCollection,\n SendbirdGroupChannelCollection,\n NotificationFiles,\n NotificationMentionedUsers,\n NotificationTranslations,\n PartialNullable,\n SendbirdDataPayload,\n SendbirdPreviousMessageListQuery,\n SendbirdSendableMessage,\n SendbirdOpenChannelListQuery,\n SendbirdGroupChannelListQuery,\n SendbirdGroupChannelUpdateParams,\n SendbirdUserMessageUpdateParams,\n SendbirdFileMessageUpdateParams,\n SendbirdUserUpdateParams,\n SendbirdRestrictedUser,\n SendbirdReaction,\n SendbirdEmojiContainer,\n SendbirdEmoji,\n SendbirdEmojiCategory,\n SendbirdOpenChannelUpdateParams,\n SendbirdOpenChannelCreateParams,\n SendbirdParticipant,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAgBA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;;;AAEO,MAAMA,IAAgB,GAAG,MAAM,KAAK,CAApC;;;;AACA,MAAMC,UAAU,GAAG,YAAY,KAAK,CAApC;;;;AACA,MAAMC,IAAI,GAAOC,GAAJ,IAAeA,GAA5B;;;;AACA,MAAMC,UAAU,GAAIC,IAAD,IAAkBA,IAAI,GAAG,IAAP,GAAc,IAAnD;;;;AACA,MAAMC,UAAU,GAAIC,KAAD,IAAwC,OAAOA,KAAP,KAAiB,UAA5E;;;;AAIA,SAASC,QAAT,CAAkBC,IAAlB,EAAiCC,IAAjC,EAAgDC,EAAhD,EAA8D;EACnE,IAAIF,IAAJ,EAAU,OAAOC,IAAP;EACV,OAAOC,EAAP;AACD;;AAEM,MAAMC,WAAW,GAAG;EACzBC,cAAc,EAAE,MADS;EAEzBC,wBAAwB,EAAE,MAFD;EAGzBC,qBAAqB,EAAE;AAHE,CAApB;;AAKA,MAAMC,cAAc,GAAG;EAC5BC,GAAG,EACD,gFACA,yGADA,GAEA,0GAFA,GAGA;AAL0B,CAAvB"}
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.confirmAndMarkAsRead = exports.confirmAndMarkAsDelivered = void 0;
7
7
  exports.getChannelUniqId = getChannelUniqId;
8
+ exports.getDefaultGroupChannelCreateParams = getDefaultGroupChannelCreateParams;
8
9
  exports.getGroupChannelChatAvailableState = void 0;
9
10
  exports.getGroupChannels = getGroupChannels;
10
11
  exports.getMembersExcludeMe = getMembersExcludeMe;
12
+ exports.getOpenChannelChatAvailableState = void 0;
11
13
  exports.getOpenChannels = getOpenChannels;
12
14
  exports.isDefaultCoverImage = isDefaultCoverImage;
13
15
  exports.isDifferentChannel = isDifferentChannel;
@@ -26,7 +28,8 @@ function isDifferentChannel(a, b) {
26
28
  }
27
29
 
28
30
  const getGroupChannelChatAvailableState = channel => {
29
- const frozen = channel.isFrozen && channel.myRole !== 'operator';
31
+ const isOperator = channel.myRole === 'operator';
32
+ const frozen = channel.isFrozen && !isOperator;
30
33
  const muted = channel.myMutedState === 'muted';
31
34
  const disabled = frozen || muted;
32
35
  return {
@@ -38,6 +41,20 @@ const getGroupChannelChatAvailableState = channel => {
38
41
 
39
42
  exports.getGroupChannelChatAvailableState = getGroupChannelChatAvailableState;
40
43
 
44
+ const getOpenChannelChatAvailableState = async (channel, userId) => {
45
+ const isOperator = channel.isOperator(userId);
46
+ const frozen = channel.isFrozen && !isOperator;
47
+ const muted = (await channel.getMyMutedInfo()).isMuted;
48
+ const disabled = frozen || muted;
49
+ return {
50
+ disabled,
51
+ frozen,
52
+ muted
53
+ };
54
+ };
55
+
56
+ exports.getOpenChannelChatAvailableState = getOpenChannelChatAvailableState;
57
+
41
58
  const confirmAndMarkAsRead = async channels => {
42
59
  channels.filter(it => it.isGroupChannel() && it.unreadMessageCount > 0).forEach(it => _bufferedRequest.BufferedRequest.markAsRead.push(() => it.markAsRead(), it.url));
43
60
  };
@@ -69,4 +86,15 @@ function getOpenChannels(channels) {
69
86
  function getChannelUniqId(channel) {
70
87
  return channel.url;
71
88
  }
89
+
90
+ function getDefaultGroupChannelCreateParams(params) {
91
+ const createParams = {
92
+ name: '',
93
+ coverUrl: '',
94
+ isDistinct: false,
95
+ invitedUserIds: params.invitedUserIds
96
+ };
97
+ if (params.currentUserId) createParams.operatorUserIds = [params.currentUserId];
98
+ return createParams;
99
+ }
72
100
  //# sourceMappingURL=channel.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isDifferentChannel","a","b","url","getGroupChannelChatAvailableState","channel","frozen","isFrozen","myRole","muted","myMutedState","disabled","confirmAndMarkAsRead","channels","filter","it","isGroupChannel","unreadMessageCount","forEach","BufferedRequest","markAsRead","push","confirmAndMarkAsDelivered","markAsDelivered","isDefaultCoverImage","coverUrl","startsWith","getMembersExcludeMe","currentUserId","members","m","userId","getGroupChannels","c","getOpenChannels","isOpenChannel","getChannelUniqId"],"sources":["channel.ts"],"sourcesContent":["import { BufferedRequest } from '../shared/bufferedRequest';\nimport type { SendbirdBaseChannel, SendbirdChannel, SendbirdGroupChannel, SendbirdOpenChannel } from '../types';\n\n/**\n * Diff utils for channel\n * @param {SendbirdBaseChannel} [a]\n * @param {SendbirdBaseChannel} [b]\n * @returns {boolean}\n * */\nexport function isDifferentChannel<T extends SendbirdBaseChannel>(a?: T, b?: T): boolean {\n if (!a || !b) return true;\n return a.url !== b.url;\n}\n\nexport const getGroupChannelChatAvailableState = (channel: SendbirdGroupChannel) => {\n const frozen = channel.isFrozen && channel.myRole !== 'operator';\n const muted = channel.myMutedState === 'muted';\n const disabled = frozen || muted;\n return { disabled, frozen, muted };\n};\n\nexport const confirmAndMarkAsRead = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsRead.push(() => it.markAsRead(), it.url));\n};\n\nexport const confirmAndMarkAsDelivered = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsDelivered.push(() => it.markAsDelivered(), it.url));\n};\n\nexport function isDefaultCoverImage(coverUrl: string) {\n return coverUrl === '' || coverUrl.startsWith('https://static.sendbird.com/sample/cover');\n}\n\nexport function getMembersExcludeMe(channel: SendbirdGroupChannel, currentUserId?: string) {\n return channel.members.filter((m) => m.userId !== currentUserId);\n}\n\nexport function getGroupChannels(channels: SendbirdChannel[]): SendbirdGroupChannel[] {\n return channels.filter((c): c is SendbirdGroupChannel => c.isGroupChannel());\n}\n\nexport function getOpenChannels(channels: SendbirdChannel[]): SendbirdOpenChannel[] {\n return channels.filter((c): c is SendbirdOpenChannel => c.isOpenChannel());\n}\n\nexport function getChannelUniqId(channel: SendbirdChannel) {\n return channel.url;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAT,CAA2DC,CAA3D,EAAkEC,CAAlE,EAAkF;EACvF,IAAI,CAACD,CAAD,IAAM,CAACC,CAAX,EAAc,OAAO,IAAP;EACd,OAAOD,CAAC,CAACE,GAAF,KAAUD,CAAC,CAACC,GAAnB;AACD;;AAEM,MAAMC,iCAAiC,GAAIC,OAAD,IAAmC;EAClF,MAAMC,MAAM,GAAGD,OAAO,CAACE,QAAR,IAAoBF,OAAO,CAACG,MAAR,KAAmB,UAAtD;EACA,MAAMC,KAAK,GAAGJ,OAAO,CAACK,YAAR,KAAyB,OAAvC;EACA,MAAMC,QAAQ,GAAGL,MAAM,IAAIG,KAA3B;EACA,OAAO;IAAEE,QAAF;IAAYL,MAAZ;IAAoBG;EAApB,CAAP;AACD,CALM;;;;AAOA,MAAMG,oBAAoB,GAAG,MAAOC,QAAP,IAA2C;EAC7EA,QAAQ,CACLC,MADH,CACWC,EAAD,IAAoCA,EAAE,CAACC,cAAH,MAAuBD,EAAE,CAACE,kBAAH,GAAwB,CAD7F,EAEGC,OAFH,CAEYH,EAAD,IAAQI,gCAAA,CAAgBC,UAAhB,CAA2BC,IAA3B,CAAgC,MAAMN,EAAE,CAACK,UAAH,EAAtC,EAAuDL,EAAE,CAACZ,GAA1D,CAFnB;AAGD,CAJM;;;;AAMA,MAAMmB,yBAAyB,GAAG,MAAOT,QAAP,IAA2C;EAClFA,QAAQ,CACLC,MADH,CACWC,EAAD,IAAoCA,EAAE,CAACC,cAAH,MAAuBD,EAAE,CAACE,kBAAH,GAAwB,CAD7F,EAEGC,OAFH,CAEYH,EAAD,IAAQI,gCAAA,CAAgBI,eAAhB,CAAgCF,IAAhC,CAAqC,MAAMN,EAAE,CAACQ,eAAH,EAA3C,EAAiER,EAAE,CAACZ,GAApE,CAFnB;AAGD,CAJM;;;;AAMA,SAASqB,mBAAT,CAA6BC,QAA7B,EAA+C;EACpD,OAAOA,QAAQ,KAAK,EAAb,IAAmBA,QAAQ,CAACC,UAAT,CAAoB,0CAApB,CAA1B;AACD;;AAEM,SAASC,mBAAT,CAA6BtB,OAA7B,EAA4DuB,aAA5D,EAAoF;EACzF,OAAOvB,OAAO,CAACwB,OAAR,CAAgBf,MAAhB,CAAwBgB,CAAD,IAAOA,CAAC,CAACC,MAAF,KAAaH,aAA3C,CAAP;AACD;;AAEM,SAASI,gBAAT,CAA0BnB,QAA1B,EAA+E;EACpF,OAAOA,QAAQ,CAACC,MAAT,CAAiBmB,CAAD,IAAkCA,CAAC,CAACjB,cAAF,EAAlD,CAAP;AACD;;AAEM,SAASkB,eAAT,CAAyBrB,QAAzB,EAA6E;EAClF,OAAOA,QAAQ,CAACC,MAAT,CAAiBmB,CAAD,IAAiCA,CAAC,CAACE,aAAF,EAAjD,CAAP;AACD;;AAEM,SAASC,gBAAT,CAA0B/B,OAA1B,EAAoD;EACzD,OAAOA,OAAO,CAACF,GAAf;AACD"}
1
+ {"version":3,"names":["isDifferentChannel","a","b","url","getGroupChannelChatAvailableState","channel","isOperator","myRole","frozen","isFrozen","muted","myMutedState","disabled","getOpenChannelChatAvailableState","userId","getMyMutedInfo","isMuted","confirmAndMarkAsRead","channels","filter","it","isGroupChannel","unreadMessageCount","forEach","BufferedRequest","markAsRead","push","confirmAndMarkAsDelivered","markAsDelivered","isDefaultCoverImage","coverUrl","startsWith","getMembersExcludeMe","currentUserId","members","m","getGroupChannels","c","getOpenChannels","isOpenChannel","getChannelUniqId","getDefaultGroupChannelCreateParams","params","createParams","name","isDistinct","invitedUserIds","operatorUserIds"],"sources":["channel.ts"],"sourcesContent":["import { BufferedRequest } from '../shared/bufferedRequest';\nimport type {\n SendbirdBaseChannel,\n SendbirdChannel,\n SendbirdGroupChannel,\n SendbirdGroupChannelCreateParams,\n SendbirdOpenChannel,\n} from '../types';\n\n/**\n * Diff utils for channel\n * @param {SendbirdBaseChannel} [a]\n * @param {SendbirdBaseChannel} [b]\n * @returns {boolean}\n * */\nexport function isDifferentChannel<T extends SendbirdBaseChannel>(a?: T, b?: T): boolean {\n if (!a || !b) return true;\n return a.url !== b.url;\n}\n\nexport const getGroupChannelChatAvailableState = (channel: SendbirdGroupChannel) => {\n const isOperator = channel.myRole === 'operator';\n const frozen = channel.isFrozen && !isOperator;\n const muted = channel.myMutedState === 'muted';\n const disabled = frozen || muted;\n return { disabled, frozen, muted };\n};\n\nexport const getOpenChannelChatAvailableState = async (channel: SendbirdOpenChannel, userId: string) => {\n const isOperator = channel.isOperator(userId);\n const frozen = channel.isFrozen && !isOperator;\n const muted = (await channel.getMyMutedInfo()).isMuted;\n const disabled = frozen || muted;\n return { disabled, frozen, muted };\n};\n\nexport const confirmAndMarkAsRead = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsRead.push(() => it.markAsRead(), it.url));\n};\n\nexport const confirmAndMarkAsDelivered = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsDelivered.push(() => it.markAsDelivered(), it.url));\n};\n\nexport function isDefaultCoverImage(coverUrl: string) {\n return coverUrl === '' || coverUrl.startsWith('https://static.sendbird.com/sample/cover');\n}\n\nexport function getMembersExcludeMe(channel: SendbirdGroupChannel, currentUserId?: string) {\n return channel.members.filter((m) => m.userId !== currentUserId);\n}\n\nexport function getGroupChannels(channels: SendbirdChannel[]): SendbirdGroupChannel[] {\n return channels.filter((c): c is SendbirdGroupChannel => c.isGroupChannel());\n}\n\nexport function getOpenChannels(channels: SendbirdChannel[]): SendbirdOpenChannel[] {\n return channels.filter((c): c is SendbirdOpenChannel => c.isOpenChannel());\n}\n\nexport function getChannelUniqId(channel: SendbirdChannel) {\n return channel.url;\n}\n\nexport function getDefaultGroupChannelCreateParams(params: {\n invitedUserIds: string[];\n currentUserId?: string;\n}): SendbirdGroupChannelCreateParams {\n const createParams: SendbirdGroupChannelCreateParams = {\n name: '',\n coverUrl: '',\n isDistinct: false,\n invitedUserIds: params.invitedUserIds,\n };\n\n if (params.currentUserId) createParams.operatorUserIds = [params.currentUserId];\n\n return createParams;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AASA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAT,CAA2DC,CAA3D,EAAkEC,CAAlE,EAAkF;EACvF,IAAI,CAACD,CAAD,IAAM,CAACC,CAAX,EAAc,OAAO,IAAP;EACd,OAAOD,CAAC,CAACE,GAAF,KAAUD,CAAC,CAACC,GAAnB;AACD;;AAEM,MAAMC,iCAAiC,GAAIC,OAAD,IAAmC;EAClF,MAAMC,UAAU,GAAGD,OAAO,CAACE,MAAR,KAAmB,UAAtC;EACA,MAAMC,MAAM,GAAGH,OAAO,CAACI,QAAR,IAAoB,CAACH,UAApC;EACA,MAAMI,KAAK,GAAGL,OAAO,CAACM,YAAR,KAAyB,OAAvC;EACA,MAAMC,QAAQ,GAAGJ,MAAM,IAAIE,KAA3B;EACA,OAAO;IAAEE,QAAF;IAAYJ,MAAZ;IAAoBE;EAApB,CAAP;AACD,CANM;;;;AAQA,MAAMG,gCAAgC,GAAG,OAAOR,OAAP,EAAqCS,MAArC,KAAwD;EACtG,MAAMR,UAAU,GAAGD,OAAO,CAACC,UAAR,CAAmBQ,MAAnB,CAAnB;EACA,MAAMN,MAAM,GAAGH,OAAO,CAACI,QAAR,IAAoB,CAACH,UAApC;EACA,MAAMI,KAAK,GAAG,CAAC,MAA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EAAlD,CAAP;AACD;;AAEM,SAASiB,eAAT,CAAyBpB,QAAzB,EAA6E;EAClF,OAAOA,QAAQ,CAACC,MAAT,CAAiBkB,CAAD,IAAiCA,CAAC,CAACE,aAAF,EAAjD,CAAP;AACD;;AAEM,SAASC,gBAAT,CAA0BnC,OAA1B,EAAoD;EACzD,OAAOA,OAAO,CAACF,GAAf;AACD;;AAEM,SAASsC,kCAAT,CAA4CC,MAA5C,EAG8B;EACnC,MAAMC,YAA8C,GAAG;IACrDC,IAAI,EAAE,EAD+C;IAErDd,QAAQ,EAAE,EAF2C;IAGrDe,UAAU,EAAE,KAHyC;IAIrDC,cAAc,EAAEJ,MAAM,CAACI;EAJ8B,CAAvD;EAOA,IAAIJ,MAAM,CAACT,aAAX,EAA0BU,YAAY,CAACI,eAAb,GAA+B,CAACL,MAAM,CAACT,aAAR,CAA/B;EAE1B,OAAOU,YAAP;AACD"}
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.calcMessageGrouping = calcMessageGrouping;
7
7
  exports.getAvailableUriFromFileMessage = getAvailableUriFromFileMessage;
8
+ exports.getFileTypeFromMessage = getFileTypeFromMessage;
9
+ exports.getMessageType = getMessageType;
8
10
  exports.getMessageUniqId = getMessageUniqId;
9
11
  exports.getReactionCount = getReactionCount;
10
12
  exports.hasSameSender = hasSameSender;
@@ -17,6 +19,8 @@ exports.messageKeyExtractor = messageKeyExtractor;
17
19
  exports.parseSendbirdNotification = parseSendbirdNotification;
18
20
  exports.shouldRenderReaction = shouldRenderReaction;
19
21
 
22
+ var _regex = require("../shared/regex");
23
+
20
24
  var _common = require("../ui-format/common");
21
25
 
22
26
  function isNewMessage(msg, currentUserId) {
@@ -118,10 +122,61 @@ function parseSendbirdNotification(dataPayload) {
118
122
  }
119
123
 
120
124
  function shouldRenderReaction(channel, reactionEnabled) {
121
- return channel.isGroupChannel() && !channel.isBroadcast && !channel.isSuper && reactionEnabled;
125
+ if (channel.isOpenChannel()) {
126
+ return false;
127
+ }
128
+
129
+ if (channel.isGroupChannel()) {
130
+ if (channel.isBroadcast) return false;
131
+ if (channel.isSuper) return false;
132
+ }
133
+
134
+ return reactionEnabled;
122
135
  }
123
136
 
124
137
  function getReactionCount(reaction) {
125
138
  return reaction.userIds.length;
126
139
  }
140
+
141
+ function getFileTypeFromMessage(message) {
142
+ return (0, _regex.getFileType)(message.type || (0, _regex.getFileExtension)(message.name));
143
+ }
144
+
145
+ function getMessageType(message) {
146
+ if (message.isAdminMessage()) {
147
+ return 'admin';
148
+ }
149
+
150
+ if (message.isUserMessage()) {
151
+ if (message.ogMetaData) {
152
+ return 'user.opengraph';
153
+ }
154
+
155
+ return 'user';
156
+ }
157
+
158
+ if (message.isFileMessage()) {
159
+ const fileType = getFileTypeFromMessage(message);
160
+
161
+ switch (fileType) {
162
+ case 'image':
163
+ case 'video':
164
+ {
165
+ return `file.${fileType}`;
166
+ }
167
+
168
+ case 'audio':
169
+ {
170
+ return `file.${fileType}`;
171
+ }
172
+
173
+ default:
174
+ {
175
+ return 'file';
176
+ }
177
+ }
178
+ }
179
+
180
+ return 'unknown';
181
+ }
127
182
  //# sourceMappingURL=message.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isNewMessage","msg","currentUserId","myMessage","isMyMessage","isAdminMessage","updatedAt","isSendableMessage","undefined","sender","userId","sendingStatus","messageKeyExtractor","message","getMessageUniqId","messageComparator","a","b","aStatusOffset","bStatusOffset","createdAt","hasSameSender","calcMessageGrouping","groupEnabled","curr","prev","next","getPrev","getMessageTimeFormat","Date","getNext","groupWithPrev","groupWithNext","isUserMessage","isFileMessage","String","messageId","reqId","getAvailableUriFromFileMessage","url","messageParams","file","uri","isSendbirdNotification","dataPayload","Boolean","parseSendbirdNotification","sendbird","JSON","parse","shouldRenderReaction","channel","reactionEnabled","isGroupChannel","isBroadcast","isSuper","getReactionCount","reaction","userIds","length"],"sources":["message.ts"],"sourcesContent":["import type {\n SendbirdBaseChannel,\n SendbirdBaseMessage,\n SendbirdDataPayload,\n SendbirdFileMessage,\n SendbirdMessage,\n SendbirdReaction,\n SendbirdSendableMessage,\n} from '../types';\nimport { getMessageTimeFormat } from '../ui-format/common';\n\nexport function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {\n const myMessage = isMyMessage(msg, currentUserId);\n if (myMessage) return false;\n if (msg.isAdminMessage()) return false;\n return msg.updatedAt === 0;\n}\n\nexport function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {\n return msg !== undefined && msg !== null && 'sendingStatus' in msg;\n}\n\nexport function isMyMessage(msg?: SendbirdMessage | null, currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##') {\n if (!isSendableMessage(msg)) return false;\n return (\n ('sender' in msg && msg.sender?.userId === currentUserId) ||\n msg.sendingStatus === 'pending' ||\n msg.sendingStatus === 'failed' ||\n msg.sendingStatus === 'canceled'\n );\n}\n\nexport function messageKeyExtractor(message: SendbirdMessage): string {\n return getMessageUniqId(message);\n}\n\n// |-------------------|-------------------|-----------------|-------------------|\n// | sending status | reqId | messageId | createdAt |\n// |-------------------|-------------------|-----------------|-------------------|\n// | pending | timestamp(A) | 0 | timestamp(B) |\n// | canceled | timestamp(A) | 0 | ? |\n// | failed | timestamp(A) | 0 | ? |\n// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |\n// |-------------------|-------------------|-----------------|-------------------|\nexport function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {\n let aStatusOffset = 0;\n let bStatusOffset = 0;\n\n if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;\n if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;\n\n return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);\n}\n\nexport function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage) {\n if (!a || !b) return false;\n if ('sender' in a && 'sender' in b) return a.sender?.userId === b.sender?.userId;\n return false;\n}\n\nexport function calcMessageGrouping(\n groupEnabled: boolean,\n curr: SendbirdMessage,\n prev?: SendbirdMessage,\n next?: SendbirdMessage,\n) {\n const getPrev = () => {\n if (!groupEnabled) return false;\n if (!prev) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, prev)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(prev.createdAt))) return false;\n return true;\n };\n\n const getNext = () => {\n if (!groupEnabled) return false;\n if (!next) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, next)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(next.createdAt))) return false;\n return true;\n };\n\n return { groupWithPrev: getPrev(), groupWithNext: getNext() };\n}\n\nexport function getMessageUniqId(msg: SendbirdBaseMessage) {\n if (msg.isUserMessage() || msg.isFileMessage()) {\n if (msg.sendingStatus === 'succeeded') return String(msg.messageId);\n return msg.reqId;\n }\n\n return String(msg.messageId);\n}\n\nexport function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {\n if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {\n return message.messageParams.file.uri;\n }\n return message.url;\n}\n\ntype RawSendbirdDataPayload = { sendbird: string | object };\nexport function isSendbirdNotification(dataPayload?: {\n [key: string]: string | object;\n}): dataPayload is RawSendbirdDataPayload {\n if (!dataPayload) return false;\n return Boolean(dataPayload['sendbird']);\n}\n\nexport function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload {\n return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;\n}\n\nexport function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean) {\n return channel.isGroupChannel() && !channel.isBroadcast && !channel.isSuper && reactionEnabled;\n}\n\nexport function getReactionCount(reaction: SendbirdReaction) {\n return reaction.userIds.length;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AASA;;AAEO,SAASA,YAAT,CAAsBC,GAAtB,EAA4CC,aAA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A4DC,eAA5D,EAAsF;EAC3F,OAAOD,OAAO,CAACE,cAAR,MAA4B,CAACF,OAAO,CAACG,WAArC,IAAoD,CAACH,OAAO,CAACI,OAA7D,IAAwEH,eAA/E;AACD;;AAEM,SAASI,gBAAT,CAA0BC,QAA1B,EAAsD;EAC3D,OAAOA,QAAQ,CAACC,OAAT,CAAiBC,MAAxB;AACD"}
1
+ {"version":3,"names":["isNewMessage","msg","currentUserId","myMessage","isMyMessage","isAdminMessage","updatedAt","isSendableMessage","undefined","sender","userId","sendingStatus","messageKeyExtractor","message","getMessageUniqId","messageComparator","a","b","aStatusOffset","bStatusOffset","createdAt","hasSameSender","calcMessageGrouping","groupEnabled","curr","prev","next","getPrev","getMessageTimeFormat","Date","getNext","groupWithPrev","groupWithNext","isUserMessage","isFileMessage","String","messageId","reqId","getAvailableUriFromFileMessage","url","messageParams","file","uri","isSendbirdNotification","dataPayload","Boolean","parseSendbirdNotification","sendbird","JSON","parse","shouldRenderReaction","channel","reactionEnabled","isOpenChannel","isGroupChannel","isBroadcast","isSuper","getReactionCount","reaction","userIds","length","getFileTypeFromMessage","getFileType","type","getFileExtension","name","getMessageType","ogMetaData","fileType"],"sources":["message.ts"],"sourcesContent":["import { getFileExtension, getFileType } from '../shared/regex';\nimport type {\n SendbirdBaseChannel,\n SendbirdBaseMessage,\n SendbirdDataPayload,\n SendbirdFileMessage,\n SendbirdMessage,\n SendbirdReaction,\n SendbirdSendableMessage,\n} from '../types';\nimport { getMessageTimeFormat } from '../ui-format/common';\n\nexport function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {\n const myMessage = isMyMessage(msg, currentUserId);\n if (myMessage) return false;\n if (msg.isAdminMessage()) return false;\n return msg.updatedAt === 0;\n}\n\nexport function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {\n return msg !== undefined && msg !== null && 'sendingStatus' in msg;\n}\n\nexport function isMyMessage(msg?: SendbirdMessage | null, currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##') {\n if (!isSendableMessage(msg)) return false;\n return (\n ('sender' in msg && msg.sender?.userId === currentUserId) ||\n msg.sendingStatus === 'pending' ||\n msg.sendingStatus === 'failed' ||\n msg.sendingStatus === 'canceled'\n );\n}\n\nexport function messageKeyExtractor(message: SendbirdMessage): string {\n return getMessageUniqId(message);\n}\n\n// |-------------------|-------------------|-----------------|-------------------|\n// | sending status | reqId | messageId | createdAt |\n// |-------------------|-------------------|-----------------|-------------------|\n// | pending | timestamp(A) | 0 | timestamp(B) |\n// | canceled | timestamp(A) | 0 | ? |\n// | failed | timestamp(A) | 0 | ? |\n// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |\n// |-------------------|-------------------|-----------------|-------------------|\nexport function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {\n let aStatusOffset = 0;\n let bStatusOffset = 0;\n\n if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;\n if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;\n\n return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);\n}\n\nexport function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage) {\n if (!a || !b) return false;\n if ('sender' in a && 'sender' in b) return a.sender?.userId === b.sender?.userId;\n return false;\n}\n\nexport function calcMessageGrouping(\n groupEnabled: boolean,\n curr: SendbirdMessage,\n prev?: SendbirdMessage,\n next?: SendbirdMessage,\n) {\n const getPrev = () => {\n if (!groupEnabled) return false;\n if (!prev) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, prev)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(prev.createdAt))) return false;\n return true;\n };\n\n const getNext = () => {\n if (!groupEnabled) return false;\n if (!next) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, next)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(next.createdAt))) return false;\n return true;\n };\n\n return { groupWithPrev: getPrev(), groupWithNext: getNext() };\n}\n\nexport function getMessageUniqId(msg: SendbirdBaseMessage) {\n if (msg.isUserMessage() || msg.isFileMessage()) {\n if (msg.sendingStatus === 'succeeded') return String(msg.messageId);\n return msg.reqId;\n }\n\n return String(msg.messageId);\n}\n\nexport function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {\n if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {\n return message.messageParams.file.uri;\n }\n return message.url;\n}\n\ntype RawSendbirdDataPayload = { sendbird: string | object };\nexport function isSendbirdNotification(dataPayload?: {\n [key: string]: string | object;\n}): dataPayload is RawSendbirdDataPayload {\n if (!dataPayload) return false;\n return Boolean(dataPayload['sendbird']);\n}\n\nexport function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload {\n return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;\n}\n\nexport function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean) {\n if (channel.isOpenChannel()) {\n return false;\n }\n\n if (channel.isGroupChannel()) {\n if (channel.isBroadcast) return false;\n if (channel.isSuper) return false;\n }\n\n return reactionEnabled;\n}\n\nexport function getReactionCount(reaction: SendbirdReaction) {\n return reaction.userIds.length;\n}\n\ntype MessageType =\n | 'user'\n | 'admin'\n | 'file'\n | 'unknown'\n | `user.${'opengraph'}`\n | `file.${'image' | 'video' | 'audio'}`;\n\nexport function getFileTypeFromMessage(message: SendbirdFileMessage) {\n return getFileType(message.type || getFileExtension(message.name));\n}\n\nexport function getMessageType(message: SendbirdMessage): MessageType {\n if (message.isAdminMessage()) {\n return 'admin';\n }\n\n if (message.isUserMessage()) {\n if (message.ogMetaData) {\n return 'user.opengraph';\n }\n return 'user';\n }\n\n if (message.isFileMessage()) {\n const fileType = getFileTypeFromMessage(message);\n switch (fileType) {\n case 'image':\n case 'video': {\n return `file.${fileType}`;\n }\n case 'audio': {\n return `file.${fileType}`;\n }\n default: {\n return 'file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ED,OAAO,SAAP;AACD"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getUserUniqId = getUserUniqId;
7
- exports.ifMuted = ifMuted;
8
7
  exports.ifOperator = ifOperator;
9
8
 
10
9
  function ifOperator(role, then, or) {
@@ -12,11 +11,6 @@ function ifOperator(role, then, or) {
12
11
  return or;
13
12
  }
14
13
 
15
- function ifMuted(muted, then, or) {
16
- if (muted) return then;
17
- return or;
18
- }
19
-
20
14
  function getUserUniqId(user) {
21
15
  return user.userId;
22
16
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ifOperator","role","then","or","ifMuted","muted","getUserUniqId","user","userId"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nimport type { UserStruct } from '../types';\n\nexport function ifOperator<T>(role: Role, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role, then: T, or: V): T | V;\nexport function ifOperator(role: Role, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function ifMuted<T>(muted: boolean, then: T): T | undefined;\nexport function ifMuted<T, V>(muted: boolean, then: T, or: V): T | V;\nexport function ifMuted(muted: boolean, then: unknown, or?: unknown) {\n if (muted) return then;\n return or;\n}\n\nexport function getUserUniqId<T extends UserStruct>(user: T) {\n return user.userId;\n}\n"],"mappings":";;;;;;;;;AAMO,SAASA,UAAT,CAAoBC,IAApB,EAAgCC,IAAhC,EAA+CC,EAA/C,EAA6D;EAClE,IAAIF,IAAI,KAAK,UAAb,EAAyB,OAAOC,IAAP;EACzB,OAAOC,EAAP;AACD;;AAIM,SAASC,OAAT,CAAiBC,KAAjB,EAAiCH,IAAjC,EAAgDC,EAAhD,EAA8D;EACnE,IAAIE,KAAJ,EAAW,OAAOH,IAAP;EACX,OAAOC,EAAP;AACD;;AAEM,SAASG,aAAT,CAA6CC,IAA7C,EAAsD;EAC3D,OAAOA,IAAI,CAACC,MAAZ;AACD"}
1
+ {"version":3,"names":["ifOperator","role","then","or","getUserUniqId","user","userId"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nimport type { UserStruct } from '../types';\n\nexport function ifOperator<T>(role: Role, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role, then: T, or: V): T | V;\nexport function ifOperator(role: Role, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function getUserUniqId<T extends UserStruct>(user: T) {\n return user.userId;\n}\n"],"mappings":";;;;;;;;AAMO,SAASA,UAAT,CAAoBC,IAApB,EAAgCC,IAAhC,EAA+CC,EAA/C,EAA6D;EAClE,IAAIF,IAAI,KAAK,UAAb,EAAyB,OAAOC,IAAP;EACzB,OAAOC,EAAP;AACD;;AAEM,SAASC,aAAT,CAA6CC,IAA7C,EAAsD;EAC3D,OAAOA,IAAI,CAACC,MAAZ;AACD"}
@@ -7,6 +7,7 @@ exports.conditionChaining = conditionChaining;
7
7
  exports.getDownscaleSize = getDownscaleSize;
8
8
  exports.hash = hash;
9
9
  exports.isImage = isImage;
10
+ exports.pick = pick;
10
11
  exports.replace = replace;
11
12
  exports.shouldCompressImage = shouldCompressImage;
12
13
 
@@ -71,4 +72,15 @@ function shouldCompressImage(filePath) {
71
72
  const extension = (0, _regex.getFileExtension)(filePath);
72
73
  return Boolean(extension.match(/jpg|jpeg|png/i) && compressionEnabled);
73
74
  }
75
+ /**
76
+ * Returns the picked data from object.
77
+ * */
78
+
79
+
80
+ function pick(obj, keys) {
81
+ return keys.reduce((pickedObj, key) => {
82
+ pickedObj[key] = obj[key];
83
+ return pickedObj;
84
+ }, {});
85
+ }
74
86
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["hash","str","String","Math","abs","split","reduce","a","c","charCodeAt","replace","start","end","text","slice","conditionChaining","conditions","values","idx","findIndex","state","Boolean","length","getDownscaleSize","origin","resizing","ratio","maxWidth","width","maxHeight","height","max","isImage","filePath","mimeType","type","getFileType","getFileExtension","shouldCompressImage","compressionEnabled","extension","match"],"sources":["index.ts"],"sourcesContent":["import { getFileExtension, getFileType } from './regex';\n\n/**\n * Converts a given string to a hashed string.\n * */\nexport function hash(str: string) {\n return String(Math.abs(str.split('').reduce((a, c) => ((a << 5) - a + c.charCodeAt(0)) | 0, 0)));\n}\n\n/**\n * Replace a specific range of text in the string with another text.\n * */\nexport function replace(str: string, start: number, end: number, text: string) {\n return str.slice(0, start) + text + str.slice(end);\n}\n\n/**\n * Returns the value corresponding to the first true index of a given condition array.\n * */\nexport function conditionChaining<T, V>(conditions: T[], values: V[]) {\n const idx = conditions.findIndex((state) => Boolean(state));\n return idx > -1 ? values[idx] : values[values.length - 1];\n}\n\n/**\n * Calculates the downscale size.\n * */\ntype Size = { width: number; height: number };\nexport function getDownscaleSize(origin: Size, resizing: Partial<Size>) {\n let ratio;\n\n const maxWidth = resizing.width || origin.width,\n maxHeight = resizing.height || origin.height;\n\n if (origin.width <= maxWidth && origin.height <= maxHeight) {\n ratio = 1;\n } else if (origin.width > maxWidth && origin.height <= maxHeight) {\n ratio = maxWidth / origin.width;\n } else if (origin.width <= maxWidth && origin.height > maxHeight) {\n ratio = maxHeight / origin.height;\n } else {\n ratio = Math.max(maxWidth / origin.width, maxHeight / origin.height);\n }\n\n return { width: origin.width * ratio, height: origin.height * ratio };\n}\n\nexport function isImage(filePath: string, mimeType?: string) {\n const type = getFileType(mimeType || getFileExtension(filePath));\n return type === 'image';\n}\n\nexport function shouldCompressImage(filePath: string, compressionEnabled = true) {\n const extension = getFileExtension(filePath);\n return Boolean(extension.match(/jpg|jpeg|png/i) && compressionEnabled);\n}\n"],"mappings":";;;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AACO,SAASA,IAAT,CAAcC,GAAd,EAA2B;EAChC,OAAOC,MAAM,CAACC,IAAI,CAACC,GAAL,CAASH,GAAG,CAACI,KAAJ,CAAU,EAAV,EAAcC,MAAd,CAAqB,CAACC,CAAD,EAAIC,CAAJ,KAAW,CAACD,CAAC,IA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,QAAhB,IAA4BH,MAAM,CAACM,MAAP,GAAgBD,SAAhD,EAA2D;IAChEH,KAAK,GAAGG,SAAS,GAAGL,MAAM,CAACM,MAA3B;EACD,CAFM,MAEA;IACLJ,KAAK,GAAGvB,IAAI,CAAC4B,GAAL,CAASJ,QAAQ,GAAGH,MAAM,CAACI,KAA3B,EAAkCC,SAAS,GAAGL,MAAM,CAACM,MAArD,CAAR;EACD;;EAED,OAAO;IAAEF,KAAK,EAAEJ,MAAM,CAACI,KAAP,GAAeF,KAAxB;IAA+BI,MAAM,EAAEN,MAAM,CAACM,MAAP,GAAgBJ;EAAvD,CAAP;AACD;;AAEM,SAASM,OAAT,CAAiBC,QAAjB,EAAmCC,QAAnC,EAAsD;EAC3D,MAAMC,IAAI,GAAG,IAAAC,kBAAA,EAAYF,QAAQ,IAAI,IAAAG,uBAAA,EAAiBJ,QAAjB,CAAxB,CAAb;EACA,OAAOE,IAAI,KAAK,OAAhB;AACD;;AAEM,SAASG,mBAAT,CAA6BL,QAA7B,EAA0E;EAAA,IAA3BM,kBAA2B,uEAAN,IAAM;EAC/E,MAAMC,SAAS,GAAG,IAAAH,uBAAA,EAAiBJ,QAAjB,CAAlB;EACA,OAAOZ,OAAO,CAACmB,SAAS,CAACC,KAAV,CAAgB,eAAhB,KAAoCF,kBAArC,CAAd;AACD"}
1
+ {"version":3,"names":["hash","str","String","Math","abs","split","reduce","a","c","charCodeAt","replace","start","end","text","slice","conditionChaining","conditions","values","idx","findIndex","state","Boolean","length","getDownscaleSize","origin","resizing","ratio","maxWidth","width","maxHeight","height","max","isImage","filePath","mimeType","type","getFileType","getFileExtension","shouldCompressImage","compressionEnabled","extension","match","pick","obj","keys","pickedObj","key"],"sources":["index.ts"],"sourcesContent":["import { getFileExtension, getFileType } from './regex';\n\n/**\n * Converts a given string to a hashed string.\n * */\nexport function hash(str: string) {\n return String(Math.abs(str.split('').reduce((a, c) => ((a << 5) - a + c.charCodeAt(0)) | 0, 0)));\n}\n\n/**\n * Replace a specific range of text in the string with another text.\n * */\nexport function replace(str: string, start: number, end: number, text: string) {\n return str.slice(0, start) + text + str.slice(end);\n}\n\n/**\n * Returns the value corresponding to the first true index of a given condition array.\n * */\nexport function conditionChaining<T, V>(conditions: T[], values: V[]) {\n const idx = conditions.findIndex((state) => Boolean(state));\n return idx > -1 ? values[idx] : values[values.length - 1];\n}\n\n/**\n * Calculates the downscale size.\n * */\ntype Size = { width: number; height: number };\nexport function getDownscaleSize(origin: Size, resizing: Partial<Size>) {\n let ratio;\n\n const maxWidth = resizing.width || origin.width,\n maxHeight = resizing.height || origin.height;\n\n if (origin.width <= maxWidth && origin.height <= maxHeight) {\n ratio = 1;\n } else if (origin.width > maxWidth && origin.height <= maxHeight) {\n ratio = maxWidth / origin.width;\n } else if (origin.width <= maxWidth && origin.height > maxHeight) {\n ratio = maxHeight / origin.height;\n } else {\n ratio = Math.max(maxWidth / origin.width, maxHeight / origin.height);\n }\n\n return { width: origin.width * ratio, height: origin.height * ratio };\n}\n\nexport function isImage(filePath: string, mimeType?: string) {\n const type = getFileType(mimeType || getFileExtension(filePath));\n return type === 'image';\n}\n\nexport function shouldCompressImage(filePath: string, compressionEnabled = true) {\n const extension = getFileExtension(filePath);\n return Boolean(extension.match(/jpg|jpeg|png/i) && compressionEnabled);\n}\n\n/**\n * Returns the picked data from object.\n * */\nexport function pick<T extends { [key: string]: unknown }, Keys extends keyof T>(obj: T, keys: Keys[]) {\n return keys.reduce((pickedObj, key) => {\n pickedObj[key] = obj[key];\n return pickedObj;\n }, {} as { [key in Keys]: T[key] });\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AACO,SAASA,IAAT,CAAcC,GAAd,EAA2B;EAChC,OAAOC,MAAM,CAACC,IAAI,CAACC,GAAL,CAASH,GAAG,CAACI,KAAJ,CAAU,EAAV,EAAcC,MAAd,CAAqB,CAACC,CAAD,EAAIC,CAAJ,KAAW,CAACD,CAAC,IAAI,CAAN,IAAWA,CAAX,GA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ACM,MAAP,GAAgBD,SAAhD,EAA2D;IAChEH,KAAK,GAAGG,SAAS,GAAGL,MAAM,CAACM,MAA3B;EACD,CAFM,MAEA;IACLJ,KAAK,GAAGvB,IAAI,CAAC4B,GAAL,CAASJ,QAAQ,GAAGH,MAAM,CAACI,KAA3B,EAAkCC,SAAS,GAAGL,MAAM,CAACM,MAArD,CAAR;EACD;;EAED,OAAO;IAAEF,KAAK,EAAEJ,MAAM,CAACI,KAAP,GAAeF,KAAxB;IAA+BI,MAAM,EAAEN,MAAM,CAACM,MAAP,GAAgBJ;EAAvD,CAAP;AACD;;AAEM,SAASM,OAAT,CAAiBC,QAAjB,EAAmCC,QAAnC,EAAsD;EAC3D,MAAMC,IAAI,GAAG,IAAAC,kBAAA,EAAYF,QAAQ,IAAI,IAAAG,uBAAA,EAAiBJ,QAAjB,CAAxB,CAAb;EACA,OAAOE,IAAI,KAAK,OAAhB;AACD;;AAEM,SAASG,mBAAT,CAA6BL,QAA7B,EAA0E;EAAA,IAA3BM,kBAA2B,uEAAN,IAAM;EAC/E,MAAMC,SAAS,GAAG,IAAAH,uBAAA,EAAiBJ,QAAjB,CAAlB;EACA,OAAOZ,OAAO,CAACmB,SAAS,CAACC,KAAV,CAAgB,eAAhB,KAAoCF,kBAArC,CAAd;AACD;AAED;AACA;AACA;;;AACO,SAASG,IAAT,CAA0EC,GAA1E,EAAkFC,IAAlF,EAAgG;EACrG,OAAOA,IAAI,CAACtC,MAAL,CAAY,CAACuC,SAAD,EAAYC,GAAZ,KAAoB;IACrCD,SAAS,CAACC,GAAD,CAAT,GAAiBH,GAAG,CAACG,GAAD,CAApB;IACA,OAAOD,SAAP;EACD,CAHM,EAGJ,EAHI,CAAP;AAID"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {\n BaseChannel,\n Emoji,\n EmojiCategory,\n EmojiContainer,\n RestrictedUser,\n SendbirdError as SBError,\n User,\n UserUpdateParams,\n} from '@sendbird/chat';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type { ModuleNamespaces, SendableMessage } from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n PreviousMessageListQuery,\n Reaction,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport interface UserStruct {\n userId: string;\n}\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\n\nexport type SendbirdReaction = Reaction;\nexport type SendbirdEmoji = Emoji;\nexport type SendbirdEmojiCategory = EmojiCategory;\nexport type SendbirdEmojiContainer = EmojiContainer;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {\n BaseChannel,\n Emoji,\n EmojiCategory,\n EmojiContainer,\n Participant,\n RestrictedUser,\n SendbirdError as SBError,\n User,\n UserUpdateParams,\n} from '@sendbird/chat';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type {\n ModuleNamespaces,\n OpenChannelCreateParams,\n OpenChannelUpdateParams,\n SendableMessage,\n} from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n PreviousMessageListQuery,\n Reaction,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelListQuery, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport type OnBeforeHandler<T> = (params: T) => T | Promise<T>;\n\nexport interface UserStruct {\n userId: string;\n}\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\n\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdOpenChannelCreateParams = OpenChannelCreateParams;\nexport type SendbirdOpenChannelUpdateParams = OpenChannelUpdateParams;\n\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdParticipant = Participant;\n\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\n\nexport type SendbirdReaction = Reaction;\nexport type SendbirdEmoji = Emoji;\nexport type SendbirdEmojiCategory = EmojiCategory;\nexport type SendbirdEmojiContainer = EmojiContainer;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdOpenChannelListQuery = OpenChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":""}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getOpenChannelTitle = exports.getOpenChannelParticipants = void 0;
7
+
8
+ const getOpenChannelTitle = function (channel) {
9
+ let DEFAULT_CHANNEL_NAME = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Open Channel';
10
+ const trimmedChannelName = channel.name.trim();
11
+ if (trimmedChannelName === '') return DEFAULT_CHANNEL_NAME;
12
+ return trimmedChannelName;
13
+ };
14
+
15
+ exports.getOpenChannelTitle = getOpenChannelTitle;
16
+
17
+ const getOpenChannelParticipants = channel => {
18
+ return `${channel.participantCount} participants`;
19
+ };
20
+
21
+ exports.getOpenChannelParticipants = getOpenChannelParticipants;
22
+ //# sourceMappingURL=openChannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getOpenChannelTitle","channel","DEFAULT_CHANNEL_NAME","trimmedChannelName","name","trim","getOpenChannelParticipants","participantCount"],"sources":["openChannel.ts"],"sourcesContent":["import type { SendbirdOpenChannel } from '../types';\n\nexport const getOpenChannelTitle = (channel: SendbirdOpenChannel, DEFAULT_CHANNEL_NAME = 'Open Channel') => {\n const trimmedChannelName = channel.name.trim();\n if (trimmedChannelName === '') return DEFAULT_CHANNEL_NAME;\n return trimmedChannelName;\n};\n\nexport const getOpenChannelParticipants = (channel: SendbirdOpenChannel) => {\n return `${channel.participantCount} participants`;\n};\n"],"mappings":";;;;;;;AAEO,MAAMA,mBAAmB,GAAG,UAACC,OAAD,EAAyE;EAAA,IAA1CC,oBAA0C,uEAAnB,cAAmB;EAC1G,MAAMC,kBAAkB,GAAGF,OAAO,CAACG,IAAR,CAAaC,IAAb,EAA3B;EACA,IAAIF,kBAAkB,KAAK,EAA3B,EAA+B,OAAOD,oBAAP;EAC/B,OAAOC,kBAAP;AACD,CAJM;;;;AAMA,MAAMG,0BAA0B,GAAIL,OAAD,IAAkC;EAC1E,OAAQ,GAAEA,OAAO,CAACM,gBAAiB,eAAnC;AACD,CAFM"}
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
2
+ import { useCallback, useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react';
3
3
  const idPool = {};
4
4
  export const useUniqId = key => {
5
5
  return useState(() => {
@@ -7,6 +7,10 @@ export const useUniqId = key => {
7
7
  return idPool[key]++;
8
8
  })[0];
9
9
  };
10
+ export const useUniqHandlerId = name => {
11
+ const id = useUniqId(name);
12
+ return `${name}_${id}`;
13
+ };
10
14
  export const useForceUpdate = () => {
11
15
  const [, updater] = useState(0);
12
16
  return useCallback(() => updater(prev => prev + 1), []);
@@ -65,4 +69,28 @@ export const useFreshCallback = callback => {
65
69
  return ref.current(...arguments);
66
70
  }, []);
67
71
  };
72
+ export const useDebounceEffect = function (action, delay) {
73
+ let deps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
74
+ const timeoutRef = useRef();
75
+ useEffect(() => {
76
+ timeoutRef.current = setTimeout(async () => {
77
+ try {
78
+ await action();
79
+ } finally {
80
+ timeoutRef.current = undefined;
81
+ }
82
+ }, delay);
83
+ return () => {
84
+ if (timeoutRef.current) {
85
+ clearTimeout(timeoutRef.current);
86
+ timeoutRef.current = undefined;
87
+ }
88
+ };
89
+ }, [delay, ...deps]);
90
+ };
91
+ export const usePartialState = initialState => {
92
+ return useReducer((prev, state) => ({ ...prev,
93
+ ...state
94
+ }), initialState);
95
+ };
68
96
  //# sourceMappingURL=index.js.map