From 9c2a1fff11b7150d4a9b632e26ff35f4e400cb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Petit?= Date: Sat, 16 Oct 2021 13:41:37 +0200 Subject: [PATCH 1/4] Fix notifications settings that were not remembered --- src/app/Pages/ActiveDeals/ActiveDeals.scss | 4 +- src/app/Pages/ActiveDeals/ActiveDeals.tsx | 4 +- .../Components/NotificationsSettings.tsx | 63 ++++++++++++++++ .../ActiveDeals/Components/SyncToggles.tsx | 71 ------------------- src/app/Pages/ActiveDeals/Components/index.ts | 4 +- src/app/redux/configActions.ts | 12 ++-- src/app/redux/configSlice.ts | 21 ++++-- src/app/redux/threeCommas/Actions.ts | 17 +++-- src/app/redux/threeCommas/initialState.ts | 2 - src/main/3Commas/index.ts | 8 ++- src/types/3Commas.ts | 2 - src/types/config.ts | 15 +++- src/utils/defaultConfig.ts | 10 ++- 13 files changed, 129 insertions(+), 104 deletions(-) create mode 100644 src/app/Pages/ActiveDeals/Components/NotificationsSettings.tsx delete mode 100644 src/app/Pages/ActiveDeals/Components/SyncToggles.tsx diff --git a/src/app/Pages/ActiveDeals/ActiveDeals.scss b/src/app/Pages/ActiveDeals/ActiveDeals.scss index a8ca4521..3b288f9e 100644 --- a/src/app/Pages/ActiveDeals/ActiveDeals.scss +++ b/src/app/Pages/ActiveDeals/ActiveDeals.scss @@ -63,7 +63,7 @@ justify-content: flex-start; padding-bottom: 4px; - .syncToggles{ + .notificationsSettings { flex: 1; align-self: flex-start; display: flex; @@ -73,7 +73,7 @@ } - .tableButtons{ + .tableButtons { flex-basis: 20%; align-items: center; display: flex; diff --git a/src/app/Pages/ActiveDeals/ActiveDeals.tsx b/src/app/Pages/ActiveDeals/ActiveDeals.tsx index b4497e9e..120dc4f6 100644 --- a/src/app/Pages/ActiveDeals/ActiveDeals.tsx +++ b/src/app/Pages/ActiveDeals/ActiveDeals.tsx @@ -5,7 +5,7 @@ import { formatDeals } from '@/app/Components/DataTable/Index' import { useAppSelector } from '@/app/redux/hooks'; import { Card_ActiveDeals, Card_totalInDeals, Card_ActiveDealReserve, Card_TotalDayProfit, Card_TotalUnrealizedProfit, Card_TotalRoi } from '@/app/Components/Charts/DataCards'; -import { SyncToggles } from './Components/index'; +import { NotificationsSettings } from './Components/index'; import './ActiveDeals.scss' @@ -51,7 +51,7 @@ const ActiveDealsPage = () => {
- +
diff --git a/src/app/Pages/ActiveDeals/Components/NotificationsSettings.tsx b/src/app/Pages/ActiveDeals/Components/NotificationsSettings.tsx new file mode 100644 index 00000000..72c7cc3f --- /dev/null +++ b/src/app/Pages/ActiveDeals/Components/NotificationsSettings.tsx @@ -0,0 +1,63 @@ +import { useAppSelector } from '@/app/redux/hooks'; +import { Checkbox, FormControlLabel } from '@mui/material'; +import React, { useState } from "react"; +import { updateNotificationsSettingsGlobal } from '../../../redux/configActions'; + +/** + * + * @returns Checkboxes for configuring the state of auto sync. + */ +const NotificationsSettings = () => { + + const { config } = useAppSelector(state => state.config); + + const [summary, setSummary] = useState(() => config.globalSettings.notifications.summary) + const [enabled, setEnabled] = useState(() => config.globalSettings.notifications.enabled) + + const changeSummary = (event: React.ChangeEvent) => { + const checked = event.target.checked + updateNotificationsSettingsGlobal({ summary: checked }) + setSummary(checked) + } + + const changeEnabled = (event: React.ChangeEvent) => { + const checked = event.target.checked + updateNotificationsSettingsGlobal({ enabled: checked }) + setEnabled(checked) + } + + return ( +
+ + } + label="Enable Notifications" + + /> + + } + label="Summarize Notifications" + /> + + +
+ ) +} + +export default NotificationsSettings; diff --git a/src/app/Pages/ActiveDeals/Components/SyncToggles.tsx b/src/app/Pages/ActiveDeals/Components/SyncToggles.tsx deleted file mode 100644 index 6e26416b..00000000 --- a/src/app/Pages/ActiveDeals/Components/SyncToggles.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React, { useEffect, useState } from "react"; - -import { FormControlLabel, Checkbox } from '@mui/material'; - -import { useAppSelector, useAppDispatch } from '@/app/redux/hooks'; -import { setSyncData } from "@/app/redux/threeCommas/threeCommasSlice"; - -import { Type_SyncOptions } from "@/types/3Commas"; - -/** - * - * @returns Checkboxes for configuring the state of auto sync. - */ -const SyncToggles = () => { - - const { syncOptions, autoRefresh } = useAppSelector(state => state.threeCommas); - const dispatch = useAppDispatch() - - const [summary, setSummary] = useState(() => syncOptions.summary) - const [notifications, setNotifications] = useState(() => syncOptions.notifications) - - const changeSummary = (event: React.ChangeEvent) => { - dispatch(setSyncData({ summary: event.target.checked })) - } - - - const changeNotifications = (event: React.ChangeEvent) => { - dispatch(setSyncData({ notifications: event.target.checked })) - } - - useEffect(() => { - setSummary(syncOptions.summary) - setNotifications(syncOptions.notifications) - }, [syncOptions]) - - - return ( -
- - } - label="Enable Notifications" - - /> - - } - label="Summarize Notifications" - /> - - -
- ) -} - -export default SyncToggles; \ No newline at end of file diff --git a/src/app/Pages/ActiveDeals/Components/index.ts b/src/app/Pages/ActiveDeals/Components/index.ts index a296dfde..11451058 100644 --- a/src/app/Pages/ActiveDeals/Components/index.ts +++ b/src/app/Pages/ActiveDeals/Components/index.ts @@ -1,8 +1,8 @@ -import SyncToggles from "./SyncToggles"; +import NotificationsSettings from "./NotificationsSettings"; import SubRowAsync from "./Subrow"; export { - SyncToggles, + NotificationsSettings, SubRowAsync } \ No newline at end of file diff --git a/src/app/redux/configActions.ts b/src/app/redux/configActions.ts index 51c90937..90497978 100644 --- a/src/app/redux/configActions.ts +++ b/src/app/redux/configActions.ts @@ -1,7 +1,7 @@ -import { setConfig, setCurrentProfile, updateCurrentProfileByPath, deleteProfileById } from '@/app/redux/configSlice' +import { setConfig, setCurrentProfile, updateCurrentProfileByPath, deleteProfileById, updateNotificationsSettings } from '@/app/redux/configSlice' import {setSyncData} from '@/app/redux/threeCommas/threeCommasSlice' -import { TconfigValues, Type_Profile, Type_ReservedFunds } from '@/types/config'; +import { TconfigValues, Type_NotificationsSettings, Type_Profile, Type_ReservedFunds } from '@/types/config'; import { removeDuplicatesInArray } from '@/utils/helperFunctions'; @@ -127,12 +127,16 @@ const deleteProfileByIdGlobal = (config: TconfigValues, profileId:string, setOpe } } - +const updateNotificationsSettingsGlobal = async (settings: Partial) => { + store.dispatch(updateNotificationsSettings(settings)) + await storeConfigInFile() +} export { updateConfig, updateReservedFundsArray, updateNestedCurrentProfile, storeConfigInFile, - deleteProfileByIdGlobal + deleteProfileByIdGlobal, + updateNotificationsSettingsGlobal, } \ No newline at end of file diff --git a/src/app/redux/configSlice.ts b/src/app/redux/configSlice.ts index 0958159e..52abb0fe 100644 --- a/src/app/redux/configSlice.ts +++ b/src/app/redux/configSlice.ts @@ -1,9 +1,8 @@ -import { createSlice } from '@reduxjs/toolkit' -import type { RootState } from './store' +import { TconfigValues, Type_Profile, Type_ReservedFunds } from '@/types/config'; +import { defaultConfig, defaultProfile } from '@/utils/defaultConfig'; +import { createSlice } from '@reduxjs/toolkit'; import { v4 as uuidv4 } from 'uuid'; -import { Type_Profile, TconfigValues, Type_ReservedFunds } from '@/types/config' -import { defaultProfile, defaultConfig } from '@/utils/defaultConfig' const defaultReservedFunds = { @@ -18,7 +17,6 @@ const defaultReservedFunds = { const initialState = { config: defaultConfig, currentProfile: defaultProfile, - reservedFunds: [defaultReservedFunds] } const configPaths = { @@ -122,7 +120,15 @@ export const configSlice = createSlice({ }, addConfigProfile: state => { state.currentProfile = { ...defaultProfile, id: uuidv4() } - } + }, + updateNotificationsSettings: (state, action) => { + const newConfig = { ...state.config } + newConfig.globalSettings.notifications = { + ...state.config.globalSettings.notifications, + ...action.payload, + } + state.config = newConfig + }, } }) @@ -130,7 +136,8 @@ export const { setConfig, setCurrentProfile, updateCurrentProfileByPath, deleteProfileById, addConfigProfile, setCurrentProfileById, - updateLastSyncTime + updateLastSyncTime, + updateNotificationsSettings, } = configSlice.actions; export { configPaths } diff --git a/src/app/redux/threeCommas/Actions.ts b/src/app/redux/threeCommas/Actions.ts index 1d18b55f..76104f75 100644 --- a/src/app/redux/threeCommas/Actions.ts +++ b/src/app/redux/threeCommas/Actions.ts @@ -223,13 +223,15 @@ const updateAllData = async (offset: number = 1000, profileData: Type_Profile, t const syncOptions = store.getState().threeCommas.syncOptions store.dispatch(setIsSyncing(true)) - let time = (syncOptions.time) ? syncOptions.time : 0; - let syncCount = (syncOptions.syncCount) ? syncOptions.syncCount : 0; - if(type === 'fullSync') syncCount = 0; + const originalTime = syncOptions.time || 0 + let time = originalTime + let syncCount = syncOptions.syncCount || 0 + if (type === 'fullSync') { + syncCount = 0 + time = 0 + } const options = { syncCount, - summary: (syncOptions.summary) ? syncOptions.summary : false, - notifications: (syncOptions.notifications) ? syncOptions.notifications : false, time, offset } @@ -244,10 +246,11 @@ const updateAllData = async (offset: number = 1000, profileData: Type_Profile, t .then((lastSyncTime) => { store.dispatch(setSyncData({ syncCount:(type === 'autoSync') ? options.syncCount + 1 : 0, - time: (type === 'autoSync') ? options.time + 15000 : 0 + // don't override syncOptions.time in case of a fullSync + // because there might be a concurrent autoSync running + time: (type === 'autoSync') ? originalTime + 15000 : originalTime })) store.dispatch(updateLastSyncTime({data: lastSyncTime })) - }) } catch (error) { diff --git a/src/app/redux/threeCommas/initialState.ts b/src/app/redux/threeCommas/initialState.ts index ac64a933..2ed6cdfb 100644 --- a/src/app/redux/threeCommas/initialState.ts +++ b/src/app/redux/threeCommas/initialState.ts @@ -61,8 +61,6 @@ export const initialState = { export type typeString = 'botData' | 'profitData' | 'activeDeals' | 'performanceData' | 'metricsData' | 'accountData' | 'balanceData' export type Type_SyncData = { - summary?: boolean, - notifications?: boolean, time?: number, syncCount?: number } diff --git a/src/main/3Commas/index.ts b/src/main/3Commas/index.ts index fdcdc534..0d33e223 100644 --- a/src/main/3Commas/index.ts +++ b/src/main/3Commas/index.ts @@ -1,4 +1,6 @@ import { update, run, query } from '@/main/Database/database'; +import {config} from '@/main/Config/config'; + const { bots, getAccountDetail, deals, getAccountSummary, getDealOrders } = require('./api'); const log = require('electron-log'); @@ -37,8 +39,12 @@ async function getDealData(type: string, options: Type_UpdateFunction, profileDa let { deals, lastSyncTime } = data + const enabled = config.get('globalSettings.notifications.enabled') + const summary = config.get('globalSettings.notifications.summary') // if notifications need to be enabled for the fullSync then the type below needs to be updated. - if (type === 'autoSync' && options.notifications && options.time != undefined || options.syncCount != 0) findAndNotifyNewDeals(deals, options.time, options.summary) + if (type === 'autoSync' && enabled && options.time != undefined || options.syncCount != 0) { + findAndNotifyNewDeals(deals, options.time, summary) + } update('deals', deals, profileData.id) // log.info(data) diff --git a/src/types/3Commas.ts b/src/types/3Commas.ts index 2d0ac1f5..09db9c95 100644 --- a/src/types/3Commas.ts +++ b/src/types/3Commas.ts @@ -274,8 +274,6 @@ export type Type_MarketOrders = { export interface Type_UpdateFunction{ offset: number time:number - summary: boolean - notifications: boolean syncCount: number } diff --git a/src/types/config.ts b/src/types/config.ts index ac7ac66a..7a7e961d 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -1,8 +1,9 @@ -import type { supportedCurrencies} from'@/utils/granularity' +import type { supportedCurrencies } from '@/utils/granularity' export interface TconfigValues { profiles: Record, current: string, + globalSettings: Type_GlobalSettings, general: { version: string }, @@ -38,6 +39,16 @@ export interface Type_Profile { } +export interface Type_GlobalSettings { + notifications: Type_NotificationsSettings +} + +export interface Type_NotificationsSettings { + enabled: boolean, + summary: boolean, +} + + export interface Type_ReservedFunds { id: number account_name: string @@ -64,7 +75,7 @@ export interface Type_ConfigContext { currency: string[] updateCurrency: any updateApiData: any - apiData: {key: string, secret: string, mode: string} + apiData: { key: string, secret: string, mode: string } reservedFunds: Type_ReservedFunds[], updateReservedFunds: any currentProfileId: string diff --git a/src/utils/defaultConfig.ts b/src/utils/defaultConfig.ts index effe0846..c9e689f5 100644 --- a/src/utils/defaultConfig.ts +++ b/src/utils/defaultConfig.ts @@ -101,9 +101,15 @@ const defaultProfile:Type_Profile = { } -const defaultConfig = { - profiles: Object.assign({[currentId]: defaultProfile}), +const defaultConfig: TconfigValues = { + profiles: Object.assign({[currentId]: defaultProfile}), current: currentId, + globalSettings: { + notifications: { + enabled: true, + summary: false, + }, + }, general: { version : version }, From a8f109eeb60ae7001f9836e277bebac61dedc1c8 Mon Sep 17 00:00:00 2001 From: Colton Shaw <46071821+coltoneshaw@users.noreply.github.com> Date: Mon, 1 Nov 2021 23:11:47 -0400 Subject: [PATCH 2/4] Add reset of sync count ot zero when switching profiles --- src/app/Features/Profiles/Components/ProfileSwitcher.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/Features/Profiles/Components/ProfileSwitcher.tsx b/src/app/Features/Profiles/Components/ProfileSwitcher.tsx index cae3666e..615b8706 100644 --- a/src/app/Features/Profiles/Components/ProfileSwitcher.tsx +++ b/src/app/Features/Profiles/Components/ProfileSwitcher.tsx @@ -55,6 +55,7 @@ const ProfileSwitcher = () => { onClick={() => { updateCurrentProfileId(p); dispatch(setCurrentProfileById({profileId: p})) + dispatch(setSyncData({syncCount: 0, time: 0})) //@ts-ignore electron.config.set('current', p) From 3344c7027f5d93144acf1772bd9e825c6a761ac0 Mon Sep 17 00:00:00 2001 From: Colton Shaw <46071821+coltoneshaw@users.noreply.github.com> Date: Mon, 1 Nov 2021 23:12:27 -0400 Subject: [PATCH 3/4] Config changes to support the new global settings --- package.json | 2 +- src/app/redux/configActions.ts | 1 + src/app/redux/configSlice.ts | 15 ++++++--------- src/main/Config/config.ts | 4 ++++ src/types/config.ts | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index fb9218de..3cf1a99b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "3c-portfolio-manager", "productName": "3C Portfolio Manager", - "version": "1.0.0", + "version": "1.1.0", "description": "An application to manage your 3Commas portfolio.", "private": true, "main": "./dist/main.js", diff --git a/src/app/redux/configActions.ts b/src/app/redux/configActions.ts index 90497978..ebd272e3 100644 --- a/src/app/redux/configActions.ts +++ b/src/app/redux/configActions.ts @@ -33,6 +33,7 @@ const updateCurrentProfile = (profileData: Type_Profile) => { store.dispatch(setCurrentProfile(profileData)); // setting this to zero here to prevent a spam of notifications with auto sync enabled. store.dispatch(setSyncData({syncCount: 0, time: 0})) + } /** diff --git a/src/app/redux/configSlice.ts b/src/app/redux/configSlice.ts index 52abb0fe..50678b74 100644 --- a/src/app/redux/configSlice.ts +++ b/src/app/redux/configSlice.ts @@ -4,15 +4,6 @@ import { createSlice } from '@reduxjs/toolkit'; import { v4 as uuidv4 } from 'uuid'; - -const defaultReservedFunds = { - id: 0, - account_name: '', - reserved_funds: 0, - is_enabled: false -} - - // Define the initial state using that type const initialState = { config: defaultConfig, @@ -41,6 +32,12 @@ const configPaths = { name: 'name', general: { defaultCurrency: 'general.defaultCurrency' + }, + globalSettings: { + notifications: { + enabled: 'globalSettings.notifications.enabled', + summary: 'globalSettings.notifications.summary', + } } } diff --git a/src/main/Config/config.ts b/src/main/Config/config.ts index f096b549..de709066 100644 --- a/src/main/Config/config.ts +++ b/src/main/Config/config.ts @@ -90,6 +90,10 @@ const config = new Store({ '1.0.0': async (store: any) => { log.info('migrating the config store to 1.0.0') await migrationToProfiles(store); + }, + '1.1.0': (store: any) => { + log.info('migrating the config store to 1.1.0') + store.set('globalSettings.notification', {enabled: true , summary: false}) } }, defaults: defaultConfig diff --git a/src/types/config.ts b/src/types/config.ts index 7a7e961d..b68bdc61 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -1,6 +1,6 @@ import type { supportedCurrencies } from '@/utils/granularity' -export interface TconfigValues { +export type TconfigValues = { profiles: Record, current: string, globalSettings: Type_GlobalSettings, @@ -43,7 +43,7 @@ export interface Type_GlobalSettings { notifications: Type_NotificationsSettings } -export interface Type_NotificationsSettings { +export type Type_NotificationsSettings = { enabled: boolean, summary: boolean, } From f128304b2dbd77592b88c5c9db9015f3009ca47d Mon Sep 17 00:00:00 2001 From: Colton Shaw <46071821+coltoneshaw@users.noreply.github.com> Date: Mon, 1 Nov 2021 23:13:56 -0400 Subject: [PATCH 4/4] cleaned up some code --- src/app/Components/Buttons/ToggleRefresh.tsx | 1 + .../Features/Profiles/Components/ProfileSwitcher.tsx | 2 ++ .../ActiveDeals/Components/NotificationsSettings.tsx | 12 ++++++++---- src/app/redux/threeCommas/Actions.ts | 2 +- src/app/redux/threeCommas/initialState.ts | 6 ++---- src/app/redux/threeCommas/threeCommasSlice.ts | 4 +--- src/main/3Commas/index.ts | 5 ++--- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/app/Components/Buttons/ToggleRefresh.tsx b/src/app/Components/Buttons/ToggleRefresh.tsx index 05f9198a..3b380cf7 100644 --- a/src/app/Components/Buttons/ToggleRefresh.tsx +++ b/src/app/Components/Buttons/ToggleRefresh.tsx @@ -56,6 +56,7 @@ const ToggleRefreshButton = ({ style, className }: Type_ButtonProps) => { if (!autoRefresh || isSyncing) return if (counter > 0) { + //@ts-ignore setActualTimeout(setTimeout(() => { setCounter(prevState => Math.max(prevState - refreshRate, 0)) }, refreshRate)); diff --git a/src/app/Features/Profiles/Components/ProfileSwitcher.tsx b/src/app/Features/Profiles/Components/ProfileSwitcher.tsx index 615b8706..4eda50bd 100644 --- a/src/app/Features/Profiles/Components/ProfileSwitcher.tsx +++ b/src/app/Features/Profiles/Components/ProfileSwitcher.tsx @@ -1,6 +1,8 @@ import React, { useEffect, useState } from "react"; import { useAppDispatch, useAppSelector } from '@/app/redux/hooks'; import { addConfigProfile, setCurrentProfileById} from '@/app/redux/configSlice' +import { setSyncData} from '@/app/redux/threeCommas/threeCommasSlice' + import { useHistory } from 'react-router-dom' import PersonIcon from '@mui/icons-material/Person'; diff --git a/src/app/Pages/ActiveDeals/Components/NotificationsSettings.tsx b/src/app/Pages/ActiveDeals/Components/NotificationsSettings.tsx index 72c7cc3f..189f3146 100644 --- a/src/app/Pages/ActiveDeals/Components/NotificationsSettings.tsx +++ b/src/app/Pages/ActiveDeals/Components/NotificationsSettings.tsx @@ -1,7 +1,7 @@ import { useAppSelector } from '@/app/redux/hooks'; import { Checkbox, FormControlLabel } from '@mui/material'; import React, { useState } from "react"; -import { updateNotificationsSettingsGlobal } from '../../../redux/configActions'; +import { updateNotificationsSettingsGlobal } from '@/app/redux/configActions'; /** * @@ -9,10 +9,10 @@ import { updateNotificationsSettingsGlobal } from '../../../redux/configActions' */ const NotificationsSettings = () => { - const { config } = useAppSelector(state => state.config); + const { enabled: storeEnabled, summary: storeSummary } = useAppSelector(state => state.config.config.globalSettings.notifications); - const [summary, setSummary] = useState(() => config.globalSettings.notifications.summary) - const [enabled, setEnabled] = useState(() => config.globalSettings.notifications.enabled) + const [summary, setSummary] = useState(() => storeEnabled) + const [enabled, setEnabled] = useState(() => storeSummary) const changeSummary = (event: React.ChangeEvent) => { const checked = event.target.checked @@ -22,6 +22,10 @@ const NotificationsSettings = () => { const changeEnabled = (event: React.ChangeEvent) => { const checked = event.target.checked + if(!checked) { + updateNotificationsSettingsGlobal({ summary: false }) + setSummary(false) + } updateNotificationsSettingsGlobal({ enabled: checked }) setEnabled(checked) } diff --git a/src/app/redux/threeCommas/Actions.ts b/src/app/redux/threeCommas/Actions.ts index 76104f75..e82de63c 100644 --- a/src/app/redux/threeCommas/Actions.ts +++ b/src/app/redux/threeCommas/Actions.ts @@ -223,7 +223,7 @@ const updateAllData = async (offset: number = 1000, profileData: Type_Profile, t const syncOptions = store.getState().threeCommas.syncOptions store.dispatch(setIsSyncing(true)) - const originalTime = syncOptions.time || 0 + const originalTime = syncOptions.time || new Date().getTime() let time = originalTime let syncCount = syncOptions.syncCount || 0 if (type === 'fullSync') { diff --git a/src/app/redux/threeCommas/initialState.ts b/src/app/redux/threeCommas/initialState.ts index 2ed6cdfb..b24972e1 100644 --- a/src/app/redux/threeCommas/initialState.ts +++ b/src/app/redux/threeCommas/initialState.ts @@ -50,8 +50,6 @@ export const initialState = { isSyncing: false, isSyncingTime: 0, syncOptions: { - summary: false, - notifications: true, time: 0, syncCount: 0 }, @@ -61,8 +59,8 @@ export const initialState = { export type typeString = 'botData' | 'profitData' | 'activeDeals' | 'performanceData' | 'metricsData' | 'accountData' | 'balanceData' export type Type_SyncData = { - time?: number, - syncCount?: number + time: number, + syncCount: number } export type setDataType = diff --git a/src/app/redux/threeCommas/threeCommasSlice.ts b/src/app/redux/threeCommas/threeCommasSlice.ts index 1aa9e964..2d0c6fe2 100644 --- a/src/app/redux/threeCommas/threeCommasSlice.ts +++ b/src/app/redux/threeCommas/threeCommasSlice.ts @@ -24,9 +24,7 @@ export const threeCommasSlice = createSlice({ state.isSyncingTime = Date.now() }, setSyncData: (state, action: PayloadAction) => { - // TODO - need to figure out a way to handle this better when multiple things are syncing at the same time - // right now this will just merge the sync data. - state.syncOptions = { ...state.syncOptions, ...action.payload } + state.syncOptions = action.payload }, setAutoRefresh: (state, action: PayloadAction) => { state.autoRefresh = action.payload diff --git a/src/main/3Commas/index.ts b/src/main/3Commas/index.ts index 0d33e223..5571c12e 100644 --- a/src/main/3Commas/index.ts +++ b/src/main/3Commas/index.ts @@ -39,10 +39,9 @@ async function getDealData(type: string, options: Type_UpdateFunction, profileDa let { deals, lastSyncTime } = data - const enabled = config.get('globalSettings.notifications.enabled') - const summary = config.get('globalSettings.notifications.summary') + const {enabled, summary} = config.get('globalSettings.notification') // if notifications need to be enabled for the fullSync then the type below needs to be updated. - if (type === 'autoSync' && enabled && options.time != undefined || options.syncCount != 0) { + if (type === 'autoSync' && enabled && options.syncCount != 0 && options.time != undefined) { findAndNotifyNewDeals(deals, options.time, summary) } update('deals', deals, profileData.id)