Support for new GroupV2 groups

This commit is contained in:
Scott Nonnenberg 2020-09-08 19:25:05 -07:00
parent 1ce0959fa1
commit 7a02cc815d
53 changed files with 7326 additions and 839 deletions

View file

@ -28,7 +28,7 @@
className: 'contact-wrapper',
Component: window.Signal.Components.ContactListItem,
props: {
...this.model.cachedProps,
...this.model.format(),
onClick: this.showIdentity.bind(this),
},
});

View file

@ -215,6 +215,9 @@
Whisper.MaxAttachmentsToast = Whisper.ToastView.extend({
template: i18n('maximumAttachments'),
});
Whisper.TimerConflictToast = Whisper.ToastView.extend({
template: i18n('GroupV2--timerConflict'),
});
Whisper.ConversationLoadingScreen = Whisper.View.extend({
templateName: 'conversation-loading-screen',
@ -311,6 +314,13 @@
this.model.updateSharedGroups.bind(this.model),
FIVE_MINUTES
);
this.model.throttledFetchLatestGroupV2Data =
this.model.throttledFetchLatestGroupV2Data ||
_.throttle(
this.model.fetchLatestGroupV2Data.bind(this.model),
FIVE_MINUTES
);
this.debouncedMaybeGrabLinkPreview = _.debounce(
this.maybeGrabLinkPreview.bind(this),
200
@ -385,8 +395,13 @@
leftGroup: this.model.get('left'),
expirationSettingName,
disableTimerChanges:
this.model.get('left') ||
!this.model.getAccepted() ||
!this.model.canChangeTimer(),
showBackButton: Boolean(this.panels && this.panels.length),
expirationSettingName,
timerOptions: Whisper.ExpirationTimerOptions.map(item => ({
name: item.getName(),
value: item.get('seconds'),
@ -1826,6 +1841,8 @@
this.setQuoteMessage(quotedMessageId);
}
this.model.throttledFetchLatestGroupV2Data();
const statusPromise = this.model.throttledGetProfiles();
// eslint-disable-next-line more/no-then
this.statusFetch = statusPromise.then(() =>
@ -2044,7 +2061,18 @@
async showMembers(e, providedMembers, options = {}) {
_.defaults(options, { needVerify: false });
const model = providedMembers || this.model.contactCollection;
let model = providedMembers || this.model.contactCollection;
if (!providedMembers && this.model.get('groupVersion') === 2) {
model = new Whisper.GroupConversationCollection(
this.model.get('membersV2').map(({ conversationId, role }) => ({
conversation: ConversationController.get(conversationId),
isAdmin:
role === window.textsecure.protobuf.Member.Role.ADMINISTRATOR,
}))
);
}
const view = new Whisper.GroupMemberList({
model,
// we pass this in to allow nested panels
@ -2496,11 +2524,17 @@
this.model.endSession();
},
setDisappearingMessages(seconds) {
if (seconds > 0) {
this.model.updateExpirationTimer(seconds);
} else {
this.model.updateExpirationTimer(null);
async setDisappearingMessages(seconds) {
try {
if (seconds > 0) {
await this.model.updateExpirationTimer(seconds);
} else {
await this.model.updateExpirationTimer(null);
}
} catch (error) {
if (error.code === 409) {
this.showToast(Whisper.TimerConflictToast);
}
}
},