Track groups I've left

// FREEBIE
This commit is contained in:
lilia 2016-02-11 14:12:09 -08:00
parent 83b25c0bfa
commit 010297f4c5
5 changed files with 54 additions and 40 deletions

View file

@ -131,13 +131,17 @@
function onGroupReceived(ev) {
var groupDetails = ev.groupDetails;
ConversationController.create({
var conversation = ConversationController.create({
id: groupDetails.id,
name: groupDetails.name,
members: groupDetails.members,
avatar: groupDetails.avatar,
type: 'group',
}).save();
});
if (!groupDetails.active) {
conversation.set({left: true});
}
conversation.save();
}
function onMessageReceived(ev) {

View file

@ -37077,6 +37077,7 @@ MessageReceiver.prototype.extend({
while (groupDetails !== undefined) {
var promise = (function(groupDetails) {
groupDetails.id = getString(groupDetails.id);
if (groupDetails.active) {
return textsecure.storage.groups.getGroup(groupDetails.id).
then(function(existingGroup) {
if (existingGroup === undefined) {
@ -37088,14 +37089,17 @@ MessageReceiver.prototype.extend({
groupDetails.id, groupDetails.members
);
}
}).then(function() {
}).then(function() { return groupDetails });
} else {
return Promise.resolve(groupDetails);
}
})(groupDetails).then(function(groupDetails) {
var ev = new Event('group');
ev.groupDetails = groupDetails;
eventTarget.dispatchEvent(ev);
}).catch(function(e) {
console.log('error processing group', groupDetails.id, e);
console.log('error processing group', e);
});
})(groupDetails);
groupDetails = groupBuffer.next();
promises.push(promise);
}

View file

@ -164,6 +164,7 @@
leaveGroup: function() {
var now = Date.now();
if (this.get('type') === 'group') {
this.save({left: true});
var message = this.messageCollection.create({
group_update: { left: 'You' },
conversationId : this.id,

View file

@ -241,6 +241,7 @@ MessageReceiver.prototype.extend({
while (groupDetails !== undefined) {
var promise = (function(groupDetails) {
groupDetails.id = getString(groupDetails.id);
if (groupDetails.active) {
return textsecure.storage.groups.getGroup(groupDetails.id).
then(function(existingGroup) {
if (existingGroup === undefined) {
@ -252,14 +253,17 @@ MessageReceiver.prototype.extend({
groupDetails.id, groupDetails.members
);
}
}).then(function() {
}).then(function() { return groupDetails });
} else {
return Promise.resolve(groupDetails);
}
})(groupDetails).then(function(groupDetails) {
var ev = new Event('group');
ev.groupDetails = groupDetails;
eventTarget.dispatchEvent(ev);
}).catch(function(e) {
console.log('error processing group', groupDetails.id, e);
console.log('error processing group', e);
});
})(groupDetails);
groupDetails = groupBuffer.next();
promises.push(promise);
}

View file

@ -97,6 +97,7 @@ message GroupDetails {
optional string name = 2;
repeated string members = 3;
optional Avatar avatar = 4;
optional bool active = 5 [default = true];
}
message ContactDetails {