Blocking/Unblocking improvements for message requests
This commit is contained in:
parent
91ea69133b
commit
9eeb68a9a7
5 changed files with 33 additions and 73 deletions
|
@ -2101,18 +2101,10 @@
|
|||
}
|
||||
|
||||
if (typeof details.blocked !== 'undefined') {
|
||||
const e164 = conversation.get('e164');
|
||||
if (details.blocked && e164) {
|
||||
storage.addBlockedNumber(e164);
|
||||
if (details.blocked) {
|
||||
conversation.block();
|
||||
} else {
|
||||
storage.removeBlockedNumber(e164);
|
||||
}
|
||||
|
||||
const uuid = conversation.get('uuid');
|
||||
if (details.blocked && uuid) {
|
||||
storage.addBlockedUuid(uuid);
|
||||
} else {
|
||||
storage.removeBlockedUuid(uuid);
|
||||
conversation.unblock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2233,9 +2225,9 @@
|
|||
}
|
||||
|
||||
if (details.blocked) {
|
||||
storage.addBlockedGroup(id);
|
||||
conversation.block();
|
||||
} else {
|
||||
storage.removeBlockedGroup(id);
|
||||
conversation.unblock();
|
||||
}
|
||||
|
||||
conversation.set(updates);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global storage, _, ConversationController */
|
||||
/* global storage, _ */
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
(function() {
|
||||
|
@ -53,7 +53,7 @@
|
|||
}
|
||||
|
||||
window.log.info('removing', uuid, 'from blocked list');
|
||||
storage.put(BLOCKED_NUMBERS_ID, _.without(numbers, uuid));
|
||||
storage.put(BLOCKED_UUIDS_ID, _.without(numbers, uuid));
|
||||
};
|
||||
|
||||
storage.isGroupBlocked = groupId => {
|
||||
|
@ -79,48 +79,4 @@
|
|||
window.log.info(`removing group(${groupId} from blocked list`);
|
||||
storage.put(BLOCKED_GROUPS_ID, _.without(groupIds, groupId));
|
||||
};
|
||||
|
||||
/**
|
||||
* Optimistically adds a conversation to our local block list.
|
||||
* @param {string} id
|
||||
*/
|
||||
storage.blockIdentifier = id => {
|
||||
const conv = ConversationController.get(id);
|
||||
if (conv) {
|
||||
const uuid = conv.get('uuid');
|
||||
if (uuid) {
|
||||
storage.addBlockedUuid(uuid);
|
||||
}
|
||||
const e164 = conv.get('e164');
|
||||
if (e164) {
|
||||
storage.addBlockedNumber(e164);
|
||||
}
|
||||
const groupId = conv.get('groupId');
|
||||
if (groupId) {
|
||||
storage.addBlockedGroup(groupId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Optimistically removes a conversation from our local block list.
|
||||
* @param {string} id
|
||||
*/
|
||||
storage.unblockIdentifier = id => {
|
||||
const conv = ConversationController.get(id);
|
||||
if (conv) {
|
||||
const uuid = conv.get('uuid');
|
||||
if (uuid) {
|
||||
storage.removeBlockedUuid(uuid);
|
||||
}
|
||||
const e164 = conv.get('e164');
|
||||
if (e164) {
|
||||
storage.removeBlockedNumber(e164);
|
||||
}
|
||||
const groupId = conv.get('groupId');
|
||||
if (groupId) {
|
||||
storage.removeBlockedGroup(groupId);
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -203,20 +203,37 @@
|
|||
return false;
|
||||
},
|
||||
|
||||
unblock() {
|
||||
block() {
|
||||
const uuid = this.get('uuid');
|
||||
if (uuid) {
|
||||
return window.storage.removeBlockedUuid(uuid);
|
||||
window.storage.addBlockedUuid(uuid);
|
||||
}
|
||||
|
||||
const e164 = this.get('e164');
|
||||
if (e164) {
|
||||
return window.storage.removeBlockedNumber(e164);
|
||||
window.storage.addBlockedNumber(e164);
|
||||
}
|
||||
|
||||
const groupId = this.get('groupId');
|
||||
if (groupId) {
|
||||
return window.storage.removeBlockedGroup(groupId);
|
||||
window.storage.addBlockedGroup(groupId);
|
||||
}
|
||||
},
|
||||
|
||||
unblock() {
|
||||
const uuid = this.get('uuid');
|
||||
if (uuid) {
|
||||
window.storage.removeBlockedUuid(uuid);
|
||||
}
|
||||
|
||||
const e164 = this.get('e164');
|
||||
if (e164) {
|
||||
window.storage.removeBlockedNumber(e164);
|
||||
}
|
||||
|
||||
const groupId = this.get('groupId');
|
||||
if (groupId) {
|
||||
window.storage.removeBlockedGroup(groupId);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -632,7 +649,7 @@
|
|||
}
|
||||
} else if (response === this.messageRequestEnum.BLOCK) {
|
||||
// Block locally, other devices should block upon receiving the sync message
|
||||
window.storage.blockIdentifier(this.get('id'));
|
||||
this.block();
|
||||
this.disableProfileSharing();
|
||||
} else if (response === this.messageRequestEnum.DELETE) {
|
||||
// Delete messages locally, other devices should delete upon receiving
|
||||
|
@ -650,7 +667,7 @@
|
|||
this.disableProfileSharing();
|
||||
this.updateLastMessage();
|
||||
// Block locally, other devices should block upon receiving the sync message
|
||||
window.storage.blockIdentifier(this.get('id'));
|
||||
this.block();
|
||||
// Leave group if this was a local action
|
||||
if (!fromSync) {
|
||||
this.leaveGroup();
|
||||
|
|
|
@ -110,11 +110,6 @@ export const MessageRequestActionsConfirmation = ({
|
|||
action: onUnblock,
|
||||
style: 'affirmative',
|
||||
},
|
||||
{
|
||||
text: i18n('MessageRequests--delete'),
|
||||
action: onDelete,
|
||||
style: 'negative',
|
||||
},
|
||||
]}
|
||||
>
|
||||
{i18n(`MessageRequests--unblock-${conversationType}-confirm-body`)}
|
||||
|
|
|
@ -207,7 +207,7 @@
|
|||
"rule": "jQuery-load(",
|
||||
"path": "js/models/conversations.js",
|
||||
"line": " // but the full ConversationController.load() sequence isn't complete. So, we",
|
||||
"lineNumber": 448,
|
||||
"lineNumber": 465,
|
||||
"reasonCategory": "exampleCode",
|
||||
"updated": "2020-08-11T21:28:50.868Z"
|
||||
},
|
||||
|
@ -215,7 +215,7 @@
|
|||
"rule": "jQuery-load(",
|
||||
"path": "js/models/conversations.js",
|
||||
"line": " // don't cache props on create, but we do later when load() calls generateProps()",
|
||||
"lineNumber": 449,
|
||||
"lineNumber": 466,
|
||||
"reasonCategory": "exampleCode",
|
||||
"updated": "2020-08-11T21:28:50.868Z"
|
||||
},
|
||||
|
@ -223,7 +223,7 @@
|
|||
"rule": "jQuery-wrap(",
|
||||
"path": "js/models/conversations.js",
|
||||
"line": " await wrap(",
|
||||
"lineNumber": 674,
|
||||
"lineNumber": 691,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2020-06-09T20:26:46.515Z"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue