Skip to content

Commit

Permalink
get rid of libtextsecure.js and componnets.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilb committed Apr 14, 2022
1 parent 323b7ec commit af9d2fd
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 73 deletions.
12 changes: 0 additions & 12 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,7 @@ dist/**
mnemonic_languages/**

# Generated files
js/curve/*
js/components.js
js/libtextsecure.js
js/util_worker.js
libtextsecure/components.js
test/test.js


# Third-party files
js/Mp3LameEncoder.min.js
js/WebAudioRecorderMp3.js
libtextsecure/test/blanket_mocha.js
test/blanket_mocha.js

# TypeScript generated files
ts/**/*.js
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
node_modules
.sass-cache
.eslintcache
build/curve25519_compiled.js
stylesheets/*.css.map
/dist
.DS_Store
Expand All @@ -14,12 +13,8 @@ release/
sql/

# generated files
js/components.js
js/util_worker.js
js/libtextsecure.js
libtextsecure/components.js
stylesheets/*.css
test/test.js

# React / TypeScript
ts/**/*.js
Expand Down
12 changes: 0 additions & 12 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
config/local-*.json
config/local.json
dist/**
js/components.js
js/util_worker.js
js/libtextsecure.js
libtextsecure/components.js
stylesheets/*.css
test/test.js

test/ts/**/*.js
ts/**/*.js
Expand All @@ -22,20 +18,12 @@ ts/test/automation/notes

# Third-party files
node_modules/**
components/**
js/curve/**
js/Mp3LameEncoder.min.js
js/WebAudioRecorderMp3.js
js/util_worker.js
libtextsecure/test/blanket_mocha.js
mnemonic_languages/**
playwright.config.js

# Managed by package manager (`yarn`/`npm`):
/package.json

# Symlink into third-party `components`:
stylesheets/_intlTelInput.scss

# Coverage
release/**
25 changes: 0 additions & 25 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,11 @@ const sass = require('node-sass');

/* eslint-disable more/no-then, no-console */

const toConcatForApp = [
'node_modules/jquery/dist/jquery.js',
'node_modules/bytebuffer/dist/bytebuffer.min.js',
'node_modules/long/dist/long.js',
'node_modules/mustache/mustache.js',
'node_modules/underscore/underscore-min.js',
'node_modules/backbone/backbone.js',
];

module.exports = grunt => {
const components = [];
// eslint-disable-next-line guard-for-in, no-restricted-syntax
for (const i in toConcatForApp) {
components.push(toConcatForApp[i]);
}

grunt.loadNpmTasks('grunt-sass');

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
components: {
src: components,
dest: 'js/components.js',
},
},
sass: {
options: {
implementation: sass,
Expand All @@ -42,10 +21,6 @@ module.exports = grunt => {
},
},
watch: {
libtextsecure: {
files: ['./libtextsecure/*.js', './libtextsecure/storage/*.js'],
tasks: ['concat:libtextsecure'],
},
protobuf: {
files: ['./protos/SignalService.proto'],
tasks: ['exec:build-protobuf'],
Expand Down
3 changes: 0 additions & 3 deletions background.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
<script>
var exports = {};
</script>

<script type="text/javascript" src="js/components.js"></script>
<script type="text/javascript" src="js/libtextsecure.js"></script>
</head>

<body id="body">
Expand Down
3 changes: 0 additions & 3 deletions password.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
style-src 'self' 'unsafe-inline';"
/>
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
<style></style>

<script type="text/javascript" src="js/components.js"></script>
</head>
<body>
<div id="root">
Expand Down
12 changes: 6 additions & 6 deletions ts/components/settings/SessionSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class SessionSettingsView extends React.Component<SettingsViewProps, Stat
const callMediaSetting = getCallMediaPermissionsSettings();
this.setState({ mediaSetting, callMediaSetting });

setTimeout(() => (document.getElementById('password-lock-input') as any)?.focus(), 100);
setTimeout(() => document.getElementById('password-lock-input')?.focus(), 100);
}

public componentWillUnmount() {
Expand Down Expand Up @@ -149,7 +149,9 @@ export class SessionSettingsView extends React.Component<SettingsViewProps, Stat
}

public async validatePasswordLock() {
const enteredPassword = String((document.getElementById('password-lock-input') as any)?.val());
const enteredPassword = String(
(document.getElementById('password-lock-input') as HTMLInputElement)?.value
);

if (!enteredPassword) {
this.setState({
Expand Down Expand Up @@ -236,11 +238,9 @@ export class SessionSettingsView extends React.Component<SettingsViewProps, Stat
}

private async onKeyUp(event: any) {
const lockPasswordFocussed = (document.getElementById('password-lock-input') as any)?.is(
':focus'
);
const lockPasswordVisible = Boolean(document.getElementById('password-lock-input'));

if (event.key === 'Enter' && lockPasswordFocussed) {
if (event.key === 'Enter' && lockPasswordVisible) {
await this.validatePasswordLock();
}

Expand Down
3 changes: 1 addition & 2 deletions ts/mains/main_renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,7 @@ async function connect() {
logger: window.log,
});

window.textsecure = window.textsecure || {};
window.textsecure.messaging = true;
window.isOnline = true;
}

function onEmpty() {
Expand Down
2 changes: 1 addition & 1 deletion ts/models/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
});

// We're offline!
if (!window.textsecure.messaging) {
if (!window.isOnline) {
const error = new Error('Network is not available');
error.name = 'SendMessageNetworkError';
(error as any).number = this.id;
Expand Down
2 changes: 1 addition & 1 deletion ts/models/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {

// One caller today: event handler for the 'Retry Send' entry on right click of a failed send message
public async retrySend() {
if (!window.textsecure.messaging) {
if (!window.isOnline) {
window?.log?.error('retrySend: Cannot retry since we are offline!');
return null;
}
Expand Down
1 change: 0 additions & 1 deletion ts/node/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,6 @@ function getMessagesCountBySender({ source }: { source: string }) {
.get({
source,
});
console.info('count messages of ', source, ' :', count);
if (!count) {
return 0;
}
Expand Down
4 changes: 3 additions & 1 deletion ts/webworker/workers/util_worker_interface.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { WorkerInterface } from '../worker_interface';
import { join } from 'path';
import { ipcRenderer } from 'electron';

let utilWorkerInterface: WorkerInterface | undefined;

export const callUtilsWorker = async (fnName: string, ...args: any): Promise<any> => {
if (!utilWorkerInterface) {
const utilWorkerPath = join('./', 'ts', 'webworker', 'workers', 'util.worker.js'); //app.getAppPath()
const apDataPath = await ipcRenderer.invoke('get-data-path');
const utilWorkerPath = join(apDataPath, 'ts', 'webworker', 'workers', 'util.worker.js');
utilWorkerInterface = new WorkerInterface(utilWorkerPath, 3 * 60 * 1000); //{ type: 'module' }
}
return utilWorkerInterface?.callWorker(fnName, ...args);
Expand Down
2 changes: 1 addition & 1 deletion ts/window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ declare global {
getSeedNodeList: () => Array<any> | undefined;
setPassword: any;
storage: any;
textsecure: LibTextsecure;
isOnline: boolean;
toggleMediaPermissions: () => Promise<void>;
toggleCallMediaPermissionsTo: (enabled: boolean) => Promise<void>;
getCallMediaPermissions: () => boolean;
Expand Down

0 comments on commit af9d2fd

Please sign in to comment.