app starts but full of errors

pull/2242/head
Audric Ackermann 3 years ago
parent 2b17ad5cfa
commit 4d72b92b25

@ -50,6 +50,6 @@
</div> </div>
<script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script> <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> </body>
</html> </html>

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

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

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

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

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

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

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

@ -10,12 +10,13 @@ import { ExpirationTimerOptions } from '../util/expiringMessages';
import { Notifications } from '../util/notifications'; import { Notifications } from '../util/notifications';
import { Registration } from '../util/registration'; import { Registration } from '../util/registration';
import { isSignInByLinking, Storage } from '../util/storage'; import { isSignInByLinking, Storage } from '../util/storage';
import jQuery from 'jquery';
import * as Data from '../data/data'; import * as Data from '../data/data';
import Backbone from 'backbone'; import Backbone from 'backbone';
import { SessionRegistrationView } from '../components/registration/SessionRegistrationView'; import { SessionRegistrationView } from '../components/registration/SessionRegistrationView';
import { SessionInboxView } from '../components/SessionInboxView'; import { SessionInboxView } from '../components/SessionInboxView';
import { deleteAllLogs } from '../node/logs'; import { deleteAllLogs } from '../node/logs';
import ReactDOM from 'react-dom';
import React from 'react';
// tslint:disable: max-classes-per-file // tslint:disable: max-classes-per-file
// Globally disable drag and drop // Globally disable drag and drop
@ -81,6 +82,7 @@ window.document.title = window.getTitle();
// Whisper.events = // Whisper.events =
// window.Whisper.events = WhisperEvents ? // window.Whisper.events = WhisperEvents ?
const WhisperEvents = _.clone(Backbone.Events); const WhisperEvents = _.clone(Backbone.Events);
window.Whisper = window.Whisper || {};
window.Whisper.events = WhisperEvents; window.Whisper.events = WhisperEvents;
window.log.info('Storage fetch'); window.log.info('Storage fetch');
@ -227,17 +229,33 @@ async function start() {
await connect(); await connect();
}); });
const appView = new AppView({ function openInbox() {
el: jQuery('body'), 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(); ExpirationTimerOptions.initExpiringMessageListener();
if (Registration.isDone() && !isSignInByLinking()) { if (Registration.isDone() && !isSignInByLinking()) {
await connect(); await connect();
appView.openInbox(); openInbox();
} else { } else {
appView.openStandalone(); openStandAlone();
} }
window.addEventListener('focus', () => { 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 // do not put the messageId here so the conversation is loaded on the last unread instead
await window.openConversationWithMessages({ conversationKey, messageId: null }); await window.openConversationWithMessages({ conversationKey, messageId: null });
} else { } else {
appView.openInbox(); openInbox();
} }
}; };
WhisperEvents.on('openInbox', () => { WhisperEvents.on('openInbox', () => {
appView.openInbox(); openInbox();
}); });
} }
@ -406,6 +424,7 @@ async function connect() {
logger: window.log, logger: window.log,
}); });
window.textsecure = window.textsecure || {};
window.textsecure.messaging = true; window.textsecure.messaging = true;
} }
@ -415,70 +434,6 @@ function onEmpty() {
Notifications.enable(); 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 { class TextScramble {
private frame: any; private frame: any;
private queue: any; private queue: any;

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

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

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

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

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

Loading…
Cancel
Save