diff --git a/package.json b/package.json index 3a8f9962..d1bb6ed9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "revolt.js", - "version": "6.0.1", + "version": "6.0.2", "main": "dist/index.js", "typings": "dist/index.d.ts", "module": "esm/index.js", diff --git a/src/config.ts b/src/config.ts index d75b62e4..cfd1188d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,4 @@ -export const LIBRARY_VERSION = "6.0.1"; +export const LIBRARY_VERSION = "6.0.2"; export const defaultConfig = { apiURL: "https://api.revolt.chat", diff --git a/src/util/Unreads.ts b/src/util/Unreads.ts index fcc800ae..741e17be 100644 --- a/src/util/Unreads.ts +++ b/src/util/Unreads.ts @@ -20,6 +20,7 @@ export interface INotificationChecker { */ export default class Unreads { private client: Client; + private loaded: boolean; private channels: ObservableMap>; /** @@ -27,6 +28,7 @@ export default class Unreads { */ constructor(client: Client) { this.channels = new ObservableMap(); + this.loaded = false; makeAutoObservable(this); this.client = client; } @@ -37,6 +39,7 @@ export default class Unreads { async sync() { const unreads = await this.client.syncFetchUnreads(); runInAction(() => { + this.loaded = true; for (const unread of unreads) { const { _id, ...data } = unread; this.channels.set(_id.channel, data); @@ -50,6 +53,11 @@ export default class Unreads { * @returns Partial channel unread object */ @computed getUnread(channel_id: string) { + if (!this.loaded) + return { + last_id: "40000000000000000000000000", + }; + return this.channels.get(channel_id); }