fix: moved disappearing message types to utils

pull/2660/head
William Grant 2 years ago
parent 1303707cd7
commit 0700ac4813

@ -2,10 +2,6 @@ import React, { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components';
import { setDisappearingMessagesByConvoId } from '../../../../interactions/conversationInteractions';
import {
DisappearingMessageConversationSetting,
DisappearingMessageConversationType,
} from '../../../../models/conversationAttributes';
import { closeRightPanel } from '../../../../state/ducks/conversations';
import { resetRightOverlayMode } from '../../../../state/ducks/section';
import { getSelectedConversationKey } from '../../../../state/selectors/conversations';
@ -18,6 +14,10 @@ import { PanelLabel } from '../../../buttons/PanelButton';
import { PanelRadioButton } from '../../../buttons/PanelRadioButton';
import { SessionIconButton } from '../../../icon';
import { getSelectedConversationExpirationSettings } from '../../../../state/selectors/conversations';
import {
DisappearingMessageConversationSetting,
DisappearingMessageConversationType,
} from '../../../../util/expiringMessages';
const StyledScrollContainer = styled.div`
width: 100%;

@ -8,7 +8,6 @@ import { CallManager, SyncUtils, ToastUtils, UserUtils } from '../session/utils'
import {
ConversationNotificationSettingType,
ConversationTypeEnum,
DisappearingMessageConversationType,
} from '../models/conversationAttributes';
import _ from 'lodash';
@ -41,6 +40,7 @@ import { setLastProfileUpdateTimestamp } from '../util/storage';
import { getSodiumRenderer } from '../session/crypto';
import { encryptProfile } from '../util/crypto/profileEncrypter';
import { uploadFileToFsWithOnionV4 } from '../session/apis/file_server_api/FileServerApi';
import { DisappearingMessageConversationType } from '../util/expiringMessages';
export const getCompleteUrlForV2ConvoId = async (convoId: string) => {
if (convoId.match(openGroupV2ConversationIdRegex)) {

@ -1,5 +1,6 @@
import { defaults } from 'lodash';
import { LastMessageStatusType } from '../state/ducks/conversations';
import { DisappearingMessageConversationType } from '../util/expiringMessages';
export enum ConversationTypeEnum {
GROUP = 'group',
@ -14,10 +15,6 @@ export enum ConversationTypeEnum {
export const ConversationNotificationSetting = ['all', 'disabled', 'mentions_only'] as const;
export type ConversationNotificationSettingType = typeof ConversationNotificationSetting[number];
// TODO Might need to be improved by using an enum
export const DisappearingMessageConversationSetting = ['off', 'deleteAfterRead', 'deleteAfterSend'];
export type DisappearingMessageConversationType = typeof DisappearingMessageConversationSetting[number];
export interface ConversationAttributes {
id: string;
type: string;

@ -3,15 +3,11 @@ import { v4 as uuidv4 } from 'uuid';
import { CallNotificationType, PropsForMessageWithConvoProps } from '../state/ducks/conversations';
import { AttachmentTypeWithPath } from '../types/Attachment';
import { Reaction, ReactionList, SortedReactionList } from '../types/Reaction';
import { DisappearingMessageType } from '../util/expiringMessages';
export type MessageModelType = 'incoming' | 'outgoing';
export type MessageDeliveryStatus = 'sending' | 'sent' | 'read' | 'error';
// TODO Might need to be improved by using an enum
export const DisappearingMessageMode = ['deleteAfterRead', 'deleteAfterSend'];
// TODO might need to be improved
export type DisappearingMessageType = typeof DisappearingMessageMode[number] | null;
export interface MessageAttributes {
// the id of the message
// this can have several uses:
@ -29,8 +25,11 @@ export interface MessageAttributes {
expireTimer: number;
expirationStartTimestamp: number;
expires_at?: number;
// TODO are having both variables redundant?
expirationTimerUpdate?: {
expirationType: DisappearingMessageType;
expireTimer: number;
lastDisappearingMessageChangeTimestamp: number;
source: string;
fromSync?: boolean;
};
@ -175,7 +174,9 @@ export interface MessageAttributesOptionals {
expirationStartTimestamp?: number;
expires_at?: number;
expirationTimerUpdate?: {
expirationType: DisappearingMessageType;
expireTimer: number;
lastDisappearingMessageChangeTimestamp: number;
source: string;
fromSync?: boolean;
};

@ -14,9 +14,9 @@ import { LightBoxOptions } from '../../components/conversation/SessionConversati
import {
ConversationNotificationSettingType,
ConversationTypeEnum,
DisappearingMessageConversationType,
} from '../../models/conversationAttributes';
import { ReactionList } from '../../types/Reaction';
import { DisappearingMessageConversationType } from '../../util/expiringMessages';
export type CallNotificationType = 'missed-call' | 'started-call' | 'answered-a-call';
export type PropsForCallNotification = {

@ -8,6 +8,14 @@ import { initWallClockListener } from './wallClockListener';
import { Data } from '../data/data';
import { getConversationController } from '../session/conversations';
// TODO Might need to be improved by using an enum
export const DisappearingMessageMode = ['deleteAfterRead', 'deleteAfterSend'];
// TODO might need to be improved
export type DisappearingMessageType = typeof DisappearingMessageMode[number] | null;
export const DisappearingMessageConversationSetting = ['off', ...DisappearingMessageMode];
export type DisappearingMessageConversationType = typeof DisappearingMessageConversationSetting[number];
export async function destroyMessagesAndUpdateRedux(
messages: Array<{
conversationKey: string;

Loading…
Cancel
Save