revolt.js
Advanced tools
Comparing version 5.2.0 to 5.2.1
@@ -13,3 +13,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import defaultsDeep from "lodash.defaultsdeep"; | ||
import { action, makeObservable, observable, runInAction } from "mobx"; | ||
import { action, makeObservable, observable } from "mobx"; | ||
import Bots from "./maps/Bots"; | ||
@@ -73,18 +73,2 @@ import Channels from "./maps/Channels"; | ||
} | ||
this.on("ready", () => { | ||
if (this.options.unreads) { | ||
this.unreads.sync(); | ||
} | ||
}); | ||
this.on("message", (message) => __awaiter(this, void 0, void 0, function* () { | ||
const channel = message.channel; | ||
if (!channel) | ||
return; | ||
runInAction(() => { | ||
if (channel.channel_type === "DirectMessage") { | ||
channel.active = true; | ||
} | ||
channel.last_message_id = message._id; | ||
}); | ||
})); | ||
} | ||
@@ -91,0 +75,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
export declare const LIBRARY_VERSION = "5.1.0-alpha.15"; | ||
export declare const LIBRARY_VERSION = "5.2.1"; | ||
export declare const defaultConfig: { | ||
@@ -3,0 +3,0 @@ apiURL: string; |
@@ -1,2 +0,2 @@ | ||
export const LIBRARY_VERSION = "5.1.0-alpha.15"; | ||
export const LIBRARY_VERSION = "5.2.1"; | ||
export const defaultConfig = { | ||
@@ -3,0 +3,0 @@ apiURL: "https://api.revolt.chat", |
@@ -91,3 +91,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const handle = (msg) => __awaiter(this, void 0, void 0, function* () { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; | ||
const data = msg.data; | ||
@@ -133,2 +133,5 @@ if (typeof data !== "string") | ||
resolve(); | ||
// Sync unreads. | ||
(_a = this.client.unreads) === null || _a === void 0 ? void 0 : _a.sync(); | ||
// Setup heartbeat. | ||
if (this.client.heartbeat > 0) { | ||
@@ -178,3 +181,14 @@ this.send({ type: "Ping", data: +new Date() }); | ||
} | ||
this.client.messages.createObj(packet, true); | ||
const message = this.client.messages.createObj(packet, true); | ||
runInAction(() => { | ||
var _a; | ||
if (channel.channel_type === "DirectMessage") { | ||
channel.active = true; | ||
} | ||
channel.last_message_id = message._id; | ||
if (this.client.unreads && | ||
((_a = message.mention_ids) === null || _a === void 0 ? void 0 : _a.includes(this.client.user._id))) { | ||
this.client.unreads.markMention(message.channel_id, message._id); | ||
} | ||
}); | ||
} | ||
@@ -218,3 +232,3 @@ break; | ||
case "ChannelDelete": { | ||
(_a = this.client.channels.get(packet.id)) === null || _a === void 0 ? void 0 : _a.delete(true); | ||
(_b = this.client.channels.get(packet.id)) === null || _b === void 0 ? void 0 : _b.delete(true); | ||
this.client.emit("channel/delete", packet.id); | ||
@@ -224,9 +238,9 @@ break; | ||
case "ChannelGroupJoin": { | ||
(_b = this.client.channels | ||
.get(packet.id)) === null || _b === void 0 ? void 0 : _b.updateGroupJoin(packet.user); | ||
(_c = this.client.channels | ||
.get(packet.id)) === null || _c === void 0 ? void 0 : _c.updateGroupJoin(packet.user); | ||
break; | ||
} | ||
case "ChannelGroupLeave": { | ||
(_c = this.client.channels | ||
.get(packet.id)) === null || _c === void 0 ? void 0 : _c.updateGroupLeave(packet.user); | ||
(_d = this.client.channels | ||
.get(packet.id)) === null || _d === void 0 ? void 0 : _d.updateGroupLeave(packet.user); | ||
break; | ||
@@ -243,3 +257,3 @@ } | ||
case "ServerDelete": { | ||
(_d = this.client.servers.get(packet.id)) === null || _d === void 0 ? void 0 : _d.delete(true); | ||
(_e = this.client.servers.get(packet.id)) === null || _e === void 0 ? void 0 : _e.delete(true); | ||
this.client.emit("server/delete", packet.id); | ||
@@ -300,3 +314,3 @@ break; | ||
if (server) { | ||
const role = Object.assign(Object.assign({}, (_e = server.roles) === null || _e === void 0 ? void 0 : _e[packet.role_id]), packet.data); | ||
const role = Object.assign(Object.assign({}, (_f = server.roles) === null || _f === void 0 ? void 0 : _f[packet.role_id]), packet.data); | ||
server.roles = Object.assign(Object.assign({}, server.roles), { [packet.role_id]: role }); | ||
@@ -310,3 +324,3 @@ this.client.emit("role/update", packet.role_id, role, packet.id); | ||
if (server) { | ||
const _k = (_f = server.roles) !== null && _f !== void 0 ? _f : {}, _l = packet.role_id, _ = _k[_l], roles = __rest(_k, [typeof _l === "symbol" ? _l : _l + ""]); | ||
const _l = (_g = server.roles) !== null && _g !== void 0 ? _g : {}, _m = packet.role_id, _ = _l[_m], roles = __rest(_l, [typeof _m === "symbol" ? _m : _m + ""]); | ||
server.roles = roles; | ||
@@ -318,4 +332,4 @@ this.client.emit("role/delete", packet.role_id, packet.id); | ||
case "UserUpdate": { | ||
(_g = this.client.users | ||
.get(packet.id)) === null || _g === void 0 ? void 0 : _g.update(packet.data, packet.clear); | ||
(_h = this.client.users | ||
.get(packet.id)) === null || _h === void 0 ? void 0 : _h.update(packet.data, packet.clear); | ||
break; | ||
@@ -346,4 +360,4 @@ } | ||
case "ChannelStopTyping": { | ||
(_h = this.client.channels | ||
.get(packet.id)) === null || _h === void 0 ? void 0 : _h.updateStopTyping(packet.user); | ||
(_j = this.client.channels | ||
.get(packet.id)) === null || _j === void 0 ? void 0 : _j.updateStopTyping(packet.user); | ||
clearInterval(timeouts[packet.id + packet.user]); | ||
@@ -353,3 +367,3 @@ break; | ||
case "ChannelAck": { | ||
(_j = this.client.unreads) === null || _j === void 0 ? void 0 : _j.markRead(packet.id, packet.message_id); | ||
(_k = this.client.unreads) === null || _k === void 0 ? void 0 : _k.markRead(packet.id, packet.message_id); | ||
break; | ||
@@ -356,0 +370,0 @@ } |
{ | ||
"type": "module", | ||
"name": "revolt.js", | ||
"version": "5.2.0", | ||
"version": "5.2.1", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/revoltchat/revolt.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
163184
4650