From ab6bccade6c5767e9bbbb43aa2a1a1bf5a7fa927 Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Wed, 6 Oct 2021 11:35:57 +1100 Subject: [PATCH 01/10] Added additional information to debug logs. --- _locales/en/messages.json | 4 +++- debug_log_preload.js | 4 ++++ js/views/debug_log_view.js | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 8b649412b..148d68311 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -443,5 +443,7 @@ "messageDeletedPlaceholder": "This message has been deleted", "messageDeleted": "Message deleted", "surveyTitle": "Take our Session Survey", - "goToOurSurvey": "Go to our survey" + "goToOurSurvey": "Go to our survey", + "operatingSystem": "Operating System: $operatingSystem$\n", + "commitHash": "Git Commit SHA: $commitHash$\n" } diff --git a/debug_log_preload.js b/debug_log_preload.js index 8121af5d6..dbd23deff 100644 --- a/debug_log_preload.js +++ b/debug_log_preload.js @@ -22,5 +22,9 @@ window.getNodeVersion = () => config.node_version; window.getEnvironment = () => config.environment; require('./js/logging'); +const os = require('os'); + +window.getOSRelease = () => `${os.type()} ${os.release} ${os.platform()}`; +window.getCommitHash = () => config.commitHash; window.closeDebugLog = () => ipcRenderer.send('close-debug-log'); diff --git a/js/views/debug_log_view.js b/js/views/debug_log_view.js index 1ed681538..17bda295a 100644 --- a/js/views/debug_log_view.js +++ b/js/views/debug_log_view.js @@ -26,9 +26,14 @@ this.render(); this.$('textarea').val(i18n('loading')); + const operatingSystemInfo = `${i18n('operatingSystem', window.getOSRelease())}`; + const commitHashInfo = i18n('commitHash', window.getCommitHash()); + // eslint-disable-next-line more/no-then window.log.fetch().then(text => { - this.$('textarea').val(text); + const debugLogWithSystemInfo = operatingSystemInfo + commitHashInfo + text; + + this.$('textarea').val(debugLogWithSystemInfo); }); }, events: { From 3c7c3220a1f5183c1313105c24e6085b6658aed2 Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Fri, 8 Oct 2021 10:59:00 +1100 Subject: [PATCH 02/10] Marking conversation as read if received a sync message from same users other device. --- ts/receiver/queuedJob.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index a1847bd8e..0baa1507a 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -9,7 +9,11 @@ import { getConversationController } from '../session/conversations'; import { ConversationModel, ConversationTypeEnum } from '../models/conversation'; import { MessageModel } from '../models/message'; import { getMessageById, getMessagesBySentAt } from '../../ts/data/data'; -import { MessageModelPropsWithoutConvoProps, messagesAdded } from '../state/ducks/conversations'; +import { + markConversationFullyRead, + MessageModelPropsWithoutConvoProps, + messagesAdded, +} from '../state/ducks/conversations'; import { updateProfileOneAtATime } from './dataMessage'; import Long from 'long'; @@ -245,6 +249,14 @@ function handleSyncedReceipts(message: MessageModel, conversation: ConversationM } message.set({ recipients }); + + // If the newly received message is from us, we assume that we've seen the messages up until that point + const receivedTimestamp = message.get('received_at'); + if (receivedTimestamp) { + conversation.markReadBouncy(receivedTimestamp).then(() => { + window?.inboxStore?.dispatch(markConversationFullyRead(conversation.id)); + }); + } } async function handleRegularMessage( From ff1d7cefe4312a1576188270be8540bac1d0faee Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Fri, 8 Oct 2021 13:33:53 +1100 Subject: [PATCH 03/10] changing some code. --- ts/receiver/queuedJob.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index 0baa1507a..00c0ddb5c 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -9,11 +9,7 @@ import { getConversationController } from '../session/conversations'; import { ConversationModel, ConversationTypeEnum } from '../models/conversation'; import { MessageModel } from '../models/message'; import { getMessageById, getMessagesBySentAt } from '../../ts/data/data'; -import { - markConversationFullyRead, - MessageModelPropsWithoutConvoProps, - messagesAdded, -} from '../state/ducks/conversations'; +import { MessageModelPropsWithoutConvoProps, messagesAdded } from '../state/ducks/conversations'; import { updateProfileOneAtATime } from './dataMessage'; import Long from 'long'; @@ -251,11 +247,9 @@ function handleSyncedReceipts(message: MessageModel, conversation: ConversationM message.set({ recipients }); // If the newly received message is from us, we assume that we've seen the messages up until that point - const receivedTimestamp = message.get('received_at'); - if (receivedTimestamp) { - conversation.markReadBouncy(receivedTimestamp).then(() => { - window?.inboxStore?.dispatch(markConversationFullyRead(conversation.id)); - }); + const sentTimestamp = message.get('sent_at'); + if (sentTimestamp) { + conversation.markRead(sentTimestamp); } } From 8d75fde012a60059c31b1af3ecfb11cb3b92730d Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Fri, 8 Oct 2021 13:57:25 +1100 Subject: [PATCH 04/10] yarn ready changes --- ts/receiver/queuedJob.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index 00c0ddb5c..794edaae0 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -227,7 +227,7 @@ function updateReadStatus(message: MessageModel, conversation: ConversationModel } } -function handleSyncedReceipts(message: MessageModel, conversation: ConversationModel) { +async function handleSyncedReceipts(message: MessageModel, conversation: ConversationModel) { const readReceipts = window.Whisper.ReadReceipts.forMessage(conversation, message); if (readReceipts.length) { const readBy = readReceipts.map((receipt: any) => receipt.get('reader')); @@ -249,7 +249,7 @@ function handleSyncedReceipts(message: MessageModel, conversation: ConversationM // If the newly received message is from us, we assume that we've seen the messages up until that point const sentTimestamp = message.get('sent_at'); if (sentTimestamp) { - conversation.markRead(sentTimestamp); + await conversation.markRead(sentTimestamp); } } @@ -318,7 +318,7 @@ async function handleRegularMessage( } if (type === 'outgoing') { - handleSyncedReceipts(message, conversation); + await handleSyncedReceipts(message, conversation); } const conversationActiveAt = conversation.get('active_at'); From 1fe6b61308ea48f0614b0adc088cd88e89bae1dd Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Mon, 11 Oct 2021 12:25:27 +1100 Subject: [PATCH 05/10] Re-adding code that wasn't commited. Adding button for debug log in settings. --- _locales/en/messages.json | 1 + .../message/OutgoingMessageStatus.tsx | 7 ++++++- .../session/settings/SessionSettings.tsx | 19 ++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 148d68311..652bb95f4 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -73,6 +73,7 @@ "attemptingReconnection": "Attempting reconnect in $reconnect_duration_in_seconds$ seconds", "submitDebugLog": "Debug log", "debugLog": "Debug Log", + "showDebugLog": "Show Debug Log", "goToReleaseNotes": "Go to Release Notes", "goToSupportPage": "Go to Support Page", "menuReportIssue": "Report an Issue", diff --git a/ts/components/conversation/message/OutgoingMessageStatus.tsx b/ts/components/conversation/message/OutgoingMessageStatus.tsx index 2a6869b75..a386fdd95 100644 --- a/ts/components/conversation/message/OutgoingMessageStatus.tsx +++ b/ts/components/conversation/message/OutgoingMessageStatus.tsx @@ -1,3 +1,4 @@ +import { ipcRenderer } from 'electron/renderer'; import React from 'react'; import styled from 'styled-components'; import { MessageDeliveryStatus } from '../../../models/messageType'; @@ -40,8 +41,12 @@ const MessageStatusRead = () => { }; const MessageStatusError = () => { + const showDebugLog = () => { + ipcRenderer.send('show-debug-log'); + }; + return ( - + ); diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index 05db39c86..487bc236b 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -14,7 +14,7 @@ import { getPasswordHash, hasLinkPreviewPopupBeenDisplayed, } from '../../../../ts/data/data'; -import { shell } from 'electron'; +import { ipcRenderer, shell } from 'electron'; import { mapDispatchToProps } from '../../../state/actions'; import { unblockConvoById } from '../../../interactions/conversationInteractions'; import { toggleAudioAutoplay } from '../../../state/ducks/userConfig'; @@ -497,6 +497,23 @@ class SettingsViewInner extends React.Component { buttonColor: SessionButtonColor.Primary, }, }, + { + id: 'debug-log-setting', + title: window.i18n('showDebugLog'), + description: undefined, + hidden: false, + type: SessionSettingType.Button, + category: SessionSettingCategory.Appearance, + setFn: undefined, + comparisonValue: undefined, + onClick: () => { + ipcRenderer.send('show-debug-log'); + }, + content: { + buttonText: window.i18n('debugLog'), + buttonColor: SessionButtonColor.Primary, + }, + }, { id: 'media-permissions', title: window.i18n('mediaPermissionsTitle'), From 3c4dc7f0388df1d3aabf52b51fbd4aeb78f67e50 Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Mon, 11 Oct 2021 12:28:34 +1100 Subject: [PATCH 06/10] Making commit hash show conditionally. --- js/views/debug_log_view.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/views/debug_log_view.js b/js/views/debug_log_view.js index 17bda295a..cb1d9e597 100644 --- a/js/views/debug_log_view.js +++ b/js/views/debug_log_view.js @@ -27,7 +27,10 @@ this.$('textarea').val(i18n('loading')); const operatingSystemInfo = `${i18n('operatingSystem', window.getOSRelease())}`; - const commitHashInfo = i18n('commitHash', window.getCommitHash()); + + const commitHashInfo = window.getCommitHash() + ? i18n('commitHash', window.getCommitHash()) + : ''; // eslint-disable-next-line more/no-then window.log.fetch().then(text => { From 04e0023d382e913ad1c5d823fba12024be955e24 Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Mon, 11 Oct 2021 12:35:14 +1100 Subject: [PATCH 07/10] fix import warning --- ts/components/conversation/message/OutgoingMessageStatus.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/components/conversation/message/OutgoingMessageStatus.tsx b/ts/components/conversation/message/OutgoingMessageStatus.tsx index a386fdd95..0701ce131 100644 --- a/ts/components/conversation/message/OutgoingMessageStatus.tsx +++ b/ts/components/conversation/message/OutgoingMessageStatus.tsx @@ -1,4 +1,4 @@ -import { ipcRenderer } from 'electron/renderer'; +import { ipcRenderer } from 'electron'; import React from 'react'; import styled from 'styled-components'; import { MessageDeliveryStatus } from '../../../models/messageType'; From 2b28ec93f993280ac953a6ca47fc05373f81727b Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Mon, 11 Oct 2021 14:20:33 +1100 Subject: [PATCH 08/10] removed translation for debug logs. --- _locales/en/messages.json | 4 +--- js/views/debug_log_view.js | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 652bb95f4..f9168cc88 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -444,7 +444,5 @@ "messageDeletedPlaceholder": "This message has been deleted", "messageDeleted": "Message deleted", "surveyTitle": "Take our Session Survey", - "goToOurSurvey": "Go to our survey", - "operatingSystem": "Operating System: $operatingSystem$\n", - "commitHash": "Git Commit SHA: $commitHash$\n" + "goToOurSurvey": "Go to our survey" } diff --git a/js/views/debug_log_view.js b/js/views/debug_log_view.js index cb1d9e597..4ef324362 100644 --- a/js/views/debug_log_view.js +++ b/js/views/debug_log_view.js @@ -26,11 +26,9 @@ this.render(); this.$('textarea').val(i18n('loading')); - const operatingSystemInfo = `${i18n('operatingSystem', window.getOSRelease())}`; + const operatingSystemInfo = `Operating System: ${window.getOSRelease()}`; - const commitHashInfo = window.getCommitHash() - ? i18n('commitHash', window.getCommitHash()) - : ''; + const commitHashInfo = window.getCommitHash() ? `Commit Hash: ${window.getCommitHash()}` : ''; // eslint-disable-next-line more/no-then window.log.fetch().then(text => { From 78738675b8f113b7b0c941aefb976040a3d1e423 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 20 Oct 2021 15:47:00 +1100 Subject: [PATCH 09/10] fix release build script --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 14fe768fd..4e6381299 100644 --- a/package.json +++ b/package.json @@ -336,6 +336,8 @@ "node_modules/socks/build/common/*.js", "node_modules/socks/build/client/*.js", "node_modules/smart-buffer/build/*.js", + "node_modules/react-draggable/build/cjs/*.js", + "node_modules/react-draggable/build/cjs/utils/*.js", "!node_modules/@journeyapps/sqlcipher/deps/*", "!node_modules/@journeyapps/sqlcipher/build/*", "!node_modules/@journeyapps/sqlcipher/lib/binding/node-*", From 55313deb91eacae5505e7b3bf9dd256814454cd8 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 20 Oct 2021 15:54:03 +1100 Subject: [PATCH 10/10] add a show user details option in the menu Fixes #1971 --- _locales/en/messages.json | 1 + ts/components/ConversationListItem.tsx | 3 ++ .../conversation/ConversationHeader.tsx | 3 ++ ts/components/dialog/UserDetailsDialog.tsx | 2 ++ .../session/menu/ConversationHeaderMenu.tsx | 10 +++++- .../menu/ConversationListItemContextMenu.tsx | 10 ++++++ ts/components/session/menu/Menu.tsx | 35 ++++++++++++++++++- 7 files changed, 62 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index f3500b1b6..3ce676fbb 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -422,6 +422,7 @@ "unpinConversation": "Unpin Conversation", "pinConversationLimitTitle": "Pinned conversations limit", "pinConversationLimitToastDescription": "You can only pin $number$ conversations", + "showUserDetails": "Show User Details", "latestUnreadIsAbove": "First unread message is above", "sendRecoveryPhraseTitle": "Sending Recovery Phrase", "sendRecoveryPhraseMessage": "You are attempting to send your recovery phrase which can be used to access your account. Are you sure you want to send this message?", diff --git a/ts/components/ConversationListItem.tsx b/ts/components/ConversationListItem.tsx index ec667eb4f..e94606cef 100644 --- a/ts/components/ConversationListItem.tsx +++ b/ts/components/ConversationListItem.tsx @@ -356,6 +356,9 @@ const ConversationListItem = (props: Props) => { left={!!left} type={type} currentNotificationSetting={currentNotificationSetting || 'all'} + avatarPath={avatarPath || null} + name={name} + profileName={profileName} /> diff --git a/ts/components/conversation/ConversationHeader.tsx b/ts/components/conversation/ConversationHeader.tsx index f321a6a6a..d8ec8287e 100644 --- a/ts/components/conversation/ConversationHeader.tsx +++ b/ts/components/conversation/ConversationHeader.tsx @@ -360,6 +360,9 @@ export const ConversationHeaderWithDetails = () => { left={left} hasNickname={hasNickname} currentNotificationSetting={currentNotificationSetting} + avatarPath={avatarPath} + name={name} + profileName={profileName} /> diff --git a/ts/components/dialog/UserDetailsDialog.tsx b/ts/components/dialog/UserDetailsDialog.tsx index 10166436c..64622765f 100644 --- a/ts/components/dialog/UserDetailsDialog.tsx +++ b/ts/components/dialog/UserDetailsDialog.tsx @@ -6,6 +6,7 @@ import useCopyToClipboard from 'react-use/lib/useCopyToClipboard'; import useKey from 'react-use/lib/useKey'; import { ConversationTypeEnum } from '../../models/conversation'; import { getConversationController } from '../../session/conversations'; +import { ToastUtils } from '../../session/utils'; import { openConversationWithMessages } from '../../state/ducks/conversations'; import { updateUserDetailsModal } from '../../state/ducks/modalDialog'; import { Avatar, AvatarSize } from '../Avatar'; @@ -77,6 +78,7 @@ export const UserDetailsDialog = (props: Props) => { buttonColor={SessionButtonColor.Primary} onClick={() => { copyToClipboard(props.conversationId); + ToastUtils.pushCopiedToClipBoard(); }} /> { @@ -50,7 +54,11 @@ const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => { left, hasNickname, currentNotificationSetting, + name, + profileName, + avatarPath, } = props; + const userName = name || profileName || conversationId; return ( @@ -75,9 +83,9 @@ const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => { {getRemoveModeratorsMenuItem(weAreAdmin, isPublic, isKickedFromGroup, conversationId)} {getUpdateGroupNameMenuItem(weAreAdmin, isKickedFromGroup, left, conversationId)} {getLeaveGroupMenuItem(isKickedFromGroup, left, isGroup, isPublic, conversationId)} - {/* TODO: add delete group */} {getInviteContactMenuItem(isGroup, isPublic, conversationId)} {getDeleteContactMenuItem(isGroup, isPublic, left, isKickedFromGroup, conversationId)} + {getShowUserDetailsMenuItem(isPrivate, conversationId, avatarPath, userName)} ); }; diff --git a/ts/components/session/menu/ConversationListItemContextMenu.tsx b/ts/components/session/menu/ConversationListItemContextMenu.tsx index 0cf88923c..0dc4d65bd 100644 --- a/ts/components/session/menu/ConversationListItemContextMenu.tsx +++ b/ts/components/session/menu/ConversationListItemContextMenu.tsx @@ -18,6 +18,7 @@ import { getMarkAllReadMenuItem, getNotificationForConvoMenuItem, getPinConversationMenuItem, + getShowUserDetailsMenuItem, } from './Menu'; export type PropsContextConversationItem = { @@ -33,6 +34,9 @@ export type PropsContextConversationItem = { left: boolean; theme?: any; currentNotificationSetting: ConversationNotificationSettingType; + name: string | undefined; + profileName: string | undefined; + avatarPath: string | null; }; const ConversationListItemContextMenu = (props: PropsContextConversationItem) => { @@ -48,9 +52,14 @@ const ConversationListItemContextMenu = (props: PropsContextConversationItem) => isKickedFromGroup, currentNotificationSetting, isPrivate, + name, + profileName, + avatarPath, } = props; const isGroup = type === 'group'; + const userName = name || profileName || conversationId; + return ( {getNotificationForConvoMenuItem({ @@ -71,6 +80,7 @@ const ConversationListItemContextMenu = (props: PropsContextConversationItem) => {getInviteContactMenuItem(isGroup, isPublic, conversationId)} {getDeleteContactMenuItem(isGroup, isPublic, left, isKickedFromGroup, conversationId)} {getLeaveGroupMenuItem(isKickedFromGroup, left, isGroup, isPublic, conversationId)} + {getShowUserDetailsMenuItem(isPrivate, conversationId, avatarPath, userName)} ); }; diff --git a/ts/components/session/menu/Menu.tsx b/ts/components/session/menu/Menu.tsx index a781c8355..f747e8e06 100644 --- a/ts/components/session/menu/Menu.tsx +++ b/ts/components/session/menu/Menu.tsx @@ -12,7 +12,11 @@ import { ConversationNotificationSettingType, } from '../../../models/conversation'; import { useDispatch, useSelector } from 'react-redux'; -import { changeNickNameModal, updateConfirmModal } from '../../../state/ducks/modalDialog'; +import { + changeNickNameModal, + updateConfirmModal, + updateUserDetailsModal, +} from '../../../state/ducks/modalDialog'; import { SectionType } from '../../../state/ducks/section'; import { getConversationController } from '../../../session/conversations'; import { @@ -241,6 +245,35 @@ export function getLeaveGroupMenuItem( return null; } +export function getShowUserDetailsMenuItem( + isPrivate: boolean | undefined, + conversationId: string, + avatarPath: string | null, + userName: string +): JSX.Element | null { + const dispatch = useDispatch(); + + if (isPrivate) { + return ( + { + dispatch( + updateUserDetailsModal({ + conversationId: conversationId, + userName, + authorAvatarPath: avatarPath, + }) + ); + }} + > + {window.i18n('showUserDetails')} + + ); + } + + return null; +} + export function getUpdateGroupNameMenuItem( isAdmin: boolean | undefined, isKickedFromGroup: boolean | undefined,