chore: fix compilation issues after conflicts resolution

pull/2784/head
Audric Ackermann 2 years ago
parent 4637f4609a
commit 0fa58a5654

@ -8,7 +8,8 @@ import { OverlayRightPanelSettings } from './overlay/OverlayRightPanelSettings';
const ClosableOverlay = () => { const ClosableOverlay = () => {
const rightOverlayMode = useSelector(getRightOverlayMode); const rightOverlayMode = useSelector(getRightOverlayMode);
const [showNewDisppearingMessageModes, setShowNewDisppearingMessageModes] = useState(false); // TODO we can probably use the ReleasedFeatures.isDisappearMessageV2FeatureReleased instead here so we can remove the state.
const [showNewDisappearingMessageModes, setShowNewDisappearingMessageModes] = useState(false);
useEffect(() => { useEffect(() => {
let isCancelled = false; let isCancelled = false;
@ -17,7 +18,7 @@ const ClosableOverlay = () => {
if (isCancelled) { if (isCancelled) {
return; return;
} }
setShowNewDisppearingMessageModes(result); setShowNewDisappearingMessageModes(result);
}) })
.catch(() => { .catch(() => {
if (isCancelled) { if (isCancelled) {
@ -33,7 +34,7 @@ const ClosableOverlay = () => {
switch (rightOverlayMode) { switch (rightOverlayMode) {
case 'disappearing-messages': case 'disappearing-messages':
// TODO legacy messages support will be removed in a future release // TODO legacy messages support will be removed in a future release
return <OverlayDisappearingMessages unlockNewModes={showNewDisppearingMessageModes} />; return <OverlayDisappearingMessages unlockNewModes={showNewDisappearingMessageModes} />;
default: default:
return <OverlayRightPanelSettings />; return <OverlayRightPanelSettings />;
} }

@ -1,27 +1,30 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components'; import styled from 'styled-components';
import { useTimerOptionsByMode } from '../../../../../hooks/useParamSelector';
import { setDisappearingMessagesByConvoId } from '../../../../../interactions/conversationInteractions'; import { setDisappearingMessagesByConvoId } from '../../../../../interactions/conversationInteractions';
import { getConversationController } from '../../../../../session/conversations';
import { closeRightPanel } from '../../../../../state/ducks/conversations'; import { closeRightPanel } from '../../../../../state/ducks/conversations';
import { resetRightOverlayMode } from '../../../../../state/ducks/section'; import { resetRightOverlayMode } from '../../../../../state/ducks/section';
import { Flex } from '../../../../basic/Flex';
import { SessionButton } from '../../../../basic/SessionButton';
import { SpacerLG, SpacerXL } from '../../../../basic/Text';
import { import {
getSelectedConversationExpirationModes, getSelectedConversationExpirationModes,
getSelectedConversationExpirationModesWithLegacy, getSelectedConversationExpirationModesWithLegacy,
getSelectedConversationExpirationSettings, useSelectedConversationKey,
getSelectedConversationKey, useSelectedExpirationType,
} from '../../../../../state/selectors/conversations'; useSelectedExpireTimer,
useSelectedIsGroup,
useSelectedWeAreAdmin,
} from '../../../../../state/selectors/selectedConversation';
import { import {
DEFAULT_TIMER_OPTION, DEFAULT_TIMER_OPTION,
DisappearingMessageConversationType, DisappearingMessageConversationType,
} from '../../../../../util/expiringMessages'; } from '../../../../../util/expiringMessages';
import { useTimerOptionsByMode } from '../../../../../hooks/useParamSelector'; import { Flex } from '../../../../basic/Flex';
import { Header } from './Header'; import { SessionButton } from '../../../../basic/SessionButton';
import { SpacerLG, SpacerXL } from '../../../../basic/Text';
import { DisappearingModes } from './DisappearingModes'; import { DisappearingModes } from './DisappearingModes';
import { Header } from './Header';
import { TimeOptions } from './TimeOptions'; import { TimeOptions } from './TimeOptions';
import { getConversationController } from '../../../../../session/conversations';
const StyledScrollContainer = styled.div` const StyledScrollContainer = styled.div`
width: 100%; width: 100%;
@ -67,12 +70,9 @@ export type PropsForExpirationSettings = {
weAreAdmin: boolean | undefined; weAreAdmin: boolean | undefined;
}; };
type OverlayDisappearingMessagesProps = { unlockNewModes: boolean }; export const OverlayDisappearingMessages = ({ unlockNewModes }: { unlockNewModes: boolean }) => {
export const OverlayDisappearingMessages = (props: OverlayDisappearingMessagesProps) => {
const { unlockNewModes } = props;
const dispatch = useDispatch(); const dispatch = useDispatch();
const selectedConversationKey = useSelector(getSelectedConversationKey); const selectedConversationKey = useSelectedConversationKey();
const disappearingModeOptions = useSelector( const disappearingModeOptions = useSelector(
unlockNewModes unlockNewModes
? getSelectedConversationExpirationModes ? getSelectedConversationExpirationModes
@ -81,21 +81,20 @@ export const OverlayDisappearingMessages = (props: OverlayDisappearingMessagesPr
// NOTE if there is only 'off' and one disappearing message mode then we trigger single mode // NOTE if there is only 'off' and one disappearing message mode then we trigger single mode
const singleMode = const singleMode =
disappearingModeOptions.off !== undefined && Object.keys(disappearingModeOptions).length === 2 disappearingModeOptions &&
disappearingModeOptions.off !== undefined &&
Object.keys(disappearingModeOptions).length === 2
? Object.keys(disappearingModeOptions)[1] ? Object.keys(disappearingModeOptions)[1]
: undefined; : undefined;
const hasOnlyOneMode = Boolean(singleMode && singleMode.length > 0); const hasOnlyOneMode = Boolean(singleMode && singleMode.length > 0);
const convoProps = useSelector(getSelectedConversationExpirationSettings); const isGroup = useSelectedIsGroup();
const expirationType = useSelectedExpirationType();
if (!convoProps) { const expireTimer = useSelectedExpireTimer();
return null; const weAreAdmin = useSelectedWeAreAdmin();
}
const { isGroup, weAreAdmin } = convoProps;
const [modeSelected, setModeSelected] = useState<DisappearingMessageConversationType | undefined>( const [modeSelected, setModeSelected] = useState<DisappearingMessageConversationType | undefined>(
convoProps.expirationType expirationType
); );
const [timeSelected, setTimeSelected] = useState<number>(0); const [timeSelected, setTimeSelected] = useState<number>(0);
const timerOptions = useTimerOptionsByMode(modeSelected, hasOnlyOneMode); const timerOptions = useTimerOptionsByMode(modeSelected, hasOnlyOneMode);
@ -127,13 +126,11 @@ export const OverlayDisappearingMessages = (props: OverlayDisappearingMessagesPr
useEffect(() => { useEffect(() => {
// NOTE loads a time value from the conversation model or the default // NOTE loads a time value from the conversation model or the default
handleSetTime( handleSetTime(
modeSelected === convoProps.expirationType && modeSelected === expirationType && expireTimer && expireTimer > -1
convoProps.expireTimer && ? expireTimer
convoProps.expireTimer > -1
? convoProps.expireTimer
: loadDefaultTimeValue(modeSelected) : loadDefaultTimeValue(modeSelected)
); );
}, [convoProps.expirationType, convoProps.expireTimer, modeSelected]); }, [expirationType, expireTimer, modeSelected]);
// TODO legacy messages support will be removed in a future // TODO legacy messages support will be removed in a future
useEffect(() => { useEffect(() => {
@ -141,7 +138,7 @@ export const OverlayDisappearingMessages = (props: OverlayDisappearingMessagesPr
const convo = getConversationController().get(selectedConversationKey); const convo = getConversationController().get(selectedConversationKey);
if (convo) { if (convo) {
let defaultExpirationType: DisappearingMessageConversationType = 'deleteAfterRead'; let defaultExpirationType: DisappearingMessageConversationType = 'deleteAfterRead';
if (convo.isMe() || convo.isMediumGroup()) { if (convo.isMe() || convo.isClosedGroup()) {
defaultExpirationType = 'deleteAfterSend'; defaultExpirationType = 'deleteAfterSend';
} }
convo.set('expirationType', defaultExpirationType); convo.set('expirationType', defaultExpirationType);
@ -150,6 +147,13 @@ export const OverlayDisappearingMessages = (props: OverlayDisappearingMessagesPr
} }
}, [unlockNewModes, selectedConversationKey, modeSelected]); }, [unlockNewModes, selectedConversationKey, modeSelected]);
if (!disappearingModeOptions) {
return null;
}
if (!selectedConversationKey) {
return null;
}
return ( return (
<StyledScrollContainer> <StyledScrollContainer>
<StyledContainer container={true} flexDirection={'column'} alignItems={'center'}> <StyledContainer container={true} flexDirection={'column'} alignItems={'center'}>

@ -262,6 +262,7 @@ export function useMentionedUs(conversationId?: string): boolean {
export function useIsTyping(conversationId?: string): boolean { export function useIsTyping(conversationId?: string): boolean {
return useConversationPropsById(conversationId)?.isTyping || false; return useConversationPropsById(conversationId)?.isTyping || false;
} }
export function useMessageExpirationPropsById(messageId?: string) { export function useMessageExpirationPropsById(messageId?: string) {
return useSelector((state: StateType) => { return useSelector((state: StateType) => {
if (!messageId) { if (!messageId) {

@ -385,12 +385,14 @@ export async function setDisappearingMessagesByConvoId(
providedExpirationType: 'off', providedExpirationType: 'off',
providedExpireTimer: 0, providedExpireTimer: 0,
providedChangeTimestamp, providedChangeTimestamp,
fromConfigMessage: false,
}); });
} else { } else {
await conversation.updateExpireTimer({ await conversation.updateExpireTimer({
providedExpirationType: expirationType, providedExpirationType: expirationType,
providedExpireTimer: seconds, providedExpireTimer: seconds,
providedChangeTimestamp, providedChangeTimestamp,
fromConfigMessage: false,
}); });
} }
} }

@ -793,6 +793,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
providedChangeTimestamp, providedChangeTimestamp,
providedSource, providedSource,
receivedAt, // is set if it comes from outside receivedAt, // is set if it comes from outside
fromConfigMessage,
fromSync = false, fromSync = false,
shouldCommit = true, shouldCommit = true,
existingMessage, existingMessage,
@ -803,6 +804,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
providedSource?: string; providedSource?: string;
receivedAt?: number; // is set if it comes from outside receivedAt?: number; // is set if it comes from outside
fromSync?: boolean; fromSync?: boolean;
fromConfigMessage: boolean;
shouldCommit?: boolean; shouldCommit?: boolean;
existingMessage?: MessageModel; existingMessage?: MessageModel;
}): Promise<void> { }): Promise<void> {
@ -861,41 +863,43 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
lastDisappearingMessageChangeTimestamp, lastDisappearingMessageChangeTimestamp,
source, source,
}); });
const commonAttributes = {
flags: SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE,
expirationTimerUpdate: {
expirationType,
expireTimer,
lastDisappearingMessageChangeTimestamp,
source,
fromSync,
},
// TODO legacy messages support will be removed in a future release
expirationType:
expirationType !== 'off' || isDisappearingMessagesV2Released ? expirationType : undefined,
expireTimer:
expirationType !== 'off' || isDisappearingMessagesV2Released ? expireTimer : undefined,
};
let message: MessageModel | undefined = existingMessage || undefined; let message: MessageModel | undefined = existingMessage || undefined;
if (!message) { // we don't have info about who made the change and when, when we get a change from a config message, so do not add a control message
if (isOutgoing) { if (!fromConfigMessage) {
message = await this.addSingleOutgoingMessage({ const commonAttributes = {
...commonAttributes, flags: SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE,
sent_at: timestamp, expirationTimerUpdate: {
}); expirationType,
} else { expireTimer,
message = await this.addSingleIncomingMessage({ lastDisappearingMessageChangeTimestamp,
...commonAttributes,
// Even though this isn't reflected to the user, we want to place the last seen
// indicator above it. We set it to 'unread' to trigger that placement.
unread: READ_MESSAGE_STATE.unread,
source, source,
sent_at: timestamp, fromSync,
received_at: timestamp, },
}); // TODO legacy messages support will be removed in a future release
expirationType:
expirationType !== 'off' || isDisappearingMessagesV2Released ? expirationType : undefined,
expireTimer:
expirationType !== 'off' || isDisappearingMessagesV2Released ? expireTimer : undefined,
};
if (!message) {
if (isOutgoing) {
message = await this.addSingleOutgoingMessage({
...commonAttributes,
sent_at: timestamp,
});
} else {
message = await this.addSingleIncomingMessage({
...commonAttributes,
// Even though this isn't reflected to the user, we want to place the last seen
// indicator above it. We set it to 'unread' to trigger that placement.
unread: READ_MESSAGE_STATE.unread,
source,
sent_at: timestamp,
received_at: timestamp,
});
}
} }
} }
@ -908,8 +912,8 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
await this.commit(); await this.commit();
} }
// if change was made remotely, don't send it to the number/group // if change was made remotely, don't send it to the contact/group
if (receivedAt) { if (receivedAt || fromSync || fromConfigMessage) {
return; return;
} }
@ -930,7 +934,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
} }
const expirationTimerMessage = new ExpirationTimerUpdateMessage(expireUpdate); const expirationTimerMessage = new ExpirationTimerUpdateMessage(expireUpdate);
return message.sendSyncMessageOnly(expirationTimerMessage); return message?.sendSyncMessageOnly(expirationTimerMessage);
} }
if (this.isPrivate()) { if (this.isPrivate()) {

@ -93,6 +93,7 @@ import { ReactionList } from '../types/Reaction';
import { roomHasBlindEnabled } from '../types/sqlSharedTypes'; import { roomHasBlindEnabled } from '../types/sqlSharedTypes';
import { import {
DisappearingMessageConversationSetting, DisappearingMessageConversationSetting,
DisappearingMessageConversationType,
DisappearingMessageUpdate, DisappearingMessageUpdate,
ExpirationTimerOptions, ExpirationTimerOptions,
setExpirationStartTimestamp, setExpirationStartTimestamp,
@ -1097,7 +1098,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
dataMessage.flags === SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE) dataMessage.flags === SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE)
); );
const expirationType = content.expirationType const expirationType: DisappearingMessageConversationType = content.expirationType
? DisappearingMessageConversationSetting[content.expirationType] ? DisappearingMessageConversationSetting[content.expirationType]
: isLegacyDataMessage : isLegacyDataMessage
? DisappearingMessageConversationSetting[3] ? DisappearingMessageConversationSetting[3]

@ -320,6 +320,7 @@ export async function handleNewClosedGroup(
providedChangeTimestamp: GetNetworkTime.getNowWithNetworkOffset(), providedChangeTimestamp: GetNetworkTime.getNowWithNetworkOffset(),
providedSource: sender, providedSource: sender,
receivedAt: Date.now(), receivedAt: Date.now(),
fromConfigMessage: false,
}); });
if (isKeyPairAlreadyHere) { if (isKeyPairAlreadyHere) {
@ -381,6 +382,7 @@ export async function handleNewClosedGroup(
providedChangeTimestamp: GetNetworkTime.getNowWithNetworkOffset(), providedChangeTimestamp: GetNetworkTime.getNowWithNetworkOffset(),
providedSource: sender, providedSource: sender,
receivedAt: envelopeTimestamp, receivedAt: envelopeTimestamp,
fromConfigMessage: fromLegacyConfig,
}); });
convo.updateLastMessage(); convo.updateLastMessage();

@ -331,7 +331,14 @@ async function handleContactsUpdate(result: IncomingConfResult): Promise<Incomin
} }
if (wrapperConvo.expirationTimerSeconds !== contactConvo.get('expireTimer')) { if (wrapperConvo.expirationTimerSeconds !== contactConvo.get('expireTimer')) {
await contactConvo.updateExpireTimer(wrapperConvo.expirationTimerSeconds); await contactConvo.updateExpireTimer({
providedExpireTimer: wrapperConvo.expirationTimerSeconds,
fromSync: true,
providedExpirationType: wrapperConvo.expirationMode,
shouldCommit: false,
providedChangeTimestamp: result.latestEnvelopeTimestamp,
fromConfigMessage: true,
});
changes = true; changes = true;
} }
@ -559,14 +566,15 @@ async function handleLegacyGroupUpdate(latestEnvelopeTimestamp: number) {
} }
if (legacyGroupConvo.get('expireTimer') !== fromWrapper.disappearingTimerSeconds) { if (legacyGroupConvo.get('expireTimer') !== fromWrapper.disappearingTimerSeconds) {
await legacyGroupConvo.updateExpireTimer( await legacyGroupConvo.updateExpireTimer({
fromWrapper.disappearingTimerSeconds, providedExpireTimer: fromWrapper.disappearingTimerSeconds,
undefined, shouldCommit: false,
latestEnvelopeTimestamp, fromSync: true,
{ providedChangeTimestamp: latestEnvelopeTimestamp,
fromSync: true, fromConfigMessage: true,
} providedExpirationType:
); fromWrapper.disappearingTimerSeconds === 0 ? 'off' : 'deleteAfterSend',
});
changes = true; changes = true;
} }
// start polling for this group if we haven't left it yet. The wrapper does not store this info for legacy group so we check from the DB entry instead // start polling for this group if we haven't left it yet. The wrapper does not store this info for legacy group so we check from the DB entry instead

@ -344,7 +344,7 @@ export async function handleMessageJob(
messageModel.isIncoming() && messageModel.isIncoming() &&
Boolean(messageModel.get('expirationStartTimestamp')) === false && Boolean(messageModel.get('expirationStartTimestamp')) === false &&
((messageModel.get('expirationType') === 'legacy' && ((messageModel.get('expirationType') === 'legacy' &&
(conversation.isMe() || conversation.isMediumGroup())) || (conversation.isMe() || conversation.isClosedGroup())) ||
messageModel.get('expirationType') === 'deleteAfterSend') messageModel.get('expirationType') === 'deleteAfterSend')
) { ) {
messageModel.set({ messageModel.set({
@ -397,6 +397,7 @@ export async function handleMessageJob(
receivedAt: messageModel.get('received_at'), receivedAt: messageModel.get('received_at'),
shouldCommit: false, shouldCommit: false,
existingMessage: messageModel, existingMessage: messageModel,
fromConfigMessage: false,
}); });
} else { } else {
// this does not commit to db nor UI unless we need to approve a convo // this does not commit to db nor UI unless we need to approve a convo

@ -269,10 +269,11 @@ export async function updateOrCreateClosedGroup(details: GroupInfo) {
// TODO What are we cleaning? // TODO What are we cleaning?
providedExpirationType: expirationType || 'deleteAfterSend', providedExpirationType: expirationType || 'deleteAfterSend',
providedExpireTimer: expireTimer, providedExpireTimer: expireTimer,
providedChangeTimestamp: getNowWithNetworkOffset(), providedChangeTimestamp: GetNetworkTime.getNowWithNetworkOffset(),
providedSource: UserUtils.getOurPubKeyStrFromCache(), providedSource: UserUtils.getOurPubKeyStrFromCache(),
receivedAt: Date.now(), receivedAt: Date.now(),
fromSync: true, fromSync: true,
fromConfigMessage: false,
}); });
} }

@ -128,7 +128,7 @@ async function handleMessageSentSuccess(
const isLegacyReadMode = const isLegacyReadMode =
convo && !convo.isMe() && convo.isPrivate() && expirationType === 'legacy'; convo && !convo.isMe() && convo.isPrivate() && expirationType === 'legacy';
const isLegacySentMode = const isLegacySentMode =
convo && (convo.isMe() || convo.isMediumGroup()) && expirationType === 'legacy'; convo && (convo.isMe() || convo.isClosedGroup()) && expirationType === 'legacy';
fetchedMessage.set({ fetchedMessage.set({
sent_to: sentTo, sent_to: sentTo,

@ -1,15 +1,12 @@
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { ConversationTypeEnum, isOpenOrClosedGroup } from '../../models/conversationAttributes'; import { ConversationTypeEnum, isOpenOrClosedGroup } from '../../models/conversationAttributes';
import { PubKey } from '../../session/types';
import { ReduxConversationType } from '../ducks/conversations'; import { ReduxConversationType } from '../ducks/conversations';
import { StateType } from '../reducer'; import { StateType } from '../reducer';
import { getCanWrite, getSubscriberCount } from './sogsRoomInfo'; import { getCanWrite, getSubscriberCount } from './sogsRoomInfo';
import { PubKey } from '../../session/types';
import {
DisappearingMessageConversationSetting,
DisappearingMessageModesWithState,
} from '../../util/expiringMessages';
import { createSelector } from '@reduxjs/toolkit'; import { createSelector } from '@reduxjs/toolkit';
import { PropsForExpirationSettings } from '../../components/conversation/right-panel/overlay/disappearing-messages/OverlayDisappearingMessages'; import { DisappearingMessageConversationSetting } from '../../util/expiringMessages';
/** /**
* Returns the formatted text for notification setting. * Returns the formatted text for notification setting.
@ -275,21 +272,21 @@ export function useSelectedWeAreAdmin() {
export const getSelectedConversationExpirationModes = createSelector( export const getSelectedConversationExpirationModes = createSelector(
getSelectedConversation, getSelectedConversation,
(convo: ReduxConversationType | undefined) => { (convo: ReduxConversationType | undefined) => {
if (!convo) {
return null;
}
let modes = DisappearingMessageConversationSetting; let modes = DisappearingMessageConversationSetting;
// TODO legacy messages support will be removed in a future release // TODO legacy messages support will be removed in a future release
// TODO remove legacy mode // TODO remove legacy mode
modes = modes.slice(0, -1); modes = modes.slice(0, -1);
if (!convo) {
return DisappearingMessageConversationSetting;
}
// Note to Self and Closed Groups only support deleteAfterSend // Note to Self and Closed Groups only support deleteAfterSend
const isClosedGroup = !convo.isPrivate && !convo.isPublic; const isClosedGroup = !convo.isPrivate && !convo.isPublic;
if (convo?.isMe || isClosedGroup) { if (convo?.isMe || isClosedGroup) {
modes = [modes[0], modes[2]]; modes = [modes[0], modes[2]];
} }
const modesWithDisabledState: DisappearingMessageModesWithState = {}; const modesWithDisabledState: Record<string, boolean> = {};
if (modes && modes.length > 1) { if (modes && modes.length > 1) {
modes.forEach(mode => { modes.forEach(mode => {
modesWithDisabledState[mode] = isClosedGroup ? !convo.weAreAdmin : false; modesWithDisabledState[mode] = isClosedGroup ? !convo.weAreAdmin : false;
@ -304,12 +301,12 @@ export const getSelectedConversationExpirationModes = createSelector(
export const getSelectedConversationExpirationModesWithLegacy = createSelector( export const getSelectedConversationExpirationModesWithLegacy = createSelector(
getSelectedConversation, getSelectedConversation,
(convo: ReduxConversationType | undefined) => { (convo: ReduxConversationType | undefined) => {
let modes = DisappearingMessageConversationSetting;
// this just won't happen // this just won't happen
if (!convo) { if (!convo) {
return DisappearingMessageConversationSetting; return null;
} }
let modes = DisappearingMessageConversationSetting;
// Note to Self and Closed Groups only support deleteAfterSend and legacy modes // Note to Self and Closed Groups only support deleteAfterSend and legacy modes
const isClosedGroup = !convo.isPrivate && !convo.isPublic; const isClosedGroup = !convo.isPrivate && !convo.isPublic;
if (convo?.isMe || isClosedGroup) { if (convo?.isMe || isClosedGroup) {
@ -319,7 +316,8 @@ export const getSelectedConversationExpirationModesWithLegacy = createSelector(
// Legacy mode is the 2nd option in the UI // Legacy mode is the 2nd option in the UI
modes = [modes[0], modes[modes.length - 1], ...modes.slice(1, modes.length - 1)]; modes = [modes[0], modes[modes.length - 1], ...modes.slice(1, modes.length - 1)];
const modesWithDisabledState: DisappearingMessageModesWithState = {}; // TODO it would be nice to type those with something else that string but it causes a lot of issues
const modesWithDisabledState: Record<string, boolean> = {};
// The new modes are disabled by default // The new modes are disabled by default
if (modes && modes.length > 1) { if (modes && modes.length > 1) {
modes.forEach(mode => { modes.forEach(mode => {
@ -332,13 +330,3 @@ export const getSelectedConversationExpirationModesWithLegacy = createSelector(
return modesWithDisabledState; return modesWithDisabledState;
} }
); );
export const getSelectedConversationExpirationSettings = createSelector(
getSelectedConversation,
(convo: ReduxConversationType | undefined): PropsForExpirationSettings => ({
expirationType: convo?.expirationType,
expireTimer: convo?.expireTimer,
isGroup: !convo?.isPrivate,
weAreAdmin: convo?.weAreAdmin,
})
);

@ -14,7 +14,6 @@ import {
import { import {
getSelectedConversation, getSelectedConversation,
getSelectedConversationKey, getSelectedConversationKey,
getSelectedConversationExpirationSettings,
} from '../selectors/selectedConversation'; } from '../selectors/selectedConversation';
import { getStagedAttachmentsForCurrentConversation } from '../selectors/stagedAttachments'; import { getStagedAttachmentsForCurrentConversation } from '../selectors/stagedAttachments';
import { getTheme } from '../selectors/theme'; import { getTheme } from '../selectors/theme';
@ -34,7 +33,6 @@ const mapStateToProps = (state: StateType) => {
stagedAttachments: getStagedAttachmentsForCurrentConversation(state), stagedAttachments: getStagedAttachmentsForCurrentConversation(state),
hasOngoingCallWithFocusedConvo: getHasOngoingCallWithFocusedConvo(state), hasOngoingCallWithFocusedConvo: getHasOngoingCallWithFocusedConvo(state),
isSelectedConvoInitialLoadingInProgress: getIsSelectedConvoInitialLoadingInProgress(state), isSelectedConvoInitialLoadingInProgress: getIsSelectedConvoInitialLoadingInProgress(state),
selectedConversationExpirationSettings: getSelectedConversationExpirationSettings(state),
}; };
}; };

@ -13,18 +13,13 @@ import { MessageModel } from '../models/message';
import { GetNetworkTime } from '../session/apis/snode_api/getNetworkTime'; import { GetNetworkTime } from '../session/apis/snode_api/getNetworkTime';
import { ReleasedFeatures } from './releaseFeature'; import { ReleasedFeatures } from './releaseFeature';
// TODO Might need to be improved by using an enum // TODO do we need to add legacy here now that it's explicitly in the protobuf?
// TODO do we need to add legacy here now that it's explicitly in the protbuf?
export const DisappearingMessageMode = ['deleteAfterRead', 'deleteAfterSend']; export const DisappearingMessageMode = ['deleteAfterRead', 'deleteAfterSend'];
export type DisappearingMessageType = typeof DisappearingMessageMode[number] | null; export type DisappearingMessageType = typeof DisappearingMessageMode[number] | null;
// TODO legacy messages support will be removed in a future release // TODO legacy messages support will be removed in a future release
export const DisappearingMessageConversationSetting = ['off', ...DisappearingMessageMode, 'legacy']; export const DisappearingMessageConversationSetting = ['off', ...DisappearingMessageMode, 'legacy'];
export type DisappearingMessageConversationType = typeof DisappearingMessageConversationSetting[number]; // TODO we should make this type a bit more hardcoded than being just resolved as a string export type DisappearingMessageConversationType = typeof DisappearingMessageConversationSetting[number]; // TODO we should make this type a bit more hardcoded than being just resolved as a string
export type DisappearingMessageModesWithState = Record<
DisappearingMessageConversationType,
boolean
>;
export const DEFAULT_TIMER_OPTION = { export const DEFAULT_TIMER_OPTION = {
DELETE_AFTER_READ: 43200, // 12 hours DELETE_AFTER_READ: 43200, // 12 hours

Loading…
Cancel
Save