Minor
This commit is contained in:
parent
2006270f6a
commit
b09fe7ec43
|
@ -1,9 +1,12 @@
|
||||||
// import Vue from 'vue';
|
// import Vue from 'vue';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
// import log from 'electron-log'; //tslint:disable-line:match-default-export-name
|
||||||
|
|
||||||
import { Character } from '../../site/character_page/interfaces';
|
import { Character } from '../../site/character_page/interfaces';
|
||||||
import { Message } from '../common';
|
import { Message } from '../common';
|
||||||
import { Conversation } from '../interfaces';
|
import { Conversation } from '../interfaces';
|
||||||
import ChannelConversation = Conversation.ChannelConversation;
|
import ChannelConversation = Conversation.ChannelConversation;
|
||||||
|
|
||||||
import { NoteCheckerCount } from '../../site/note-checker';
|
import { NoteCheckerCount } from '../../site/note-checker';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +78,11 @@ class EventBusManager {
|
||||||
|
|
||||||
|
|
||||||
$emit(eventName: string, eventData: EventBusEvent): void {
|
$emit(eventName: string, eventData: EventBusEvent): void {
|
||||||
|
// const d = Date.now();
|
||||||
|
|
||||||
_.each(this.eventCallbacks[eventName] || [], (cb) => (cb(eventData)));
|
_.each(this.eventCallbacks[eventName] || [], (cb) => (cb(eventData)));
|
||||||
|
|
||||||
|
// log.silly('event.bus.emit', { eventName, eventData, time: (Date.now() - d) / 1000 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,9 @@ export interface ProfileCacheQueueEntry {
|
||||||
|
|
||||||
|
|
||||||
export class CacheManager {
|
export class CacheManager {
|
||||||
|
// @ts-ignore
|
||||||
|
private _isVue = true;
|
||||||
|
|
||||||
static readonly PROFILE_QUERY_DELAY = 400; //1 * 1000;
|
static readonly PROFILE_QUERY_DELAY = 400; //1 * 1000;
|
||||||
|
|
||||||
adCache: AdCache = new AdCache();
|
adCache: AdCache = new AdCache();
|
||||||
|
|
|
@ -41,7 +41,7 @@ export default class WordDefinition extends Vue {
|
||||||
readonly expression?: string;
|
readonly expression?: string;
|
||||||
|
|
||||||
@Hook('mounted')
|
@Hook('mounted')
|
||||||
mounted(): void {
|
async mounted(): Promise<void> {
|
||||||
const webview = this.getWebview();
|
const webview = this.getWebview();
|
||||||
|
|
||||||
const eventProcessor = async (event: EventBusEvent): Promise<void> => {
|
const eventProcessor = async (event: EventBusEvent): Promise<void> => {
|
||||||
|
@ -52,6 +52,8 @@ export default class WordDefinition extends Vue {
|
||||||
|
|
||||||
webview.addEventListener('update-target-url', eventProcessor);
|
webview.addEventListener('update-target-url', eventProcessor);
|
||||||
webview.addEventListener('dom-ready', eventProcessor);
|
webview.addEventListener('dom-ready', eventProcessor);
|
||||||
|
|
||||||
|
// await remote.webContents.fromId(webview.getWebContentsId()).session.clearStorageData({storages: ['cookies', 'indexdb']});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ import { WorkerClient } from './worker/client';
|
||||||
|
|
||||||
|
|
||||||
export class WorkerStore implements PermanentIndexedStore {
|
export class WorkerStore implements PermanentIndexedStore {
|
||||||
|
// @ts-ignore
|
||||||
|
private _isVue = true;
|
||||||
|
|
||||||
protected readonly workerClient: WorkerClient;
|
protected readonly workerClient: WorkerClient;
|
||||||
|
|
||||||
constructor(jsEndpointFile: string) {
|
constructor(jsEndpointFile: string) {
|
||||||
|
|
|
@ -8,9 +8,14 @@ export interface WaiterDef {
|
||||||
id: string;
|
id: string;
|
||||||
resolve(result?: any): void;
|
resolve(result?: any): void;
|
||||||
reject(result?: any): void;
|
reject(result?: any): void;
|
||||||
|
initiated: number;
|
||||||
|
request: IndexedRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WorkerClient {
|
export class WorkerClient {
|
||||||
|
// @ts-ignore
|
||||||
|
private _isVue = true;
|
||||||
|
|
||||||
private readonly worker: Worker;
|
private readonly worker: Worker;
|
||||||
|
|
||||||
private idCounter = 0;
|
private idCounter = 0;
|
||||||
|
@ -30,8 +35,8 @@ export class WorkerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private when(id: string, resolve: (result?: any) => void, reject: (reason?: any) => void): void {
|
private when(id: string, resolve: (result?: any) => void, reject: (reason?: any) => void, request: IndexedRequest): void {
|
||||||
this.waiters.push({ id, resolve, reject });
|
this.waiters.push({ id, resolve, reject, request, initiated: Date.now() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +44,7 @@ export class WorkerClient {
|
||||||
return (e: Event) => {
|
return (e: Event) => {
|
||||||
const res = (e as any).data as IndexedResponse;
|
const res = (e as any).data as IndexedResponse;
|
||||||
|
|
||||||
log.silly('store.worker.client.msg', { res });
|
// log.silly('store.worker.client.msg', { res });
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
log.error('store.worker.client.msg.invalid', { res });
|
log.error('store.worker.client.msg.invalid', { res });
|
||||||
|
@ -54,8 +59,10 @@ export class WorkerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.state === 'ok') {
|
if (res.state === 'ok') {
|
||||||
|
// log.silly('store.worker.client.msg.ok', { t: (Date.now() - waiter.initiated) / 1000, req: waiter.request });
|
||||||
waiter.resolve(res.result);
|
waiter.resolve(res.result);
|
||||||
} else {
|
} 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));
|
waiter.reject(new Error(res.msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +73,8 @@ export class WorkerClient {
|
||||||
|
|
||||||
private clearWaiter(id: string): void {
|
private clearWaiter(id: string): void {
|
||||||
this.waiters = _.filter(this.waiters, (w) => (w.id !== id));
|
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(
|
this.when(
|
||||||
id,
|
id,
|
||||||
resolve,
|
resolve,
|
||||||
reject
|
reject,
|
||||||
|
request
|
||||||
);
|
);
|
||||||
|
|
||||||
this.worker.postMessage(request);
|
this.worker.postMessage(request);
|
||||||
|
|
Loading…
Reference in New Issue