fix: do not force ttl for groupExpireTimerUpdate

pull/3040/head
Audric Ackermann 1 year ago
parent bc30064c57
commit 9d984355dc

@ -187,6 +187,7 @@ export const TimerNotification = (props: PropsForExpirationTimer) => {
const textToRender = useTextToRender(props); const textToRender = useTextToRender(props);
const isGroupOrCommunity = useSelectedIsGroupOrCommunity(); const isGroupOrCommunity = useSelectedIsGroupOrCommunity();
const isGroupV2 = useSelectedIsGroupV2(); const isGroupV2 = useSelectedIsGroupV2();
// renderOff is true when the update is put to off, or when we have a legacy group control message (as they are not expiring at all)
const renderOffIcon = props.disabled || (isGroupOrCommunity && !isGroupV2); const renderOffIcon = props.disabled || (isGroupOrCommunity && !isGroupV2);
if (!textToRender || textToRender.length === 0) { if (!textToRender || textToRender.length === 0) {

@ -882,15 +882,23 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
expirationMode = 'off'; expirationMode = 'off';
expireTimer = 0; expireTimer = 0;
} }
const shouldAddExpireUpdateMessage = const shouldAddExpireUpdateMsgPrivate = this.isPrivate() && !fromConfigMessage;
(this.isPrivate() && !fromConfigMessage) || const isLegacyGroup = this.isClosedGroup() && !PubKey.isClosedGroupV3(this.id);
(this.isClosedGroup() &&
!PubKey.isClosedGroupV3(this.id) && /**
* it's ugly, but we want to add a message for legacy groups only when
* - not coming from a config message
* - effectively changes the setting
* - ignores a off setting for a legacy group (as we can get a setting from restored from configMessage, and a newgroup can still be in the swarm when linking a device
*/
const shouldAddExpireUpdateMsgGroup =
isLegacyGroup &&
!fromConfigMessage && !fromConfigMessage &&
expirationMode !== this.get('expirationMode') && (expirationMode !== this.get('expirationMode') || expireTimer !== this.get('expireTimer')) &&
expireTimer !== this.get('expireTimer') && expirationMode !== 'off';
expirationMode !== 'off' &&
expireTimer !== 0); const shouldAddExpireUpdateMessage =
shouldAddExpireUpdateMsgPrivate || shouldAddExpireUpdateMsgGroup;
// When we add a disappearing messages notification to the conversation, we want it // When we add a disappearing messages notification to the conversation, we want it
// to be above the message that initiated that change, hence the subtraction. // to be above the message that initiated that change, hence the subtraction.

@ -1,4 +1,5 @@
import { SignalService } from '../../../../protobuf'; import { SignalService } from '../../../../protobuf';
import { TTL_DEFAULT } from '../../../constants';
import { PubKey } from '../../../types'; import { PubKey } from '../../../types';
import { StringUtils } from '../../../utils'; import { StringUtils } from '../../../utils';
import { DataMessage } from '../DataMessage'; import { DataMessage } from '../DataMessage';
@ -60,4 +61,11 @@ export class ExpirationTimerUpdateMessage extends DataMessage {
return data; return data;
} }
public ttl(): number {
if (this.groupId) {
return TTL_DEFAULT.CONTENT_MESSAGE;
}
return super.ttl();
}
} }

Loading…
Cancel
Save