chore: address PR reviews

pull/3281/head
Audric Ackermann 4 months ago
parent 9e32aa01ef
commit d4cae6e5b2
No known key found for this signature in database

@ -9,7 +9,7 @@ import {
} from '../../state/selectors/conversations';
import { useSelectedConversationKey } from '../../state/selectors/selectedConversation';
import { MessageDateBreak } from './message/message-item/DateBreak';
import { CommunityInvitation } from './message/message-item/GroupInvitation';
import { CommunityInvitation } from './message/message-item/CommunityInvitation';
import { GroupUpdateMessage } from './message/message-item/GroupUpdateMessage';
import { Message } from './message/message-item/Message';
import { MessageRequestResponse } from './message/message-item/MessageRequestResponse';

@ -42,10 +42,10 @@ const FollowSettingButton = styled.button`
function useFollowSettingsButtonClick({ messageId }: WithMessageId) {
const selectedConvoKey = useSelectedConversationKey();
const timespanSeconds = useMessageExpirationUpdateTimespanSeconds(messageId) || 0;
const expirationMode = useMessageExpirationUpdateMode(messageId) || 'off';
const disabled = useMessageExpirationUpdateDisabled(messageId) || false;
const timespanText = useMessageExpirationUpdateTimespanText(messageId) || '';
const timespanSeconds = useMessageExpirationUpdateTimespanSeconds(messageId);
const expirationMode = useMessageExpirationUpdateMode(messageId);
const disabled = useMessageExpirationUpdateDisabled(messageId);
const timespanText = useMessageExpirationUpdateTimespanText(messageId);
const dispatch = useDispatch();
const onExit = () => dispatch(updateConfirmModal(null));
@ -108,9 +108,9 @@ function useFollowSettingsButtonClick({ messageId }: WithMessageId) {
}
function useAreSameThanOurSide({ messageId }: WithMessageId) {
const timespanSeconds = useMessageExpirationUpdateTimespanSeconds(messageId) || 0;
const expirationMode = useMessageExpirationUpdateMode(messageId) || 'off';
const disabled = useMessageExpirationUpdateDisabled(messageId) || false;
const timespanSeconds = useMessageExpirationUpdateTimespanSeconds(messageId);
const expirationMode = useMessageExpirationUpdateMode(messageId);
const disabled = useMessageExpirationUpdateDisabled(messageId);
const selectedMode = useSelectedConversationDisappearingMode();
const selectedTimespan = useSelectedExpireTimer();
@ -129,7 +129,7 @@ const FollowSettingsButton = ({ messageId }: WithMessageId) => {
const v2Released = ReleasedFeatures.isUserConfigFeatureReleasedCached();
const isPrivateAndFriend = useSelectedIsPrivateFriend();
const expirationMode = useMessageExpirationUpdateMode(messageId) || 'off';
const expirationMode = useMessageExpirationUpdateMode(messageId);
const authorIsUs = useMessageAuthorIsUs(messageId);
const click = useFollowSettingsButtonClick({

@ -242,7 +242,7 @@ export async function deleteMessagesFromSwarmAndCompletelyLocally(
// LEGACY GROUPS -- we cannot delete on the swarm (just unsend which is done separately)
if (conversation.isClosedGroup() && PubKey.is05Pubkey(pubkey)) {
window.log.info('Cannot delete message from a closed group swarm, so we just complete delete.');
await deletesMessageLocallyOnly({ conversation, messages, deletionType: 'complete' });
await deleteMessagesLocallyOnly({ conversation, messages, deletionType: 'complete' });
return;
}
window.log.info(
@ -257,7 +257,7 @@ export async function deleteMessagesFromSwarmAndCompletelyLocally(
'deleteMessagesFromSwarmAndCompletelyLocally: some messages failed to be deleted. Maybe they were already deleted?'
);
}
await deletesMessageLocallyOnly({ conversation, messages, deletionType: 'complete' });
await deleteMessagesLocallyOnly({ conversation, messages, deletionType: 'complete' });
}
/**
@ -273,7 +273,7 @@ export async function deleteMessagesFromSwarmAndMarkAsDeletedLocally(
window.log.info(
'Cannot delete messages from a legacy closed group swarm, so we just markDeleted.'
);
await deletesMessageLocallyOnly({ conversation, messages, deletionType: 'markDeleted' });
await deleteMessagesLocallyOnly({ conversation, messages, deletionType: 'markDeleted' });
return;
}
@ -290,7 +290,7 @@ export async function deleteMessagesFromSwarmAndMarkAsDeletedLocally(
'deleteMessagesFromSwarmAndMarkAsDeletedLocally: some messages failed to be deleted but still removing the messages content... '
);
}
await deletesMessageLocallyOnly({ conversation, messages, deletionType: 'markDeleted' });
await deleteMessagesLocallyOnly({ conversation, messages, deletionType: 'markDeleted' });
}
/**
@ -298,7 +298,7 @@ export async function deleteMessagesFromSwarmAndMarkAsDeletedLocally(
* @param message Message to delete
* @param deletionType 'complete' means completely delete the item from the database, markDeleted means empty the message content but keep an entry
*/
async function deletesMessageLocallyOnly({
async function deleteMessagesLocallyOnly({
conversation,
messages,
deletionType,
@ -380,7 +380,7 @@ const doDeleteSelectedMessagesInSOGS = async (
toDeleteLocallyIds.map(async id => {
const msgToDeleteLocally = await Data.getMessageById(id);
if (msgToDeleteLocally) {
return deletesMessageLocallyOnly({
return deleteMessagesLocallyOnly({
conversation,
messages: [msgToDeleteLocally],
deletionType: 'complete',
@ -457,7 +457,7 @@ const doDeleteSelectedMessages = async ({
// delete just for me in a groupv2 only means delete locally (not even synced to our other devices)
if (conversation.isClosedGroupV2()) {
await deletesMessageLocallyOnly({
await deleteMessagesLocallyOnly({
conversation,
messages: selectedMessages,
deletionType: 'markDeleted',

@ -36,7 +36,7 @@ import { OpenGroupUtils } from '../session/apis/open_group_api/utils';
import { getOpenGroupV2FromConversationId } from '../session/apis/open_group_api/utils/OpenGroupUtils';
import { ExpirationTimerUpdateMessage } from '../session/messages/outgoing/controlMessage/ExpirationTimerUpdateMessage';
import { TypingMessage } from '../session/messages/outgoing/controlMessage/TypingMessage';
import { GroupInvitationMessage } from '../session/messages/outgoing/visibleMessage/GroupInvitationMessage';
import { CommunityInvitationMessage } from '../session/messages/outgoing/visibleMessage/CommunityInvitationMessage';
import { OpenGroupVisibleMessage } from '../session/messages/outgoing/visibleMessage/OpenGroupVisibleMessage';
import {
VisibleMessage,
@ -494,7 +494,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
* Fetches from the Database an update of what are the memory only informations like mentionedUs and the unreadCount, etc
*/
public async refreshInMemoryDetails(providedMemoryDetails?: SaveConversationReturn) {
if (!SessionUtilConvoInfoVolatile.isConvoToStoreInWrapper(this)) {
return;
}
@ -2145,7 +2144,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const communityInvitation = message.getCommunityInvitation();
if (communityInvitation && communityInvitation.url) {
const groupInviteMessage = new GroupInvitationMessage({
const communityInviteMessage = new CommunityInvitationMessage({
identifier: id,
createAtNetworkTimestamp: networkTimestamp,
name: communityInvitation.name,
@ -2156,7 +2155,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
// we need the return await so that errors are caught in the catch {}
await MessageQueue.use().sendToPubKey(
destinationPubkey,
groupInviteMessage,
communityInviteMessage,
SnodeNamespaces.Default
);
return;

@ -54,7 +54,7 @@ import {
MessageModelPropsWithoutConvoProps,
PropsForAttachment,
PropsForExpirationTimer,
PropsForGroupInvitation,
PropsForCommunityInvitation,
PropsForGroupUpdate,
PropsForGroupUpdateAdd,
PropsForGroupUpdateAvatarChange,
@ -125,7 +125,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
public getMessageModelProps(): MessageModelPropsWithoutConvoProps {
const propsForDataExtractionNotification = this.getPropsForDataExtractionNotification();
const propsForGroupInvitation = this.getPropsForGroupInvitation();
const propsForCommunityInvitation = this.getPropsForCommunityInvitation();
const propsForGroupUpdateMessage = this.getPropsForGroupUpdateMessage();
const propsForTimerNotification = this.getPropsForTimerNotification();
const isMessageResponse = this.isMessageRequestResponse();
@ -141,8 +141,8 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
if (isMessageResponse) {
messageProps.propsForMessageRequestResponse = {};
}
if (propsForGroupInvitation) {
messageProps.propsForGroupInvitation = propsForGroupInvitation;
if (propsForCommunityInvitation) {
messageProps.propsForCommunityInvitation = propsForCommunityInvitation;
}
if (propsForGroupUpdateMessage) {
messageProps.propsForGroupUpdateMessage = propsForGroupUpdateMessage;
@ -455,7 +455,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
return props;
}
private getPropsForGroupInvitation(): PropsForGroupInvitation | null {
private getPropsForCommunityInvitation(): PropsForCommunityInvitation | null {
const invitation = this.getCommunityInvitation();
if (!invitation || !invitation.url) {
return null;

@ -145,16 +145,6 @@ export type DataExtractionNotificationMsg = {
export type PropsForDataExtractionNotification = DataExtractionNotificationMsg;
export type PropsForMessageRequestResponse = MessageRequestResponseMsg & {
conversationId?: string;
name?: string;
messageId: string;
receivedAt?: number;
isUnread: boolean;
isApproved?: boolean;
source?: string;
};
export type MessageGroupUpdate = {
left?: Array<PubkeyType>;
joined?: Array<PubkeyType>;

@ -2,16 +2,16 @@ import { SignalService } from '../../../../protobuf';
import { DataMessage } from '../DataMessage';
import { ExpirableMessageParams } from '../ExpirableMessage';
interface GroupInvitationMessageParams extends ExpirableMessageParams {
interface CommunityInvitationMessageParams extends ExpirableMessageParams {
url: string;
name: string;
}
export class GroupInvitationMessage extends DataMessage {
export class CommunityInvitationMessage extends DataMessage {
private readonly url: string;
private readonly name: string;
constructor(params: GroupInvitationMessageParams) {
constructor(params: CommunityInvitationMessageParams) {
super({
createAtNetworkTimestamp: params.createAtNetworkTimestamp,
identifier: params.identifier,

@ -33,13 +33,13 @@ import { WithConvoId, WithMessageHash, WithMessageId } from '../../session/types
export type MessageModelPropsWithoutConvoProps = {
propsForMessage: PropsForMessageWithoutConvoProps;
propsForGroupInvitation?: PropsForGroupInvitation; // plop: cleaned up
propsForTimerNotification?: PropsForExpirationTimer; // plop: cleaned up
propsForDataExtractionNotification?: PropsForDataExtractionNotification; // plop: cleaned up
propsForGroupUpdateMessage?: PropsForGroupUpdate; // plop: cleaned up
propsForCallNotification?: PropsForCallNotification; // plop: cleaned up
propsForMessageRequestResponse?: PropsForMessageRequestResponse; // plop: cleaned up
propsForInteractionNotification?: PropsForInteractionNotification; // plop: cleaned up
propsForCommunityInvitation?: PropsForCommunityInvitation;
propsForTimerNotification?: PropsForExpirationTimer;
propsForDataExtractionNotification?: PropsForDataExtractionNotification;
propsForGroupUpdateMessage?: PropsForGroupUpdate;
propsForCallNotification?: PropsForCallNotification;
propsForMessageRequestResponse?: PropsForMessageRequestResponse;
propsForInteractionNotification?: PropsForInteractionNotification;
};
export type MessageModelPropsWithConvoProps = SortedMessageModelProps & {
@ -122,7 +122,7 @@ export type PropsForGroupUpdate = {
change: PropsForGroupUpdateType;
};
export type PropsForGroupInvitation = {
export type PropsForCommunityInvitation = {
serverName: string;
fullUrl: string;
};

@ -149,7 +149,7 @@ export const getSortedMessagesTypesOfSelectedConversation = createSelector(
? ('data-extraction' as const)
: msg.propsForMessageRequestResponse
? ('message-request-response' as const)
: msg.propsForGroupInvitation
: msg.propsForCommunityInvitation
? ('group-invitation' as const)
: msg.propsForGroupUpdateMessage
? ('group-notification' as const)

@ -194,20 +194,20 @@ export function useMessageSelected(messageId?: string) {
* Return the full url needed to join a community through a community invitation message
*/
export function useMessageCommunityInvitationFullUrl(messageId: string) {
return useMessagePropsByMessageId(messageId)?.propsForGroupInvitation?.fullUrl;
return useMessagePropsByMessageId(messageId)?.propsForCommunityInvitation?.fullUrl;
}
/**
* Return the community display name to have a guess of what a community is about
*/
export function useMessageCommunityInvitationCommunityName(messageId: string) {
return useMessagePropsByMessageId(messageId)?.propsForGroupInvitation?.serverName;
return useMessagePropsByMessageId(messageId)?.propsForCommunityInvitation?.serverName;
}
/**
* =========================================
* Below are selectors for call notification
* =========================================
* ==========================================
* Below are selectors for call notifications
* ==========================================
*/
/**
@ -224,7 +224,7 @@ export function useMessageCallNotificationType(messageId: string) {
*/
/**
* Return the call notification type linked to the specified message
* Return the data exrtaction type linked to the specified message
*/
export function useMessageDataExtractionType(messageId: string) {
return useMessagePropsByMessageId(messageId)?.propsForDataExtractionNotification?.type;
@ -237,7 +237,7 @@ export function useMessageDataExtractionType(messageId: string) {
*/
/**
* Return the call notification type linked to the specified message
* Return the interaction notification type linked to the specified message
*/
export function useMessageInteractionNotification(messageId: string) {
return useMessagePropsByMessageId(messageId)?.propsForInteractionNotification?.notificationType;
@ -253,7 +253,7 @@ export function useMessageInteractionNotification(messageId: string) {
* Return the expiration update mode linked to the specified message
*/
export function useMessageExpirationUpdateMode(messageId: string) {
return useMessagePropsByMessageId(messageId)?.propsForTimerNotification?.expirationMode;
return useMessagePropsByMessageId(messageId)?.propsForTimerNotification?.expirationMode || 'off';
}
/**
@ -265,7 +265,7 @@ export function useMessageExpirationUpdateDisabled(messageId: string) {
}
/**
* Return the timespan in seconds to which this expiration timer update is sett
* Return the timespan in seconds to which this expiration timer update is set
*/
export function useMessageExpirationUpdateTimespanSeconds(messageId: string) {
return useMessagePropsByMessageId(messageId)?.propsForTimerNotification?.timespanSeconds;
@ -275,7 +275,7 @@ export function useMessageExpirationUpdateTimespanSeconds(messageId: string) {
* Return the timespan in text (localised) built from the field timespanSeconds
*/
export function useMessageExpirationUpdateTimespanText(messageId: string) {
return useMessagePropsByMessageId(messageId)?.propsForTimerNotification?.timespanText;
return useMessagePropsByMessageId(messageId)?.propsForTimerNotification?.timespanText || '';
}
/**

@ -3,16 +3,16 @@ import { beforeEach } from 'mocha';
import { SignalService } from '../../../../protobuf';
import { Constants } from '../../../../session';
import { GroupInvitationMessage } from '../../../../session/messages/outgoing/visibleMessage/GroupInvitationMessage';
import { CommunityInvitationMessage } from '../../../../session/messages/outgoing/visibleMessage/CommunityInvitationMessage';
describe('GroupInvitationMessage', () => {
let message: GroupInvitationMessage;
describe('CommunityInvitationMessage', () => {
let message: CommunityInvitationMessage;
const createAtNetworkTimestamp = Date.now();
const url = 'http://localhost';
const name = 'test';
beforeEach(() => {
message = new GroupInvitationMessage({
message = new CommunityInvitationMessage({
createAtNetworkTimestamp,
url,
name,

Loading…
Cancel
Save