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'; } from '../../state/selectors/conversations';
import { useSelectedConversationKey } from '../../state/selectors/selectedConversation'; import { useSelectedConversationKey } from '../../state/selectors/selectedConversation';
import { MessageDateBreak } from './message/message-item/DateBreak'; 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 { GroupUpdateMessage } from './message/message-item/GroupUpdateMessage';
import { Message } from './message/message-item/Message'; import { Message } from './message/message-item/Message';
import { MessageRequestResponse } from './message/message-item/MessageRequestResponse'; import { MessageRequestResponse } from './message/message-item/MessageRequestResponse';

@ -42,10 +42,10 @@ const FollowSettingButton = styled.button`
function useFollowSettingsButtonClick({ messageId }: WithMessageId) { function useFollowSettingsButtonClick({ messageId }: WithMessageId) {
const selectedConvoKey = useSelectedConversationKey(); const selectedConvoKey = useSelectedConversationKey();
const timespanSeconds = useMessageExpirationUpdateTimespanSeconds(messageId) || 0; const timespanSeconds = useMessageExpirationUpdateTimespanSeconds(messageId);
const expirationMode = useMessageExpirationUpdateMode(messageId) || 'off'; const expirationMode = useMessageExpirationUpdateMode(messageId);
const disabled = useMessageExpirationUpdateDisabled(messageId) || false; const disabled = useMessageExpirationUpdateDisabled(messageId);
const timespanText = useMessageExpirationUpdateTimespanText(messageId) || ''; const timespanText = useMessageExpirationUpdateTimespanText(messageId);
const dispatch = useDispatch(); const dispatch = useDispatch();
const onExit = () => dispatch(updateConfirmModal(null)); const onExit = () => dispatch(updateConfirmModal(null));
@ -108,9 +108,9 @@ function useFollowSettingsButtonClick({ messageId }: WithMessageId) {
} }
function useAreSameThanOurSide({ messageId }: WithMessageId) { function useAreSameThanOurSide({ messageId }: WithMessageId) {
const timespanSeconds = useMessageExpirationUpdateTimespanSeconds(messageId) || 0; const timespanSeconds = useMessageExpirationUpdateTimespanSeconds(messageId);
const expirationMode = useMessageExpirationUpdateMode(messageId) || 'off'; const expirationMode = useMessageExpirationUpdateMode(messageId);
const disabled = useMessageExpirationUpdateDisabled(messageId) || false; const disabled = useMessageExpirationUpdateDisabled(messageId);
const selectedMode = useSelectedConversationDisappearingMode(); const selectedMode = useSelectedConversationDisappearingMode();
const selectedTimespan = useSelectedExpireTimer(); const selectedTimespan = useSelectedExpireTimer();
@ -129,7 +129,7 @@ const FollowSettingsButton = ({ messageId }: WithMessageId) => {
const v2Released = ReleasedFeatures.isUserConfigFeatureReleasedCached(); const v2Released = ReleasedFeatures.isUserConfigFeatureReleasedCached();
const isPrivateAndFriend = useSelectedIsPrivateFriend(); const isPrivateAndFriend = useSelectedIsPrivateFriend();
const expirationMode = useMessageExpirationUpdateMode(messageId) || 'off'; const expirationMode = useMessageExpirationUpdateMode(messageId);
const authorIsUs = useMessageAuthorIsUs(messageId); const authorIsUs = useMessageAuthorIsUs(messageId);
const click = useFollowSettingsButtonClick({ 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) // LEGACY GROUPS -- we cannot delete on the swarm (just unsend which is done separately)
if (conversation.isClosedGroup() && PubKey.is05Pubkey(pubkey)) { if (conversation.isClosedGroup() && PubKey.is05Pubkey(pubkey)) {
window.log.info('Cannot delete message from a closed group swarm, so we just complete delete.'); 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; return;
} }
window.log.info( window.log.info(
@ -257,7 +257,7 @@ export async function deleteMessagesFromSwarmAndCompletelyLocally(
'deleteMessagesFromSwarmAndCompletelyLocally: some messages failed to be deleted. Maybe they were already deleted?' '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( window.log.info(
'Cannot delete messages from a legacy closed group swarm, so we just markDeleted.' '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; return;
} }
@ -290,7 +290,7 @@ export async function deleteMessagesFromSwarmAndMarkAsDeletedLocally(
'deleteMessagesFromSwarmAndMarkAsDeletedLocally: some messages failed to be deleted but still removing the messages content... ' '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 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 * @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, conversation,
messages, messages,
deletionType, deletionType,
@ -380,7 +380,7 @@ const doDeleteSelectedMessagesInSOGS = async (
toDeleteLocallyIds.map(async id => { toDeleteLocallyIds.map(async id => {
const msgToDeleteLocally = await Data.getMessageById(id); const msgToDeleteLocally = await Data.getMessageById(id);
if (msgToDeleteLocally) { if (msgToDeleteLocally) {
return deletesMessageLocallyOnly({ return deleteMessagesLocallyOnly({
conversation, conversation,
messages: [msgToDeleteLocally], messages: [msgToDeleteLocally],
deletionType: 'complete', 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) // delete just for me in a groupv2 only means delete locally (not even synced to our other devices)
if (conversation.isClosedGroupV2()) { if (conversation.isClosedGroupV2()) {
await deletesMessageLocallyOnly({ await deleteMessagesLocallyOnly({
conversation, conversation,
messages: selectedMessages, messages: selectedMessages,
deletionType: 'markDeleted', 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 { getOpenGroupV2FromConversationId } from '../session/apis/open_group_api/utils/OpenGroupUtils';
import { ExpirationTimerUpdateMessage } from '../session/messages/outgoing/controlMessage/ExpirationTimerUpdateMessage'; import { ExpirationTimerUpdateMessage } from '../session/messages/outgoing/controlMessage/ExpirationTimerUpdateMessage';
import { TypingMessage } from '../session/messages/outgoing/controlMessage/TypingMessage'; 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 { OpenGroupVisibleMessage } from '../session/messages/outgoing/visibleMessage/OpenGroupVisibleMessage';
import { import {
VisibleMessage, 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 * Fetches from the Database an update of what are the memory only informations like mentionedUs and the unreadCount, etc
*/ */
public async refreshInMemoryDetails(providedMemoryDetails?: SaveConversationReturn) { public async refreshInMemoryDetails(providedMemoryDetails?: SaveConversationReturn) {
if (!SessionUtilConvoInfoVolatile.isConvoToStoreInWrapper(this)) { if (!SessionUtilConvoInfoVolatile.isConvoToStoreInWrapper(this)) {
return; return;
} }
@ -2145,7 +2144,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const communityInvitation = message.getCommunityInvitation(); const communityInvitation = message.getCommunityInvitation();
if (communityInvitation && communityInvitation.url) { if (communityInvitation && communityInvitation.url) {
const groupInviteMessage = new GroupInvitationMessage({ const communityInviteMessage = new CommunityInvitationMessage({
identifier: id, identifier: id,
createAtNetworkTimestamp: networkTimestamp, createAtNetworkTimestamp: networkTimestamp,
name: communityInvitation.name, 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 {} // we need the return await so that errors are caught in the catch {}
await MessageQueue.use().sendToPubKey( await MessageQueue.use().sendToPubKey(
destinationPubkey, destinationPubkey,
groupInviteMessage, communityInviteMessage,
SnodeNamespaces.Default SnodeNamespaces.Default
); );
return; return;

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

@ -145,16 +145,6 @@ export type DataExtractionNotificationMsg = {
export type PropsForDataExtractionNotification = 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 = { export type MessageGroupUpdate = {
left?: Array<PubkeyType>; left?: Array<PubkeyType>;
joined?: Array<PubkeyType>; joined?: Array<PubkeyType>;

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

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

@ -149,7 +149,7 @@ export const getSortedMessagesTypesOfSelectedConversation = createSelector(
? ('data-extraction' as const) ? ('data-extraction' as const)
: msg.propsForMessageRequestResponse : msg.propsForMessageRequestResponse
? ('message-request-response' as const) ? ('message-request-response' as const)
: msg.propsForGroupInvitation : msg.propsForCommunityInvitation
? ('group-invitation' as const) ? ('group-invitation' as const)
: msg.propsForGroupUpdateMessage : msg.propsForGroupUpdateMessage
? ('group-notification' as const) ? ('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 * Return the full url needed to join a community through a community invitation message
*/ */
export function useMessageCommunityInvitationFullUrl(messageId: string) { 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 * Return the community display name to have a guess of what a community is about
*/ */
export function useMessageCommunityInvitationCommunityName(messageId: string) { 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) { export function useMessageDataExtractionType(messageId: string) {
return useMessagePropsByMessageId(messageId)?.propsForDataExtractionNotification?.type; 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) { export function useMessageInteractionNotification(messageId: string) {
return useMessagePropsByMessageId(messageId)?.propsForInteractionNotification?.notificationType; return useMessagePropsByMessageId(messageId)?.propsForInteractionNotification?.notificationType;
@ -253,7 +253,7 @@ export function useMessageInteractionNotification(messageId: string) {
* Return the expiration update mode linked to the specified message * Return the expiration update mode linked to the specified message
*/ */
export function useMessageExpirationUpdateMode(messageId: string) { 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) { export function useMessageExpirationUpdateTimespanSeconds(messageId: string) {
return useMessagePropsByMessageId(messageId)?.propsForTimerNotification?.timespanSeconds; 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 * Return the timespan in text (localised) built from the field timespanSeconds
*/ */
export function useMessageExpirationUpdateTimespanText(messageId: string) { 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 { SignalService } from '../../../../protobuf';
import { Constants } from '../../../../session'; import { Constants } from '../../../../session';
import { GroupInvitationMessage } from '../../../../session/messages/outgoing/visibleMessage/GroupInvitationMessage'; import { CommunityInvitationMessage } from '../../../../session/messages/outgoing/visibleMessage/CommunityInvitationMessage';
describe('GroupInvitationMessage', () => { describe('CommunityInvitationMessage', () => {
let message: GroupInvitationMessage; let message: CommunityInvitationMessage;
const createAtNetworkTimestamp = Date.now(); const createAtNetworkTimestamp = Date.now();
const url = 'http://localhost'; const url = 'http://localhost';
const name = 'test'; const name = 'test';
beforeEach(() => { beforeEach(() => {
message = new GroupInvitationMessage({ message = new CommunityInvitationMessage({
createAtNetworkTimestamp, createAtNetworkTimestamp,
url, url,
name, name,

Loading…
Cancel
Save