Merge pull request #1467 from Bilb/fix-delete-group-menu-left

Be sure to show a right click menu to delete a closed group when we already left it
pull/1469/head
Audric Ackermann 4 years ago committed by GitHub
commit e34ffb89fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -106,8 +106,6 @@
window.document.title = window.getTitle();
// start a background worker for ecc
textsecure.startWorker('js/libsignal-protocol-worker.js');
let messageReceiver;
Whisper.events = _.clone(Backbone.Events);
Whisper.events.isListenedTo = eventName =>

@ -1360,7 +1360,11 @@
let title = i18n('delete');
let message = i18n('deleteContactConfirmation');
if (this.isGroup()) {
if (
this.isGroup() &&
!this.get('left') &&
!this.get('isKickedFromGroup')
) {
title = i18n('leaveGroup');
message = i18n('leaveGroupConfirmation');
}

@ -25316,77 +25316,6 @@
})();
; (function () {
'use strict';
// I am the...workee?
var origCurve25519 = Internal.curve25519_async;
Internal.startWorker = function (url) {
Internal.stopWorker(); // there can be only one
Internal.curve25519_async = new Curve25519Worker(url);
Internal.Curve.async = Internal.wrapCurve25519(Internal.curve25519_async);
libsignal.Curve.async = Internal.wrapCurve(Internal.Curve.async);
};
Internal.stopWorker = function () {
if (Internal.curve25519_async instanceof Curve25519Worker) {
var worker = Internal.curve25519_async.worker;
Internal.curve25519_async = origCurve25519;
Internal.Curve.async = Internal.wrapCurve25519(Internal.curve25519_async);
libsignal.Curve.async = Internal.wrapCurve(Internal.Curve.async);
worker.terminate();
}
};
libsignal.worker = {
startWorker: Internal.startWorker,
stopWorker: Internal.stopWorker,
};
function Curve25519Worker(url) {
this.jobs = {};
this.jobId = 0;
this.worker = new Worker(url);
this.worker.onmessage = function (e) {
var job = this.jobs[e.data.id];
if (e.data.error && typeof job.onerror === 'function') {
job.onerror(new Error(e.data.error));
} else if (typeof job.onsuccess === 'function') {
job.onsuccess(e.data.result);
}
delete this.jobs[e.data.id];
}.bind(this);
}
Curve25519Worker.prototype = {
constructor: Curve25519Worker,
postMessage: function (methodName, args, onsuccess, onerror) {
return new Promise(function (resolve, reject) {
this.jobs[this.jobId] = { onsuccess: resolve, onerror: reject };
this.worker.postMessage({ id: this.jobId, methodName: methodName, args: args });
this.jobId++;
}.bind(this));
},
keyPair: function (privKey) {
return this.postMessage('keyPair', [privKey]);
},
sharedSecret: function (pubKey, privKey) {
return this.postMessage('sharedSecret', [pubKey, privKey]);
},
sign: function (privKey, message) {
return this.postMessage('sign', [privKey, message]);
},
verify: function (pubKey, message, sig) {
return this.postMessage('verify', [pubKey, message, sig]);
}
};
})();
/*
Copyright 2013 Daniel Wirtz <dcode@dcode.io>

@ -1,11 +1,8 @@
/* global window, textsecure, SignalProtocolStore, libsignal */
/* global window, textsecure, SignalProtocolStore */
// eslint-disable-next-line func-names
(function() {
window.textsecure = window.textsecure || {};
window.textsecure.storage = window.textsecure.storage || {};
textsecure.storage.protocol = new SignalProtocolStore();
textsecure.startWorker = libsignal.worker.startWorker;
textsecure.stopWorker = libsignal.worker.stopWorker;
})();

@ -125,6 +125,8 @@ export const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => {
isMe,
isGroup,
isPublic,
left,
isKickedFromGroup,
onDeleteContact,
window.i18n
)}

@ -92,6 +92,8 @@ export const ConversationListItemContextMenu = (
isMe,
type === 'group',
isPublic,
left,
isKickedFromGroup,
onDeleteContact,
window.i18n
)}

@ -39,9 +39,12 @@ function showCopyId(isPublic: boolean, isGroup: boolean): boolean {
function showDeleteContact(
isMe: boolean,
isGroup: boolean,
isPublic: boolean
isPublic: boolean,
isGroupLeft: boolean,
isKickedFromGroup: boolean
): boolean {
return !isMe && Boolean(!isGroup || isPublic);
// you need to have left a closed group first to be able to delete it completely.
return (!isMe && !isGroup) || (isGroup && (isGroupLeft || isKickedFromGroup));
}
function showAddModerators(
@ -97,10 +100,20 @@ export function getDeleteContactMenuItem(
isMe: boolean | undefined,
isGroup: boolean | undefined,
isPublic: boolean | undefined,
isLeft: boolean | undefined,
isKickedFromGroup: boolean | undefined,
action: any,
i18n: LocalizerType
): JSX.Element | null {
if (showDeleteContact(Boolean(isMe), Boolean(isGroup), Boolean(isPublic))) {
if (
showDeleteContact(
Boolean(isMe),
Boolean(isGroup),
Boolean(isPublic),
Boolean(isLeft),
Boolean(isKickedFromGroup)
)
) {
if (isPublic) {
return <Item onClick={action}>{i18n('leaveGroup')}</Item>;
}

@ -64,7 +64,6 @@ const excludedFiles = [
'^test/test.js',
// From libsignal-protocol-javascript project
'^js/libsignal-protocol-worker.js',
'^libtextsecure/libsignal-protocol.js',
// Test files

Loading…
Cancel
Save