Merge branch 'master' into attachments

This commit is contained in:
thecodrr
2021-10-04 11:56:52 +05:00
3 changed files with 25 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
export default class Debug {
strip(item) {
return JSON.stringify({
title: !!item.title,
description: !!item.description,
headline: !!item.headline,
colored: !!item.color,
type: item.type,
notebooks: item.notebooks,
tags: item.tags,
id: item.id,
contentId: item.contentId,
dateEdited: item.dateEdited,
dateDeleted: item.dateDeleted,
dateCreated: item.dateCreated,
additionalData: item.additionalData,
});
}
}

View File

@@ -21,6 +21,7 @@ import http from "../utils/http";
import Monographs from "./monographs";
import Offers from "./offers";
import Attachments from "../collections/attachments";
import Debug from "./debug";
/**
* @type {EventSource}
@@ -51,7 +52,8 @@ class Database {
async init() {
EV.subscribeMulti(
[EVENTS.userLoggedIn, EVENTS.userFetched, EVENTS.tokenRefreshed],
this.connectSSE.bind(this)
this.connectSSE,
this
);
EV.subscribe(EVENTS.attachmentDeleted, async (attachment) => {
console.log("deleted:", attachment);
@@ -81,6 +83,7 @@ class Database {
this.outbox = new Outbox(this);
this.monographs = new Monographs(this);
this.offers = new Offers();
this.debug = new Debug();
// collections
/** @type {Notes} */

View File

@@ -7,9 +7,9 @@ class EventManager {
this._registry.clear();
}
subscribeMulti(names, handler) {
subscribeMulti(names, handler, thisArg) {
names.forEach((name) => {
this.subscribe(name, handler);
this.subscribe(name, handler.bind(thisArg));
});
}