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,25 +37077,29 @@ MessageReceiver.prototype.extend({
while (groupDetails !== undefined) {
var promise = (function(groupDetails) {
groupDetails.id = getString(groupDetails.id);
return textsecure.storage.groups.getGroup(groupDetails.id).
then(function(existingGroup) {
if (existingGroup === undefined) {
return textsecure.storage.groups.createNewGroup(
groupDetails.members, groupDetails.id
);
} else {
return textsecure.storage.groups.updateNumbers(
groupDetails.id, groupDetails.members
);
}
}).then(function() {
var ev = new Event('group');
ev.groupDetails = groupDetails;
eventTarget.dispatchEvent(ev);
}).catch(function(e) {
console.log('error processing group', groupDetails.id, e);
});
})(groupDetails);
if (groupDetails.active) {
return textsecure.storage.groups.getGroup(groupDetails.id).
then(function(existingGroup) {
if (existingGroup === undefined) {
return textsecure.storage.groups.createNewGroup(
groupDetails.members, groupDetails.id
);
} else {
return textsecure.storage.groups.updateNumbers(
groupDetails.id, groupDetails.members
);
}
}).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', e);
});
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,25 +241,29 @@ MessageReceiver.prototype.extend({
while (groupDetails !== undefined) {
var promise = (function(groupDetails) {
groupDetails.id = getString(groupDetails.id);
return textsecure.storage.groups.getGroup(groupDetails.id).
then(function(existingGroup) {
if (existingGroup === undefined) {
return textsecure.storage.groups.createNewGroup(
groupDetails.members, groupDetails.id
);
} else {
return textsecure.storage.groups.updateNumbers(
groupDetails.id, groupDetails.members
);
}
}).then(function() {
var ev = new Event('group');
ev.groupDetails = groupDetails;
eventTarget.dispatchEvent(ev);
}).catch(function(e) {
console.log('error processing group', groupDetails.id, e);
});
})(groupDetails);
if (groupDetails.active) {
return textsecure.storage.groups.getGroup(groupDetails.id).
then(function(existingGroup) {
if (existingGroup === undefined) {
return textsecure.storage.groups.createNewGroup(
groupDetails.members, groupDetails.id
);
} else {
return textsecure.storage.groups.updateNumbers(
groupDetails.id, groupDetails.members
);
}
}).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', e);
});
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 {