mirror of
https://github.com/block-core/blockcore-notes.git
synced 2024-09-29 14:30:43 +00:00
Fix Circle Service with new database code
This commit is contained in:
parent
54074601f0
commit
391a2a71e0
@ -185,6 +185,7 @@ export class AppComponent {
|
|||||||
|
|
||||||
/** Run initialize whenever user has been authenticated. */
|
/** Run initialize whenever user has been authenticated. */
|
||||||
async initialize() {
|
async initialize() {
|
||||||
|
debugger;
|
||||||
// await this.storage.open();
|
// await this.storage.open();
|
||||||
// await this.storage.initialize();
|
// await this.storage.initialize();
|
||||||
await this.db.initialize('blockcore-' + this.appState.getPublicKey());
|
await this.db.initialize('blockcore-' + this.appState.getPublicKey());
|
||||||
@ -253,6 +254,8 @@ export class AppComponent {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
debugger;
|
||||||
|
|
||||||
// Create the listeners (filters) for relays:
|
// Create the listeners (filters) for relays:
|
||||||
// TODO: There is limit on maximum following, we need a strategy to handle that.
|
// TODO: There is limit on maximum following, we need a strategy to handle that.
|
||||||
// potentially subscribing and unsubscribing on intervals with a .since field between each interval.
|
// potentially subscribing and unsubscribing on intervals with a .since field between each interval.
|
||||||
@ -263,7 +266,11 @@ export class AppComponent {
|
|||||||
|
|
||||||
console.log('PUB KEYS:', pubKeys);
|
console.log('PUB KEYS:', pubKeys);
|
||||||
|
|
||||||
this.relayService.queueSubscription([{ authors: pubKeys }]);
|
// Subscribe to new events but don't get any history (limit: 0).
|
||||||
|
|
||||||
|
console.log('queueSubscription:', { authors: pubKeys, since: this.db.state.since });
|
||||||
|
|
||||||
|
this.relayService.queueSubscription([{ authors: pubKeys, since: this.db.state.since }]);
|
||||||
|
|
||||||
// this.relayService.
|
// this.relayService.
|
||||||
|
|
||||||
|
@ -2,53 +2,44 @@
|
|||||||
|
|
||||||
<div class="feed-page">
|
<div class="feed-page">
|
||||||
<!-- <p>Circles is how you organize people you follow. Different circles can have different rules applied and circles is an important way to make the experience more enjoyable.</p> -->
|
<!-- <p>Circles is how you organize people you follow. Different circles can have different rules applied and circles is an important way to make the experience more enjoyable.</p> -->
|
||||||
|
|
||||||
|
<mat-card class="circle-container" *ngFor="let circle of circleService.circles">
|
||||||
<div *ngIf="items$ | withStatus | async as items">
|
<div class="circle-item"><mat-icon matListItemIcon [style.color]="circle.color">trip_origin</mat-icon></div>
|
||||||
<ng-template [ngIf]="items.value">
|
<div class="circle-item">
|
||||||
<mat-card class="circle-container" *ngFor="let circle of items.value">
|
{{ circle.name }}<br />
|
||||||
<div class="circle-item"><mat-icon matListItemIcon [style.color]="circle.color">trip_origin</mat-icon></div>
|
<span class="dimmed"><span>Count: {{ countMembers(circle) }}</span></span
|
||||||
<div class="circle-item">
|
><br />
|
||||||
{{ circle.name }}<br />
|
<span class="dimmed"><span *ngIf="circle.public">Public</span> <span *ngIf="!circle.public">Private</span> - {{ circle.style | circlestyle }} - Created: {{ circle.created | ago }}</span>
|
||||||
<span class="dimmed"
|
</div>
|
||||||
><span>Count: {{ countMembers(circle) }}</span></span
|
<div class="circle-item">
|
||||||
><br />
|
<button class="circle-button" mat-icon-button [matMenuTriggerFor]="menu">
|
||||||
<span class="dimmed"><span *ngIf="circle.public">Public</span> <span *ngIf="!circle.public">Private</span> - {{ circle.style | circlestyle }} - Created: {{ circle.created | ago }}</span>
|
<mat-icon class="circle-button-icon">more_vert</mat-icon>
|
||||||
</div>
|
</button>
|
||||||
<div class="circle-item">
|
|
||||||
<button class="circle-button" mat-icon-button [matMenuTriggerFor]="menu">
|
<mat-menu #menu="matMenu">
|
||||||
<mat-icon class="circle-button-icon">more_vert</mat-icon>
|
<button mat-menu-item [matMenuTriggerFor]="copyMenu">
|
||||||
</button>
|
<mat-icon>copy_all</mat-icon>
|
||||||
|
<span>Copy</span>
|
||||||
<mat-menu #menu="matMenu">
|
</button>
|
||||||
<button mat-menu-item [matMenuTriggerFor]="copyMenu">
|
<button *ngIf="circle.id" mat-menu-item (click)="deleteCircle(circle.id)">
|
||||||
<mat-icon>copy_all</mat-icon>
|
<mat-icon>delete</mat-icon>
|
||||||
<span>Copy</span>
|
<span>Delete Circle</span>
|
||||||
</button>
|
</button>
|
||||||
<button *ngIf="circle.id" mat-menu-item (click)="deleteCircle(circle.id)">
|
</mat-menu>
|
||||||
<mat-icon>delete</mat-icon>
|
|
||||||
<span>Delete Circle</span>
|
<mat-menu #copyMenu="matMenu">
|
||||||
</button>
|
<button mat-menu-item (click)="copyPubKeys(circle)">
|
||||||
</mat-menu>
|
<mat-icon>content_copy</mat-icon>
|
||||||
|
<span>Public Keys (npub)</span>
|
||||||
<mat-menu #copyMenu="matMenu">
|
</button>
|
||||||
<button mat-menu-item (click)="copyPubKeys(circle)">
|
<button mat-menu-item (click)="copyPubKeysHex(circle)">
|
||||||
<mat-icon>content_copy</mat-icon>
|
<mat-icon>content_copy</mat-icon>
|
||||||
<span>Public Keys (npub)</span>
|
<span>Public Keys (hex)</span>
|
||||||
</button>
|
</button>
|
||||||
<button mat-menu-item (click)="copyPubKeysHex(circle)">
|
</mat-menu>
|
||||||
<mat-icon>content_copy</mat-icon>
|
</div>
|
||||||
<span>Public Keys (hex)</span>
|
</mat-card>
|
||||||
</button>
|
|
||||||
</mat-menu>
|
|
||||||
</div>
|
|
||||||
</mat-card>
|
|
||||||
</ng-template>
|
|
||||||
<ng-template [ngIf]="items.loading"><mat-spinner class="loading"></mat-spinner></ng-template>
|
|
||||||
<ng-template [ngIf]="items.error">Error {{ items.error }}</ng-template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <mat-card class="circle-container" *ngFor="let circle of circles">
|
<!-- <mat-card class="circle-container" *ngFor="let circle of circles">
|
||||||
<div class="circle-item"><mat-icon matListItemIcon [style.color]="circle.color">trip_origin</mat-icon></div>
|
<div class="circle-item"><mat-icon matListItemIcon [style.color]="circle.color">trip_origin</mat-icon></div>
|
||||||
<div class="circle-item">
|
<div class="circle-item">
|
||||||
|
@ -26,12 +26,12 @@ export class CirclesComponent {
|
|||||||
following: NostrProfileDocument[] = [];
|
following: NostrProfileDocument[] = [];
|
||||||
searchTerm: any;
|
searchTerm: any;
|
||||||
|
|
||||||
items: Circle[] = [];
|
// items: Circle[] = [];
|
||||||
items$ = this.circleService.items$.pipe(
|
// items$ = this.circleService.items$.pipe(
|
||||||
tap((items) => {
|
// tap((items) => {
|
||||||
this.items = items;
|
// this.items = items;
|
||||||
})
|
// })
|
||||||
);
|
// );
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public appState: ApplicationState,
|
public appState: ApplicationState,
|
||||||
@ -104,13 +104,13 @@ export class CirclesComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getPublicPublicKeys() {
|
private getPublicPublicKeys() {
|
||||||
console.log(this.items);
|
// console.log(this.items);
|
||||||
console.log(this.following);
|
console.log(this.following);
|
||||||
|
|
||||||
const items: string[] = [];
|
const items: string[] = [];
|
||||||
|
|
||||||
for (let i = 0; i < this.items.length; i++) {
|
for (let i = 0; i < this.circleService.circles.length; i++) {
|
||||||
const circle = this.items[i];
|
const circle = this.circleService.circles[i];
|
||||||
|
|
||||||
if (circle.public) {
|
if (circle.public) {
|
||||||
const profiles = this.getFollowingInCircle(circle.id);
|
const profiles = this.getFollowingInCircle(circle.id);
|
||||||
@ -242,6 +242,6 @@ export class CirclesComponent {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
this.subscriptions.push(this.profileService.items$.subscribe((profiles) => (this.following = profiles)) as Subscription);
|
// this.subscriptions.push(this.profileService.items$.subscribe((profiles) => (this.following = profiles)) as Subscription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import { StorageService } from '../services/storage';
|
|||||||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
|
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
|
||||||
import { dexieToRx } from '../shared/utilities';
|
import { dexieToRx } from '../shared/utilities';
|
||||||
import { liveQuery } from 'dexie';
|
import { liveQuery } from 'dexie';
|
||||||
|
|
||||||
interface DefaultProfile {
|
interface DefaultProfile {
|
||||||
pubkey: string;
|
pubkey: string;
|
||||||
pubkeynpub: string;
|
pubkeynpub: string;
|
||||||
@ -182,6 +182,8 @@ export class HomeComponent {
|
|||||||
// Do what should be done next...
|
// Do what should be done next...
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await this.db.storage.delete();
|
||||||
|
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Circle } from './interfaces';
|
import { Circle } from './interfaces';
|
||||||
import { BehaviorSubject, from, Observable } from 'rxjs';
|
import { BehaviorSubject, from, Observable } from 'rxjs';
|
||||||
import { liveQuery } from 'dexie';
|
|
||||||
import { StorageService } from './storage';
|
import { StorageService } from './storage';
|
||||||
import { CacheService } from './cache';
|
import { CacheService } from './cache';
|
||||||
import { Utilities } from './utilities';
|
import { Utilities } from './utilities';
|
||||||
@ -11,32 +10,30 @@ import { dexieToRx } from '../shared/utilities';
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class CircleService {
|
export class CircleService {
|
||||||
static DEFAULT: Circle[] = [{ id: 0, name: 'Following', color: '#e91e63', style: 1, public: true },
|
static DEFAULT: Circle[] = [
|
||||||
{id: 1, name: "Text", color: '#7cb342', style: 2, public: true},
|
{ id: 0, name: 'Following', color: '#e91e63', style: 1, public: true },
|
||||||
{id: 2, name: "Photo", color: '#ffb300', style: 3, public: true},
|
{ id: 1, name: 'Text', color: '#7cb342', style: 2, public: true },
|
||||||
{id: 3, name: "Film", color: '#26c6da', style: 4, public: true},
|
{ id: 2, name: 'Photo', color: '#ffb300', style: 3, public: true },
|
||||||
{id: 4, name: "Music", color: '#ba9eea', style: 5, public: true},
|
{ id: 3, name: 'Film', color: '#26c6da', style: 4, public: true },
|
||||||
{id: 5, name: "Podcast", color: '#ff8a65', style: 6, public: true}];
|
{ id: 4, name: 'Music', color: '#ba9eea', style: 5, public: true },
|
||||||
|
{ id: 5, name: 'Podcast', color: '#ff8a65', style: 6, public: true },
|
||||||
private get table() {
|
];
|
||||||
return this.db.circles;
|
|
||||||
}
|
|
||||||
|
|
||||||
circles: Circle[] = [];
|
circles: Circle[] = [];
|
||||||
|
|
||||||
cache = new CacheService();
|
cache = new CacheService();
|
||||||
|
|
||||||
items$ = dexieToRx(liveQuery(() => this.items()));
|
// items$ = dexieToRx(liveQuery(() => this.items()));
|
||||||
|
|
||||||
async items() {
|
// async items() {
|
||||||
return await this.table.toArray();
|
// return await this.table.toArray();
|
||||||
}
|
// }
|
||||||
|
|
||||||
constructor(private db: StorageService, private utilities: Utilities) {}
|
constructor(private db: StorageService, private utilities: Utilities) {}
|
||||||
|
|
||||||
/** Important to call to ensure we have the default circle added */
|
/** Important to call to ensure we have the default circle added */
|
||||||
async initialize() {
|
async initialize() {
|
||||||
const defaultCircle = await this.table.get(0);
|
const defaultCircle = await this.db.storage.getCircle(0);
|
||||||
|
|
||||||
if (!defaultCircle) {
|
if (!defaultCircle) {
|
||||||
for (let index = 0; index < CircleService.DEFAULT.length; index++) {
|
for (let index = 0; index < CircleService.DEFAULT.length; index++) {
|
||||||
@ -45,10 +42,7 @@ export class CircleService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the circle so we can lookup quickly.
|
this.circles = await this.db.storage.getCircles();
|
||||||
this.items$.subscribe((circles) => {
|
|
||||||
this.circles = circles;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSync(id?: number) {
|
getSync(id?: number) {
|
||||||
@ -68,7 +62,7 @@ export class CircleService {
|
|||||||
if (this.circles.length > 0) {
|
if (this.circles.length > 0) {
|
||||||
return this.circles.find((c) => c.id == id);
|
return this.circles.find((c) => c.id == id);
|
||||||
} else {
|
} else {
|
||||||
return await this.table.get(id);
|
return await this.db.storage.getCircle(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,15 +74,10 @@ export class CircleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.modified = now;
|
document.modified = now;
|
||||||
await this.table.put(document);
|
await this.db.storage.putCircle(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(id: number) {
|
async delete(id: number) {
|
||||||
await this.table.delete(id);
|
await this.db.storage.deleteCircle(id);
|
||||||
}
|
|
||||||
|
|
||||||
/** Wipes all circles. */
|
|
||||||
async wipe() {
|
|
||||||
this.table.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,12 @@ export interface NostrRelaySubscription {
|
|||||||
filters: Filter[];
|
filters: Filter[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface StateDocument {
|
||||||
|
id: number;
|
||||||
|
since: number;
|
||||||
|
modified?: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface NostrRelayDocument {
|
export interface NostrRelayDocument {
|
||||||
url: string;
|
url: string;
|
||||||
// read: boolean;
|
// read: boolean;
|
||||||
|
@ -206,8 +206,6 @@ export class RelayService {
|
|||||||
const index = this.workers.findIndex((v) => v.url == url);
|
const index = this.workers.findIndex((v) => v.url == url);
|
||||||
const worker = this.workers[index];
|
const worker = this.workers[index];
|
||||||
|
|
||||||
debugger;
|
|
||||||
|
|
||||||
for (let index = 0; index < this.subs2.length; index++) {
|
for (let index = 0; index < this.subs2.length; index++) {
|
||||||
const sub = this.subs2[index];
|
const sub = this.subs2[index];
|
||||||
worker.subscribe(sub.filters, sub.id);
|
worker.subscribe(sub.filters, sub.id);
|
||||||
|
@ -2,8 +2,9 @@ import { Injectable } from '@angular/core';
|
|||||||
import Dexie, { Table } from 'dexie';
|
import Dexie, { Table } from 'dexie';
|
||||||
import { ApplicationState } from './applicationstate';
|
import { ApplicationState } from './applicationstate';
|
||||||
import { DatabaseService } from './database';
|
import { DatabaseService } from './database';
|
||||||
import { Circle, NostrEventDocument, NostrNoteDocument, NostrProfileDocument, NostrRelayDocument } from './interfaces';
|
import { Circle, NostrEventDocument, NostrNoteDocument, NostrProfileDocument, NostrRelayDocument, StateDocument } from './interfaces';
|
||||||
import { Storage } from '../types/storage';
|
import { Storage } from '../types/storage';
|
||||||
|
import * as moment from 'moment';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@ -34,15 +35,42 @@ export class StorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
db!: DatabaseService;
|
db!: DatabaseService;
|
||||||
|
state!: StateDocument;
|
||||||
|
|
||||||
async initialize(databaseName: string) {
|
async initialize(databaseName: string) {
|
||||||
// Open the new storage database.
|
// Open the new storage database.
|
||||||
this.storage = new Storage('blockcore-notes-' + this.appState.getPublicKey(), 1);
|
this.storage = new Storage('blockcore-notes-' + this.appState.getPublicKey(), 1);
|
||||||
await this.storage.open();
|
await this.storage.open();
|
||||||
|
|
||||||
|
let state = await this.storage.getState();
|
||||||
|
|
||||||
|
if (!state) {
|
||||||
|
// The initial since we will use is two days past.
|
||||||
|
const timeAgo = moment().subtract(2, 'days').unix();
|
||||||
|
|
||||||
|
state = {
|
||||||
|
id: 1,
|
||||||
|
since: timeAgo,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.state = state;
|
||||||
|
|
||||||
|
// Update the state on interval.
|
||||||
|
setTimeout(async () => {
|
||||||
|
console.log('Persisting state...');
|
||||||
|
|
||||||
|
// The since will always be set slightly back in time to counteract difference in clocks
|
||||||
|
// for different event creators on the nostr network.
|
||||||
|
const timeAgo = moment().subtract(10, 'minutes').unix();
|
||||||
|
this.state.since = timeAgo;
|
||||||
|
|
||||||
|
await this.storage.putState(this.state);
|
||||||
|
}, 60 * 1000);
|
||||||
|
|
||||||
// TODO: Remove, old code.
|
// TODO: Remove, old code.
|
||||||
this.db = new DatabaseService(databaseName);
|
// this.db = new DatabaseService(databaseName);
|
||||||
return this.db.open();
|
// return this.db.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
</mat-menu>
|
</mat-menu>
|
||||||
|
|
||||||
<mat-menu #categories="matMenu">
|
<mat-menu #categories="matMenu">
|
||||||
<button *ngFor="let circle of circleService.items$ | async" mat-menu-item (click)="follow(circle.id)">
|
<button *ngFor="let circle of circleService.circles" mat-menu-item (click)="follow(circle.id)">
|
||||||
<mat-icon [style.color]="circle.color">trip_origin</mat-icon>
|
<mat-icon [style.color]="circle.color">trip_origin</mat-icon>
|
||||||
<span>{{ circle.name }}</span>
|
<span>{{ circle.name }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { openDB, deleteDB, wrap, unwrap, IDBPDatabase, DBSchema } from 'idb';
|
import { openDB, deleteDB, wrap, unwrap, IDBPDatabase, DBSchema } from 'idb';
|
||||||
import { Circle, NostrEventDocument, NostrNoteDocument, NostrProfileDocument, NostrRelayDocument } from '../services/interfaces';
|
import { Circle, NostrEventDocument, NostrNoteDocument, NostrProfileDocument, NostrRelayDocument, StateDocument } from '../services/interfaces';
|
||||||
|
|
||||||
/** Make sure you read and learn: https://github.com/jakearchibald/idb */
|
/** Make sure you read and learn: https://github.com/jakearchibald/idb */
|
||||||
|
|
||||||
@ -8,6 +8,10 @@ export function now() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface NotesDB extends DBSchema {
|
interface NotesDB extends DBSchema {
|
||||||
|
state: {
|
||||||
|
value: StateDocument;
|
||||||
|
key: number;
|
||||||
|
};
|
||||||
relays: {
|
relays: {
|
||||||
value: NostrRelayDocument;
|
value: NostrRelayDocument;
|
||||||
key: string;
|
key: string;
|
||||||
@ -35,7 +39,7 @@ interface NotesDB extends DBSchema {
|
|||||||
export class Storage {
|
export class Storage {
|
||||||
public db!: IDBPDatabase<NotesDB>;
|
public db!: IDBPDatabase<NotesDB>;
|
||||||
|
|
||||||
constructor(private name: string, private version: number) { }
|
constructor(private name: string, private version: number) {}
|
||||||
|
|
||||||
async open() {
|
async open() {
|
||||||
this.db = await openDB<NotesDB>(this.name, this.version, {
|
this.db = await openDB<NotesDB>(this.name, this.version, {
|
||||||
@ -43,6 +47,7 @@ export class Storage {
|
|||||||
db.createObjectStore('relays', { keyPath: 'url' });
|
db.createObjectStore('relays', { keyPath: 'url' });
|
||||||
db.createObjectStore('notes', { keyPath: 'id' });
|
db.createObjectStore('notes', { keyPath: 'id' });
|
||||||
db.createObjectStore('circles', { keyPath: 'id' });
|
db.createObjectStore('circles', { keyPath: 'id' });
|
||||||
|
db.createObjectStore('state', { keyPath: 'id' });
|
||||||
|
|
||||||
const eventsStore = db.createObjectStore('events', { keyPath: 'id' });
|
const eventsStore = db.createObjectStore('events', { keyPath: 'id' });
|
||||||
eventsStore.createIndex('pubkey', 'pubkey');
|
eventsStore.createIndex('pubkey', 'pubkey');
|
||||||
@ -67,10 +72,24 @@ export class Storage {
|
|||||||
this.db.close();
|
this.db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getState() {
|
||||||
|
return this.db.get('state', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
async putState(value: StateDocument) {
|
||||||
|
value.id = 1;
|
||||||
|
value.modified = now();
|
||||||
|
return this.db.put('state', value);
|
||||||
|
}
|
||||||
|
|
||||||
async getCircle(key: number) {
|
async getCircle(key: number) {
|
||||||
return this.db.get('circles', key);
|
return this.db.get('circles', key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getCircles() {
|
||||||
|
return this.db.getAll('circles');
|
||||||
|
}
|
||||||
|
|
||||||
async putCircle(value: Circle) {
|
async putCircle(value: Circle) {
|
||||||
value.modified = now();
|
value.modified = now();
|
||||||
return this.db.put('circles', value);
|
return this.db.put('circles', value);
|
||||||
@ -118,6 +137,10 @@ export class Storage {
|
|||||||
return this.db.put('relays', value);
|
return this.db.put('relays', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteCircle(key: number) {
|
||||||
|
return this.db.delete('circles', key);
|
||||||
|
}
|
||||||
|
|
||||||
async deleteRelay(key: string) {
|
async deleteRelay(key: string) {
|
||||||
return this.db.delete('relays', key);
|
return this.db.delete('relays', key);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,6 @@ addEventListener('message', async (ev: MessageEvent) => {
|
|||||||
await relayWorker.publish(request.data);
|
await relayWorker.publish(request.data);
|
||||||
break;
|
break;
|
||||||
case 'subscribe':
|
case 'subscribe':
|
||||||
debugger;
|
|
||||||
await relayWorker.subscribe(request.data.filters, request.data.id);
|
await relayWorker.subscribe(request.data.filters, request.data.id);
|
||||||
break;
|
break;
|
||||||
case 'unsubscribe':
|
case 'unsubscribe':
|
||||||
@ -136,7 +135,6 @@ export class RelayWorker {
|
|||||||
|
|
||||||
relay.on('disconnect', () => {
|
relay.on('disconnect', () => {
|
||||||
console.log(`DISCONNECTED! ${relay?.url}`);
|
console.log(`DISCONNECTED! ${relay?.url}`);
|
||||||
debugger;
|
|
||||||
this.subscriptions = [];
|
this.subscriptions = [];
|
||||||
postMessage({ type: 'status', data: 0, url: relay.url } as RelayResponse);
|
postMessage({ type: 'status', data: 0, url: relay.url } as RelayResponse);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user