Fixed conversation w/ deleted message on top

Closes #349
Closes #326
This commit is contained in:
Igor Zhukov 2014-07-07 12:55:46 +04:00
parent fd3758327a
commit fef4457417
4 changed files with 81 additions and 60 deletions

View File

@ -399,7 +399,18 @@ angular.module('myApp.controllers', [])
$scope.$on('dialog_flush', function (e, dialog) {
for (var i = 0; i < $scope.dialogs.length; i++) {
if ($scope.dialogs[i].peerID == dialog.peerID) {
$scope.dialogs.splice(i, 1);
$scope.dialogs[i].deleted = true;
break;
}
}
});
$scope.$on('history_delete', function (e, historyUpdate) {
for (var i = 0; i < $scope.dialogs.length; i++) {
if ($scope.dialogs[i].peerID == historyUpdate.peerID) {
if (historyUpdate.msgs[$scope.dialogs[i].id]) {
$scope.dialogs[i].deleted = true;
}
break;
}
}
@ -1091,7 +1102,7 @@ angular.module('myApp.controllers', [])
$scope.history = newHistory;
updateHistoryGroups();
}
})
});
$scope.$on('dialog_flush', function (e, dialog) {
if (dialog.peerID == $scope.curDialog.peerID) {

View File

@ -118,7 +118,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
return new SecureRandom();
})
.factory('MtpMessageIdGenerator', function (Storage) {
.factory('MtpDateManager', function (Storage) {
var lastMessageID = [0, 0],
timeOffset = 0;
@ -155,18 +155,23 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
lastMessageID = [0, 0];
timeOffset = newTimeOffset;
console.log('Apply server time', serverTime, localTime, newTimeOffset, changed);
console.log(dT(), 'Apply server time', serverTime, localTime, newTimeOffset, changed);
return changed;
};
function getTimeOffset () {
return timeOffset;
};
return {
generateID: generateMessageID,
applyServerTime: applyServerTime
applyServerTime: applyServerTime,
getTimeOffset: getTimeOffset
};
})
.factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecureRandom, MtpMessageIdGenerator, CryptoWorker, $http, $q, $timeout) {
.factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecureRandom, MtpDateManager, CryptoWorker, $http, $q, $timeout) {
function mtpSendPlainRequest (dcID, requestBuffer) {
var requestLength = requestBuffer.byteLength,
@ -174,7 +179,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
var header = new TLSerialization();
header.storeLongP(0, 0, 'auth_key_id'); // Auth key
header.storeLong(MtpMessageIdGenerator.generateID(), 'msg_id'); // Msg_id
header.storeLong(MtpDateManager.generateID(), 'msg_id'); // Msg_id
header.storeInt(requestLength, 'request_length');
var headerBuffer = header.getBuffer(),
@ -386,7 +391,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
throw new Error('server_DH_inner_data SHA1-hash mismatch');
}
MtpMessageIdGenerator.applyServerTime(auth.serverTime, auth.localTime);
MtpDateManager.applyServerTime(auth.serverTime, auth.localTime);
};
function mtpSendSetClientDhParams(auth) {
@ -534,7 +539,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
})
.factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerator, MtpSecureRandom, Storage, CryptoWorker, $http, $q, $timeout, $interval, $rootScope) {
.factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpDateManager, MtpSecureRandom, Storage, CryptoWorker, $http, $q, $timeout, $interval, $rootScope) {
var updatesProcessor,
iii = 0,
@ -637,7 +642,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
sentMessage.inner = newInner;
}
sentMessage.msg_id = MtpMessageIdGenerator.generateID();
sentMessage.msg_id = MtpDateManager.generateID();
sentMessage.seq_no = this.generateSeqNo(
sentMessage.notContentRelated ||
sentMessage.container
@ -664,7 +669,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
serializer.storeMethod(method, params);
var messageID = MtpMessageIdGenerator.generateID(),
var messageID = MtpDateManager.generateID(),
seqNo = this.generateSeqNo(),
message = {
msg_id: messageID,
@ -685,7 +690,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
var serializer = new TLSerialization({mtproto: true});
serializer.storeObject(object, 'Object');
var messageID = MtpMessageIdGenerator.generateID(),
var messageID = MtpDateManager.generateID(),
seqNo = this.generateSeqNo(options.notContentRelated),
message = {
msg_id: messageID,
@ -720,7 +725,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
options.resultType = serializer.storeMethod(method, params);
var messageID = MtpMessageIdGenerator.generateID(),
var messageID = MtpDateManager.generateID(),
seqNo = this.generateSeqNo(),
message = {
msg_id: messageID,
@ -844,7 +849,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
serializer.storeMethod('ping', {ping_id: pingID});
var pingMessage = {
msg_id: MtpMessageIdGenerator.generateID(),
msg_id: MtpDateManager.generateID(),
seq_no: this.generateSeqNo(true),
body: serializer.getBytes()
};
@ -959,7 +964,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
var serializer = new TLSerialization({mtproto: true});
serializer.storeMethod('http_wait', {max_delay: 0, wait_after: 0, max_wait: 1000});
messages.push({
msg_id: MtpMessageIdGenerator.generateID(),
msg_id: MtpDateManager.generateID(),
seq_no: this.generateSeqNo(),
body: serializer.getBytes()
});
@ -990,7 +995,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
}
var containerSentMessage = {
msg_id: MtpMessageIdGenerator.generateID(),
msg_id: MtpDateManager.generateID(),
seq_no: this.generateSeqNo(true),
container: true,
inner: innerMessages
@ -1340,7 +1345,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
}
if (message.error_code == 16 || message.error_code == 17) {
if (MtpMessageIdGenerator.applyServerTime(
if (MtpDateManager.applyServerTime(
bigStringInt(messageID).shiftRight(32).toString(10)
)) {
this.updateSession();

View File

@ -1992,14 +1992,14 @@ angular.module('myApp.services', [])
history.msgs[messageID] = true;
if (messagesForHistory[messageID]) {
messagesForHistory[messageID].DELETED = true;
messagesForHistory[messageID].deleted = true;
delete messagesForHistory[messageID];
}
if (messagesForDialogs[messageID]) {
messagesForDialogs[messageID].DELETED = true;
messagesForDialogs[messageID].deleted = true;
delete messagesForDialogs[messageID];
}
message.DELETED = true;
message.deleted = true;
delete messagesStorage[messageID];
}
}

View File

@ -30,7 +30,11 @@
</span>
</div>
<div class="im_dialog_message">
<div ng-switch="dialogMessage.deleted">
<div ng-switch-when="true" class="im_dialog_message">
<span class="im_dialog_message_text">deleted message</span>
</div>
<div ng-switch-default class="im_dialog_message">
<span class="im_dialog_chat_from_wrap">
<span
class="im_dialog_chat_from"
@ -78,6 +82,7 @@
<span class="im_dialog_message_text" ng-if="dialogMessage.message.length" ng-bind-html="dialogMessage.richMessage"></span>
</div>
</div>
</div>
</a>