@viewberapp/chat 0.0.79 → 0.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/API.d.ts +3 -3
- package/dist/API.js +3 -3
- package/dist/CachedChat.js +1 -1
- package/dist/Chat.d.ts +1 -1
- package/dist/Chat.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/util/getLatestMessage.d.ts +3 -0
- package/dist/util/getLatestMessage.js +18 -0
- package/dist/util/getLatestMessage.js.map +1 -0
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.js +3 -3
- package/dist/util/index.js.map +1 -1
- package/package.json +2 -2
package/dist/API.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface ConstructApiParams {
|
|
|
9
9
|
getChatAblyTokenRoute: () => string;
|
|
10
10
|
getChatStoreMessageRoute: (chatId: number) => string;
|
|
11
11
|
getChatForAppointmentRoute: (appointmentId: number) => string;
|
|
12
|
-
|
|
12
|
+
markChatMessagesReadUpToRoute: (chatId: number, messageId: number) => string;
|
|
13
13
|
}
|
|
14
14
|
export declare type GetAblyTokenReturnValue = {
|
|
15
15
|
token: Record<any, any>;
|
|
@@ -46,13 +46,13 @@ export default class API {
|
|
|
46
46
|
private getChatAblyTokenRoute;
|
|
47
47
|
private getChatStoreMessageRoute;
|
|
48
48
|
private getChatForAppointmentRoute;
|
|
49
|
-
private
|
|
49
|
+
private markChatMessagesReadUpToRoute;
|
|
50
50
|
constructor(params: ConstructApiParams);
|
|
51
51
|
getAblyToken: (chats: number[]) => Promise<GetAblyTokenReturnValue>;
|
|
52
52
|
storeMessage: (chatId: number, message: string, options?: SendMessageOptions) => Promise<StoreMessageReturnValue>;
|
|
53
53
|
getLatestMessages: (chatId: number) => Promise<GetLatestMessagesReturnValue>;
|
|
54
54
|
getChatIdFromAppointmentId: (appointmentId: number) => Promise<GetChatIdFromAppointmentIdReturnValue>;
|
|
55
|
-
|
|
55
|
+
markChatMessagesReadUpTo: (chatId: number, message: Message) => Promise<{
|
|
56
56
|
error: ChatError | undefined;
|
|
57
57
|
}>;
|
|
58
58
|
private constructHeaders;
|
package/dist/API.js
CHANGED
|
@@ -91,8 +91,8 @@ class API {
|
|
|
91
91
|
resolve({ error: { code: 'error' } });
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
|
-
this.
|
|
95
|
-
this.axios.post(this.
|
|
94
|
+
this.markChatMessagesReadUpTo = (chatId, message) => new Promise((resolve, reject) => {
|
|
95
|
+
this.axios.post(this.markChatMessagesReadUpToRoute(chatId, message.id), undefined, {
|
|
96
96
|
headers: this.constructHeaders(),
|
|
97
97
|
}).then(response => {
|
|
98
98
|
resolve({ error: undefined });
|
|
@@ -116,7 +116,7 @@ class API {
|
|
|
116
116
|
this.getChatAblyTokenRoute = params.getChatAblyTokenRoute;
|
|
117
117
|
this.getChatStoreMessageRoute = params.getChatStoreMessageRoute;
|
|
118
118
|
this.getChatForAppointmentRoute = params.getChatForAppointmentRoute;
|
|
119
|
-
this.
|
|
119
|
+
this.markChatMessagesReadUpToRoute = params.markChatMessagesReadUpToRoute;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
exports.default = API;
|
package/dist/CachedChat.js
CHANGED
|
@@ -95,7 +95,7 @@ class CachedChat {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
markMessagesReadUpTo(message) {
|
|
98
|
-
return this.api.
|
|
98
|
+
return this.api.markChatMessagesReadUpTo(this.id, message);
|
|
99
99
|
}
|
|
100
100
|
addMessage(message) {
|
|
101
101
|
if (message instanceof PendingMessage_1.default) {
|
package/dist/Chat.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface ChatOptions {
|
|
|
11
11
|
getChatAblyTokenRoute: ConstructApiParams['getChatAblyTokenRoute'];
|
|
12
12
|
getChatStoreMessageRoute: ConstructApiParams['getChatStoreMessageRoute'];
|
|
13
13
|
getChatForAppointmentRoute: ConstructApiParams['getChatForAppointmentRoute'];
|
|
14
|
-
|
|
14
|
+
markChatMessagesReadUpToRoute: ConstructApiParams['markChatMessagesReadUpToRoute'];
|
|
15
15
|
}
|
|
16
16
|
export declare type ConnectionStatus = 'initialized' | 'connecting' | 'connected' | 'disconnected' | 'suspended' | 'closing' | 'closed' | 'failed';
|
|
17
17
|
declare const Chat: {
|
package/dist/Chat.js
CHANGED
|
@@ -49,7 +49,7 @@ const Chat = (function () {
|
|
|
49
49
|
let getChatAblyTokenRoute;
|
|
50
50
|
let getChatStoreMessageRoute;
|
|
51
51
|
let getChatForAppointmentRoute;
|
|
52
|
-
let
|
|
52
|
+
let markChatMessagesReadUpToRoute;
|
|
53
53
|
let api;
|
|
54
54
|
let logger;
|
|
55
55
|
let ably;
|
|
@@ -67,7 +67,7 @@ const Chat = (function () {
|
|
|
67
67
|
getChatAblyTokenRoute = options.getChatAblyTokenRoute;
|
|
68
68
|
getChatStoreMessageRoute = options.getChatStoreMessageRoute;
|
|
69
69
|
getChatForAppointmentRoute = options.getChatForAppointmentRoute;
|
|
70
|
-
|
|
70
|
+
markChatMessagesReadUpToRoute = options.markChatMessagesReadUpToRoute;
|
|
71
71
|
api = makeApi();
|
|
72
72
|
logger = options.logger || new logger_1.ConsoleLogger;
|
|
73
73
|
ably = new Ably.Realtime({
|
|
@@ -170,7 +170,7 @@ const Chat = (function () {
|
|
|
170
170
|
getChatAblyTokenRoute,
|
|
171
171
|
getChatStoreMessageRoute,
|
|
172
172
|
getChatForAppointmentRoute,
|
|
173
|
-
|
|
173
|
+
markChatMessagesReadUpToRoute
|
|
174
174
|
});
|
|
175
175
|
const logout = () => {
|
|
176
176
|
setJwtToken(undefined);
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import useChat from "./react/useChat";
|
|
|
3
3
|
import useAppointmentChat from "./react/useAppointmentChat";
|
|
4
4
|
export { ConsoleLogger, RollbarLogger, NullLogger } from './logger';
|
|
5
5
|
export { Message, MessageRow, AdminMessage, ConnectionAndChannelStatusLabel } from './react';
|
|
6
|
-
export {
|
|
6
|
+
export { getLatestMessage } from './util';
|
|
7
7
|
export { Chat, useChat, useAppointmentChat };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useAppointmentChat = exports.useChat = exports.Chat = exports.
|
|
6
|
+
exports.useAppointmentChat = exports.useChat = exports.Chat = exports.getLatestMessage = exports.ConnectionAndChannelStatusLabel = exports.AdminMessage = exports.MessageRow = exports.Message = exports.NullLogger = exports.RollbarLogger = exports.ConsoleLogger = void 0;
|
|
7
7
|
const Chat_1 = __importDefault(require("./Chat"));
|
|
8
8
|
exports.Chat = Chat_1.default;
|
|
9
9
|
const useChat_1 = __importDefault(require("./react/useChat"));
|
|
@@ -20,5 +20,5 @@ Object.defineProperty(exports, "MessageRow", { enumerable: true, get: function (
|
|
|
20
20
|
Object.defineProperty(exports, "AdminMessage", { enumerable: true, get: function () { return react_1.AdminMessage; } });
|
|
21
21
|
Object.defineProperty(exports, "ConnectionAndChannelStatusLabel", { enumerable: true, get: function () { return react_1.ConnectionAndChannelStatusLabel; } });
|
|
22
22
|
var util_1 = require("./util");
|
|
23
|
-
Object.defineProperty(exports, "
|
|
23
|
+
Object.defineProperty(exports, "getLatestMessage", { enumerable: true, get: function () { return util_1.getLatestMessage; } });
|
|
24
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AACb,kDAA0B;AAsBtB,eAtBG,cAAI,CAsBH;AArBR,8DAAsC;AAsBlC,kBAtBG,iBAAO,CAsBH;AArBX,oFAA4D;AAsBxD,6BAtBG,4BAAkB,CAsBH;AApBtB,mCAIkB;AAHd,uGAAA,aAAa,OAAA;AACb,uGAAA,aAAa,OAAA;AACb,oGAAA,UAAU,OAAA;AAGd,iCAKiB;AAJb,gGAAA,OAAO,OAAA;AACP,mGAAA,UAAU,OAAA;AACV,qGAAA,YAAY,OAAA;AACZ,wHAAA,+BAA+B,OAAA;AAGnC,+BAEgB;AADZ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AACb,kDAA0B;AAsBtB,eAtBG,cAAI,CAsBH;AArBR,8DAAsC;AAsBlC,kBAtBG,iBAAO,CAsBH;AArBX,oFAA4D;AAsBxD,6BAtBG,4BAAkB,CAsBH;AApBtB,mCAIkB;AAHd,uGAAA,aAAa,OAAA;AACb,uGAAA,aAAa,OAAA;AACb,oGAAA,UAAU,OAAA;AAGd,iCAKiB;AAJb,gGAAA,OAAO,OAAA;AACP,mGAAA,UAAU,OAAA;AACV,qGAAA,YAAY,OAAA;AACZ,wHAAA,+BAA+B,OAAA;AAGnC,+BAEgB;AADZ,wGAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +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;
|
|
18
|
+
//# sourceMappingURL=getLatestMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLatestMessage.js","sourceRoot":"","sources":["../../src/util/getLatestMessage.ts"],"names":[],"mappings":";;;AAAA,wCAAoD;AAEpD,mCAAgC;AAEzB,MAAM,gBAAgB,GAAG,CAAC,QAAoC,EAAqB,EAAE;IACxF,IAAI,aAAgC,CAAC;IAErC,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,aAAa,CAAC,IAAI,aAAa,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE;gBACvD,aAAa,GAAG,OAAO,CAAC;aAC3B;QACL,CAAC,CAAC,CAAC;KACN;IAED,OAAO,aAAa,CAAC;AACzB,CAAC,CAAA;AAZY,QAAA,gBAAgB,oBAY5B"}
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { isNil } from "./isNil";
|
|
2
2
|
import { groupMessages } from "./groupMessages";
|
|
3
|
-
import {
|
|
4
|
-
export { isNil, groupMessages,
|
|
3
|
+
import { getLatestMessage } from "./getLatestMessage";
|
|
4
|
+
export { isNil, groupMessages, getLatestMessage };
|
package/dist/util/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getLatestMessage = exports.groupMessages = exports.isNil = void 0;
|
|
4
4
|
const isNil_1 = require("./isNil");
|
|
5
5
|
Object.defineProperty(exports, "isNil", { enumerable: true, get: function () { return isNil_1.isNil; } });
|
|
6
6
|
const groupMessages_1 = require("./groupMessages");
|
|
7
7
|
Object.defineProperty(exports, "groupMessages", { enumerable: true, get: function () { return groupMessages_1.groupMessages; } });
|
|
8
|
-
const
|
|
9
|
-
Object.defineProperty(exports, "
|
|
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
|
package/dist/util/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAK5B,sFALK,aAAK,OAKL;AAJT,mDAAgD;AAK5C,8FALK,6BAAa,OAKL;AAJjB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAK5B,sFALK,aAAK,OAKL;AAJT,mDAAgD;AAK5C,8FALK,6BAAa,OAKL;AAJjB,yDAAsD;AAKlD,iGALK,mCAAgB,OAKL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewberapp/chat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
4
|
"description": "Viewber chat",
|
|
5
5
|
"author": "Jacob <jacob.chen@viewber.co.uk>",
|
|
6
6
|
"homepage": "https://bitbucket.org/ezadr/viewberjs#readme",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"react": "^16.14.0",
|
|
42
42
|
"rollbar": "^2.25.0"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "a6b3d64a7b9249d44497333fe216b6362282c300"
|
|
45
45
|
}
|