@viewberapp/chat 0.1.10 → 0.1.12

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 (65) hide show
  1. package/LICENSE +20 -20
  2. package/dist/API.d.ts +91 -91
  3. package/dist/API.js +241 -241
  4. package/dist/CachedChat.d.ts +64 -64
  5. package/dist/CachedChat.js +241 -241
  6. package/dist/Chat.d.ts +66 -66
  7. package/dist/Chat.js +270 -270
  8. package/dist/ChatError.d.ts +4 -4
  9. package/dist/ChatError.js +2 -2
  10. package/dist/ChatSubscription.d.ts +82 -82
  11. package/dist/ChatSubscription.js +128 -128
  12. package/dist/Message.d.ts +25 -25
  13. package/dist/Message.js +35 -35
  14. package/dist/OnlineUser.d.ts +8 -8
  15. package/dist/OnlineUser.js +9 -9
  16. package/dist/PendingMessage.d.ts +23 -23
  17. package/dist/PendingMessage.js +23 -23
  18. package/dist/index.d.ts +8 -8
  19. package/dist/index.js +27 -27
  20. package/dist/logger/ConsoleLogger.d.ts +8 -8
  21. package/dist/logger/ConsoleLogger.js +20 -20
  22. package/dist/logger/NullLogger.d.ts +8 -8
  23. package/dist/logger/NullLogger.js +10 -10
  24. package/dist/logger/RollbarLogger.d.ts +11 -11
  25. package/dist/logger/RollbarLogger.js +23 -23
  26. package/dist/logger/index.d.ts +12 -12
  27. package/dist/logger/index.js +12 -12
  28. package/dist/react/components/AdminMessage.d.ts +6 -6
  29. package/dist/react/components/AdminMessage.js +59 -59
  30. package/dist/react/components/ConnectionAndChannelStatusLabel.d.ts +7 -7
  31. package/dist/react/components/ConnectionAndChannelStatusLabel.js +59 -59
  32. package/dist/react/components/Message.d.ts +23 -23
  33. package/dist/react/components/Message.js +87 -87
  34. package/dist/react/components/MessageDateTime.d.ts +8 -8
  35. package/dist/react/components/MessageDateTime.js +31 -31
  36. package/dist/react/components/MessageList.d.ts +46 -46
  37. package/dist/react/components/MessageList.js +107 -107
  38. package/dist/react/components/MessageRow.d.ts +5 -5
  39. package/dist/react/components/MessageRow.js +34 -34
  40. package/dist/react/components/index.d.ts +6 -6
  41. package/dist/react/components/index.js +13 -13
  42. package/dist/react/index.d.ts +3 -3
  43. package/dist/react/index.js +16 -16
  44. package/dist/react/useAppointmentChat.d.ts +3 -3
  45. package/dist/react/useAppointmentChat.js +10 -10
  46. package/dist/react/useChat.d.ts +38 -38
  47. package/dist/react/useChat.js +125 -125
  48. package/dist/react/useRealtimeTotalUserUnreadChatMessages.d.ts +12 -12
  49. package/dist/react/useRealtimeTotalUserUnreadChatMessages.js +137 -137
  50. package/dist/util/getLatestMessage.d.ts +3 -3
  51. package/dist/util/getLatestMessage.js +17 -17
  52. package/dist/util/getLatestMessageId.d.ts +3 -0
  53. package/dist/util/getLatestMessageId.js +18 -0
  54. package/dist/util/getLatestMessageId.js.map +1 -0
  55. package/dist/util/groupMessages.d.ts +8 -8
  56. package/dist/util/groupMessages.js +30 -30
  57. package/dist/util/index.d.ts +4 -4
  58. package/dist/util/index.js +9 -9
  59. package/dist/util/isNil.d.ts +1 -1
  60. package/dist/util/isNil.js +7 -7
  61. package/dist/util/jwtTokenChanged.d.ts +1 -1
  62. package/dist/util/jwtTokenChanged.js +10 -10
  63. package/dist/util/useIsMounted.d.ts +1 -1
  64. package/dist/util/useIsMounted.js +13 -13
  65. package/package.json +2 -2
@@ -1,138 +1,138 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.useRealtimeTotalUserUnreadChatMessages = void 0;
30
- const react_1 = __importStar(require("react"));
31
- const util_1 = require("../util");
32
- const Chat_1 = __importDefault(require("../Chat"));
33
- const useRealtimeTotalUserUnreadChatMessages = (userId, options) => {
34
- const [chatIsInitialized, setChatIsInitialized] = (0, react_1.useState)(Chat_1.default.isInitialized());
35
- const [channelStatus, setChannelStatus] = (0, react_1.useState)();
36
- const [totalUnreadMessages, setTotalUnreadMessages] = (0, react_1.useState)();
37
- const loadUserChatUnreadMessageCount = (0, react_1.useCallback)(() => {
38
- Chat_1.default.api().getUserChatUnreadMessageCount({
39
- appointmentId: options === null || options === void 0 ? void 0 : options.appointmentId,
40
- appointmentIsConfirmedForViewing: options === null || options === void 0 ? void 0 : options.appointmentIsConfirmedForViewing
41
- }).then(res => {
42
- if (!(0, util_1.isNil)(res.count)) {
43
- setTotalUnreadMessages(res.count);
44
- }
45
- if (options === null || options === void 0 ? void 0 : options.__debug__) {
46
- console.log(res);
47
- }
48
- }).catch(err => {
49
- if (options === null || options === void 0 ? void 0 : options.__debug__) {
50
- console.error(err);
51
- }
52
- });
53
- }, [
54
- userId,
55
- options === null || options === void 0 ? void 0 : options.appointmentId,
56
- options === null || options === void 0 ? void 0 : options.requireAppointmentId,
57
- options === null || options === void 0 ? void 0 : options.appointmentIsConfirmedForViewing
58
- ]);
59
- react_1.default.useEffect(() => {
60
- let listener = (isInitialized) => {
61
- setChatIsInitialized(isInitialized);
62
- if (options === null || options === void 0 ? void 0 : options.__debug__) {
63
- console.log("useRealtimeTotalUserUnreadChatMessages chat isInitialized change", isInitialized);
64
- }
65
- };
66
- Chat_1.default.addEventListener('initialized', listener);
67
- return () => {
68
- Chat_1.default.removeEventListener('initialized', listener);
69
- };
70
- }, []);
71
- react_1.default.useEffect(() => {
72
- if (!chatIsInitialized
73
- || (0, util_1.isNil)(userId)
74
- || ((options === null || options === void 0 ? void 0 : options.requireAppointmentId) && (0, util_1.isNil)(options === null || options === void 0 ? void 0 : options.appointmentId))) {
75
- if (options === null || options === void 0 ? void 0 : options.__debug__) {
76
- console.log("useRealtimeTotalUserUnreadChatMessages initialize realtime listener early return", {
77
- chatIsInitialized,
78
- userId,
79
- appointmentId: options === null || options === void 0 ? void 0 : options.appointmentId,
80
- requireAppointmentId: options === null || options === void 0 ? void 0 : options.requireAppointmentId
81
- });
82
- }
83
- return;
84
- }
85
- loadUserChatUnreadMessageCount();
86
- Chat_1.default.connect();
87
- const channel = Chat_1.default.channel(`viewber:users:${userId}`);
88
- const chatMessageCreatedListener = (message) => {
89
- var _a;
90
- if (!(0, util_1.isNil)(options === null || options === void 0 ? void 0 : options.appointmentId)
91
- && ((_a = message.data.chat) === null || _a === void 0 ? void 0 : _a.request_accept_id) !== (options === null || options === void 0 ? void 0 : options.appointmentId)) {
92
- if (options === null || options === void 0 ? void 0 : options.__debug__) {
93
- console.log("useRealtimeTotalUserUnreadChatMessages chat.message.created early return", {
94
- userId,
95
- appointmentId: options === null || options === void 0 ? void 0 : options.appointmentId,
96
- requireAppointmentId: options === null || options === void 0 ? void 0 : options.requireAppointmentId,
97
- message
98
- });
99
- }
100
- return;
101
- }
102
- else if (options === null || options === void 0 ? void 0 : options.__debug__) {
103
- console.log("useRealtimeTotalUserUnreadChatMessages chat.message.created", {
104
- userId,
105
- appointmentId: options === null || options === void 0 ? void 0 : options.appointmentId,
106
- requireAppointmentId: options === null || options === void 0 ? void 0 : options.requireAppointmentId,
107
- message
108
- });
109
- }
110
- loadUserChatUnreadMessageCount();
111
- };
112
- const channelStatusListener = (stateChange) => {
113
- setChannelStatus(stateChange.current);
114
- };
115
- channel.subscribe('chat.message.created', chatMessageCreatedListener, err => {
116
- if (options === null || options === void 0 ? void 0 : options.__debug__) {
117
- console.error("useRealtimeTotalUserUnreadChatMessages chat.message.created subscribe error", err);
118
- }
119
- });
120
- channel.on(channelStatusListener);
121
- return () => {
122
- channel.unsubscribe('chat.message.created', chatMessageCreatedListener);
123
- channel.off(channelStatusListener);
124
- };
125
- }, [
126
- chatIsInitialized,
127
- userId,
128
- options === null || options === void 0 ? void 0 : options.appointmentId,
129
- options === null || options === void 0 ? void 0 : options.requireAppointmentId,
130
- options === null || options === void 0 ? void 0 : options.appointmentIsConfirmedForViewing
131
- ]);
132
- return {
133
- channelStatus,
134
- totalUnreadMessages
135
- };
136
- };
137
- exports.useRealtimeTotalUserUnreadChatMessages = useRealtimeTotalUserUnreadChatMessages;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.useRealtimeTotalUserUnreadChatMessages = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const util_1 = require("../util");
32
+ const Chat_1 = __importDefault(require("../Chat"));
33
+ const useRealtimeTotalUserUnreadChatMessages = (userId, options) => {
34
+ const [chatIsInitialized, setChatIsInitialized] = (0, react_1.useState)(Chat_1.default.isInitialized());
35
+ const [channelStatus, setChannelStatus] = (0, react_1.useState)();
36
+ const [totalUnreadMessages, setTotalUnreadMessages] = (0, react_1.useState)();
37
+ const loadUserChatUnreadMessageCount = (0, react_1.useCallback)(() => {
38
+ Chat_1.default.api().getUserChatUnreadMessageCount({
39
+ appointmentId: options === null || options === void 0 ? void 0 : options.appointmentId,
40
+ appointmentIsConfirmedForViewing: options === null || options === void 0 ? void 0 : options.appointmentIsConfirmedForViewing
41
+ }).then(res => {
42
+ if (!(0, util_1.isNil)(res.count)) {
43
+ setTotalUnreadMessages(res.count);
44
+ }
45
+ if (options === null || options === void 0 ? void 0 : options.__debug__) {
46
+ console.log(res);
47
+ }
48
+ }).catch(err => {
49
+ if (options === null || options === void 0 ? void 0 : options.__debug__) {
50
+ console.error(err);
51
+ }
52
+ });
53
+ }, [
54
+ userId,
55
+ options === null || options === void 0 ? void 0 : options.appointmentId,
56
+ options === null || options === void 0 ? void 0 : options.requireAppointmentId,
57
+ options === null || options === void 0 ? void 0 : options.appointmentIsConfirmedForViewing
58
+ ]);
59
+ react_1.default.useEffect(() => {
60
+ let listener = (isInitialized) => {
61
+ setChatIsInitialized(isInitialized);
62
+ if (options === null || options === void 0 ? void 0 : options.__debug__) {
63
+ console.log("useRealtimeTotalUserUnreadChatMessages chat isInitialized change", isInitialized);
64
+ }
65
+ };
66
+ Chat_1.default.addEventListener('initialized', listener);
67
+ return () => {
68
+ Chat_1.default.removeEventListener('initialized', listener);
69
+ };
70
+ }, []);
71
+ react_1.default.useEffect(() => {
72
+ if (!chatIsInitialized
73
+ || (0, util_1.isNil)(userId)
74
+ || ((options === null || options === void 0 ? void 0 : options.requireAppointmentId) && (0, util_1.isNil)(options === null || options === void 0 ? void 0 : options.appointmentId))) {
75
+ if (options === null || options === void 0 ? void 0 : options.__debug__) {
76
+ console.log("useRealtimeTotalUserUnreadChatMessages initialize realtime listener early return", {
77
+ chatIsInitialized,
78
+ userId,
79
+ appointmentId: options === null || options === void 0 ? void 0 : options.appointmentId,
80
+ requireAppointmentId: options === null || options === void 0 ? void 0 : options.requireAppointmentId
81
+ });
82
+ }
83
+ return;
84
+ }
85
+ loadUserChatUnreadMessageCount();
86
+ Chat_1.default.connect();
87
+ const channel = Chat_1.default.channel(`viewber:users:${userId}`);
88
+ const chatMessageCreatedListener = (message) => {
89
+ var _a;
90
+ if (!(0, util_1.isNil)(options === null || options === void 0 ? void 0 : options.appointmentId)
91
+ && ((_a = message.data.chat) === null || _a === void 0 ? void 0 : _a.request_accept_id) !== (options === null || options === void 0 ? void 0 : options.appointmentId)) {
92
+ if (options === null || options === void 0 ? void 0 : options.__debug__) {
93
+ console.log("useRealtimeTotalUserUnreadChatMessages chat.message.created early return", {
94
+ userId,
95
+ appointmentId: options === null || options === void 0 ? void 0 : options.appointmentId,
96
+ requireAppointmentId: options === null || options === void 0 ? void 0 : options.requireAppointmentId,
97
+ message
98
+ });
99
+ }
100
+ return;
101
+ }
102
+ else if (options === null || options === void 0 ? void 0 : options.__debug__) {
103
+ console.log("useRealtimeTotalUserUnreadChatMessages chat.message.created", {
104
+ userId,
105
+ appointmentId: options === null || options === void 0 ? void 0 : options.appointmentId,
106
+ requireAppointmentId: options === null || options === void 0 ? void 0 : options.requireAppointmentId,
107
+ message
108
+ });
109
+ }
110
+ loadUserChatUnreadMessageCount();
111
+ };
112
+ const channelStatusListener = (stateChange) => {
113
+ setChannelStatus(stateChange.current);
114
+ };
115
+ channel.subscribe('chat.message.created', chatMessageCreatedListener, err => {
116
+ if (options === null || options === void 0 ? void 0 : options.__debug__) {
117
+ console.error("useRealtimeTotalUserUnreadChatMessages chat.message.created subscribe error", err);
118
+ }
119
+ });
120
+ channel.on(channelStatusListener);
121
+ return () => {
122
+ channel.unsubscribe('chat.message.created', chatMessageCreatedListener);
123
+ channel.off(channelStatusListener);
124
+ };
125
+ }, [
126
+ chatIsInitialized,
127
+ userId,
128
+ options === null || options === void 0 ? void 0 : options.appointmentId,
129
+ options === null || options === void 0 ? void 0 : options.requireAppointmentId,
130
+ options === null || options === void 0 ? void 0 : options.appointmentIsConfirmedForViewing
131
+ ]);
132
+ return {
133
+ channelStatus,
134
+ totalUnreadMessages
135
+ };
136
+ };
137
+ exports.useRealtimeTotalUserUnreadChatMessages = useRealtimeTotalUserUnreadChatMessages;
138
138
  //# sourceMappingURL=useRealtimeTotalUserUnreadChatMessages.js.map
@@ -1,3 +1,3 @@
1
- import Message from "../Message";
2
- import PendingMessage from "../PendingMessage";
3
- export declare const getLatestMessage: (messages: (Message | PendingMessage)[]) => Message | undefined;
1
+ import Message from "../Message";
2
+ import PendingMessage from "../PendingMessage";
3
+ export declare const getLatestMessage: (messages: (Message | PendingMessage)[]) => Message | undefined;
@@ -1,18 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLatestMessage = void 0;
4
- const Message_1 = require("../Message");
5
- const isNil_1 = require("./isNil");
6
- const getLatestMessage = (messages) => {
7
- let latestMessage;
8
- for (let i = 0, il = messages.length; i < il; i++) {
9
- (0, Message_1.isMessageThen)(messages[i], message => {
10
- if ((0, isNil_1.isNil)(latestMessage) || latestMessage.id < message.id) {
11
- latestMessage = message;
12
- }
13
- });
14
- }
15
- return latestMessage;
16
- };
17
- exports.getLatestMessage = getLatestMessage;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLatestMessage = void 0;
4
+ const Message_1 = require("../Message");
5
+ const isNil_1 = require("./isNil");
6
+ const getLatestMessage = (messages) => {
7
+ let latestMessage;
8
+ for (let i = 0, il = messages.length; i < il; i++) {
9
+ (0, Message_1.isMessageThen)(messages[i], message => {
10
+ if ((0, isNil_1.isNil)(latestMessage) || latestMessage.id < message.id) {
11
+ latestMessage = message;
12
+ }
13
+ });
14
+ }
15
+ return latestMessage;
16
+ };
17
+ exports.getLatestMessage = getLatestMessage;
18
18
  //# sourceMappingURL=getLatestMessage.js.map
@@ -0,0 +1,3 @@
1
+ import Message from "../Message";
2
+ import PendingMessage from "../PendingMessage";
3
+ export declare const getLatestMessageId: (messages: (Message | PendingMessage)[]) => number | undefined;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLatestMessageId = void 0;
4
+ const Message_1 = require("../Message");
5
+ const isNil_1 = require("./isNil");
6
+ const getLatestMessageId = (messages) => {
7
+ let latestId;
8
+ for (let i = 0, il = messages.length; i < il; i++) {
9
+ (0, Message_1.isMessageThen)(messages[i], message => {
10
+ if ((0, isNil_1.isNil)(latestId) || latestId < message.id) {
11
+ latestId = message.id;
12
+ }
13
+ });
14
+ }
15
+ return latestId;
16
+ };
17
+ exports.getLatestMessageId = getLatestMessageId;
18
+ //# sourceMappingURL=getLatestMessageId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLatestMessageId.js","sourceRoot":"","sources":["../../src/util/getLatestMessageId.ts"],"names":[],"mappings":";;;AAAA,wCAAoD;AAEpD,mCAAgC;AAEzB,MAAM,kBAAkB,GAAG,CAAC,QAAoC,EAAoB,EAAE;IACzF,IAAI,QAA0B,CAAC;IAE/B,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,EAAE,GAAC,QAAQ,CAAC,MAAM,EAAC,CAAC,GAAC,EAAE,EAAC,CAAC,EAAE,EAAE;QACrC,IAAA,uBAAa,EAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE;YACjC,IAAI,IAAA,aAAK,EAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,OAAO,CAAC,EAAE,EAAE;gBAC1C,QAAQ,GAAG,OAAO,CAAC,EAAE,CAAC;aACzB;QACL,CAAC,CAAC,CAAC;KACN;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAA;AAZY,QAAA,kBAAkB,sBAY9B"}
@@ -1,8 +1,8 @@
1
- import Message, { Sender } from "../Message";
2
- export declare type MessageGroup = MessageGroupItem[];
3
- export interface MessageGroupItem {
4
- senderId: number;
5
- sender: Sender;
6
- messages: Message[];
7
- }
8
- export declare const groupMessages: (messages: Message[]) => MessageGroup;
1
+ import Message, { Sender } from "../Message";
2
+ export declare type MessageGroup = MessageGroupItem[];
3
+ export interface MessageGroupItem {
4
+ senderId: number;
5
+ sender: Sender;
6
+ messages: Message[];
7
+ }
8
+ export declare const groupMessages: (messages: Message[]) => MessageGroup;
@@ -1,31 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.groupMessages = void 0;
4
- const groupMessages = (messages) => {
5
- const messageGroup = [];
6
- let currentMessageGroupItem = undefined;
7
- for (let i = 0, il = messages.length; i < il; i++) {
8
- if (!currentMessageGroupItem) {
9
- currentMessageGroupItem = {
10
- senderId: messages[i].senderId,
11
- sender: messages[i].sender,
12
- messages: [messages[i]]
13
- };
14
- messageGroup.push(currentMessageGroupItem);
15
- continue;
16
- }
17
- if (currentMessageGroupItem.senderId === messages[i].senderId) {
18
- currentMessageGroupItem.messages.push(messages[i]);
19
- continue;
20
- }
21
- currentMessageGroupItem = {
22
- senderId: messages[i].senderId,
23
- sender: messages[i].sender,
24
- messages: [messages[i]]
25
- };
26
- messageGroup.push(currentMessageGroupItem);
27
- }
28
- return messageGroup;
29
- };
30
- exports.groupMessages = groupMessages;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.groupMessages = void 0;
4
+ const groupMessages = (messages) => {
5
+ const messageGroup = [];
6
+ let currentMessageGroupItem = undefined;
7
+ for (let i = 0, il = messages.length; i < il; i++) {
8
+ if (!currentMessageGroupItem) {
9
+ currentMessageGroupItem = {
10
+ senderId: messages[i].senderId,
11
+ sender: messages[i].sender,
12
+ messages: [messages[i]]
13
+ };
14
+ messageGroup.push(currentMessageGroupItem);
15
+ continue;
16
+ }
17
+ if (currentMessageGroupItem.senderId === messages[i].senderId) {
18
+ currentMessageGroupItem.messages.push(messages[i]);
19
+ continue;
20
+ }
21
+ currentMessageGroupItem = {
22
+ senderId: messages[i].senderId,
23
+ sender: messages[i].sender,
24
+ messages: [messages[i]]
25
+ };
26
+ messageGroup.push(currentMessageGroupItem);
27
+ }
28
+ return messageGroup;
29
+ };
30
+ exports.groupMessages = groupMessages;
31
31
  //# sourceMappingURL=groupMessages.js.map
@@ -1,4 +1,4 @@
1
- import { isNil } from "./isNil";
2
- import { groupMessages } from "./groupMessages";
3
- import { getLatestMessage } from "./getLatestMessage";
4
- export { isNil, groupMessages, getLatestMessage };
1
+ import { isNil } from "./isNil";
2
+ import { groupMessages } from "./groupMessages";
3
+ import { getLatestMessage } from "./getLatestMessage";
4
+ export { isNil, groupMessages, getLatestMessage };
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLatestMessage = exports.groupMessages = exports.isNil = void 0;
4
- const isNil_1 = require("./isNil");
5
- Object.defineProperty(exports, "isNil", { enumerable: true, get: function () { return isNil_1.isNil; } });
6
- const groupMessages_1 = require("./groupMessages");
7
- Object.defineProperty(exports, "groupMessages", { enumerable: true, get: function () { return groupMessages_1.groupMessages; } });
8
- const getLatestMessage_1 = require("./getLatestMessage");
9
- Object.defineProperty(exports, "getLatestMessage", { enumerable: true, get: function () { return getLatestMessage_1.getLatestMessage; } });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLatestMessage = exports.groupMessages = exports.isNil = void 0;
4
+ const isNil_1 = require("./isNil");
5
+ Object.defineProperty(exports, "isNil", { enumerable: true, get: function () { return isNil_1.isNil; } });
6
+ const groupMessages_1 = require("./groupMessages");
7
+ Object.defineProperty(exports, "groupMessages", { enumerable: true, get: function () { return groupMessages_1.groupMessages; } });
8
+ const getLatestMessage_1 = require("./getLatestMessage");
9
+ Object.defineProperty(exports, "getLatestMessage", { enumerable: true, get: function () { return getLatestMessage_1.getLatestMessage; } });
10
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- export declare const isNil: (value: any) => value is null | undefined;
1
+ export declare const isNil: (value: any) => value is null | undefined;
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNil = void 0;
4
- const isNil = (value) => {
5
- return value == null;
6
- };
7
- exports.isNil = isNil;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNil = void 0;
4
+ const isNil = (value) => {
5
+ return value == null;
6
+ };
7
+ exports.isNil = isNil;
8
8
  //# sourceMappingURL=isNil.js.map
@@ -1 +1 @@
1
- export declare const jwtTokenChanged: (tokenA?: string, tokenB?: string) => boolean;
1
+ export declare const jwtTokenChanged: (tokenA?: string, tokenB?: string) => boolean;
@@ -1,11 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jwtTokenChanged = void 0;
4
- const isNil_1 = require("./isNil");
5
- const jwtTokenChanged = (tokenA, tokenB) => {
6
- return (tokenA !== tokenB)
7
- || ((0, isNil_1.isNil)(tokenA) && !(0, isNil_1.isNil)(tokenB))
8
- || ((0, isNil_1.isNil)(tokenB) && !(0, isNil_1.isNil)(tokenA));
9
- };
10
- exports.jwtTokenChanged = jwtTokenChanged;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jwtTokenChanged = void 0;
4
+ const isNil_1 = require("./isNil");
5
+ const jwtTokenChanged = (tokenA, tokenB) => {
6
+ return (tokenA !== tokenB)
7
+ || ((0, isNil_1.isNil)(tokenA) && !(0, isNil_1.isNil)(tokenB))
8
+ || ((0, isNil_1.isNil)(tokenB) && !(0, isNil_1.isNil)(tokenA));
9
+ };
10
+ exports.jwtTokenChanged = jwtTokenChanged;
11
11
  //# sourceMappingURL=jwtTokenChanged.js.map
@@ -1 +1 @@
1
- export declare const useIsMounted: () => () => boolean;
1
+ export declare const useIsMounted: () => () => boolean;
@@ -1,14 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useIsMounted = void 0;
4
- const react_1 = require("react");
5
- const useIsMounted = () => {
6
- const isMountedRef = (0, react_1.useRef)(true);
7
- const isMounted = (0, react_1.useCallback)(() => isMountedRef.current, []);
8
- (0, react_1.useEffect)(() => {
9
- return () => void (isMountedRef.current = false);
10
- }, []);
11
- return isMounted;
12
- };
13
- exports.useIsMounted = useIsMounted;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsMounted = void 0;
4
+ const react_1 = require("react");
5
+ const useIsMounted = () => {
6
+ const isMountedRef = (0, react_1.useRef)(true);
7
+ const isMounted = (0, react_1.useCallback)(() => isMountedRef.current, []);
8
+ (0, react_1.useEffect)(() => {
9
+ return () => void (isMountedRef.current = false);
10
+ }, []);
11
+ return isMounted;
12
+ };
13
+ exports.useIsMounted = useIsMounted;
14
14
  //# sourceMappingURL=useIsMounted.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewberapp/chat",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Viewber chat",
5
5
  "author": "Jacob <jacob.chen@viewber.co.uk>",
6
6
  "homepage": "https://bitbucket.org/ezadr/viewberjs#readme",
@@ -42,5 +42,5 @@
42
42
  "react": "^16.14.0",
43
43
  "rollbar": "^2.25.0"
44
44
  },
45
- "gitHead": "19cedb3fcfa41ad110319c5e817427ff15243d76"
45
+ "gitHead": "b249fdf99ae4e8495c76ebffd0e603707b237c01"
46
46
  }