Skip to content

Commit 986184b

Browse files
authored
Merge pull request #1596 from session-foundation/fix-qa-issues-user-settings
fix: issues found by QA on user settings - 2
2 parents 7da2599 + 5afb102 commit 986184b

File tree

17 files changed

+239
-125
lines changed

17 files changed

+239
-125
lines changed

stylesheets/_modules.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321

322322
.module-conversation-list-item__header__name {
323323
flex-grow: 1;
324-
flex-shrink: 1;
324+
flex-shrink: 1000; // we need this to take all the shrinking instead of the ListItemIcons
325325
font-size: 14px;
326326
line-height: 18px;
327327

ts/components/dialog/UpdateConversationDetailsDialog.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ function useDescriptionErrorString({
101101
// description is always optional
102102
return '';
103103
}
104-
const charLength = newDescription?.length || 0;
104+
105+
// "👨🏻‍❤️‍💋‍👨🏻" is supposed to be 1char, but 35 bytes, and this is the only way
106+
// I found to have this to have the correct count
107+
const segmenter = new Intl.Segmenter('en', { granularity: 'grapheme' });
108+
const charLength = [...segmenter.segment(newDescription)].length;
109+
105110
const byteLength = new TextEncoder().encode(newDescription).length;
106111

107112
if (

ts/components/dialog/user-settings/components.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const StyledProfileName = styled(Flex)`
9191
}
9292
`;
9393

94-
const StyledName = styled.p`
94+
const StyledName = styled.div`
9595
font-size: var(--font-size-xl);
9696
line-height: 1.4;
9797
font-weight: 700;
@@ -116,14 +116,15 @@ export const ProfileName = (props: { profileName: string; onClick: () => void })
116116
<StyledProfileName $container={true} $justifyContent="center" $alignItems="center">
117117
<StyledName data-testid="your-profile-name" onClick={onClick}>
118118
{profileName}
119+
{showPro.show ? (
120+
<ProIconButton
121+
iconSize={'medium'}
122+
dataTestId="pro-badge-profile-name"
123+
onClick={showPro.cb}
124+
style={{ display: 'inline-flex', marginInlineStart: 'var(--margins-sm)' }}
125+
/>
126+
) : null}
119127
</StyledName>
120-
{showPro.show ? (
121-
<ProIconButton
122-
iconSize={'medium'}
123-
dataTestId="pro-badge-profile-name"
124-
onClick={showPro.cb}
125-
/>
126-
) : null}
127128
</StyledProfileName>
128129
);
129130
};

ts/components/leftpane/conversation-list-item/HeaderItem.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const NotificationSettingIcon = () => {
3636
iconType="mute"
3737
iconColor={'var(--conversation-tab-text-color)'}
3838
iconSize="small"
39+
style={{ flexShrink: 0 }}
3940
/>
4041
);
4142
case 'mentions_only':
@@ -44,6 +45,7 @@ const NotificationSettingIcon = () => {
4445
iconType="bell"
4546
iconColor={'var(--conversation-tab-text-color)'}
4647
iconSize="small"
48+
style={{ flexShrink: 0 }}
4749
/>
4850
);
4951
default:
@@ -63,7 +65,12 @@ const PinIcon = () => {
6365
const isPinned = useIsPinned(conversationId);
6466

6567
return isPinned ? (
66-
<SessionIcon iconType="pin" iconColor={'var(--conversation-tab-text-color)'} iconSize="small" />
68+
<SessionIcon
69+
iconType="pin"
70+
iconColor={'var(--conversation-tab-text-color)'}
71+
iconSize="small"
72+
style={{ flexShrink: 0 }}
73+
/>
6774
) : null;
6875
};
6976

@@ -100,6 +107,7 @@ const MentionAtSymbol = styled.span`
100107
min-width: 16px;
101108
border-radius: 8px;
102109
cursor: pointer;
110+
flex-shrink: 0;
103111
104112
&:hover {
105113
filter: grayscale(0.7);

ts/components/leftpane/overlay/choose-action/ContactRow.tsx

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
import { createPortal } from 'react-dom';
2+
import { contextMenu } from 'react-contexify';
3+
import type { ReactNode } from 'react';
14
import styled, { CSSProperties } from 'styled-components';
5+
26
import { openConversationWithMessages } from '../../../../state/ducks/conversations';
37
import { Avatar, AvatarSize } from '../../../avatar/Avatar';
48
import { useShowUserDetailsCbFromConversation } from '../../../menuAndSettingsHooks/useShowUserDetailsCb';
59
import { ContactName } from '../../../conversation/ContactName/ContactName';
10+
import { MemoConversationListItemContextMenu } from '../../../menu/ConversationListItemContextMenu';
11+
import { ContextConversationProvider } from '../../../../contexts/ConvoIdContext';
12+
13+
const Portal = ({ children }: { children: ReactNode }) => {
14+
return createPortal(children, document.querySelector('.inbox.index') as Element);
15+
};
616

717
type Props = { id: string; displayName?: string; style: CSSProperties };
818

@@ -56,23 +66,35 @@ export const ContactRowBreak = (props: { char: string; key: string; style: CSSPr
5666

5767
export const ContactRow = (props: Props) => {
5868
const { id, style } = props;
69+
const triggerId = `contact-row-${id}-ctxmenu`;
5970

6071
return (
61-
<StyledRowContainer
62-
style={style}
63-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
64-
onClick={async () => openConversationWithMessages({ conversationKey: id, messageId: null })}
65-
>
66-
<AvatarItem id={id} />
67-
<ContactName
68-
data-testid="module-conversation__user__profile-name"
69-
pubkey={id}
70-
contactNameContext="contact-list-row"
71-
extraNameStyle={{
72-
color: 'var(--text-primary-color)',
73-
fontSize: 'var(--font-size-lg)',
72+
<ContextConversationProvider value={id}>
73+
<StyledRowContainer
74+
style={style}
75+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
76+
onClick={async () => openConversationWithMessages({ conversationKey: id, messageId: null })}
77+
onContextMenu={e => {
78+
contextMenu.show({
79+
id: triggerId,
80+
event: e,
81+
});
7482
}}
75-
/>
76-
</StyledRowContainer>
83+
>
84+
<AvatarItem id={id} />
85+
<ContactName
86+
data-testid="module-conversation__user__profile-name"
87+
pubkey={id}
88+
contactNameContext="contact-list-row"
89+
extraNameStyle={{
90+
color: 'var(--text-primary-color)',
91+
fontSize: 'var(--font-size-lg)',
92+
}}
93+
/>
94+
<Portal>
95+
<MemoConversationListItemContextMenu triggerId={triggerId} />
96+
</Portal>
97+
</StyledRowContainer>
98+
</ContextConversationProvider>
7799
);
78100
};

ts/mains/main_node.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ app.on('ready', async () => {
709709
const userDataPath = getRealPath(app.getPath('userData'));
710710
const installPath = getRealPath(join(app.getAppPath(), '..', '..'));
711711

712+
// Register signal handlers
713+
process.on('SIGINT', () => gracefulShutdown('SIGINT')); // Ctrl+C
714+
process.on('SIGTERM', () => gracefulShutdown('SIGTERM')); // Termination request
715+
712716
installFileHandler({
713717
protocol: electronProtocol,
714718
userDataPath,
@@ -859,7 +863,7 @@ async function requestShutdown() {
859863
setTimeout(() => {
860864
console.log('requestShutdown: Response never received; forcing shutdown.');
861865
resolve(undefined);
862-
}, 2 * DURATION.MINUTES);
866+
}, 1 * DURATION.MINUTES);
863867
});
864868

865869
try {
@@ -869,6 +873,13 @@ async function requestShutdown() {
869873
}
870874
}
871875

876+
async function gracefulShutdown(signal: string) {
877+
console.warn(`Received ${signal}, shutting down...`);
878+
await requestShutdown();
879+
app.quit();
880+
console.warn(`Received ${signal}, shutting down: done`);
881+
}
882+
872883
app.on('before-quit', () => {
873884
console.log('before-quit event', {
874885
readyForShutdown: mainWindow ? readyForShutdown : null,

ts/models/conversation.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,14 @@ export class ConversationModel extends Model<ConversationAttributes> {
275275
const type = this.get('type');
276276
switch (type) {
277277
case ConversationTypeEnum.PRIVATE:
278-
return this.id;
278+
return `priv:${ed25519Str(this.id)}`;
279279
case ConversationTypeEnum.GROUPV2:
280-
return `group(${ed25519Str(this.id)})`;
280+
return `group:${ed25519Str(this.id)}`;
281281
case ConversationTypeEnum.GROUP: {
282282
if (this.isPublic()) {
283-
return this.id;
283+
return `comm:${this.id}`;
284284
}
285-
return `group(${ed25519Str(this.id)})`;
285+
return `group_legacy:${ed25519Str(this.id)}`;
286286
}
287287
default:
288288
assertUnreachable(type, `idForLogging case not handled for type:"${type}"`);
@@ -954,10 +954,7 @@ export class ConversationModel extends Model<ConversationAttributes> {
954954
const networkTimestamp = NetworkTime.now();
955955

956956
window?.log?.info(
957-
'Sending message to conversation',
958-
this.idForLogging(),
959-
'with networkTimestamp: ',
960-
networkTimestamp
957+
`Sending message to conversation ${this.idForLogging()} with networkTimestamp: ${networkTimestamp}`
961958
);
962959

963960
const attachmentsWithVoiceMessage = attachments
@@ -1163,13 +1160,12 @@ export class ConversationModel extends Model<ConversationAttributes> {
11631160
}
11641161
}
11651162

1166-
// Note: we agreed that a **legacy closed** group ControlMessage message does not expire.
1167-
// Group v2 on the other hand, have expiring disappearing control message
1163+
// Private chats and group v2 are the two types of conversation
1164+
// where this function can be called, and both have expiring
1165+
// disappearing control messages.
11681166

1169-
message.setExpirationType(
1170-
this.isClosedGroup() && !this.isClosedGroupV2() ? 'unknown' : expirationType
1171-
);
1172-
message.setExpireTimer(this.isClosedGroup() && !this.isClosedGroupV2() ? 0 : expireTimer);
1167+
message.setExpirationType(expirationType);
1168+
message.setExpireTimer(expireTimer);
11731169

11741170
if (!message.id) {
11751171
message.setId(v4());

ts/models/message.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ContentMessage } from '../session/messages/outgoing';
88
import { ClosedGroupV2VisibleMessage } from '../session/messages/outgoing/visibleMessage/ClosedGroupVisibleMessage';
99
import { PubKey } from '../session/types';
1010
import {
11+
MessageUtils,
1112
UserUtils,
1213
attachmentIdAsStrFromUrl,
1314
uploadAttachmentsToFileServer,
@@ -89,7 +90,7 @@ import {
8990
getPromotedGroupUpdateChangeStr,
9091
} from './groupUpdate';
9192
import { NetworkTime } from '../util/NetworkTime';
92-
import { MessageQueue } from '../session/sending';
93+
import { MessageQueue, MessageSender } from '../session/sending';
9394
import { getTimerNotificationStr } from './timerNotifications';
9495
import {
9596
ExpirationTimerUpdate,
@@ -173,7 +174,7 @@ export class MessageModel extends Model<MessageAttributes> {
173174
}
174175

175176
public idForLogging() {
176-
return `${this.get('source')} ${this.get('sent_at')}`;
177+
return `msg(${this.id}, ${this.getConversation()?.idForLogging()}, ${this.get('sent_at')})`;
177178
}
178179

179180
public isExpirationTimerUpdate() {
@@ -1113,9 +1114,14 @@ export class MessageModel extends Model<MessageAttributes> {
11131114
);
11141115

11151116
if (syncMessage) {
1116-
await MessageQueue.use().sendSyncMessage({
1117-
namespace: SnodeNamespaces.Default,
1118-
message: syncMessage,
1117+
await MessageSender.sendSingleMessage({
1118+
isSyncMessage: true,
1119+
message: await MessageUtils.toRawMessage(
1120+
PubKey.cast(UserUtils.getOurPubKeyStrFromCache()),
1121+
syncMessage,
1122+
SnodeNamespaces.Default
1123+
),
1124+
abortSignal: null,
11191125
});
11201126
}
11211127
}
@@ -1359,6 +1365,13 @@ export class MessageModel extends Model<MessageAttributes> {
13591365
this.set({ expirationStartTimestamp });
13601366
}
13611367

1368+
public setExpiresAt(expiresAt: number | undefined) {
1369+
if (expiresAt === this.getExpiresAt()) {
1370+
return;
1371+
}
1372+
this.set({ expires_at: expiresAt });
1373+
}
1374+
13621375
public getPreview() {
13631376
return this.get('preview');
13641377
}

ts/models/messageFactory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function getSharedAttributesForPublicMessage({
8383
messageHash: '', // we do not care of a messageHash for an opengroup message. we have serverId for that
8484
// NOTE Community messages do not support disappearing messages
8585
expirationStartTimestamp: undefined,
86+
expires_at: undefined,
8687
};
8788
}
8889

ts/receiver/queuedJob.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ async function markConvoAsReadIfOutgoingMessage(
365365
const isOutgoingMessage =
366366
message.get('type') === 'outgoing' || message.get('direction') === 'outgoing';
367367
if (isOutgoingMessage) {
368-
const sentAt = message.get('sent_at') || message.get('serverTimestamp');
368+
const sentAt = message.get('serverTimestamp') || message.get('sent_at');
369369
if (sentAt) {
370370
const expirationType = message.getExpirationType();
371371
const expireTimer = message.getExpireTimerSeconds();
@@ -432,16 +432,19 @@ export async function handleMessageJob(
432432
messageModel.getExpirationType(),
433433
messageModel.getExpireTimerSeconds()
434434
);
435-
436-
if (expirationMode === 'deleteAfterSend') {
437-
messageModel.setMessageExpirationStartTimestamp(
438-
DisappearingMessages.setExpirationStartTimestamp(
439-
expirationMode,
440-
messageModel.get('sent_at'),
441-
'handleMessageJob',
442-
messageModel.id
443-
)
435+
const expireTimer = messageModel.getExpireTimerSeconds();
436+
437+
if (expirationMode === 'deleteAfterSend' && expireTimer > 0) {
438+
const expirationStartTimestamp = DisappearingMessages.setExpirationStartTimestamp(
439+
expirationMode,
440+
messageModel.get('sent_at'),
441+
'handleMessageJob',
442+
messageModel.id
444443
);
444+
if (expirationStartTimestamp) {
445+
messageModel.setMessageExpirationStartTimestamp(expirationStartTimestamp);
446+
messageModel.setExpiresAt(expirationStartTimestamp + expireTimer * 1000);
447+
}
445448
}
446449
}
447450

0 commit comments

Comments
 (0)