@sendbird/uikit-chat-hooks 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +2 -2
  2. package/lib/commonjs/channel/useGroupChannel.js +0 -4
  3. package/lib/commonjs/channel/useGroupChannel.js.map +1 -1
  4. package/lib/commonjs/channel/useGroupChannelList/index.js +0 -5
  5. package/lib/commonjs/channel/useGroupChannelList/index.js.map +1 -1
  6. package/lib/commonjs/channel/useGroupChannelList/reducer.js +12 -29
  7. package/lib/commonjs/channel/useGroupChannelList/reducer.js.map +1 -1
  8. package/lib/commonjs/channel/useGroupChannelList/useGroupChannelListWithCollection.js +1 -22
  9. package/lib/commonjs/channel/useGroupChannelList/useGroupChannelListWithCollection.js.map +1 -1
  10. package/lib/commonjs/channel/useGroupChannelList/useGroupChannelListWithQuery.js +1 -18
  11. package/lib/commonjs/channel/useGroupChannelList/useGroupChannelListWithQuery.js.map +1 -1
  12. package/lib/commonjs/channel/useGroupChannelMessages/index.js +0 -5
  13. package/lib/commonjs/channel/useGroupChannelMessages/index.js.map +1 -1
  14. package/lib/commonjs/channel/useGroupChannelMessages/reducer.js +18 -28
  15. package/lib/commonjs/channel/useGroupChannelMessages/reducer.js.map +1 -1
  16. package/lib/commonjs/channel/useGroupChannelMessages/useGroupChannelMessagesWithCollection.js +8 -37
  17. package/lib/commonjs/channel/useGroupChannelMessages/useGroupChannelMessagesWithCollection.js.map +1 -1
  18. package/lib/commonjs/channel/useGroupChannelMessages/useGroupChannelMessagesWithQuery.js +21 -49
  19. package/lib/commonjs/channel/useGroupChannelMessages/useGroupChannelMessagesWithQuery.js.map +1 -1
  20. package/lib/commonjs/channel/useOpenChannel.js +0 -4
  21. package/lib/commonjs/channel/useOpenChannel.js.map +1 -1
  22. package/lib/commonjs/channel/useOpenChannelList/index.js +0 -3
  23. package/lib/commonjs/channel/useOpenChannelList/index.js.map +1 -1
  24. package/lib/commonjs/channel/useOpenChannelList/reducer.js +2 -21
  25. package/lib/commonjs/channel/useOpenChannelList/reducer.js.map +1 -1
  26. package/lib/commonjs/channel/useOpenChannelList/useOpenChannelListWithQuery.js +1 -18
  27. package/lib/commonjs/channel/useOpenChannelList/useOpenChannelListWithQuery.js.map +1 -1
  28. package/lib/commonjs/channel/useOpenChannelMessages/index.js +0 -3
  29. package/lib/commonjs/channel/useOpenChannelMessages/index.js.map +1 -1
  30. package/lib/commonjs/channel/useOpenChannelMessages/reducer.js +18 -28
  31. package/lib/commonjs/channel/useOpenChannelMessages/reducer.js.map +1 -1
  32. package/lib/commonjs/channel/useOpenChannelMessages/useOpenChannelMessagesWithQuery.js +1 -30
  33. package/lib/commonjs/channel/useOpenChannelMessages/useOpenChannelMessagesWithQuery.js.map +1 -1
  34. package/lib/commonjs/common/useAppFeatures.js +0 -3
  35. package/lib/commonjs/common/useAppFeatures.js.map +1 -1
  36. package/lib/commonjs/common/useMessageOutgoingStatus.js +0 -11
  37. package/lib/commonjs/common/useMessageOutgoingStatus.js.map +1 -1
  38. package/lib/commonjs/common/usePushTrigger.js +0 -6
  39. package/lib/commonjs/common/usePushTrigger.js.map +1 -1
  40. package/lib/commonjs/common/useTotalUnreadMessageCount.js +0 -7
  41. package/lib/commonjs/common/useTotalUnreadMessageCount.js.map +1 -1
  42. package/lib/commonjs/common/useUserList.js +3 -18
  43. package/lib/commonjs/common/useUserList.js.map +1 -1
  44. package/lib/commonjs/handler/useChannelHandler.js +15 -41
  45. package/lib/commonjs/handler/useChannelHandler.js.map +1 -1
  46. package/lib/commonjs/handler/useConnectionHandler.js +14 -11
  47. package/lib/commonjs/handler/useConnectionHandler.js.map +1 -1
  48. package/lib/commonjs/handler/useUserEventHandler.js +0 -8
  49. package/lib/commonjs/handler/useUserEventHandler.js.map +1 -1
  50. package/lib/commonjs/index.js +0 -23
  51. package/lib/commonjs/index.js.map +1 -1
  52. package/lib/commonjs/model/CustomQuery.js +0 -6
  53. package/lib/commonjs/model/CustomQuery.js.map +1 -1
  54. package/lib/module/channel/useGroupChannel.js.map +1 -1
  55. package/lib/module/channel/useGroupChannelList/index.js.map +1 -1
  56. package/lib/module/channel/useGroupChannelList/reducer.js +12 -26
  57. package/lib/module/channel/useGroupChannelList/reducer.js.map +1 -1
  58. package/lib/module/channel/useGroupChannelList/useGroupChannelListWithCollection.js +1 -15
  59. package/lib/module/channel/useGroupChannelList/useGroupChannelListWithCollection.js.map +1 -1
  60. package/lib/module/channel/useGroupChannelList/useGroupChannelListWithQuery.js +1 -11
  61. package/lib/module/channel/useGroupChannelList/useGroupChannelListWithQuery.js.map +1 -1
  62. package/lib/module/channel/useGroupChannelMessages/index.js.map +1 -1
  63. package/lib/module/channel/useGroupChannelMessages/reducer.js +18 -25
  64. package/lib/module/channel/useGroupChannelMessages/reducer.js.map +1 -1
  65. package/lib/module/channel/useGroupChannelMessages/useGroupChannelMessagesWithCollection.js +9 -30
  66. package/lib/module/channel/useGroupChannelMessages/useGroupChannelMessagesWithCollection.js.map +1 -1
  67. package/lib/module/channel/useGroupChannelMessages/useGroupChannelMessagesWithQuery.js +23 -46
  68. package/lib/module/channel/useGroupChannelMessages/useGroupChannelMessagesWithQuery.js.map +1 -1
  69. package/lib/module/channel/useOpenChannel.js.map +1 -1
  70. package/lib/module/channel/useOpenChannelList/index.js.map +1 -1
  71. package/lib/module/channel/useOpenChannelList/reducer.js +2 -18
  72. package/lib/module/channel/useOpenChannelList/reducer.js.map +1 -1
  73. package/lib/module/channel/useOpenChannelList/useOpenChannelListWithQuery.js +1 -13
  74. package/lib/module/channel/useOpenChannelList/useOpenChannelListWithQuery.js.map +1 -1
  75. package/lib/module/channel/useOpenChannelMessages/index.js.map +1 -1
  76. package/lib/module/channel/useOpenChannelMessages/reducer.js +18 -25
  77. package/lib/module/channel/useOpenChannelMessages/reducer.js.map +1 -1
  78. package/lib/module/channel/useOpenChannelMessages/useOpenChannelMessagesWithQuery.js +1 -25
  79. package/lib/module/channel/useOpenChannelMessages/useOpenChannelMessagesWithQuery.js.map +1 -1
  80. package/lib/module/common/useAppFeatures.js.map +1 -1
  81. package/lib/module/common/useMessageOutgoingStatus.js +0 -6
  82. package/lib/module/common/useMessageOutgoingStatus.js.map +1 -1
  83. package/lib/module/common/usePushTrigger.js.map +1 -1
  84. package/lib/module/common/useTotalUnreadMessageCount.js +0 -1
  85. package/lib/module/common/useTotalUnreadMessageCount.js.map +1 -1
  86. package/lib/module/common/useUserList.js +3 -13
  87. package/lib/module/common/useUserList.js.map +1 -1
  88. package/lib/module/handler/useChannelHandler.js +15 -35
  89. package/lib/module/handler/useChannelHandler.js.map +1 -1
  90. package/lib/module/handler/useConnectionHandler.js +15 -6
  91. package/lib/module/handler/useConnectionHandler.js.map +1 -1
  92. package/lib/module/handler/useUserEventHandler.js +0 -2
  93. package/lib/module/handler/useUserEventHandler.js.map +1 -1
  94. package/lib/module/index.js +0 -1
  95. package/lib/module/index.js.map +1 -1
  96. package/lib/module/model/CustomQuery.js +0 -4
  97. package/lib/module/model/CustomQuery.js.map +1 -1
  98. package/lib/typescript/src/channel/useGroupChannelList/reducer.d.ts +1 -1
  99. package/lib/typescript/src/channel/useGroupChannelMessages/reducer.d.ts +2 -2
  100. package/lib/typescript/src/channel/useOpenChannelMessages/reducer.d.ts +2 -2
  101. package/lib/typescript/src/common/useUserList.d.ts +1 -1
  102. package/lib/typescript/src/handler/useChannelHandler.d.ts +1 -1
  103. package/lib/typescript/src/handler/useConnectionHandler.d.ts +1 -2
  104. package/lib/typescript/src/index.d.ts +0 -1
  105. package/package.json +15 -9
  106. package/src/channel/useGroupChannelList/reducer.ts +11 -7
  107. package/src/channel/useGroupChannelList/useGroupChannelListWithCollection.ts +1 -1
  108. package/src/channel/useGroupChannelList/useGroupChannelListWithQuery.ts +1 -1
  109. package/src/channel/useGroupChannelMessages/reducer.ts +11 -10
  110. package/src/channel/useGroupChannelMessages/useGroupChannelMessagesWithCollection.ts +69 -72
  111. package/src/channel/useGroupChannelMessages/useGroupChannelMessagesWithQuery.ts +32 -42
  112. package/src/channel/useOpenChannelList/useOpenChannelListWithQuery.ts +1 -1
  113. package/src/channel/useOpenChannelMessages/reducer.ts +11 -10
  114. package/src/channel/useOpenChannelMessages/useOpenChannelMessagesWithQuery.ts +1 -1
  115. package/src/common/useUserList.ts +2 -2
  116. package/src/handler/useChannelHandler.ts +11 -24
  117. package/src/handler/useConnectionHandler.ts +11 -5
  118. package/src/index.ts +0 -1
  119. package/lib/commonjs/common/useTotalUnreadChannelCount.js +0 -29
  120. package/lib/commonjs/common/useTotalUnreadChannelCount.js.map +0 -1
  121. package/lib/module/common/useTotalUnreadChannelCount.js +0 -17
  122. package/lib/module/common/useTotalUnreadChannelCount.js.map +0 -1
  123. package/lib/typescript/src/common/useTotalUnreadChannelCount.d.ts +0 -6
  124. package/src/common/useTotalUnreadChannelCount.ts +0 -26
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","ConnectionHandler","Logger","useConnectionHandler","sdk","handlerId","hookHandler","deps","info","handler","handlerKeys","Object","keys","forEach","key","addConnectionHandler","removeConnectionHandler"],"sources":["useConnectionHandler.ts"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport { ConnectionHandler } from '@sendbird/chat';\nimport { Logger, SendbirdChatSDK } from '@sendbird/uikit-utils';\n\nexport const useConnectionHandler = (\n sdk: SendbirdChatSDK,\n handlerId: string,\n hookHandler: Partial<ConnectionHandler>,\n deps: React.DependencyList = [],\n) => {\n useEffect(() => {\n Logger.info('[useConnectionHandler]', handlerId);\n\n const handler = new ConnectionHandler();\n const handlerKeys = Object.keys(handler) as (keyof typeof handler)[];\n handlerKeys.forEach((key) => {\n // @ts-ignore\n if (hookHandler[key]) handler[key] = hookHandler[key];\n });\n\n sdk.addConnectionHandler(handlerId, handler);\n return () => sdk.removeConnectionHandler(handlerId);\n }, [sdk, handlerId, ...deps]);\n};\n"],"mappings":"AAAA,SAAgBA,SAAhB,QAAiC,OAAjC;AAEA,SAASC,iBAAT,QAAkC,gBAAlC;AACA,SAASC,MAAT,QAAwC,uBAAxC;AAEA,OAAO,MAAMC,oBAAoB,GAAG,UAClCC,GADkC,EAElCC,SAFkC,EAGlCC,WAHkC,EAK/B;EAAA,IADHC,IACG,uEAD0B,EAC1B;EACHP,SAAS,CAAC,MAAM;IACdE,MAAM,CAACM,IAAP,CAAY,wBAAZ,EAAsCH,SAAtC;IAEA,MAAMI,OAAO,GAAG,IAAIR,iBAAJ,EAAhB;IACA,MAAMS,WAAW,GAAGC,MAAM,CAACC,IAAP,CAAYH,OAAZ,CAApB;IACAC,WAAW,CAACG,OAAZ,CAAqBC,GAAD,IAAS;MAC3B;MACA,IAAIR,WAAW,CAACQ,GAAD,CAAf,EAAsBL,OAAO,CAACK,GAAD,CAAP,GAAeR,WAAW,CAACQ,GAAD,CAA1B;IACvB,CAHD;IAKAV,GAAG,CAACW,oBAAJ,CAAyBV,SAAzB,EAAoCI,OAApC;IACA,OAAO,MAAML,GAAG,CAACY,uBAAJ,CAA4BX,SAA5B,CAAb;EACD,CAZQ,EAYN,CAACD,GAAD,EAAMC,SAAN,EAAiB,GAAGE,IAApB,CAZM,CAAT;AAaD,CAnBM"}
1
+ {"version":3,"names":["useEffect","useLayoutEffect","useRef","ConnectionHandler","Logger","useConnectionHandler","sdk","handlerId","hookHandler","handlerRef","current","info","handler","handlerKeys","Object","keys","forEach","key","_handlerRef$current$k","_handlerRef$current","_len","arguments","length","args","Array","_key","call","addConnectionHandler","removeConnectionHandler"],"sources":["useConnectionHandler.ts"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef } from 'react';\n\nimport { ConnectionHandler } from '@sendbird/chat';\nimport { Logger, SendbirdChatSDK } from '@sendbird/uikit-utils';\n\nexport const useConnectionHandler = (\n sdk: SendbirdChatSDK,\n handlerId: string,\n hookHandler: Partial<ConnectionHandler>,\n) => {\n const handlerRef = useRef<Partial<ConnectionHandler>>();\n useLayoutEffect(() => {\n handlerRef.current = hookHandler;\n });\n\n useEffect(() => {\n Logger.info('[useConnectionHandler]', handlerId);\n\n const handler = new ConnectionHandler();\n const handlerKeys = Object.keys(handler) as (keyof typeof handler)[];\n handlerKeys.forEach((key) => {\n handler[key] = (...args: unknown[]) => {\n // @ts-ignore\n handlerRef.current[key]?.(...args);\n };\n });\n\n sdk.addConnectionHandler(handlerId, handler);\n return () => sdk.removeConnectionHandler(handlerId);\n }, [sdk, handlerId]);\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAE1D,SAASC,iBAAiB,QAAQ,gBAAgB;AAClD,SAASC,MAAM,QAAyB,uBAAuB;AAE/D,OAAO,MAAMC,oBAAoB,GAAGA,CAClCC,GAAoB,EACpBC,SAAiB,EACjBC,WAAuC,KACpC;EACH,MAAMC,UAAU,GAAGP,MAAM,EAA8B;EACvDD,eAAe,CAAC,MAAM;IACpBQ,UAAU,CAACC,OAAO,GAAGF,WAAW;EAClC,CAAC,CAAC;EAEFR,SAAS,CAAC,MAAM;IACdI,MAAM,CAACO,IAAI,CAAC,wBAAwB,EAAEJ,SAAS,CAAC;IAEhD,MAAMK,OAAO,GAAG,IAAIT,iBAAiB,EAAE;IACvC,MAAMU,WAAW,GAAGC,MAAM,CAACC,IAAI,CAACH,OAAO,CAA6B;IACpEC,WAAW,CAACG,OAAO,CAAEC,GAAG,IAAK;MAC3BL,OAAO,CAACK,GAAG,CAAC,GAAG,YAAwB;QAAA,IAAAC,qBAAA,EAAAC,mBAAA;QAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAApBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;UAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;QAAA;QACrB;QACA,CAAAP,qBAAA,IAAAC,mBAAA,GAAAV,UAAU,CAACC,OAAO,EAACO,GAAG,CAAC,cAAAC,qBAAA,uBAAvBA,qBAAA,CAAAQ,IAAA,CAAAP,mBAAA,EAA0B,GAAGI,IAAI,CAAC;MACpC,CAAC;IACH,CAAC,CAAC;IAEFjB,GAAG,CAACqB,oBAAoB,CAACpB,SAAS,EAAEK,OAAO,CAAC;IAC5C,OAAO,MAAMN,GAAG,CAACsB,uBAAuB,CAACrB,SAAS,CAAC;EACrD,CAAC,EAAE,CAACD,GAAG,EAAEC,SAAS,CAAC,CAAC;AACtB,CAAC"}
@@ -13,11 +13,9 @@ export const useUserEventHandler = (sdk, handlerId, hookHandler) => {
13
13
  handlerKeys.forEach(key => {
14
14
  handler[key] = function () {
15
15
  var _handlerRef$current$k, _handlerRef$current;
16
-
17
16
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
18
17
  args[_key] = arguments[_key];
19
18
  }
20
-
21
19
  // @ts-ignore
22
20
  (_handlerRef$current$k = (_handlerRef$current = handlerRef.current)[key]) === null || _handlerRef$current$k === void 0 ? void 0 : _handlerRef$current$k.call(_handlerRef$current, ...args);
23
21
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useLayoutEffect","useRef","UserEventHandler","Logger","useUserEventHandler","sdk","handlerId","hookHandler","handlerRef","current","debug","handler","handlerKeys","Object","keys","forEach","key","args","addUserEventHandler","removeUserEventHandler"],"sources":["useUserEventHandler.ts"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef } from 'react';\n\nimport { UserEventHandler } from '@sendbird/chat';\nimport type { SendbirdChatSDK } from '@sendbird/uikit-utils';\nimport { Logger } from '@sendbird/uikit-utils';\n\nexport const useUserEventHandler = (\n sdk: SendbirdChatSDK,\n handlerId: string,\n hookHandler: Partial<UserEventHandler>,\n) => {\n const handlerRef = useRef(hookHandler);\n useLayoutEffect(() => {\n handlerRef.current = hookHandler;\n });\n\n useEffect(() => {\n Logger.debug('[useUserEventHandler] hook called by', handlerId);\n\n const handler = new UserEventHandler();\n const handlerKeys = Object.keys(handler) as (keyof typeof handler)[];\n\n handlerKeys.forEach((key) => {\n handler[key] = (...args: unknown[]) => {\n // @ts-ignore\n handlerRef.current[key]?.(...args);\n };\n });\n\n sdk.addUserEventHandler(handlerId, handler);\n return () => sdk.removeUserEventHandler(handlerId);\n }, [sdk, handlerId]);\n};\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,eAApB,EAAqCC,MAArC,QAAmD,OAAnD;AAEA,SAASC,gBAAT,QAAiC,gBAAjC;AAEA,SAASC,MAAT,QAAuB,uBAAvB;AAEA,OAAO,MAAMC,mBAAmB,GAAG,CACjCC,GADiC,EAEjCC,SAFiC,EAGjCC,WAHiC,KAI9B;EACH,MAAMC,UAAU,GAAGP,MAAM,CAACM,WAAD,CAAzB;EACAP,eAAe,CAAC,MAAM;IACpBQ,UAAU,CAACC,OAAX,GAAqBF,WAArB;EACD,CAFc,CAAf;EAIAR,SAAS,CAAC,MAAM;IACdI,MAAM,CAACO,KAAP,CAAa,sCAAb,EAAqDJ,SAArD;IAEA,MAAMK,OAAO,GAAG,IAAIT,gBAAJ,EAAhB;IACA,MAAMU,WAAW,GAAGC,MAAM,CAACC,IAAP,CAAYH,OAAZ,CAApB;IAEAC,WAAW,CAACG,OAAZ,CAAqBC,GAAD,IAAS;MAC3BL,OAAO,CAACK,GAAD,CAAP,GAAe,YAAwB;QAAA;;QAAA,kCAApBC,IAAoB;UAApBA,IAAoB;QAAA;;QACrC;QACA,gDAAAT,UAAU,CAACC,OAAX,EAAmBO,GAAnB,2GAA0B,GAAGC,IAA7B;MACD,CAHD;IAID,CALD;IAOAZ,GAAG,CAACa,mBAAJ,CAAwBZ,SAAxB,EAAmCK,OAAnC;IACA,OAAO,MAAMN,GAAG,CAACc,sBAAJ,CAA2Bb,SAA3B,CAAb;EACD,CAfQ,EAeN,CAACD,GAAD,EAAMC,SAAN,CAfM,CAAT;AAgBD,CA1BM"}
1
+ {"version":3,"names":["useEffect","useLayoutEffect","useRef","UserEventHandler","Logger","useUserEventHandler","sdk","handlerId","hookHandler","handlerRef","current","debug","handler","handlerKeys","Object","keys","forEach","key","_handlerRef$current$k","_handlerRef$current","_len","arguments","length","args","Array","_key","call","addUserEventHandler","removeUserEventHandler"],"sources":["useUserEventHandler.ts"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef } from 'react';\n\nimport { UserEventHandler } from '@sendbird/chat';\nimport type { SendbirdChatSDK } from '@sendbird/uikit-utils';\nimport { Logger } from '@sendbird/uikit-utils';\n\nexport const useUserEventHandler = (\n sdk: SendbirdChatSDK,\n handlerId: string,\n hookHandler: Partial<UserEventHandler>,\n) => {\n const handlerRef = useRef(hookHandler);\n useLayoutEffect(() => {\n handlerRef.current = hookHandler;\n });\n\n useEffect(() => {\n Logger.debug('[useUserEventHandler] hook called by', handlerId);\n\n const handler = new UserEventHandler();\n const handlerKeys = Object.keys(handler) as (keyof typeof handler)[];\n\n handlerKeys.forEach((key) => {\n handler[key] = (...args: unknown[]) => {\n // @ts-ignore\n handlerRef.current[key]?.(...args);\n };\n });\n\n sdk.addUserEventHandler(handlerId, handler);\n return () => sdk.removeUserEventHandler(handlerId);\n }, [sdk, handlerId]);\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAE1D,SAASC,gBAAgB,QAAQ,gBAAgB;AAEjD,SAASC,MAAM,QAAQ,uBAAuB;AAE9C,OAAO,MAAMC,mBAAmB,GAAGA,CACjCC,GAAoB,EACpBC,SAAiB,EACjBC,WAAsC,KACnC;EACH,MAAMC,UAAU,GAAGP,MAAM,CAACM,WAAW,CAAC;EACtCP,eAAe,CAAC,MAAM;IACpBQ,UAAU,CAACC,OAAO,GAAGF,WAAW;EAClC,CAAC,CAAC;EAEFR,SAAS,CAAC,MAAM;IACdI,MAAM,CAACO,KAAK,CAAC,sCAAsC,EAAEJ,SAAS,CAAC;IAE/D,MAAMK,OAAO,GAAG,IAAIT,gBAAgB,EAAE;IACtC,MAAMU,WAAW,GAAGC,MAAM,CAACC,IAAI,CAACH,OAAO,CAA6B;IAEpEC,WAAW,CAACG,OAAO,CAAEC,GAAG,IAAK;MAC3BL,OAAO,CAACK,GAAG,CAAC,GAAG,YAAwB;QAAA,IAAAC,qBAAA,EAAAC,mBAAA;QAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAApBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;UAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;QAAA;QACrB;QACA,CAAAP,qBAAA,IAAAC,mBAAA,GAAAV,UAAU,CAACC,OAAO,EAACO,GAAG,CAAC,cAAAC,qBAAA,uBAAvBA,qBAAA,CAAAQ,IAAA,CAAAP,mBAAA,EAA0B,GAAGI,IAAI,CAAC;MACpC,CAAC;IACH,CAAC,CAAC;IAEFjB,GAAG,CAACqB,mBAAmB,CAACpB,SAAS,EAAEK,OAAO,CAAC;IAC3C,OAAO,MAAMN,GAAG,CAACsB,sBAAsB,CAACrB,SAAS,CAAC;EACpD,CAAC,EAAE,CAACD,GAAG,EAAEC,SAAS,CAAC,CAAC;AACtB,CAAC"}
@@ -7,7 +7,6 @@ export { useOpenChannel } from './channel/useOpenChannel';
7
7
  export { useAppFeatures } from './common/useAppFeatures';
8
8
  export { useMessageOutgoingStatus } from './common/useMessageOutgoingStatus';
9
9
  export { usePushTrigger } from './common/usePushTrigger';
10
- export { useTotalUnreadChannelCount } from './common/useTotalUnreadChannelCount';
11
10
  export { useTotalUnreadMessageCount } from './common/useTotalUnreadMessageCount';
12
11
  export { useUserList } from './common/useUserList';
13
12
  export { useChannelHandler } from './handler/useChannelHandler';
@@ -1 +1 @@
1
- {"version":3,"names":["useGroupChannelList","useGroupChannelMessages","useGroupChannel","useOpenChannelList","useOpenChannelMessages","useOpenChannel","useAppFeatures","useMessageOutgoingStatus","usePushTrigger","useTotalUnreadChannelCount","useTotalUnreadMessageCount","useUserList","useChannelHandler","useConnectionHandler","useUserEventHandler","CustomQuery"],"sources":["index.ts"],"sourcesContent":["export { useGroupChannelList } from './channel/useGroupChannelList';\nexport { useGroupChannelMessages } from './channel/useGroupChannelMessages';\nexport { useGroupChannel } from './channel/useGroupChannel';\n\nexport { useOpenChannelList } from './channel/useOpenChannelList';\nexport { useOpenChannelMessages } from './channel/useOpenChannelMessages';\nexport { useOpenChannel } from './channel/useOpenChannel';\n\nexport { useAppFeatures } from './common/useAppFeatures';\nexport { useMessageOutgoingStatus } from './common/useMessageOutgoingStatus';\nexport { usePushTrigger } from './common/usePushTrigger';\nexport { useTotalUnreadChannelCount } from './common/useTotalUnreadChannelCount';\nexport { useTotalUnreadMessageCount } from './common/useTotalUnreadMessageCount';\nexport { useUserList } from './common/useUserList';\n\nexport { useChannelHandler } from './handler/useChannelHandler';\nexport { useConnectionHandler } from './handler/useConnectionHandler';\nexport { useUserEventHandler } from './handler/useUserEventHandler';\n\nexport { CustomQuery } from './model/CustomQuery';\n\nexport type {\n UseGroupChannelList,\n UseGroupChannelListOptions,\n UseGroupChannelMessages,\n UseGroupChannelMessagesOptions,\n UseUserListOptions,\n UseUserListReturn,\n CustomQueryInterface,\n CustomBidirectionalQueryInterface,\n UseOpenChannelMessagesOptions,\n UseOpenChannelListOptions,\n UseOpenChannelList,\n UseOpenChannelMessages,\n} from './types';\n"],"mappings":"AAAA,SAASA,mBAAT,QAAoC,+BAApC;AACA,SAASC,uBAAT,QAAwC,mCAAxC;AACA,SAASC,eAAT,QAAgC,2BAAhC;AAEA,SAASC,kBAAT,QAAmC,8BAAnC;AACA,SAASC,sBAAT,QAAuC,kCAAvC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AAEA,SAASC,cAAT,QAA+B,yBAA/B;AACA,SAASC,wBAAT,QAAyC,mCAAzC;AACA,SAASC,cAAT,QAA+B,yBAA/B;AACA,SAASC,0BAAT,QAA2C,qCAA3C;AACA,SAASC,0BAAT,QAA2C,qCAA3C;AACA,SAASC,WAAT,QAA4B,sBAA5B;AAEA,SAASC,iBAAT,QAAkC,6BAAlC;AACA,SAASC,oBAAT,QAAqC,gCAArC;AACA,SAASC,mBAAT,QAAoC,+BAApC;AAEA,SAASC,WAAT,QAA4B,qBAA5B"}
1
+ {"version":3,"names":["useGroupChannelList","useGroupChannelMessages","useGroupChannel","useOpenChannelList","useOpenChannelMessages","useOpenChannel","useAppFeatures","useMessageOutgoingStatus","usePushTrigger","useTotalUnreadMessageCount","useUserList","useChannelHandler","useConnectionHandler","useUserEventHandler","CustomQuery"],"sources":["index.ts"],"sourcesContent":["export { useGroupChannelList } from './channel/useGroupChannelList';\nexport { useGroupChannelMessages } from './channel/useGroupChannelMessages';\nexport { useGroupChannel } from './channel/useGroupChannel';\n\nexport { useOpenChannelList } from './channel/useOpenChannelList';\nexport { useOpenChannelMessages } from './channel/useOpenChannelMessages';\nexport { useOpenChannel } from './channel/useOpenChannel';\n\nexport { useAppFeatures } from './common/useAppFeatures';\nexport { useMessageOutgoingStatus } from './common/useMessageOutgoingStatus';\nexport { usePushTrigger } from './common/usePushTrigger';\nexport { useTotalUnreadMessageCount } from './common/useTotalUnreadMessageCount';\nexport { useUserList } from './common/useUserList';\n\nexport { useChannelHandler } from './handler/useChannelHandler';\nexport { useConnectionHandler } from './handler/useConnectionHandler';\nexport { useUserEventHandler } from './handler/useUserEventHandler';\n\nexport { CustomQuery } from './model/CustomQuery';\n\nexport type {\n UseGroupChannelList,\n UseGroupChannelListOptions,\n UseGroupChannelMessages,\n UseGroupChannelMessagesOptions,\n UseUserListOptions,\n UseUserListReturn,\n CustomQueryInterface,\n CustomBidirectionalQueryInterface,\n UseOpenChannelMessagesOptions,\n UseOpenChannelListOptions,\n UseOpenChannelList,\n UseOpenChannelMessages,\n} from './types';\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,+BAA+B;AACnE,SAASC,uBAAuB,QAAQ,mCAAmC;AAC3E,SAASC,eAAe,QAAQ,2BAA2B;AAE3D,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,sBAAsB,QAAQ,kCAAkC;AACzE,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,wBAAwB,QAAQ,mCAAmC;AAC5E,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,0BAA0B,QAAQ,qCAAqC;AAChF,SAASC,WAAW,QAAQ,sBAAsB;AAElD,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,oBAAoB,QAAQ,gCAAgC;AACrE,SAASC,mBAAmB,QAAQ,+BAA+B;AAEnE,SAASC,WAAW,QAAQ,qBAAqB"}
@@ -2,18 +2,14 @@ export class CustomQuery {
2
2
  constructor(params) {
3
3
  this.params = params;
4
4
  }
5
-
6
5
  get isLoading() {
7
6
  return this.params.isLoading();
8
7
  }
9
-
10
8
  get hasNext() {
11
9
  return this.params.hasNext();
12
10
  }
13
-
14
11
  next() {
15
12
  return this.params.next();
16
13
  }
17
-
18
14
  }
19
15
  //# sourceMappingURL=CustomQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CustomQuery","constructor","params","isLoading","hasNext","next"],"sources":["CustomQuery.ts"],"sourcesContent":["import type { CustomQueryInterface } from '../types';\n\ntype ConstructorParams<T> = {\n next: () => Promise<T[]>;\n isLoading: () => boolean;\n hasNext: () => boolean;\n};\n\nexport class CustomQuery<T> implements CustomQueryInterface<T> {\n constructor(private params: ConstructorParams<T>) {}\n get isLoading(): boolean {\n return this.params.isLoading();\n }\n get hasNext(): boolean {\n return this.params.hasNext();\n }\n next() {\n return this.params.next();\n }\n}\n"],"mappings":"AAQA,OAAO,MAAMA,WAAN,CAAwD;EAC7DC,WAAW,CAASC,MAAT,EAAuC;IAAA,KAA9BA,MAA8B,GAA9BA,MAA8B;EAAE;;EACvC,IAATC,SAAS,GAAY;IACvB,OAAO,KAAKD,MAAL,CAAYC,SAAZ,EAAP;EACD;;EACU,IAAPC,OAAO,GAAY;IACrB,OAAO,KAAKF,MAAL,CAAYE,OAAZ,EAAP;EACD;;EACDC,IAAI,GAAG;IACL,OAAO,KAAKH,MAAL,CAAYG,IAAZ,EAAP;EACD;;AAV4D"}
1
+ {"version":3,"names":["CustomQuery","constructor","params","isLoading","hasNext","next"],"sources":["CustomQuery.ts"],"sourcesContent":["import type { CustomQueryInterface } from '../types';\n\ntype ConstructorParams<T> = {\n next: () => Promise<T[]>;\n isLoading: () => boolean;\n hasNext: () => boolean;\n};\n\nexport class CustomQuery<T> implements CustomQueryInterface<T> {\n constructor(private params: ConstructorParams<T>) {}\n get isLoading(): boolean {\n return this.params.isLoading();\n }\n get hasNext(): boolean {\n return this.params.hasNext();\n }\n next() {\n return this.params.next();\n }\n}\n"],"mappings":"AAQA,OAAO,MAAMA,WAAW,CAAuC;EAC7DC,WAAWA,CAASC,MAA4B,EAAE;IAAA,KAA9BA,MAA4B,GAA5BA,MAA4B;EAAG;EACnD,IAAIC,SAASA,CAAA,EAAY;IACvB,OAAO,IAAI,CAACD,MAAM,CAACC,SAAS,EAAE;EAChC;EACA,IAAIC,OAAOA,CAAA,EAAY;IACrB,OAAO,IAAI,CAACF,MAAM,CAACE,OAAO,EAAE;EAC9B;EACAC,IAAIA,CAAA,EAAG;IACL,OAAO,IAAI,CAACH,MAAM,CAACG,IAAI,EAAE;EAC3B;AACF"}
@@ -5,7 +5,7 @@ export declare const useGroupChannelListReducer: (order?: Order) => {
5
5
  updateRefreshing: (status: boolean) => void;
6
6
  updateChannels: (channels: SendbirdChannel[]) => void;
7
7
  deleteChannels: (channelUrls: string[]) => void;
8
- setChannels: (channels: SendbirdChannel[], clearPrev: boolean) => void;
8
+ setChannels: (channels: SendbirdChannel[], clearBeforeAction: boolean) => void;
9
9
  updateOrder: (order?: Order) => void;
10
10
  loading: boolean;
11
11
  refreshing: boolean;
@@ -3,8 +3,8 @@ import type { UseGroupChannelMessagesOptions } from '../../types';
3
3
  export declare const useGroupChannelMessagesReducer: (userId?: string, sortComparator?: UseGroupChannelMessagesOptions['sortComparator']) => {
4
4
  updateLoading: (status: boolean) => void;
5
5
  updateRefreshing: (status: boolean) => void;
6
- updateMessages: (messages: SendbirdBaseMessage[], clearPrev: boolean, currentUserId?: string) => void;
7
- updateNextMessages: (messages: SendbirdBaseMessage[], clearPrev: boolean, currentUserId?: string) => void;
6
+ updateMessages: (messages: SendbirdBaseMessage[], clearBeforeAction: boolean, currentUserId?: string) => void;
7
+ updateNextMessages: (messages: SendbirdBaseMessage[], clearBeforeAction: boolean, currentUserId?: string) => void;
8
8
  deleteMessages: (messageIds: number[], reqIds: string[]) => void;
9
9
  deleteNextMessages: (messageIds: number[], reqIds: string[]) => void;
10
10
  loading: boolean;
@@ -3,8 +3,8 @@ import type { UseOpenChannelMessagesOptions } from '../../types';
3
3
  export declare const useOpenChannelMessagesReducer: (userId?: string, sortComparator?: UseOpenChannelMessagesOptions['sortComparator']) => {
4
4
  updateLoading: (status: boolean) => void;
5
5
  updateRefreshing: (status: boolean) => void;
6
- updateMessages: (messages: SendbirdBaseMessage[], clearPrev: boolean, currentUserId?: string) => void;
7
- updateNextMessages: (messages: SendbirdBaseMessage[], clearPrev: boolean, currentUserId?: string) => void;
6
+ updateMessages: (messages: SendbirdBaseMessage[], clearBeforeAction: boolean, currentUserId?: string) => void;
7
+ updateNextMessages: (messages: SendbirdBaseMessage[], clearBeforeAction: boolean, currentUserId?: string) => void;
8
8
  deleteMessages: (messageIds: number[], reqIds: string[]) => void;
9
9
  deleteNextMessages: (messageIds: number[], reqIds: string[]) => void;
10
10
  loading: boolean;
@@ -21,4 +21,4 @@ import type { CustomQueryInterface, UseUserListOptions, UseUserListReturn } from
21
21
  * })
22
22
  * ```
23
23
  * */
24
- export declare const useUserList: <Options extends UseUserListOptions<QueriedUser>, QueriedUser extends UserStruct = Options["queryCreator"] extends Optional<() => CustomQueryInterface<infer User extends UserStruct>> ? User : import("@sendbird/chat").User>(sdk: SendbirdChatSDK, options?: Options | undefined) => UseUserListReturn<QueriedUser>;
24
+ export declare const useUserList: <Options extends UseUserListOptions<UserStruct>, QueriedUser extends UserStruct = Options["queryCreator"] extends Optional<() => CustomQueryInterface<infer User extends UserStruct>> ? User : import("@sendbird/chat").User>(sdk: SendbirdChatSDK, options?: UseUserListOptions<QueriedUser> | undefined) => UseUserListReturn<QueriedUser>;
@@ -1,6 +1,6 @@
1
1
  import { GroupChannelHandler } from '@sendbird/chat/groupChannel';
2
2
  import { OpenChannelHandler } from '@sendbird/chat/openChannel';
3
- import { SendbirdChatSDK } from '@sendbird/uikit-utils';
3
+ import type { SendbirdChatSDK } from '@sendbird/uikit-utils';
4
4
  type ChannelType = 'open' | 'group';
5
5
  export declare const useChannelHandler: <T extends ChannelType = "group">(sdk: SendbirdChatSDK, handlerId: string, hookHandler: Partial<T extends "group" ? GroupChannelHandler : OpenChannelHandler>, type?: T) => void;
6
6
  export {};
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { ConnectionHandler } from '@sendbird/chat';
3
2
  import { SendbirdChatSDK } from '@sendbird/uikit-utils';
4
- export declare const useConnectionHandler: (sdk: SendbirdChatSDK, handlerId: string, hookHandler: Partial<ConnectionHandler>, deps?: React.DependencyList) => void;
3
+ export declare const useConnectionHandler: (sdk: SendbirdChatSDK, handlerId: string, hookHandler: Partial<ConnectionHandler>) => void;
@@ -7,7 +7,6 @@ export { useOpenChannel } from './channel/useOpenChannel';
7
7
  export { useAppFeatures } from './common/useAppFeatures';
8
8
  export { useMessageOutgoingStatus } from './common/useMessageOutgoingStatus';
9
9
  export { usePushTrigger } from './common/usePushTrigger';
10
- export { useTotalUnreadChannelCount } from './common/useTotalUnreadChannelCount';
11
10
  export { useTotalUnreadMessageCount } from './common/useTotalUnreadMessageCount';
12
11
  export { useUserList } from './common/useUserList';
13
12
  export { useChannelHandler } from './handler/useChannelHandler';
package/package.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "name": "@sendbird/uikit-chat-hooks",
3
- "version": "2.4.1",
4
- "description": "React hooks that built with SendbirdChat SDK",
3
+ "version": "2.4.2",
4
+ "description": "A set of React hooks for integrating Sendbird chat functionality into your React app.",
5
+ "keywords": [
6
+ "sendbird",
7
+ "uikit",
8
+ "chat",
9
+ "React",
10
+ "hooks",
11
+ "messaging",
12
+ "real-time"
13
+ ],
5
14
  "main": "lib/commonjs/index",
6
15
  "module": "lib/module/index",
7
16
  "types": "lib/typescript/src/index.d.ts",
@@ -18,10 +27,6 @@
18
27
  "build": "bob build",
19
28
  "clean": "del lib"
20
29
  },
21
- "keywords": [
22
- "react",
23
- "sendbird"
24
- ],
25
30
  "repository": {
26
31
  "type": "git",
27
32
  "url": "https://github.com/sendbird/sendbird-uikit-react-native.git",
@@ -38,11 +43,12 @@
38
43
  "access": "public"
39
44
  },
40
45
  "dependencies": {
41
- "@sendbird/uikit-utils": "2.4.1"
46
+ "@sendbird/uikit-utils": "2.4.2"
42
47
  },
43
48
  "devDependencies": {
49
+ "@sendbird/uikit-testing-tools": "2.4.2",
44
50
  "@types/react": "*",
45
- "react": "^16.13.1",
51
+ "react": "17.0.2",
46
52
  "react-native-builder-bob": "^0.18.0",
47
53
  "typescript": "4.9.4"
48
54
  },
@@ -69,5 +75,5 @@
69
75
  "readmeFile": "./README.md",
70
76
  "displayName": "@sendbird/uikit-chat-hooks"
71
77
  },
72
- "gitHead": "9ba7a005c941a3edd5b0f78d88d8cd1df6c280fc"
78
+ "gitHead": "ae9e60edc60cdd4f6e9b0e4019e84584e807bc2c"
73
79
  }
@@ -20,7 +20,7 @@ type Action =
20
20
  }
21
21
  | {
22
22
  type: 'set_channels';
23
- value: { channels: SendbirdChannel[]; clearPrev: boolean };
23
+ value: { channels: SendbirdChannel[]; clearBeforeAction: boolean };
24
24
  }
25
25
  | {
26
26
  type: 'update_order';
@@ -38,10 +38,12 @@ const defaultReducer = ({ ...draft }: State, action: Action) => {
38
38
  const compareByOrder = createCompareByOrder(draft.order);
39
39
 
40
40
  switch (action.type) {
41
- case 'update_refreshing':
41
+ case 'update_refreshing': {
42
+ draft.refreshing = action.value.status;
43
+ break;
44
+ }
42
45
  case 'update_loading': {
43
- const key = action.type === 'update_loading' ? 'loading' : 'refreshing';
44
- draft[key] = action.value.status;
46
+ draft.loading = action.value.status;
45
47
  break;
46
48
  }
47
49
  case 'update_channels': {
@@ -63,7 +65,7 @@ const defaultReducer = ({ ...draft }: State, action: Action) => {
63
65
  break;
64
66
  }
65
67
  case 'set_channels': {
66
- if (action.value.clearPrev) {
68
+ if (action.value.clearBeforeAction) {
67
69
  draft.groupChannels = getGroupChannels(action.value.channels);
68
70
  } else {
69
71
  draft.groupChannels = [...draft.groupChannels, ...getGroupChannels(action.value.channels)];
@@ -74,6 +76,8 @@ const defaultReducer = ({ ...draft }: State, action: Action) => {
74
76
  }
75
77
  case 'update_order': {
76
78
  draft.order = action.value.order;
79
+ const compareByOrder = createCompareByOrder(draft.order);
80
+ compareByOrder && (draft.groupChannels = draft.groupChannels.sort(compareByOrder));
77
81
  break;
78
82
  }
79
83
  }
@@ -94,8 +98,8 @@ export const useGroupChannelListReducer = (order?: Order) => {
94
98
  const deleteChannels = (channelUrls: string[]) => {
95
99
  dispatch({ type: 'delete_channels', value: { channelUrls } });
96
100
  };
97
- const setChannels = (channels: SendbirdChannel[], clearPrev: boolean) => {
98
- dispatch({ type: 'set_channels', value: { channels, clearPrev } });
101
+ const setChannels = (channels: SendbirdChannel[], clearBeforeAction: boolean) => {
102
+ dispatch({ type: 'set_channels', value: { channels, clearBeforeAction } });
99
103
  };
100
104
  const updateLoading = (status: boolean) => {
101
105
  dispatch({ type: 'update_loading', value: { status } });
@@ -90,7 +90,7 @@ export const useGroupChannelListWithCollection: UseGroupChannelList = (sdk, user
90
90
  updateLoading(true);
91
91
  await init(userId);
92
92
  updateLoading(false);
93
- }, [init, userId]);
93
+ }, [userId]);
94
94
 
95
95
  useChannelHandler(sdk, handlerId, {
96
96
  onUserBanned: (channel, user) => {
@@ -63,7 +63,7 @@ export const useGroupChannelListWithQuery: UseGroupChannelList = (sdk, userId, o
63
63
  updateLoading(true);
64
64
  await init(userId);
65
65
  updateLoading(false);
66
- }, [init, userId]);
66
+ }, [userId]);
67
67
 
68
68
  useChannelHandler(sdk, handlerId, {
69
69
  onChannelChanged: (channel) => updateChannels([channel]),
@@ -12,7 +12,7 @@ type Action =
12
12
  }
13
13
  | {
14
14
  type: 'update_messages' | 'update_next_messages';
15
- value: { messages: SendbirdBaseMessage[]; clearPrev: boolean; currentUserId?: string };
15
+ value: { messages: SendbirdBaseMessage[]; clearBeforeAction: boolean; currentUserId?: string };
16
16
  }
17
17
  | {
18
18
  type: 'delete_messages' | 'delete_next_messages';
@@ -28,18 +28,19 @@ type State = {
28
28
 
29
29
  const defaultReducer = ({ ...draft }: State, action: Action) => {
30
30
  switch (action.type) {
31
- case 'update_refreshing':
31
+ case 'update_refreshing': {
32
+ draft['refreshing'] = action.value.status;
33
+ return draft;
34
+ }
32
35
  case 'update_loading': {
33
- const key = action.type === 'update_loading' ? 'loading' : 'refreshing';
34
- draft[key] = action.value.status;
35
-
36
+ draft['loading'] = action.value.status;
36
37
  return draft;
37
38
  }
38
39
  case 'update_messages':
39
40
  case 'update_next_messages': {
40
41
  const key = action.type === 'update_messages' ? 'messageMap' : 'nextMessageMap';
41
42
  const receivedMessagesAsMap = arrayToMapWithGetter(action.value.messages, getMessageUniqId);
42
- if (action.value.clearPrev) {
43
+ if (action.value.clearBeforeAction) {
43
44
  draft[key] = receivedMessagesAsMap;
44
45
  } else {
45
46
  draft[key] = { ...draft[key], ...receivedMessagesAsMap };
@@ -82,14 +83,14 @@ export const useGroupChannelMessagesReducer = (
82
83
  nextMessageMap: {},
83
84
  });
84
85
 
85
- const updateMessages = (messages: SendbirdBaseMessage[], clearPrev: boolean, currentUserId?: string) => {
86
- dispatch({ type: 'update_messages', value: { messages, clearPrev, currentUserId } });
86
+ const updateMessages = (messages: SendbirdBaseMessage[], clearBeforeAction: boolean, currentUserId?: string) => {
87
+ dispatch({ type: 'update_messages', value: { messages, clearBeforeAction, currentUserId } });
87
88
  };
88
89
  const deleteMessages = (messageIds: number[], reqIds: string[]) => {
89
90
  dispatch({ type: 'delete_messages', value: { messageIds, reqIds } });
90
91
  };
91
- const updateNextMessages = (messages: SendbirdBaseMessage[], clearPrev: boolean, currentUserId?: string) => {
92
- dispatch({ type: 'update_next_messages', value: { messages, clearPrev, currentUserId } });
92
+ const updateNextMessages = (messages: SendbirdBaseMessage[], clearBeforeAction: boolean, currentUserId?: string) => {
93
+ dispatch({ type: 'update_next_messages', value: { messages, clearBeforeAction, currentUserId } });
93
94
  };
94
95
  const deleteNextMessages = (messageIds: number[], reqIds: string[]) => {
95
96
  dispatch({ type: 'delete_next_messages', value: { messageIds, reqIds } });
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useRef } from 'react';
1
+ import { useEffect, useRef } from 'react';
2
2
 
3
3
  import { MessageCollectionInitPolicy, MessageEventSource, MessageFilter } from '@sendbird/chat/groupChannel';
4
4
  import type {
@@ -63,85 +63,82 @@ export const useGroupChannelMessagesWithCollection: UseGroupChannelMessages = (s
63
63
  }
64
64
  };
65
65
 
66
- const init = useCallback(
67
- async (uid?: string, callback?: () => void) => {
68
- if (collectionRef.current) collectionRef.current?.dispose();
66
+ const init = useFreshCallback(async (uid?: string, callback?: () => void) => {
67
+ if (collectionRef.current) collectionRef.current?.dispose();
69
68
 
70
- if (uid) {
71
- collectionRef.current = createMessageCollection(channel, options?.collectionCreator);
72
- updateNextMessages([], true, sdk.currentUser.userId);
73
- channelMarkAsRead();
69
+ if (uid) {
70
+ collectionRef.current = createMessageCollection(channel, options?.collectionCreator);
71
+ updateNextMessages([], true, sdk.currentUser.userId);
72
+ channelMarkAsRead();
74
73
 
75
- collectionRef.current?.setMessageCollectionHandler({
76
- onMessagesAdded: (_, __, messages) => {
77
- channelMarkAsRead(_.source);
78
- updateNextMessages(messages, false, sdk.currentUser.userId);
79
- },
80
- onMessagesUpdated: (_, __, messages) => {
81
- channelMarkAsRead(_.source);
74
+ collectionRef.current?.setMessageCollectionHandler({
75
+ onMessagesAdded: (_, __, messages) => {
76
+ channelMarkAsRead(_.source);
77
+ updateNextMessages(messages, false, sdk.currentUser.userId);
78
+ },
79
+ onMessagesUpdated: (_, __, messages) => {
80
+ channelMarkAsRead(_.source);
82
81
 
83
- // NOTE: admin message is not added via onMessagesAdded handler, not checked yet is this a bug.
84
- if (_.source === MessageEventSource.EVENT_MESSAGE_RECEIVED) {
85
- const nextMessageIds = nextMessages.map((it) => it.messageId);
86
- const nonAddedMessagesFromReceivedEvent = messages.filter(
87
- (it) => nextMessageIds.indexOf(it.messageId) === -1,
88
- );
89
- updateNextMessages(nonAddedMessagesFromReceivedEvent, false, sdk.currentUser.userId);
90
- }
82
+ // NOTE: admin message is not added via onMessagesAdded handler, not checked yet is this a bug.
83
+ if (_.source === MessageEventSource.EVENT_MESSAGE_RECEIVED) {
84
+ const nextMessageIds = nextMessages.map((it) => it.messageId);
85
+ const nonAddedMessagesFromReceivedEvent = messages.filter(
86
+ (it) => nextMessageIds.indexOf(it.messageId) === -1,
87
+ );
88
+ updateNextMessages(nonAddedMessagesFromReceivedEvent, false, sdk.currentUser.userId);
89
+ }
91
90
 
92
- // NOTE: v4 MESSAGE_RECEIVED is called twice from onMessagesAdded and onMessagesUpdated when receiving new message.
93
- // This is not intended behavior but not bugs.
94
- if (_.source !== MessageEventSource.EVENT_MESSAGE_RECEIVED) {
95
- updateMessages(messages, false, sdk.currentUser.userId);
96
- }
97
- },
98
- onMessagesDeleted: (_, __, messageIds) => {
99
- deleteMessages(messageIds, []);
100
- deleteNextMessages(messageIds, []);
101
- },
102
- onChannelDeleted: () => {
103
- options?.onChannelDeleted?.();
104
- },
105
- onChannelUpdated: (_, eventChannel) => {
106
- if (eventChannel.isGroupChannel() && !isDifferentChannel(eventChannel, channel)) {
107
- forceUpdate();
108
- }
109
- },
110
- onHugeGapDetected: () => {
111
- init(uid);
112
- },
113
- });
91
+ // NOTE: v4 MESSAGE_RECEIVED is called twice from onMessagesAdded and onMessagesUpdated when receiving new message.
92
+ // This is not intended behavior but not bugs.
93
+ if (_.source !== MessageEventSource.EVENT_MESSAGE_RECEIVED) {
94
+ updateMessages(messages, false, sdk.currentUser.userId);
95
+ }
96
+ },
97
+ onMessagesDeleted: (_, __, messageIds) => {
98
+ deleteMessages(messageIds, []);
99
+ deleteNextMessages(messageIds, []);
100
+ },
101
+ onChannelDeleted: () => {
102
+ options?.onChannelDeleted?.();
103
+ },
104
+ onChannelUpdated: (_, eventChannel) => {
105
+ if (eventChannel.isGroupChannel() && !isDifferentChannel(eventChannel, channel)) {
106
+ forceUpdate();
107
+ }
108
+ },
109
+ onHugeGapDetected: () => {
110
+ init(uid);
111
+ },
112
+ });
114
113
 
115
- collectionRef.current
116
- .initialize(MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)
117
- .onCacheResult((err, messages) => {
118
- if (err) sdk.isCacheEnabled && Logger.error('[useGroupChannelMessagesWithCollection/onCacheResult]', err);
119
- else {
120
- Logger.debug('[useGroupChannelMessagesWithCollection/onCacheResult]', 'message length:', messages.length);
114
+ collectionRef.current
115
+ .initialize(MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)
116
+ .onCacheResult((err, messages) => {
117
+ if (err) sdk.isCacheEnabled && Logger.error('[useGroupChannelMessagesWithCollection/onCacheResult]', err);
118
+ else {
119
+ Logger.debug('[useGroupChannelMessagesWithCollection/onCacheResult]', 'message length:', messages.length);
121
120
 
122
- updateMessages(messages, true, sdk.currentUser.userId);
121
+ updateMessages(messages, true, sdk.currentUser.userId);
122
+ updateMessages(collectionRef.current?.pendingMessages ?? [], false, sdk.currentUser.userId);
123
+ updateMessages(collectionRef.current?.failedMessages ?? [], false, sdk.currentUser.userId);
124
+ }
125
+ callback?.();
126
+ })
127
+ .onApiResult((err, messages) => {
128
+ if (err) Logger.warn('[useGroupChannelMessagesWithCollection/onApiResult]', err);
129
+ else {
130
+ Logger.debug('[useGroupChannelMessagesWithCollection/onApiResult]', 'message length:', messages.length);
131
+
132
+ updateMessages(messages, true, sdk.currentUser.userId);
133
+ if (sdk.isCacheEnabled) {
123
134
  updateMessages(collectionRef.current?.pendingMessages ?? [], false, sdk.currentUser.userId);
124
135
  updateMessages(collectionRef.current?.failedMessages ?? [], false, sdk.currentUser.userId);
125
136
  }
126
- callback?.();
127
- })
128
- .onApiResult((err, messages) => {
129
- if (err) Logger.warn('[useGroupChannelMessagesWithCollection/onApiResult]', err);
130
- else {
131
- Logger.debug('[useGroupChannelMessagesWithCollection/onApiResult]', 'message length:', messages.length);
132
-
133
- updateMessages(messages, true, sdk.currentUser.userId);
134
- if (sdk.isCacheEnabled) {
135
- updateMessages(collectionRef.current?.pendingMessages ?? [], false, sdk.currentUser.userId);
136
- updateMessages(collectionRef.current?.failedMessages ?? [], false, sdk.currentUser.userId);
137
- }
138
- }
139
- callback?.();
140
- });
141
- }
142
- },
143
- [sdk, channel.url, options?.collectionCreator],
144
- );
137
+ }
138
+ callback?.();
139
+ });
140
+ }
141
+ });
145
142
 
146
143
  useChannelHandler(sdk, handlerId, {
147
144
  onUserBanned(channel, bannedUser) {
@@ -161,7 +158,7 @@ export const useGroupChannelMessagesWithCollection: UseGroupChannelMessages = (s
161
158
  updateLoading(true);
162
159
  init(userId, () => updateLoading(false));
163
160
  }, 0);
164
- }, [init, userId]);
161
+ }, [channel.url, userId]);
165
162
 
166
163
  useEffect(() => {
167
164
  return () => {