UNPKG

weverse

Version:
41 lines (40 loc) 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ClientNotifications = exports.WeverseNotification = void 0; const client_1 = require("../client"); class WeverseNotification extends (0, client_1.AssignType)() { constructor(props, community, artist) { super(props); this.artist = artist !== null && artist !== void 0 ? artist : undefined; this.community = community; } toJSON() { const partial = Object.assign({}, this); delete partial.community; delete partial.artist; return partial; } } exports.WeverseNotification = WeverseNotification; class ClientNotifications { constructor() { this.all = []; this.new = []; this.allMap = new Map(); } get(id) { return this.allMap.get(id); } addMany(notifications) { this.new = []; notifications.forEach(n => { if (!this.allMap.has(n.id)) { this.all.push(n); this.allMap.set(n.id, n); this.new.push(n); } }); return this.new; } } exports.ClientNotifications = ClientNotifications;