mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
update notification when chat history is cleared
This commit is contained in:
parent
a8f66a078b
commit
eb3f17c1fd
@ -15,6 +15,7 @@ const factory = (Crypto, Hash, Util, Realtime, Messaging,
|
||||
|
||||
var Types = {
|
||||
message: 'MSG',
|
||||
cleared: 'CLEARED',
|
||||
unfriend: 'UNFRIEND',
|
||||
mapId: 'MAP_ID',
|
||||
mapIdAck: 'MAP_ID_ACK'
|
||||
@ -271,6 +272,11 @@ const factory = (Crypto, Hash, Util, Realtime, Messaging,
|
||||
return true;
|
||||
}
|
||||
var proxy = ctx.store.proxy;
|
||||
if (parsedMsg[0] === Types.cleared) {
|
||||
channel.messages = [];
|
||||
ctx.emit('CLEAR_CHANNEL', channel.id, channel.clients);
|
||||
return;
|
||||
}
|
||||
if (parsedMsg[0] === Types.unfriend) {
|
||||
curvePublic = parsedMsg[1];
|
||||
|
||||
@ -917,11 +923,21 @@ const factory = (Crypto, Hash, Util, Realtime, Messaging,
|
||||
var channel = ctx.channels[id];
|
||||
if (!channel) { return void cb({error: 'NO_CHANNEL'}); }
|
||||
if (!ctx.store.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
|
||||
var proxy = ctx.store.proxy || {};
|
||||
ctx.store.rpc.clearOwnedChannel(id, function (err) {
|
||||
cb({error:err});
|
||||
if (!err) {
|
||||
channel.messages = [];
|
||||
ctx.emit('CLEAR_CHANNEL', id, channel.clients);
|
||||
var msg = [Types.cleared, proxy.curvePublic, +new Date()];
|
||||
var msgStr = JSON.stringify(msg);
|
||||
var cryptMsg = channel.encrypt(msgStr);
|
||||
|
||||
channel.wc.bcast(cryptMsg).then(function () {
|
||||
// Success (message sent)
|
||||
}, function (err) {
|
||||
console.error('Failed to send message:', err);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -253,7 +253,8 @@ define([
|
||||
var displaySystemMessage = function (id, message) {
|
||||
var $messagebox = $(getChat(id)).find('.cp-app-contacts-messages');
|
||||
if (!$messagebox.length) { return; }
|
||||
$messagebox.append(h('div.cp-app-contacts-message.cp-app-contacts-system-notification', message));
|
||||
var noticeElement = h('div.cp-app-contacts-message.cp-app-contacts-system-notification', message);
|
||||
$messagebox.append(noticeElement);
|
||||
normalizeLabels($messagebox);
|
||||
scrollChatToBottom();
|
||||
};
|
||||
@ -357,7 +358,6 @@ define([
|
||||
return;
|
||||
}
|
||||
clearChannel(id);
|
||||
send(Messages.contacts_historyCleared);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -780,10 +780,6 @@ define([
|
||||
|
||||
debug(message);
|
||||
|
||||
if (message.text === Messages.contacts_historyCleared) {
|
||||
displaySystemMessage(chanId, message.text);
|
||||
return;
|
||||
}
|
||||
var el_message = markup.message(message);
|
||||
|
||||
if (message.type === 'MSG') {
|
||||
@ -1155,6 +1151,7 @@ define([
|
||||
}
|
||||
if (cmd === 'CLEAR_CHANNEL') {
|
||||
clearChannel(data);
|
||||
displaySystemMessage(data, Messages.contacts_historyCleared);
|
||||
return;
|
||||
}
|
||||
if (cmd === 'PADCHAT_READY') {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user