app starts but full of errors

This commit is contained in:
Audric Ackermann 2022-04-01 16:55:17 +11:00
parent 2b17ad5cfa
commit 4d72b92b25
14 changed files with 72 additions and 113 deletions

View File

@ -50,6 +50,6 @@
</div>
<script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="js/about_start.js"></script>
<script type="text/javascript" src="ts/start/about_start.js"></script>
</body>
</html>

View File

@ -20,7 +20,7 @@
img-src 'self' blob: data:;
media-src 'self' blob:;
object-src 'none';
script-src 'self' 'unsafe-eval';
script-src 'self' 'unsafe-inline';
style-src 'self' 'unsafe-inline';"
/>
<title>Session</title>
@ -31,14 +31,17 @@
<script type="text/javascript" src="js/libtextsecure.js"></script>
</head>
<body>
<div class="app-loading-screen">
<div class="content session-full-logo">
<img src="images/session/brand.svg" class="session-brand-logo" />
<img src="images/session/session-text.svg" class="session-text-logo" />
<body id="body">
<div id="root">
<div class="app-loading-screen">
<div class="content session-full-logo">
<img src="images/session/brand.svg" class="session-brand-logo" />
<img src="images/session/session-text.svg" class="session-text-logo" />
</div>
</div>
</div>
<script type="text/javascript" src="ts/mains/main_renderer.js"></script>
<script type="text/javascript">
require('./ts/mains/main_renderer.js');
</script>
</body>
</html>

View File

@ -18,7 +18,7 @@
<style></style>
</head>
<body>
<div id="app"></div>
<div id="root"></div>
</body>
<script type="text/javascript" src="js/debug_log_start.js"></script>

View File

@ -20,10 +20,12 @@
<script type="text/javascript" src="js/components.js"></script>
</head>
<body>
<div class="app-loading-screen">
<div class="content session-full-logo">
<img src="images/session/brand.svg" class="session-brand-logo" />
<img src="images/session/session-text.svg" class="session-text-logo" />
<div id="root">
<div class="app-loading-screen">
<div class="content session-full-logo">
<img src="images/session/brand.svg" class="session-brand-logo" />
<img src="images/session/session-text.svg" class="session-text-logo" />
</div>
</div>
</div>
<script type="text/javascript" src="js/password_start.js"></script>

View File

@ -208,9 +208,9 @@ const { WorkerInterface } = require('./ts/node/util_worker_interface');
// A Worker with a 3 minute timeout
console.warn('app', require('electron/main').app);
const utilWorkerPath = path.join(app.getAppPath(), 'js', 'util_worker.js');
const utilWorker = new WorkerInterface(utilWorkerPath, 3 * 60 * 1000);
// console.warn('app', require('electron/main').app);
// const utilWorkerPath = path.join(app.getAppPath(), 'js', 'util_worker.js');
// const utilWorker = new WorkerInterface(utilWorkerPath, 3 * 60 * 1000);
window.callWorker = (fnName, ...args) => utilWorker.callWorker(fnName, ...args);
// Linux seems to periodically let the event loop stop, so this is a global workaround

View File

@ -184,11 +184,9 @@ export function initData() {
// any warnings that might be sent to the console in that case.
ipcRenderer.setMaxListeners(0);
_.forEach(channelsToMake, fn => {
if (_.isFunction(fn)) {
makeChannel(fn.name);
}
});
channelsToMake.forEach(makeChannel);
console.warn('after initData channels', channels);
ipcRenderer.on(`${SQL_CHANNEL_KEY}-done`, (_event, jobId, errorForDisplay, result) => {
const job = _getJob(jobId);

View File

@ -26,11 +26,11 @@ export function useAppIsFocused() {
}, []);
useEffect(() => {
app.on('browser-window-focus', onFocusCallback);
app.on('browser-window-blur', onBlurCallback);
// app.on('browser-window-focus', onFocusCallback);
// app.on('browser-window-blur', onBlurCallback);
return () => {
app.removeListener('browser-window-blur', onBlurCallback);
app.removeListener('browser-window-focus', onFocusCallback);
// app.removeListener('browser-window-blur', onBlurCallback);
// app.removeListener('browser-window-focus', onFocusCallback);
};
});

View File

@ -264,7 +264,7 @@ async function createWindow() {
fullscreen: false as boolean | undefined,
backgroundColor: '#000',
webPreferences: {
nodeIntegration: false,
nodeIntegration: true,
enableRemoteModule: true,
nodeIntegrationInWorker: true,
contextIsolation: false,
@ -484,7 +484,7 @@ async function showPasswordWindow() {
nodeIntegration: false,
enableRemoteModule: true,
nodeIntegrationInWorker: false,
contextIsolation: false,
contextIsolation: true,
// sandbox: true,
preload: path.join(__dirname, '..', 'password_preload.js'),

View File

@ -10,12 +10,13 @@ import { ExpirationTimerOptions } from '../util/expiringMessages';
import { Notifications } from '../util/notifications';
import { Registration } from '../util/registration';
import { isSignInByLinking, Storage } from '../util/storage';
import jQuery from 'jquery';
import * as Data from '../data/data';
import Backbone from 'backbone';
import { SessionRegistrationView } from '../components/registration/SessionRegistrationView';
import { SessionInboxView } from '../components/SessionInboxView';
import { deleteAllLogs } from '../node/logs';
import ReactDOM from 'react-dom';
import React from 'react';
// tslint:disable: max-classes-per-file
// Globally disable drag and drop
@ -81,6 +82,7 @@ window.document.title = window.getTitle();
// Whisper.events =
// window.Whisper.events = WhisperEvents ?
const WhisperEvents = _.clone(Backbone.Events);
window.Whisper = window.Whisper || {};
window.Whisper.events = WhisperEvents;
window.log.info('Storage fetch');
@ -227,17 +229,33 @@ async function start() {
await connect();
});
const appView = new AppView({
el: jQuery('body'),
});
function openInbox() {
const rtlLocales = ['fa', 'ar', 'he'];
const loc = (window.i18n as any).getLocale();
if (rtlLocales.includes(loc) && !document.getElementById('body')?.classList.contains('rtl')) {
document.getElementById('body')?.classList.add('rtl');
}
const hideMenuBar = Storage.get('hide-menu-bar', true) as boolean;
window.setAutoHideMenuBar(hideMenuBar);
window.setMenuBarVisibility(!hideMenuBar);
getConversationController()
.loadPromise()
?.then(() => {
ReactDOM.render(<SessionInboxView />, document.getElementById('root'));
});
}
function openStandAlone() {
ReactDOM.render(<SessionRegistrationView />, document.getElementById('root'));
}
ExpirationTimerOptions.initExpiringMessageListener();
if (Registration.isDone() && !isSignInByLinking()) {
await connect();
appView.openInbox();
openInbox();
} else {
appView.openStandalone();
openStandAlone();
}
window.addEventListener('focus', () => {
@ -324,12 +342,12 @@ async function start() {
// do not put the messageId here so the conversation is loaded on the last unread instead
await window.openConversationWithMessages({ conversationKey, messageId: null });
} else {
appView.openInbox();
openInbox();
}
};
WhisperEvents.on('openInbox', () => {
appView.openInbox();
openInbox();
});
}
@ -406,6 +424,7 @@ async function connect() {
logger: window.log,
});
window.textsecure = window.textsecure || {};
window.textsecure.messaging = true;
}
@ -415,70 +434,6 @@ function onEmpty() {
Notifications.enable();
}
class AppView extends Backbone.View {
private inboxView: any | null = null;
private standaloneView: any;
public initialize() {
this.inboxView = null;
const rtlLocales = ['fa', 'ar', 'he'];
const loc = (window.i18n as any).getLocale();
if (rtlLocales.includes(loc)) {
this.$el.addClass('rtl');
}
const hideMenuBar = Storage.get('hide-menu-bar', true) as boolean;
window.setAutoHideMenuBar(hideMenuBar);
window.setMenuBarVisibility(!hideMenuBar);
}
// events: {
// openInbox: 'openInbox';
// };
public openView(view: any) {
// tslint:disable-next-line: no-inner-html
this.el.innerHTML = '';
this.el.append(view.el);
this.delegateEvents();
}
public openStandalone() {
this.resetViews();
this.standaloneView = SessionRegistrationView();
this.openView(this.standaloneView);
}
public closeStandalone() {
if (this.standaloneView) {
this.standaloneView.remove();
this.standaloneView = null;
}
}
public resetViews() {
this.closeStandalone();
}
public openInbox() {
if (!this.inboxView) {
this.inboxView = new SessionInboxView({
window,
});
return getConversationController()
.loadPromise()
?.then(() => {
this.openView(this.inboxView);
});
}
if (!$.contains(this.el, this.inboxView.el)) {
this.openView(this.inboxView);
}
window.focus(); // FIXME
return Promise.resolve();
}
}
class TextScramble {
private frame: any;
private queue: any;

View File

@ -43,10 +43,10 @@ export function initializeSqlChannel() {
});
console.warn('********* registering get-user-data-path');
ipcMain.on('get-user-data-path', () => {
ipcMain.handle('get-user-data-path', () => {
return app.getPath('userData');
});
ipcMain.on('get-data-path', () => {
ipcMain.handle('get-data-path', () => {
return app.getAppPath();
});
initialized = true;

View File

@ -1,8 +1,9 @@
import { BrowserWindow } from 'electron';
export function isElectronWindowFocused() {
const [yourBrowserWindow] = BrowserWindow.getAllWindows();
const isFocused = yourBrowserWindow?.isFocused() || false;
// const [yourBrowserWindow] = BrowserWindow.getAllWindows();
// const isFocused = yourBrowserWindow?.isFocused() || false;
// throw new Error('TOFIX');
return false;
return isFocused;
}

View File

@ -2,7 +2,7 @@
// Add version and commit hash
$('.version').text(`v${window.getVersion()}`);
$('.commitHash').text(window.getCommitHash());
$('.commitHash').text(window.getCommitHash() || '');
// Add debugging metadata - environment if not production, app instance name
const states = [];
@ -17,10 +17,10 @@ if (window.getAppInstance()) {
$('.environment').text(states.join(' - '));
// Install the 'dismiss with escape key' handler
$(document).on('keyup', e => {
'use strict';
// $(document).on('keyup', e => {
// 'use strict';
if (e.keyCode === 27) {
window.closeAbout();
}
});
// if (e.keyCode === 27) {
// window.closeAbout();
// }
// });

View File

@ -13,4 +13,4 @@ import { DebugLogView } from '../views/DebugLogView';
// });
// Whisper ?
window.ReactDOM.render(<DebugLogView />, document.getElementById('app'));
window.ReactDOM.render(<DebugLogView />, document.getElementById('root'));

View File

@ -10,4 +10,4 @@ import { SessionPasswordPrompt } from '../components/SessionPasswordPrompt';
// window.view.$el.prependTo($body);
// className: 'password overlay',
// Component: window.Signal.Components.SessionPasswordPrompt,
window.ReactDOM.render(<SessionPasswordPrompt />, document.getElementById('app'));
window.ReactDOM.render(<SessionPasswordPrompt />, document.getElementById('root'));