More logging
This commit is contained in:
parent
d7bb947413
commit
567df79af1
|
@ -1,4 +1,5 @@
|
|||
import {WebSocketConnection} from '../fchat';
|
||||
import log from 'electron-log'; //tslint:disable-line:match-default-export-name
|
||||
|
||||
export default class Socket implements WebSocketConnection {
|
||||
static host = 'wss://chat.f-list.net/chat2';
|
||||
|
@ -14,6 +15,7 @@ export default class Socket implements WebSocketConnection {
|
|||
}
|
||||
|
||||
close(): void {
|
||||
log.debug('socket.close');
|
||||
this.socket.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -153,8 +153,8 @@ export class ImageDomMutator {
|
|||
this.add('vimeo.com', this.getBaseJsMutatorScript(['#video, video', '#image, img']));
|
||||
this.add('sex.com', this.getBaseJsMutatorScript(['.image_frame video', '.image_frame img']));
|
||||
// this.add('redirect.media.tumblr.com', this.getBaseJsMutatorScript(['picture video', 'picture img']));
|
||||
this.add(/^[a-zA-Z0-9-]+\.media\.tumblr\.com$/, this.getBaseJsMutatorScript(['.photoset video', '.photoset img', '#base-container video', '#base-container img', 'picture video', 'picture img', 'video', 'img']));
|
||||
this.add(/^[a-zA-Z0-9-]+\.tumblr\.com$/, this.getBaseJsMutatorScript(['.photoset iframe', '.photoset video', '.photoset img', 'picture video', 'picture img', 'video', 'img']));
|
||||
this.add(/^[a-zA-Z0-9-]+\.media\.tumblr\.com$/, this.getBaseJsMutatorScript(['.photoset video', '.photoset img', '#base-container video', '#base-container img', 'picture video', 'picture img', 'video', 'img']), undefined, 'dom-ready');
|
||||
this.add(/^[a-zA-Z0-9-]+\.tumblr\.com$/, this.getBaseJsMutatorScript(['.photoset iframe', '.photoset video', '.photoset img', 'picture video', 'picture img', 'video', 'img']), undefined, 'dom-ready');
|
||||
this.add('postimg.cc', this.getBaseJsMutatorScript(['video', '#main-image']));
|
||||
this.add('gifsauce.com', this.getBaseJsMutatorScript(['video']));
|
||||
// this.add('motherless.com', this.getBaseJsMutatorScript(['.content video', '.content img']));
|
||||
|
|
|
@ -141,7 +141,7 @@
|
|||
);
|
||||
|
||||
|
||||
log.info('About to load keytar');
|
||||
log.info('init.chat.keytar.load.start');
|
||||
|
||||
/* tslint:disable: no-any no-unsafe-any */ //because this is hacky
|
||||
|
||||
|
@ -153,7 +153,8 @@
|
|||
}>('keytar/build/Release/keytar.node');
|
||||
for(const key in keyStore) keyStore[key] = promisify(<(...args: any[]) => any>keyStore[key].bind(keyStore, 'fchat'));
|
||||
//tslint:enable
|
||||
log.info('Loaded keytar.');
|
||||
|
||||
log.info('init.chat.keytar.load.done');
|
||||
|
||||
@Component({
|
||||
components: {chat: Chat, modal: Modal, characterPage: CharacterPage, logs: Logs}
|
||||
|
@ -180,6 +181,8 @@
|
|||
|
||||
|
||||
async startAndUpgradeCache(): Promise<void> {
|
||||
log.debug('init.chat.cache.start');
|
||||
|
||||
const timer = setTimeout(
|
||||
() => {
|
||||
this.shouldShowSpinner = true;
|
||||
|
@ -190,22 +193,34 @@
|
|||
// tslint:disable-next-line no-floating-promises
|
||||
await core.cache.start(this.settings, this.hasCompletedUpgrades);
|
||||
|
||||
log.debug('init.chat.cache.done');
|
||||
|
||||
clearTimeout(timer);
|
||||
|
||||
parent.send('rising-upgrade-complete');
|
||||
electron.ipcRenderer.send('rising-upgrade-complete');
|
||||
|
||||
this.hasCompletedUpgrades = true;
|
||||
}
|
||||
|
||||
|
||||
@Hook('mounted')
|
||||
onMounted(): void {
|
||||
log.debug('init.chat.mounted');
|
||||
}
|
||||
|
||||
|
||||
@Hook('created')
|
||||
async created(): Promise<void> {
|
||||
await this.startAndUpgradeCache();
|
||||
|
||||
if(this.settings.account.length > 0) this.saveLogin = true;
|
||||
|
||||
keyStore.getPassword(this.settings.account)
|
||||
.then((value: string) => this.password = value, (err: Error) => this.error = err.message);
|
||||
|
||||
log.debug('init.chat.keystore.get.done');
|
||||
|
||||
Vue.set(core.state, 'generalSettings', this.settings);
|
||||
|
||||
electron.ipcRenderer.on('settings',
|
||||
|
@ -222,11 +237,14 @@
|
|||
this.fixCharacter = this.fixCharacters[0];
|
||||
(<Modal>this.$refs['fixLogsModal']).show();
|
||||
});
|
||||
|
||||
window.addEventListener('keydown', (e) => {
|
||||
if(getKey(e) === Keys.Tab && e.ctrlKey && !e.altKey && !e.shiftKey)
|
||||
parent.send('switch-tab', this.character);
|
||||
});
|
||||
|
||||
log.debug('init.chat.listeners.done');
|
||||
|
||||
/*if (process.env.NODE_ENV !== 'production') {
|
||||
const dt = require('@vue/devtools');
|
||||
|
||||
|
|
|
@ -89,17 +89,23 @@
|
|||
|
||||
@Hook('mounted')
|
||||
async mounted(): Promise<void> {
|
||||
log.debug('init.window.mounting');
|
||||
// top bar devtools
|
||||
// browserWindow.webContents.openDevTools({ mode: 'detach' });
|
||||
|
||||
updateSupportedLanguages(browserWindow.webContents.session.availableSpellCheckerLanguages);
|
||||
|
||||
log.debug('init.window.languages.supported');
|
||||
// console.log('MOUNT DICTIONARIES', getSafeLanguages(this.settings.spellcheckLang), this.settings.spellcheckLang);
|
||||
|
||||
browserWindow.webContents.session.setSpellCheckerLanguages(getSafeLanguages(this.settings.spellcheckLang));
|
||||
|
||||
log.debug('init.window.languages');
|
||||
|
||||
await this.addTab();
|
||||
|
||||
log.debug('init.window.tab');
|
||||
|
||||
electron.ipcRenderer.on('settings', (_e: Event, settings: GeneralSettings) => {
|
||||
this.settings = settings;
|
||||
|
||||
|
@ -113,7 +119,6 @@
|
|||
electron.ipcRenderer.on('update-available', (_e: Event, available: boolean) => this.hasUpdate = available);
|
||||
electron.ipcRenderer.on('fix-logs', () => this.activeTab!.view.webContents.send('fix-logs'));
|
||||
electron.ipcRenderer.on('quit', () => this.destroyAllTabs());
|
||||
|
||||
electron.ipcRenderer.on('update-dictionaries', (_e: Event, langs: string[]) => {
|
||||
// console.log('UPDATE DICTIONARIES', langs);
|
||||
|
||||
|
@ -189,6 +194,8 @@
|
|||
return false;
|
||||
};
|
||||
this.isMaximized = browserWindow.isMaximized();
|
||||
|
||||
log.debug('init.window.mounted');
|
||||
}
|
||||
|
||||
destroyAllTabs(): void {
|
||||
|
@ -243,12 +250,18 @@
|
|||
this.tabMap[view.webContents.id] = tab;
|
||||
this.show(tab);
|
||||
this.lockTab = true;
|
||||
|
||||
log.debug('init.window.tab.load');
|
||||
|
||||
await view.webContents.loadURL(url.format({
|
||||
pathname: path.join(__dirname, 'index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true,
|
||||
query: {settings: JSON.stringify(this.settings), hasCompletedUpgrades: JSON.stringify(this.hasCompletedUpgrades)}
|
||||
}));
|
||||
|
||||
log.debug('init.window.tab.load.complete');
|
||||
|
||||
tab.view.setBounds(getWindowBounds());
|
||||
this.lockTab = false;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ import Index from './Index.vue';
|
|||
import log from 'electron-log'; // tslint:disable-line: match-default-export-name
|
||||
|
||||
|
||||
log.debug('init.chat');
|
||||
|
||||
document.addEventListener('keydown', (e: KeyboardEvent) => {
|
||||
if(e.ctrlKey && e.shiftKey && getKey(e) === Keys.KeyI)
|
||||
electron.remote.getCurrentWebContents().toggleDevTools();
|
||||
|
@ -218,9 +220,14 @@ if(params['import'] !== undefined)
|
|||
}
|
||||
onSettings(settings);
|
||||
|
||||
|
||||
log.debug('init.chat.core');
|
||||
|
||||
const connection = new Connection(`F-Chat 3.0 (${process.platform})`, electron.remote.app.getVersion(), Socket);
|
||||
initCore(connection, settings, Logs, SettingsStore, Notifications);
|
||||
|
||||
log.debug('init.chat.vue');
|
||||
|
||||
//tslint:disable-next-line:no-unused-expression
|
||||
new Index({
|
||||
el: '#app',
|
||||
|
|
|
@ -300,6 +300,8 @@ function showPatchNotes(): void {
|
|||
|
||||
|
||||
function onReady(): void {
|
||||
let hasCompletedUpgrades = false;
|
||||
|
||||
const logLevel = (process.env.NODE_ENV === 'production') ? 'info' : 'silly';
|
||||
|
||||
log.transports.file.level = settings.risingSystemLogLevel || logLevel;
|
||||
|
@ -394,11 +396,17 @@ function onReady(): void {
|
|||
{
|
||||
label: `&${l('title')}`,
|
||||
submenu: [
|
||||
{label: l('action.newWindow'), click: createWindow, accelerator: 'CmdOrCtrl+n'},
|
||||
{
|
||||
label: l('action.newWindow'),
|
||||
click: () => {
|
||||
if (hasCompletedUpgrades) createWindow();
|
||||
},
|
||||
accelerator: 'CmdOrCtrl+n'
|
||||
},
|
||||
{
|
||||
label: l('action.newTab'),
|
||||
click: (_m: Electron.MenuItem, w: Electron.BrowserWindow) => {
|
||||
if(tabCount < 3) w.webContents.send('open-tab');
|
||||
if((hasCompletedUpgrades) && (tabCount < 3)) w.webContents.send('open-tab');
|
||||
},
|
||||
accelerator: 'CmdOrCtrl+t'
|
||||
},
|
||||
|
@ -596,6 +604,7 @@ function onReady(): void {
|
|||
});
|
||||
|
||||
electron.ipcMain.on('rising-upgrade-complete', () => {
|
||||
hasCompletedUpgrades = true;
|
||||
for(const w of electron.webContents.getAllWebContents()) w.send('rising-upgrade-complete');
|
||||
});
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ import log from 'electron-log'; //tslint:disable-line:match-default-export-name
|
|||
import {GeneralSettings} from './common';
|
||||
import Window from './Window.vue';
|
||||
|
||||
log.info('init.window');
|
||||
|
||||
const params = <{[key: string]: string | undefined}>qs.parse(window.location.search.substr(1));
|
||||
const settings = <GeneralSettings>JSON.parse(params['settings']!);
|
||||
|
||||
|
@ -13,6 +15,7 @@ log.transports.file.level = settings.risingSystemLogLevel || logLevel;
|
|||
log.transports.console.level = settings.risingSystemLogLevel || logLevel;
|
||||
log.transports.file.maxSize = 5 * 1024 * 1024;
|
||||
|
||||
log.info('init.window.vue');
|
||||
|
||||
//tslint:disable-next-line:no-unused-expression
|
||||
new Window({
|
||||
|
|
|
@ -94,7 +94,7 @@ export default class Connection implements Interfaces.Connection {
|
|||
const data = msg.length > 6 ? <object>JSON.parse(msg.substr(4)) : undefined;
|
||||
|
||||
log.silly(
|
||||
'socket.message',
|
||||
'socket.recv',
|
||||
{
|
||||
type, data
|
||||
}
|
||||
|
@ -268,8 +268,13 @@ export default class Connection implements Interfaces.Connection {
|
|||
}
|
||||
|
||||
send<K extends keyof Interfaces.ClientCommands>(command: K, data?: Interfaces.ClientCommands[K]): void {
|
||||
if(this.socket !== undefined && this.socket.readyState === WebSocketConnection.ReadyState.OPEN)
|
||||
this.socket.send(<string>command + (data !== undefined ? ` ${JSON.stringify(data)}` : ''));
|
||||
if(this.socket !== undefined && this.socket.readyState === WebSocketConnection.ReadyState.OPEN) {
|
||||
const msg = <string>command + (data !== undefined ? ` ${JSON.stringify(data)}` : '');
|
||||
|
||||
log.debug('socket.send', { data: msg });
|
||||
|
||||
this.socket.send(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//tslint:disable:no-unsafe-any no-any
|
||||
|
@ -366,6 +371,13 @@ export default class Connection implements Interfaces.Connection {
|
|||
|
||||
private resetPinTimeout(): void {
|
||||
if(this.pinTimeout) clearTimeout(this.pinTimeout);
|
||||
this.pinTimeout = setTimeout(() => this.socket!.close(), 90000);
|
||||
|
||||
this.pinTimeout = setTimeout(
|
||||
() => {
|
||||
log.error('pin.timeout');
|
||||
this.socket!.close();
|
||||
},
|
||||
90000
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue