diff --git a/ts/components/NoticeBanner.tsx b/ts/components/NoticeBanner.tsx index a8d1e432e..f91c496cb 100644 --- a/ts/components/NoticeBanner.tsx +++ b/ts/components/NoticeBanner.tsx @@ -5,7 +5,6 @@ import { SessionIconButton, SessionIconType } from './icon'; import { StyledRootDialog } from './dialog/StyledRootDialog'; const StyledNoticeBanner = styled(Flex)` - position: relative; background-color: var(--primary-color); color: var(--black-color); font-size: var(--font-size-md); @@ -15,14 +14,13 @@ const StyledNoticeBanner = styled(Flex)` cursor: pointer; .session-icon-button { - position: absolute; right: var(--margins-sm); pointer-events: none; } `; const StyledText = styled.span` - margin-right: var(--margins-xl); + margin-right: var(--margins-sm); `; type NoticeBannerProps = { @@ -65,7 +63,7 @@ const StyledGroupInviteBanner = styled(Flex)` // when part a a dialog, invert it and make it narrower (as the dialog grows to make it fit) ${StyledRootDialog} & { background-color: unset; - color: var(--orange-color); + color: var(--text-primary-color); max-width: 300px; } `; diff --git a/ts/components/conversation/AddMentions.tsx b/ts/components/conversation/AddMentions.tsx index 1021ac699..d0e128361 100644 --- a/ts/components/conversation/AddMentions.tsx +++ b/ts/components/conversation/AddMentions.tsx @@ -34,7 +34,7 @@ const Mention = (props: MentionProps) => { return ( - @{foundConvo?.getContactProfileNameOrShortenedPubKey() || PubKey.shorten(props.text)} + @{foundConvo?.getNicknameOrRealUsernameOrPlaceholder() || PubKey.shorten(props.text)} ); }; diff --git a/ts/components/conversation/message/message-content/ClickToTrustSender.tsx b/ts/components/conversation/message/message-content/ClickToTrustSender.tsx index a9cd1637e..13a3ff005 100644 --- a/ts/components/conversation/message/message-content/ClickToTrustSender.tsx +++ b/ts/components/conversation/message/message-content/ClickToTrustSender.tsx @@ -46,7 +46,7 @@ export const ClickToTrustSender = (props: { messageId: string }) => { i18nMessage: { token: 'attachmentsAutoDownloadModalDescription', args: { - conversation_name: convo.getContactProfileNameOrShortenedPubKey(), + conversation_name: convo.getNicknameOrRealUsernameOrPlaceholder(), }, }, closeTheme: SessionButtonColor.Danger, diff --git a/ts/components/dialog/InviteContactsDialog.tsx b/ts/components/dialog/InviteContactsDialog.tsx index f28f66f07..e4250b745 100644 --- a/ts/components/dialog/InviteContactsDialog.tsx +++ b/ts/components/dialog/InviteContactsDialog.tsx @@ -127,7 +127,7 @@ const InviteContactsDialogInner = (props: Props) => { const isGroupV2 = useSelectedIsGroupV2(); const [shareHistory, setShareHistory] = useState(false); - const { uniqueValues: selectedContacts, addTo, removeFrom } = useSet(); + const { uniqueValues: selectedContacts, addTo, removeFrom, empty } = useSet(); if (isPrivate) { throw new Error('InviteContactsDialogInner must be a group'); @@ -144,27 +144,28 @@ const InviteContactsDialogInner = (props: Props) => { }; const onClickOK = () => { - if (selectedContacts.length > 0) { - if (isPublic) { - void submitForOpenGroup(conversationId, selectedContacts); - } else { - if (PubKey.is03Pubkey(conversationId)) { - const forcedAsPubkeys = selectedContacts as Array; - const action = groupInfoActions.currentDeviceGroupMembersChange({ - addMembersWithoutHistory: shareHistory ? [] : forcedAsPubkeys, - addMembersWithHistory: shareHistory ? forcedAsPubkeys : [], - removeMembers: [], - groupPk: conversationId, - alsoRemoveMessages: false, - }); - dispatch(action as any); - return; - } - void submitForClosedGroup(conversationId, selectedContacts); - } + if (selectedContacts.length <= 0) { + closeDialog(); + return; } - - closeDialog(); + if (isPublic) { + void submitForOpenGroup(conversationId, selectedContacts); + return; + } + if (PubKey.is03Pubkey(conversationId)) { + const forcedAsPubkeys = selectedContacts as Array; + const action = groupInfoActions.currentDeviceGroupMembersChange({ + addMembersWithoutHistory: shareHistory ? [] : forcedAsPubkeys, + addMembersWithHistory: shareHistory ? forcedAsPubkeys : [], + removeMembers: [], + groupPk: conversationId, + alsoRemoveMessages: false, + }); + dispatch(action as any); + empty(); + return; + } + void submitForClosedGroup(conversationId, selectedContacts); }; useKey((event: KeyboardEvent) => { @@ -182,7 +183,7 @@ const InviteContactsDialogInner = (props: Props) => { const hasContacts = validContactsForInvite.length > 0; return ( - + {hasContacts && isGroupV2 && } diff --git a/ts/components/leftpane/overlay/OverlayClosedGroup.tsx b/ts/components/leftpane/overlay/OverlayClosedGroup.tsx index 88b75d08c..f59949021 100644 --- a/ts/components/leftpane/overlay/OverlayClosedGroup.tsx +++ b/ts/components/leftpane/overlay/OverlayClosedGroup.tsx @@ -134,7 +134,6 @@ export const OverlayClosedGroupV2 = () => { async function onEnterPressed() { setGroupNameError(undefined); - setGroupName(''); if (isCreatingGroup) { window?.log?.warn('Closed group creation already in progress'); return; diff --git a/ts/interactions/conversationInteractions.ts b/ts/interactions/conversationInteractions.ts index 67b97e7d6..4fb24dabe 100644 --- a/ts/interactions/conversationInteractions.ts +++ b/ts/interactions/conversationInteractions.ts @@ -268,7 +268,7 @@ export const declineConversationWithConfirm = ({ // restoring from seed we might not have the sender of that invite, so we need to take care of not having one (and not block) const originNameToBlock = alsoBlock && !!conversationIdOrigin - ? ConvoHub.use().get(conversationIdOrigin)?.getContactProfileNameOrShortenedPubKey() + ? ConvoHub.use().get(conversationIdOrigin)?.getNicknameOrRealUsernameOrPlaceholder() : null; const convoName = ConvoHub.use().get(conversationId)?.getNicknameOrRealUsernameOrPlaceholder(); diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 8efbcc4ff..612144420 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -1817,9 +1817,8 @@ export class ConversationModel extends Backbone.Model { } /** - * For a private convo, returns the loki profile name if set, or a shortened - * version of the contact pubkey. - * Throws an error if called on a group convo. + * For a private convo, returns nickname || ('You' || userDisplayName) || shortened(pk) + * Throws an error if called on a no-private convo. * */ public getContactProfileNameOrShortenedPubKey() { diff --git a/ts/models/groupUpdate.ts b/ts/models/groupUpdate.ts index e2f3194fb..1e6f0b8a1 100644 --- a/ts/models/groupUpdate.ts +++ b/ts/models/groupUpdate.ts @@ -14,15 +14,15 @@ function usAndXOthers(arr: Array) { export function getKickedGroupUpdateStr( kicked: Array, - groupName: string + _groupName: string ): LocalizerComponentPropsObject { const { others, us } = usAndXOthers(kicked); - const othersNames = others.map(ConvoHub.use().getContactProfileNameOrShortenedPubKey); + const othersNames = others.map(ConvoHub.use().getNicknameOrRealUsernameOrPlaceholder); if (us) { switch (others.length) { case 0: - return { token: 'groupRemovedYou', args: { group_name: groupName } }; + return { token: 'groupRemovedYouGeneral' }; case 1: return { token: 'groupRemovedYouTwo', args: { other_name: othersNames[0] } }; default: @@ -66,7 +66,7 @@ export function getLeftGroupUpdateChangeStr(left: Array): LocalizerCompo : { token: 'groupMemberLeft', args: { - name: ConvoHub.use().getContactProfileNameOrShortenedPubKey(others[0]), + name: ConvoHub.use().getNicknameOrRealUsernameOrPlaceholder(others[0]), }, }; } @@ -78,7 +78,7 @@ export function getJoinedGroupUpdateChangeStr( _groupName: string ): LocalizerComponentPropsObject { const { others, us } = usAndXOthers(joined); - const othersNames = others.map(ConvoHub.use().getContactProfileNameOrShortenedPubKey); + const othersNames = others.map(ConvoHub.use().getNicknameOrRealUsernameOrPlaceholder); if (groupv2) { if (us) { @@ -164,7 +164,7 @@ export function getPromotedGroupUpdateChangeStr( joined: Array ): LocalizerComponentPropsObject { const { others, us } = usAndXOthers(joined); - const othersNames = others.map(ConvoHub.use().getContactProfileNameOrShortenedPubKey); + const othersNames = others.map(ConvoHub.use().getNicknameOrRealUsernameOrPlaceholder); if (us) { switch (othersNames.length) { diff --git a/ts/models/message.ts b/ts/models/message.ts index aa971348f..24ab54df9 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -343,16 +343,16 @@ export class MessageModel extends Backbone.Model { ) as DataExtractionNotificationMsg; if (dataExtraction.type === SignalService.DataExtractionNotification.Type.SCREENSHOT) { return window.i18n.stripped('screenshotTaken', { - name: ConvoHub.use().getContactProfileNameOrShortenedPubKey(dataExtraction.source), + name: ConvoHub.use().getNicknameOrRealUsernameOrPlaceholder(dataExtraction.source), }); } return window.i18n.stripped('attachmentsMediaSaved', { - name: ConvoHub.use().getContactProfileNameOrShortenedPubKey(dataExtraction.source), + name: ConvoHub.use().getNicknameOrRealUsernameOrPlaceholder(dataExtraction.source), }); } if (this.isCallNotification()) { - const name = ConvoHub.use().getContactProfileNameOrShortenedPubKey( + const name = ConvoHub.use().getNicknameOrRealUsernameOrPlaceholder( this.get('conversationId') ); const callNotificationType = this.get('callNotificationType'); @@ -448,7 +448,7 @@ export class MessageModel extends Backbone.Model { (pubkeysInDesc || []).forEach((pubkeyWithAt: string) => { const pubkey = pubkeyWithAt.slice(1); const isUS = isUsAnySogsFromCache(pubkey); - const displayName = ConvoHub.use().getContactProfileNameOrShortenedPubKey(pubkey); + const displayName = ConvoHub.use().getNicknameOrRealUsernameOrPlaceholder(pubkey); if (isUS) { bodyMentionsMappedToNames = bodyMentionsMappedToNames?.replace( pubkeyWithAt, diff --git a/ts/models/timerNotifications.ts b/ts/models/timerNotifications.ts index 94199e9cd..77ee40628 100644 --- a/ts/models/timerNotifications.ts +++ b/ts/models/timerNotifications.ts @@ -24,7 +24,7 @@ export function getTimerNotificationStr({ const timespanText = TimerOptions.getName(timespanSeconds || 0); const disabled = !timespanSeconds || timespanSeconds <= 0; - const authorName = ConvoHub.use().getContactProfileNameOrShortenedPubKey(author); + const authorName = ConvoHub.use().getNicknameOrRealUsernameOrPlaceholder(author); // TODO: legacy messages support will be removed in a future release if (isLegacyDisappearingModeEnabled(expirationMode)) { diff --git a/ts/session/conversations/ConversationController.ts b/ts/session/conversations/ConversationController.ts index a11f372ad..f9f839215 100644 --- a/ts/session/conversations/ConversationController.ts +++ b/ts/session/conversations/ConversationController.ts @@ -160,12 +160,12 @@ class ConvoController { return conversation; } - public getContactProfileNameOrShortenedPubKey(pubKey: string): string { + public getNicknameOrRealUsernameOrPlaceholder(pubKey: string): string { const conversation = ConvoHub.use().get(pubKey); if (!conversation) { return pubKey; } - return conversation.getContactProfileNameOrShortenedPubKey(); + return conversation.getNicknameOrRealUsernameOrPlaceholder(); } public async getOrCreateAndWait( diff --git a/ts/state/ducks/metaGroups.ts b/ts/state/ducks/metaGroups.ts index 8d8b5e6b8..f9d382ab4 100644 --- a/ts/state/ducks/metaGroups.ts +++ b/ts/state/ducks/metaGroups.ts @@ -150,6 +150,14 @@ const initNewGroupInWrapper = createAsyncThunk( groupEd25519Pubkey: toFixedUint8ArrayOfLength(groupEd2519Pk, 32).buffer, }); + const infos = await MetaGroupWrapperActions.infoGet(groupPk); + if (!infos) { + throw new Error(`getInfos of ${groupPk} returned empty result even if it was just init.`); + } + // if the name exceeds libsession-util max length for group name, the name will be saved truncated + infos.name = groupName; + await MetaGroupWrapperActions.infoSet(groupPk, infos); + for (let index = 0; index < uniqMembers.length; index++) { const member = uniqMembers[index]; const convoMember = ConvoHub.use().get(member); @@ -173,13 +181,6 @@ const initNewGroupInWrapper = createAsyncThunk( } } - const infos = await MetaGroupWrapperActions.infoGet(groupPk); - if (!infos) { - throw new Error(`getInfos of ${groupPk} returned empty result even if it was just init.`); - } - infos.name = groupName; - await MetaGroupWrapperActions.infoSet(groupPk, infos); - const membersFromWrapper = await MetaGroupWrapperActions.memberGetAll(groupPk); if (!membersFromWrapper || isEmpty(membersFromWrapper)) { throw new Error( diff --git a/ts/themes/oceanDark.ts b/ts/themes/oceanDark.ts index f76e8bd3d..f9160c43c 100644 --- a/ts/themes/oceanDark.ts +++ b/ts/themes/oceanDark.ts @@ -51,7 +51,7 @@ export const oceanDark: ThemeColorVariables = { '--button-outline-border-hover-color': 'var(--text-primary-color)', '--button-outline-disabled-color': 'var(--disabled-color)', - '--button-solid-background-color': 'var(--background-secondary-color)', + '--button-solid-background-color': THEMES.OCEAN_DARK.COLOR1, '--button-solid-background-hover-color': THEMES.OCEAN_DARK.COLOR4, '--button-solid-text-color': 'var(--text-primary-color)', '--button-solid-text-hover-color': 'var(--text-primary-color)',