diff --git a/chat/preview/event-bus.ts b/chat/preview/event-bus.ts index e3bb42e..e214d90 100644 --- a/chat/preview/event-bus.ts +++ b/chat/preview/event-bus.ts @@ -1,9 +1,12 @@ // import Vue from 'vue'; import _ from 'lodash'; +// import log from 'electron-log'; //tslint:disable-line:match-default-export-name + import { Character } from '../../site/character_page/interfaces'; import { Message } from '../common'; import { Conversation } from '../interfaces'; import ChannelConversation = Conversation.ChannelConversation; + import { NoteCheckerCount } from '../../site/note-checker'; /** @@ -75,7 +78,11 @@ class EventBusManager { $emit(eventName: string, eventData: EventBusEvent): void { + // const d = Date.now(); + _.each(this.eventCallbacks[eventName] || [], (cb) => (cb(eventData))); + + // log.silly('event.bus.emit', { eventName, eventData, time: (Date.now() - d) / 1000 }); } diff --git a/learn/cache-manager.ts b/learn/cache-manager.ts index 0811dfb..ced4e5e 100644 --- a/learn/cache-manager.ts +++ b/learn/cache-manager.ts @@ -33,6 +33,9 @@ export interface ProfileCacheQueueEntry { export class CacheManager { + // @ts-ignore + private _isVue = true; + static readonly PROFILE_QUERY_DELAY = 400; //1 * 1000; adCache: AdCache = new AdCache(); diff --git a/learn/dictionary/WordDefinition.vue b/learn/dictionary/WordDefinition.vue index 46c2615..b9d3686 100644 --- a/learn/dictionary/WordDefinition.vue +++ b/learn/dictionary/WordDefinition.vue @@ -41,7 +41,7 @@ export default class WordDefinition extends Vue { readonly expression?: string; @Hook('mounted') - mounted(): void { + async mounted(): Promise { const webview = this.getWebview(); const eventProcessor = async (event: EventBusEvent): Promise => { @@ -52,6 +52,8 @@ export default class WordDefinition extends Vue { webview.addEventListener('update-target-url', eventProcessor); webview.addEventListener('dom-ready', eventProcessor); + + // await remote.webContents.fromId(webview.getWebContentsId()).session.clearStorageData({storages: ['cookies', 'indexdb']}); } diff --git a/learn/store/worker.ts b/learn/store/worker.ts index 5510dd6..37d5af3 100644 --- a/learn/store/worker.ts +++ b/learn/store/worker.ts @@ -6,6 +6,9 @@ import { WorkerClient } from './worker/client'; export class WorkerStore implements PermanentIndexedStore { + // @ts-ignore + private _isVue = true; + protected readonly workerClient: WorkerClient; constructor(jsEndpointFile: string) { diff --git a/learn/store/worker/client.ts b/learn/store/worker/client.ts index 2099881..dd92e56 100644 --- a/learn/store/worker/client.ts +++ b/learn/store/worker/client.ts @@ -8,9 +8,14 @@ export interface WaiterDef { id: string; resolve(result?: any): void; reject(result?: any): void; + initiated: number; + request: IndexedRequest; } export class WorkerClient { + // @ts-ignore + private _isVue = true; + private readonly worker: Worker; private idCounter = 0; @@ -30,8 +35,8 @@ export class WorkerClient { } - private when(id: string, resolve: (result?: any) => void, reject: (reason?: any) => void): void { - this.waiters.push({ id, resolve, reject }); + private when(id: string, resolve: (result?: any) => void, reject: (reason?: any) => void, request: IndexedRequest): void { + this.waiters.push({ id, resolve, reject, request, initiated: Date.now() }); } @@ -39,7 +44,7 @@ export class WorkerClient { return (e: Event) => { const res = (e as any).data as IndexedResponse; - log.silly('store.worker.client.msg', { res }); + // log.silly('store.worker.client.msg', { res }); if (!res) { log.error('store.worker.client.msg.invalid', { res }); @@ -54,8 +59,10 @@ export class WorkerClient { } if (res.state === 'ok') { + // log.silly('store.worker.client.msg.ok', { t: (Date.now() - waiter.initiated) / 1000, req: waiter.request }); waiter.resolve(res.result); } else { + log.error('store.worker.client.msg.err', { t: (Date.now() - waiter.initiated) / 1000, msg: res.msg, req: waiter.request }); waiter.reject(new Error(res.msg)); } @@ -66,6 +73,8 @@ export class WorkerClient { private clearWaiter(id: string): void { this.waiters = _.filter(this.waiters, (w) => (w.id !== id)); + + // log.silly('store.worker.waiter.clear', this.waiters.length); } @@ -84,7 +93,8 @@ export class WorkerClient { this.when( id, resolve, - reject + reject, + request ); this.worker.postMessage(request);