From 62300dcb5b71d834424f25b40b9312076b0ee1b6 Mon Sep 17 00:00:00 2001 From: Emily Date: Tue, 20 Aug 2024 09:52:36 +1000 Subject: [PATCH 01/14] feat: adds in notifications dot: updated setBadgeCount and using global unread message count --- ts/components/leftpane/ActionsPanel.tsx | 13 +++++++++++-- ts/mains/main_node.ts | 9 +++++++++ ts/state/selectors/conversations.ts | 4 +++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ts/components/leftpane/ActionsPanel.tsx b/ts/components/leftpane/ActionsPanel.tsx index 1186699efa..3c6a535da8 100644 --- a/ts/components/leftpane/ActionsPanel.tsx +++ b/ts/components/leftpane/ActionsPanel.tsx @@ -1,3 +1,4 @@ +import { ipcRenderer } from 'electron'; import { debounce } from 'lodash'; import { useEffect, useRef, useState } from 'react'; @@ -13,6 +14,8 @@ import { syncConfigurationIfNeeded } from '../../session/utils/sync/syncUtils'; import { clearSearch } from '../../state/ducks/search'; import { resetLeftOverlayMode, SectionType, showLeftPaneSection } from '../../state/ducks/section'; import { + _getGlobalUnreadCount, + _getSortedConversations, getGlobalUnreadMessageCount, getOurPrimaryConversation, } from '../../state/selectors/conversations'; @@ -37,18 +40,18 @@ import { LeftPaneSectionContainer } from './LeftPaneSectionContainer'; import { SettingsKey } from '../../data/settings-key'; import { useFetchLatestReleaseFromFileServer } from '../../hooks/useFetchLatestReleaseFromFileServer'; +import { useHotkey } from '../../hooks/useHotkey'; import { forceRefreshRandomSnodePool, getFreshSwarmFor, } from '../../session/apis/snode_api/snodePool'; import { ConfigurationSync } from '../../session/utils/job_runners/jobs/ConfigurationSyncJob'; +import { getIsModalVisble } from '../../state/selectors/modal'; import { useIsDarkTheme } from '../../state/selectors/theme'; import { switchThemeTo } from '../../themes/switchTheme'; import { ReleasedFeatures } from '../../util/releaseFeature'; import { getOppositeTheme } from '../../util/theme'; import { SessionNotificationCount } from '../icon/SessionNotificationCount'; -import { useHotkey } from '../../hooks/useHotkey'; -import { getIsModalVisble } from '../../state/selectors/modal'; const Section = (props: { type: SectionType }) => { const ourNumber = useSelector(getOurNumber); @@ -216,6 +219,12 @@ const doAppStartUp = async () => { }, 20000); }; +global.setTimeout(() => { + const unreadMessageCount = useSelector(getGlobalUnreadMessageCount); + // Send the calculated count to the main process to update the badge count + ipcRenderer.send('update-badge-count', unreadMessageCount); +}, 3000); + /** * ActionsPanel is the far left banner (not the left pane). * The panel with buttons to switch between the message/contact/settings/theme views diff --git a/ts/mains/main_node.ts b/ts/mains/main_node.ts index b9b221bc04..80fb672db0 100644 --- a/ts/mains/main_node.ts +++ b/ts/mains/main_node.ts @@ -10,6 +10,7 @@ import { dialog, protocol as electronProtocol, ipcMain as ipc, + ipcMain, IpcMainEvent, Menu, nativeTheme, @@ -1023,6 +1024,14 @@ ipc.on('get-start-in-tray', event => { } }); +ipcMain.on('update-badge-count', (_event, count) => { + if (count === 0) { + app.setBadgeCount(0); // Clear the badge + } else { + app.setBadgeCount(count); // Set the badge count + } +}); + ipc.on('get-opengroup-pruning', event => { try { const val = userConfig.get('opengroupPruning'); diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 5473c6e551..336d02ed42 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -306,7 +306,9 @@ const _getContacts = ( }); }; -const _getGlobalUnreadCount = (sortedConversations: Array): number => { +export const _getGlobalUnreadCount = ( + sortedConversations: Array +): number => { let globalUnreadCount = 0; for (const conversation of sortedConversations) { // Blocked conversation are now only visible from the settings, not in the conversation list, so don't add it neither to the contacts list nor the conversation list From 6dd261567d59f38bb6259dbc59582de347531193 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 20 Sep 2024 15:02:08 +1000 Subject: [PATCH 02/14] feat: adds notifications dot on the badge icon for Mac --- ts/components/leftpane/ActionsPanel.tsx | 22 +++++++++++++++------- ts/mains/main_node.ts | 10 ++++++---- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ts/components/leftpane/ActionsPanel.tsx b/ts/components/leftpane/ActionsPanel.tsx index 3c6a535da8..1a8d8cb31d 100644 --- a/ts/components/leftpane/ActionsPanel.tsx +++ b/ts/components/leftpane/ActionsPanel.tsx @@ -14,8 +14,6 @@ import { syncConfigurationIfNeeded } from '../../session/utils/sync/syncUtils'; import { clearSearch } from '../../state/ducks/search'; import { resetLeftOverlayMode, SectionType, showLeftPaneSection } from '../../state/ducks/section'; import { - _getGlobalUnreadCount, - _getSortedConversations, getGlobalUnreadMessageCount, getOurPrimaryConversation, } from '../../state/selectors/conversations'; @@ -219,11 +217,11 @@ const doAppStartUp = async () => { }, 20000); }; -global.setTimeout(() => { - const unreadMessageCount = useSelector(getGlobalUnreadMessageCount); - // Send the calculated count to the main process to update the badge count - ipcRenderer.send('update-badge-count', unreadMessageCount); -}, 3000); +// global.setTimeout(() => { +// const unreadMessageCount = useSelector(getGlobalUnreadMessageCount); +// // Send the calculated count to the main process to update the badge count +// ipcRenderer.send('update-badge-count', unreadMessageCount); +// }, 3000); /** * ActionsPanel is the far left banner (not the left pane). @@ -247,6 +245,16 @@ export const ActionsPanel = () => { return () => clearTimeout(timeout); }, []); + const globalUnreadMessageCount = useSelector(getGlobalUnreadMessageCount); + const unreadToShow = globalUnreadMessageCount; + + // Reuse the unreadToShow from the global state to update the badge count + useEffect(() => { + if (unreadToShow !== undefined) { + ipcRenderer.send('update-badge-count', unreadToShow); + } + }, [unreadToShow]); + useInterval(cleanUpOldDecryptedMedias, startCleanUpMedia ? cleanUpMediasInterval : null); useFetchLatestReleaseFromFileServer(); diff --git a/ts/mains/main_node.ts b/ts/mains/main_node.ts index 80fb672db0..a3c018bda0 100644 --- a/ts/mains/main_node.ts +++ b/ts/mains/main_node.ts @@ -1025,10 +1025,12 @@ ipc.on('get-start-in-tray', event => { }); ipcMain.on('update-badge-count', (_event, count) => { - if (count === 0) { - app.setBadgeCount(0); // Clear the badge - } else { - app.setBadgeCount(count); // Set the badge count + if (app.isReady()) { + if (count === 0) { + app.setBadgeCount(0); // Clear the badge + } else { + app.setBadgeCount(count); // Set the badge count + } } }); From 78935dacdfc6c13c37e910cbf537bb17f2b588fd Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 20 Sep 2024 15:18:09 +1000 Subject: [PATCH 03/14] chore: removes unnecessary comments --- ts/components/leftpane/ActionsPanel.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ts/components/leftpane/ActionsPanel.tsx b/ts/components/leftpane/ActionsPanel.tsx index 1a8d8cb31d..bba9b0bcee 100644 --- a/ts/components/leftpane/ActionsPanel.tsx +++ b/ts/components/leftpane/ActionsPanel.tsx @@ -217,12 +217,6 @@ const doAppStartUp = async () => { }, 20000); }; -// global.setTimeout(() => { -// const unreadMessageCount = useSelector(getGlobalUnreadMessageCount); -// // Send the calculated count to the main process to update the badge count -// ipcRenderer.send('update-badge-count', unreadMessageCount); -// }, 3000); - /** * ActionsPanel is the far left banner (not the left pane). * The panel with buttons to switch between the message/contact/settings/theme views From 26c1522c083b032a138d864531a29f7824b7b134 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 24 Sep 2024 17:16:04 +1000 Subject: [PATCH 04/14] chore: target master push events with full name --- .github/workflows/build-binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index 1d39adeae2..1e6bb5824f 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -25,7 +25,7 @@ concurrency: env: # we want to publish on "push to master" only. When we don't want to publish, we want to upload artefacts - SHOULD_PUBLISH: ${{ github.event_name == 'push' && github.ref == 'master' }} + SHOULD_PUBLISH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} jobs: build_linux: From 18862abf59d095cd0573311aed6e4bfc13115436 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 24 Sep 2024 17:32:05 +1000 Subject: [PATCH 05/14] fix: fix the sed in CI so we build for the correct target --- .github/workflows/build-binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index 1e6bb5824f..507e011783 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -77,7 +77,7 @@ jobs: # we want this to run only when on "push" to "master" if: ${{ env.SHOULD_PUBLISH == 'true' }} run: | - sed -i 's/\"target\": \\[\"deb\"\\]/\"target\": \"${{ matrix.pkg_to_build }}\"/g' package.json; yarn build-release-publish + sed -i 's/"target": \["deb"\]/"target": "${{ matrix.pkg_to_build }}"/g' package.json && yarn build-release-publish build_windows: runs-on: windows-2022 From 980554cd0291c89b9d28978f262668403a218d8c Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 30 Sep 2024 14:05:42 +1000 Subject: [PATCH 06/14] chore: bump session to 1.14.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0639684950..d5b0f2cd63 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "session-desktop", "productName": "Session", "description": "Private messaging from your desktop", - "version": "1.14.1", + "version": "1.14.2", "license": "GPL-3.0", "author": { "name": "Oxen Labs", From 72940c6221e245ca44a7ba2c1b83c2780950ff83 Mon Sep 17 00:00:00 2001 From: yougotwill Date: Fri, 25 Oct 2024 14:47:29 +1100 Subject: [PATCH 07/14] fix: dont use white for the copy url button in the modal --- ts/components/dialog/OpenUrlModal.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/ts/components/dialog/OpenUrlModal.tsx b/ts/components/dialog/OpenUrlModal.tsx index db5ff30f9a..de729a32d6 100644 --- a/ts/components/dialog/OpenUrlModal.tsx +++ b/ts/components/dialog/OpenUrlModal.tsx @@ -61,7 +61,6 @@ export function OpenUrlModal(props: OpenUrlModalState) { /> Date: Fri, 8 Nov 2024 13:58:43 +1100 Subject: [PATCH 08/14] Update ts/mains/main_node.ts Co-authored-by: Audric Ackermann --- ts/mains/main_node.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ts/mains/main_node.ts b/ts/mains/main_node.ts index a3c018bda0..8c7f63a1d7 100644 --- a/ts/mains/main_node.ts +++ b/ts/mains/main_node.ts @@ -1026,11 +1026,7 @@ ipc.on('get-start-in-tray', event => { ipcMain.on('update-badge-count', (_event, count) => { if (app.isReady()) { - if (count === 0) { - app.setBadgeCount(0); // Clear the badge - } else { - app.setBadgeCount(count); // Set the badge count - } + app.setBadgeCount(isNumber(count) && isFinite(count) && count >= 0 ? count : 0); } }); From 61c91be91ce642ea8778d71ad2f17e5fb2edda7d Mon Sep 17 00:00:00 2001 From: wafflesvsfrankie <92288602+burtonemily@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:48:27 +1100 Subject: [PATCH 09/14] fix: addresses feedback --- ts/components/leftpane/ActionsPanel.tsx | 15 ++++++++++----- ts/state/selectors/conversations.ts | 4 +--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ts/components/leftpane/ActionsPanel.tsx b/ts/components/leftpane/ActionsPanel.tsx index bba9b0bcee..62635a6026 100644 --- a/ts/components/leftpane/ActionsPanel.tsx +++ b/ts/components/leftpane/ActionsPanel.tsx @@ -5,6 +5,7 @@ import { useEffect, useRef, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useInterval from 'react-use/lib/useInterval'; import useTimeoutFn from 'react-use/lib/useTimeoutFn'; +import { useThrottleFn } from 'react-use'; import { Data } from '../../data/data'; import { getConversationController } from '../../session/conversations'; @@ -243,11 +244,15 @@ export const ActionsPanel = () => { const unreadToShow = globalUnreadMessageCount; // Reuse the unreadToShow from the global state to update the badge count - useEffect(() => { - if (unreadToShow !== undefined) { - ipcRenderer.send('update-badge-count', unreadToShow); - } - }, [unreadToShow]); + useThrottleFn( + () => { + if (unreadToShow !== undefined) { + ipcRenderer.send('update-badge-count', unreadToShow); + } + }, + 2000, + [] + ); useInterval(cleanUpOldDecryptedMedias, startCleanUpMedia ? cleanUpMediasInterval : null); diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 336d02ed42..5473c6e551 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -306,9 +306,7 @@ const _getContacts = ( }); }; -export const _getGlobalUnreadCount = ( - sortedConversations: Array -): number => { +const _getGlobalUnreadCount = (sortedConversations: Array): number => { let globalUnreadCount = 0; for (const conversation of sortedConversations) { // Blocked conversation are now only visible from the settings, not in the conversation list, so don't add it neither to the contacts list nor the conversation list From 948e5df6fd1de1004e4481cd6f88327c088bc723 Mon Sep 17 00:00:00 2001 From: wafflesvsfrankie <92288602+burtonemily@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:53:54 +1100 Subject: [PATCH 10/14] fix: updates import for useThrottleFn --- ts/components/leftpane/ActionsPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/components/leftpane/ActionsPanel.tsx b/ts/components/leftpane/ActionsPanel.tsx index 62635a6026..2279c06cca 100644 --- a/ts/components/leftpane/ActionsPanel.tsx +++ b/ts/components/leftpane/ActionsPanel.tsx @@ -5,7 +5,7 @@ import { useEffect, useRef, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useInterval from 'react-use/lib/useInterval'; import useTimeoutFn from 'react-use/lib/useTimeoutFn'; -import { useThrottleFn } from 'react-use'; +import useThrottleFn from 'react-use/lib/useThrottleFn'; import { Data } from '../../data/data'; import { getConversationController } from '../../session/conversations'; From 1caf0fe03ae5566a78086dc812a85918d8d9e31f Mon Sep 17 00:00:00 2001 From: wafflesvsfrankie <92288602+burtonemily@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:40:51 +1100 Subject: [PATCH 11/14] fix: addresses feedback --- ts/components/leftpane/ActionsPanel.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ts/components/leftpane/ActionsPanel.tsx b/ts/components/leftpane/ActionsPanel.tsx index 2279c06cca..1d60214347 100644 --- a/ts/components/leftpane/ActionsPanel.tsx +++ b/ts/components/leftpane/ActionsPanel.tsx @@ -241,13 +241,12 @@ export const ActionsPanel = () => { }, []); const globalUnreadMessageCount = useSelector(getGlobalUnreadMessageCount); - const unreadToShow = globalUnreadMessageCount; // Reuse the unreadToShow from the global state to update the badge count useThrottleFn( () => { - if (unreadToShow !== undefined) { - ipcRenderer.send('update-badge-count', unreadToShow); + if (globalUnreadMessageCount !== undefined) { + ipcRenderer.send('update-badge-count', globalUnreadMessageCount); } }, 2000, From df3ac5d0fafc4683585173e598ed0370c9c055fa Mon Sep 17 00:00:00 2001 From: wafflesvsfrankie <92288602+burtonemily@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:49:00 +1100 Subject: [PATCH 12/14] fix: fixes invalid isNumber and isFinite function --- ts/mains/main_node.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ts/mains/main_node.ts b/ts/mains/main_node.ts index 8c7f63a1d7..5e04ee5bb8 100644 --- a/ts/mains/main_node.ts +++ b/ts/mains/main_node.ts @@ -1026,7 +1026,9 @@ ipc.on('get-start-in-tray', event => { ipcMain.on('update-badge-count', (_event, count) => { if (app.isReady()) { - app.setBadgeCount(isNumber(count) && isFinite(count) && count >= 0 ? count : 0); + app.setBadgeCount( + typeof count === 'number' && Number.isFinite(count) && count >= 0 ? count : 0 + ); } }); From 81fbf35a32ca45497ff5c7872b8302c2efe46da0 Mon Sep 17 00:00:00 2001 From: wafflesvsfrankie <92288602+burtonemily@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:55:59 +1100 Subject: [PATCH 13/14] fix: adds in globalUnreadMessageCount into the dependency array for useThrottleFn --- ts/components/leftpane/ActionsPanel.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ts/components/leftpane/ActionsPanel.tsx b/ts/components/leftpane/ActionsPanel.tsx index 1d60214347..4a67bc81bf 100644 --- a/ts/components/leftpane/ActionsPanel.tsx +++ b/ts/components/leftpane/ActionsPanel.tsx @@ -244,13 +244,13 @@ export const ActionsPanel = () => { // Reuse the unreadToShow from the global state to update the badge count useThrottleFn( - () => { + (unreadCount: number) => { if (globalUnreadMessageCount !== undefined) { - ipcRenderer.send('update-badge-count', globalUnreadMessageCount); + ipcRenderer.send('update-badge-count', unreadCount); } }, 2000, - [] + [globalUnreadMessageCount] ); useInterval(cleanUpOldDecryptedMedias, startCleanUpMedia ? cleanUpMediasInterval : null); From ca81a50aef8f9dc6ff940e5df2993c4f47a64668 Mon Sep 17 00:00:00 2001 From: wafflesvsfrankie <92288602+burtonemily@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:43:18 +1100 Subject: [PATCH 14/14] fix: adds isFinite and isNumber from lodash --- ts/mains/main_node.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ts/mains/main_node.ts b/ts/mains/main_node.ts index 5e04ee5bb8..abc8ef65c3 100644 --- a/ts/mains/main_node.ts +++ b/ts/mains/main_node.ts @@ -27,7 +27,7 @@ import { platform as osPlatform } from 'process'; import url from 'url'; import Logger from 'bunyan'; -import _, { isEmpty } from 'lodash'; +import _, { isEmpty, isNumber, isFinite } from 'lodash'; import pify from 'pify'; import { setupGlobalErrorHandler } from '../node/global_errors'; // checked - only node @@ -1027,7 +1027,7 @@ ipc.on('get-start-in-tray', event => { ipcMain.on('update-badge-count', (_event, count) => { if (app.isReady()) { app.setBadgeCount( - typeof count === 'number' && Number.isFinite(count) && count >= 0 ? count : 0 + isNumber(count) && isFinite(count) && count >= 0 ? count : 0 ); } });