Track groups I've left
// FREEBIE
This commit is contained in:
parent
83b25c0bfa
commit
010297f4c5
5 changed files with 54 additions and 40 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue