UNPKG

weverse

Version:
36 lines (35 loc) 942 B
import { AssignType } from "../client"; export class WeverseNotification extends 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; } } export 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; } }