migrate about_start to not use jquery

pull/2242/head
Audric Ackermann 2 years ago
parent f164302617
commit 475c92eeb4
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -11,7 +11,7 @@
img-src 'self' blob: data:;
media-src 'self' blob:;
object-src 'none';
script-src 'self';
script-src 'self' 'unsafe-inline';
style-src 'self' 'unsafe-inline';"
/>
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
@ -49,7 +49,8 @@
<a class="privacy" href="https://getsession.org/terms-of-service/">Terms of Service</a>
</div>
<script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="ts/start/about_start.js"></script>
<script type="text/javascript">
require('./ts/mains/about_start.js');
</script>
</body>
</html>

@ -8,9 +8,6 @@ const config = url.parse(window.location.toString(), true).query;
const { locale } = config;
const localeMessages = ipcRenderer.sendSync('locale-data');
global.dcodeIO = global.dcodeIO || {};
global.dcodeIO.ByteBuffer = require('bytebuffer');
window.getEnvironment = () => config.environment;
window.getVersion = () => config.version;
window.getCommitHash = () => config.commitHash;

@ -11,15 +11,22 @@
img-src 'self' blob: data:;
media-src 'self' blob:;
object-src 'none';
script-src 'self';
script-src 'self' 'unsafe-inline';
style-src 'self' 'unsafe-inline';"
/>
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
<style></style>
<script>
var exports = {};
</script>
</head>
<body>
<div id="root"></div>
</body>
<script type="text/javascript" src="js/debug_log_start.js"></script>
<script>
var exports = {};
</script>
<script type="text/javascript">
require('./ts/mains/debug_log_start.js');
</script>
</html>

@ -3,15 +3,10 @@
const { ipcRenderer } = require('electron');
const url = require('url');
const i18n = require('./ts/util/i18n');
const { DebugLogView } = require('./ts/views/DebugLogView');
const config = url.parse(window.location.toString(), true).query;
const { locale } = config;
const localeMessages = ipcRenderer.sendSync('locale-data');
global.dcodeIO = global.dcodeIO || {};
global.dcodeIO.ByteBuffer = require('bytebuffer');
window._ = require('lodash');
window.React = require('react');
@ -35,7 +30,4 @@ window.getCommitHash = () => config.commitHash;
window.closeDebugLog = () => ipcRenderer.send('close-debug-log');
window.Views = {};
window.Views.DebugLogView = DebugLogView;
window.saveLog = logText => ipcRenderer.send('save-debug-log', logText);

@ -11,7 +11,7 @@
img-src 'self' blob: data:;
media-src 'self' blob:;
object-src 'none';
script-src 'self';
script-src 'self' 'unsafe-inline';
style-src 'self' 'unsafe-inline';"
/>
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
@ -28,6 +28,8 @@
</div>
</div>
</div>
<script type="text/javascript" src="js/password_start.js"></script>
<script type="text/javascript">
require('./ts/mains/password_start.js');
</script>
</body>
</html>

@ -8,9 +8,6 @@ const config = url.parse(window.location.toString(), true).query;
const { locale } = config;
const localeMessages = ipcRenderer.sendSync('locale-data');
global.dcodeIO = global.dcodeIO || {};
global.dcodeIO.ByteBuffer = require('bytebuffer');
window.React = require('react');
window.ReactDOM = require('react-dom');

@ -15,9 +15,6 @@ if (config.appInstance) {
}
// tslint:disable: no-require-imports no-var-requires
global.dcodeIO = global.dcodeIO || {};
global.dcodeIO.ByteBuffer = require('bytebuffer');
window.platform = process.platform;
window.getTitle = () => title;
window.getEnvironment = () => configAny.environment;

@ -1,5 +1,8 @@
$onionPathLineColor: rgba(#7a7a7a, 0.6);
#root {
height: 100%;
}
.subtle {
opacity: $session-subtle-factor;
}

@ -9,7 +9,6 @@ import {
hasSyncedInitialConfigurationItem,
lastAvatarUploadTimestamp,
removeConversation,
removeOneOpenGroupV1Message,
} from '../../data/data';
import { getMessageQueue } from '../../session/sending';
import { useDispatch, useSelector } from 'react-redux';
@ -192,16 +191,6 @@ const triggerSyncIfNeeded = async () => {
}
};
const scheduleDeleteOpenGroupV1Messages = async () => {
const leftToRemove = await removeOneOpenGroupV1Message();
if (leftToRemove > 0) {
window?.log?.info(`We still have ${leftToRemove} opengroupv1 messages to remove...`);
setTimeout(scheduleDeleteOpenGroupV1Messages, 10000);
} else {
window?.log?.info('No more opengroupv1 messages to remove...');
}
};
const removeAllV1OpenGroups = async () => {
const allV1Convos = (await getAllOpenGroupV1Conversations()).models || [];
// do not remove messages of opengroupv1 for now. We have to find a way of doing it without making the whole app extremely slow
@ -222,8 +211,6 @@ const removeAllV1OpenGroups = async () => {
window.log.warn(`failed to delete opengroupv1 ${v1Convo.id}`, e);
}
}
setTimeout(scheduleDeleteOpenGroupV1Messages, 10000);
};
const triggerAvatarReUploadIfNeeded = async () => {

@ -3,7 +3,11 @@ import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
// tslint:disable-next-line: no-submodule-imports
import useUpdate from 'react-use/lib/useUpdate';
import { createOrUpdateItem, hasLinkPreviewPopupBeenDisplayed } from '../../../data/data';
import {
createOrUpdateItem,
fillWithTestData,
hasLinkPreviewPopupBeenDisplayed,
} from '../../../data/data';
import { ToastUtils } from '../../../session/utils';
import { updateConfirmModal } from '../../../state/ducks/modalDialog';
import { toggleAudioAutoplay } from '../../../state/ducks/userConfig';

@ -3,15 +3,10 @@
import _ from 'lodash';
import { MessageResultProps } from '../components/search/MessageSearchResults';
import {
ConversationCollection,
ConversationModel,
ConversationTypeEnum,
} from '../models/conversation';
import { ConversationCollection, ConversationModel } from '../models/conversation';
import { MessageCollection, MessageModel } from '../models/message';
import { MessageAttributes, MessageDirection } from '../models/messageType';
import { HexKeyPair } from '../receiver/keypairs';
import { getConversationController } from '../session/conversations';
import { getSodiumRenderer } from '../session/crypto';
import { PubKey } from '../session/types';
import { ReduxConversationType } from '../state/ducks/conversations';

@ -89,7 +89,6 @@ const channelsToMake = new Set([
'getLatestClosedGroupEncryptionKeyPair',
'addClosedGroupEncryptionKeyPair',
'removeAllClosedGroupEncryptionKeyPairs',
'removeOneOpenGroupV1Message',
'fillWithTestData',
...channelsToMakeForOpengroupV2,
]);

@ -0,0 +1,29 @@
// Add version and commit hash
global.setTimeout(() => {
const version = document.getElementsByClassName('version').item(0);
const commit = document.getElementsByClassName('commitHash').item(0);
const environment = document.getElementsByClassName('environment').item(0);
// Add debugging metadata - environment if not production, app instance name
const states = [];
if (window.getEnvironment() !== 'production') {
states.push(window.getEnvironment());
}
if (window.getAppInstance()) {
states.push(window.getAppInstance());
}
if (version) {
version.innerHTML = `v${window.getVersion()}`;
}
if (commit) {
commit.innerHTML = window.getCommitHash() || '';
}
if (environment) {
environment.innerHTML = states.join(' - ');
}
}, 1000);

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

@ -28,7 +28,6 @@ import packageJson from '../../package.json'; // checked - only node
setupGlobalErrorHandler();
import electronLocalshortcut from 'electron-localshortcut';
console;
// tslint:disable: no-console
@ -493,13 +492,13 @@ async function showPasswordWindow() {
minHeight,
autoHideMenuBar: false,
webPreferences: {
nodeIntegration: false,
nodeIntegration: true,
enableRemoteModule: true,
nodeIntegrationInWorker: false,
contextIsolation: false,
// sandbox: true,
preload: path.join(__dirname, '..', 'password_preload.js'),
preload: path.join(__dirname, '..', '..', 'password_preload.js'),
nativeWindowOpen: true,
},
// don't setup icon, the executable one will be used by default
@ -507,7 +506,7 @@ async function showPasswordWindow() {
passwordWindow = new BrowserWindow(windowOptions);
await passwordWindow.loadURL(prepareURL([__dirname, 'password.html']));
await passwordWindow.loadURL(prepareURL([__dirname, '..', '..', 'password.html']));
captureClicks(passwordWindow);
@ -560,17 +559,17 @@ async function showAbout() {
const options = {
width: 500,
height: 400,
resizable: false,
height: 500,
resizable: true,
title: locale.messages.about,
autoHideMenuBar: true,
backgroundColor: '#000',
show: false,
webPreferences: {
nodeIntegration: false,
nodeIntegration: true,
nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, '..', 'about_preload.js'),
preload: path.join(__dirname, '..', '..', 'about_preload.js'),
nativeWindowOpen: true,
},
parent: mainWindow,
@ -580,7 +579,7 @@ async function showAbout() {
captureClicks(aboutWindow);
await aboutWindow.loadURL(prepareURL([__dirname, 'about.html']));
await aboutWindow.loadURL(prepareURL([__dirname, '..', '..', 'about.html']));
aboutWindow.on('closed', () => {
aboutWindow = null;
@ -608,17 +607,17 @@ async function showDebugLogWindow() {
const options = {
width: Math.max(size[0] - 100, WINDOW_SIZE.minWidth),
height: Math.max(size[1] - 100, WINDOW_SIZE.minHeight),
resizable: false,
resizable: true,
title: locale.messages.debugLog,
autoHideMenuBar: true,
backgroundColor: '#000',
show: false,
modal: true,
webPreferences: {
nodeIntegration: false,
nodeIntegration: true,
nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, '..', 'debug_log_preload.js'),
preload: path.join(__dirname, '..', '..', 'debug_log_preload.js'),
nativeWindowOpen: true,
},
parent: mainWindow,
@ -628,7 +627,7 @@ async function showDebugLogWindow() {
captureClicks(debugLogWindow);
await debugLogWindow.loadURL(prepareURL([__dirname, 'debug_log.html'], { theme }));
await debugLogWindow.loadURL(prepareURL([__dirname, '..', '..', 'debug_log.html'], { theme }));
debugLogWindow.on('closed', () => {
debugLogWindow = null;

@ -31,6 +31,7 @@ if (environment === 'production') {
}
// We load config after we've made our modifications to NODE_ENV
//tslint-disable no-require-imports no-var-requires
const c = require('config');
(c as any).environment = environment;

@ -50,6 +50,7 @@ export async function encryptAttachmentBufferNode(
sodium.crypto_secretstream_xchacha20poly1305_TAG_FINAL
);
//tslint-disable restrict-plus-operands
const encryptedBufferWithHeader = new Uint8Array(bufferOut.length + header.length);
encryptedBufferWithHeader.set(header);
encryptedBufferWithHeader.set(bufferOut, header.length);

@ -64,6 +64,7 @@ export async function initializeLogger() {
ipc.on('fetch-log', event => {
fs.mkdirSync(logPath, { recursive: true });
console.info('fetching logs from logPath');
fetch(logPath).then(
data => {

@ -3330,35 +3330,6 @@ function removeV2OpenGroupRoom(conversationId: string) {
});
}
function removeOneOpenGroupV1Message() {
const row = assertGlobalInstance()
.prepare(
`SELECT count(*) from ${MESSAGES_TABLE} WHERE
conversationId LIKE 'publicChat:1@%';`
)
.get();
const toRemoveCount = row['count(*)'];
if (toRemoveCount <= 0) {
return 0;
}
console.info('left opengroupv1 message to remove: ', toRemoveCount);
const rowMessageIds = assertGlobalInstance()
.prepare(
`SELECT id from ${MESSAGES_TABLE} WHERE conversationId LIKE 'publicChat:1@%' ORDER BY id LIMIT 1;`
)
.all();
const messagesIds = map(rowMessageIds, r => r.id)[0];
console.time('removeOneOpenGroupV1Message');
removeMessage(messagesIds);
console.timeEnd('removeOneOpenGroupV1Message');
return toRemoveCount - 1;
}
// tslint:disable: binary-expression-operand-order
// tslint:disable: insecure-random
@ -3451,7 +3422,7 @@ function fillWithTestData(numConvosToAdd: number, numMsgsToAdd: number) {
const msgObjToAdd = {
// body: `fake body ${activeAt}`,
body: `fakeMsgIdx-spongebob-${index} ${fakeBodyText} ${activeAt}`,
conversationId: `${convoId}`,
conversationId: `05${id}`,
// eslint-disable-next-line camelcase
expires_at: 0,
hasAttachments: 0,
@ -3467,7 +3438,7 @@ function fillWithTestData(numConvosToAdd: number, numMsgsToAdd: number) {
sent_at: Date.now(),
source: `${convoId}`,
sourceDevice: 1,
type: '%',
type: 'outgoing',
unread: 1,
expireTimer: 0,
expirationStartTimestamp: 0,
@ -3602,5 +3573,4 @@ export const sqlNode = {
getAllV2OpenGroupRooms,
getV2OpenGroupRoomByRoomId,
removeV2OpenGroupRoom,
removeOneOpenGroupV1Message,
};

@ -28,6 +28,7 @@ import {
import { MessageModel } from '../models/message';
import { isUsFromCache } from '../session/utils/User';
import { decryptProfile } from '../util/crypto/profileEncrypter';
import ByteBuffer from 'bytebuffer';
export async function updateProfileOneAtATime(
conversation: ConversationModel,
@ -52,8 +53,6 @@ async function createOrUpdateProfile(
profile: SignalService.DataMessage.ILokiProfile,
profileKey?: Uint8Array | null
) {
const { dcodeIO } = window;
// Retain old values unless changed:
const newProfile = conversation.get('profile') || {};

@ -21,6 +21,7 @@ import { getMessageById } from '../../../ts/data/data';
import { getConversationController } from '../conversations';
import { ed25519Str } from '../onions/onionPath';
import { EmptySwarmError } from '../utils/errors';
import ByteBuffer from 'bytebuffer';
const DEFAULT_CONNECTIONS = 1;
@ -128,7 +129,7 @@ export async function TEST_sendMessageToSnode(
isSyncMessage?: boolean,
messageId?: string
): Promise<void> {
const data64 = window.dcodeIO.ByteBuffer.wrap(data).toString('base64');
const data64 = ByteBuffer.wrap(data).toString('base64');
const swarm = await getSwarmFor(pubKey);
window?.log?.debug(

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

@ -94,14 +94,13 @@ function format(entries: Array<EntryType>) {
return redactAll(entries.map(formatLine).join('\n'));
}
async function fetch() {
export async function fetch() {
return new Promise(resolve => {
ipc.send('fetch-log');
ipc.on('fetched-log', (_event, text) => {
const result = `${getHeader()}\n${format(text)}`;
resolve(result);
});
ipc.send('fetch-log');
});
}
@ -130,7 +129,6 @@ window.log = {
info: _.partial(logAtLevel, 'info', 'INFO '),
debug: _.partial(logAtLevel, 'debug', 'DEBUG'),
trace: _.partial(logAtLevel, 'trace', 'TRACE'),
fetch,
};
window.onerror = (_message, _script, _line, _col, error) => {

@ -1,7 +1,44 @@
import React, { useEffect, useState } from 'react';
import styled from 'styled-components';
import { fetch } from '../util/logging';
export const DebugLogView = () => {
const StyledContent = styled.div`
display: flex;
flex-direction: column;
padding: 10px;
height: 100%;
`;
const DebugLogTextArea = (props: { content: string }) => {
console.warn('DebugLogTextArea ', props.content);
return <textarea spellCheck="false" rows={10} value={props.content} style={{ height: '100%' }} />;
};
const DebugLogButtons = (props: { content: string }) => {
return (
<div className="buttons">
<button
className="grey submit"
onClick={e => {
e.preventDefault();
if (props.content.length <= 20) {
// loading
return;
}
(window as any).saveLog(props.content);
(window as any).closeDebugLog();
}}
>
{window.i18n('saveLogToDesktop')}
</button>
</div>
);
};
const DebugLogViewAndSave = () => {
const [content, setContent] = useState(window.i18n('loading'));
useEffect(() => {
const operatingSystemInfo = `Operating System: ${(window as any).getOSRelease()}`;
@ -10,15 +47,25 @@ export const DebugLogView = () => {
: '';
// eslint-disable-next-line more/no-then
window.log.fetch().then((text: string) => {
const debugLogWithSystemInfo = operatingSystemInfo + commitHashInfo + text;
setContent(debugLogWithSystemInfo);
});
fetch()
.then((text: any) => {
const debugLogWithSystemInfo = operatingSystemInfo + commitHashInfo + text;
setContent(debugLogWithSystemInfo);
})
.catch(console.warn);
}, []);
return (
<div className="content">
<>
<DebugLogTextArea content={content} />
<DebugLogButtons content={content} />
</>
);
};
export const DebugLogView = () => {
return (
<StyledContent>
<div>
<button
className="x close"
@ -30,26 +77,7 @@ export const DebugLogView = () => {
<h1> {window.i18n('debugLog')} </h1>
<p> {window.i18n('debugLogExplanation')}</p>
</div>
<textarea spellCheck="false" rows={5}>
{content}
</textarea>
<div className="buttons">
<button
className="grey submit"
onClick={e => {
e.preventDefault();
if (content.length <= 20) {
// loading
return;
}
(window as any).saveLog(content);
(window as any).closeDebugLog();
}}
>
{window.i18n('saveLogToDesktop')}
</button>
</div>
</div>
<DebugLogViewAndSave />
</StyledContent>
);
};

@ -29,7 +29,7 @@ const functions = {
bytesFromString,
};
// tslint:disable: function-name
//tslint-disable no-console
onmessage = async (e: any) => {
const [jobId, fnName, ...args] = e.data;

Loading…
Cancel
Save