Skip to content

Commit 224f90e

Browse files
committed
Rename serverPush to pushFromServer
1 parent e1368b7 commit 224f90e

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

jgclark.Dashboard/src/clickHandlers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,9 @@ export async function doDashboardSettingsChanged(data: MessageDataObject, settin
524524

525525
// DataStore.settings = combinedUpdatedSettings
526526
const res = await saveSettings(pluginID, combinedUpdatedSettings)
527-
const updatedPluginData = { [settingName]: newSettings } // was also: serverPush: { [settingName]: true }
527+
const updatedPluginData = { [settingName]: newSettings } // was also: pushFromServer: { [settingName]: true }
528528
if (perspectivesToSave) {
529-
// updatedPluginData.serverPush ? updatedPluginData.serverPush.perspectiveSettings = true
529+
// updatedPluginData.pushFromServer ? updatedPluginData.pushFromServer.perspectiveSettings = true
530530
// $FlowFixMe(incompatible-type)
531531
updatedPluginData.perspectiveSettings = perspectivesToSave
532532
}

jgclark.Dashboard/src/perspectiveClickHandlers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export async function doSwitchToPerspective(data: MessageDataObject): Promise<TB
188188
const updatesToPluginData = {
189189
perspectiveSettings: revisedDefs,
190190
dashboardSettings: newDashboardSettings,
191-
serverPush: { dashboardSettings: true, perspectiveSettings: true },
191+
pushFromServer: { dashboardSettings: true, perspectiveSettings: true },
192192
sections: [],
193193
lastChange: `_Switched to perspective ${switchToName} ${dt()} changed from plugin`,
194194
}
@@ -232,7 +232,7 @@ export async function doPerspectiveSettingsChanged(data: MessageDataObject): Pro
232232
// after (potential) multi-editing in the PerspectivesTable, we need to clean the dashboardSettings for each perspective
233233
// because the tagsToShow may have been changed, so we need to clean out the showSection* vars
234234
const cleanedPerspSettings = newSettings.map((p) => ({ ...p, dashboardSettings: cleanDashboardSettingsInAPerspective(p.dashboardSettings) }))
235-
const updatedPluginData = { perspectiveSettings: cleanedPerspSettings, dashboardSettings, serverPush: { perspectiveSettings: true, dashboardSettings: true } }
235+
const updatedPluginData = { perspectiveSettings: cleanedPerspSettings, dashboardSettings, pushFromServer: { perspectiveSettings: true, dashboardSettings: true } }
236236
if (dashboardSettings.usePerspectives) {
237237
const currentPerspDef = getActivePerspectiveDef(cleanedPerspSettings)
238238
if (currentPerspDef && currentPerspDef.name !== '-') {

jgclark.Dashboard/src/react/customHooks/useSyncDashboardSettingsWithPlugin.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const useSyncDashboardSettingsWithPlugin = (
3434
pluginDataDSettings: any,
3535
dispatch: (action: DispatchAction) => void,
3636
sendActionToPlugin: SendActionToPlugin,
37-
pluginData: TPluginData, // for tracking serverPush
37+
pluginData: TPluginData, // for tracking pushFromServer
3838
updatePluginData: (data: any, msg: string) => void,
3939
compareFn: CompareFn = compareObjects,
4040
) => {
@@ -45,7 +45,7 @@ export const useSyncDashboardSettingsWithPlugin = (
4545
useEffect(() => {
4646
const pluginDataDSettingsChanged = pluginDataDSettings && compareFn(lastpluginDataDSettingsRef.current, pluginDataDSettings) !== null
4747
logDebug(
48-
`useSyncDashboardSettingsWithPlugin effect1 PLUGIN->REACT checking pluginData?.serverPush?.dashboardSettings=${String(pluginData?.serverPush?.dashboardSettings) || ''}`,
48+
`useSyncDashboardSettingsWithPlugin effect1 PLUGIN->REACT checking pluginData?.pushFromServer?.dashboardSettings=${String(pluginData?.pushFromServer?.dashboardSettings) || ''}`,
4949
)
5050
if (pluginDataDSettingsChanged) {
5151
logDebug(
@@ -79,15 +79,15 @@ export const useSyncDashboardSettingsWithPlugin = (
7979
`useSyncDashboardSettingsWithPlugin dashboardSettings in REACT changed BB dashboardSettingsChanged: ${String(
8080
dashboardSettingsChanged,
8181
)} pluginData.perspectiveChanging:${String(pluginData.perspectiveChanging)}`,
82-
{ dashboardSettings, realDiff, serverPush: pluginData?.serverPush?.dashboardSettings },
82+
{ dashboardSettings, realDiff, pushFromServer: pluginData?.pushFromServer?.dashboardSettings },
8383
)
84-
if (pluginData?.serverPush?.dashboardSettings) {
84+
if (pluginData?.pushFromServer?.dashboardSettings) {
8585
logDebug(
86-
`useSyncDashboardSettingsWithPlugin pluginData changed; serverPush=${JSON.stringify(
87-
pluginData.serverPush,
88-
)} changing serverPush.dashboardSettings to false; not sending to server`,
86+
`useSyncDashboardSettingsWithPlugin pluginData changed; pushFromServer=${JSON.stringify(
87+
pluginData.pushFromServer,
88+
)} changing pushFromServer.dashboardSettings to false; not sending to server`,
8989
)
90-
const newPluginData = { ...pluginData, serverPush: { ...pluginData.serverPush, dashboardSettings: false } }
90+
const newPluginData = { ...pluginData, pushFromServer: { ...pluginData.pushFromServer, dashboardSettings: false } }
9191
updatePluginData(newPluginData, `acknowledging server push`)
9292
// was a server push so don't need to send to server
9393
} else {
@@ -117,12 +117,12 @@ export const useSyncDashboardSettingsWithPlugin = (
117117
}, [dashboardSettings, sendActionToPlugin, compareFn, pluginData])
118118

119119
useEffect(() => {
120-
if (pluginData.serverPush.dashboardSettings) {
121-
logDebug(`useSyncDashboardSettingsWithPlugin pluginData.serverPush.dashboardSettings is true; resetting it`, {
120+
if (pluginData.pushFromServer.dashboardSettings) {
121+
logDebug(`useSyncDashboardSettingsWithPlugin pluginData.pushFromServer.dashboardSettings is true; resetting it`, {
122122
pluginData,
123123
})
124-
const newPluginData = { ...pluginData, serverPush: { ...pluginData.serverPush, dashboardSettings: false } }
124+
const newPluginData = { ...pluginData, pushFromServer: { ...pluginData.pushFromServer, dashboardSettings: false } }
125125
updatePluginData(newPluginData, `acknowledging server push`)
126126
}
127-
}, [pluginData.serverPush.dashboardSettings])
127+
}, [pluginData.pushFromServer.dashboardSettings])
128128
}

jgclark.Dashboard/src/reactMain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ export async function getPluginData(dashboardSettings: TDashboardSettings, persp
540540
platform: NotePlan.environment.platform, // used in dialog positioning
541541
themeName: dashboardSettings.dashboardTheme ? dashboardSettings.dashboardTheme : Editor.currentTheme?.name || '<could not get theme>',
542542
version: pluginJson['plugin.version'],
543-
serverPush: {
543+
pushFromServer: {
544544
dashboardSettings: true,
545545
perspectiveSettings: true,
546546
},

jgclark.Dashboard/src/types.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
//-----------------------------------------------------------------------------
33
// Types for Dashboard code
4-
// Last updated 2025-05-15 for v2.3.0.b2, @jgclark
4+
// Last updated 2025-05-18 for v2.3.0, @jgclark
55
//-----------------------------------------------------------------------------
66
// Types for Settings
77

@@ -149,7 +149,7 @@ export type TSection = {
149149
actionButtons?: Array<TActionButton>,
150150
generatedDate?: Date, // note different from lastFullRefresh on whole project
151151
totalCount?: number, // for when not all possible items are passed in pluginData
152-
doneCounts?: TDoneCount, // number of tasks and checklists completed today etc.
152+
doneCounts?: TDoneCount, // number of tasks (and potentially checklists) completed in the relevant calendar note
153153
showColoredBackground?: boolean, // whether to show a colored background for the section
154154
}
155155

@@ -379,8 +379,9 @@ export type TPluginData = {
379379
themeName: string /* the theme name used when generating the dashboard */,
380380
platform: string /* the platform used when generating the dashboard */,
381381
version: string /* version of this plugin */,
382-
serverPush: {
383-
/* see below for documentation */ dashboardSettings?: boolean,
382+
pushFromServer: {
383+
/* see below for documentation */
384+
dashboardSettings?: boolean,
384385
perspectiveSettings?: boolean,
385386
},
386387
demoMode: boolean /* use fake content for demo/test purposes */,
@@ -389,11 +390,11 @@ export type TPluginData = {
389390
}
390391

391392
/**
392-
* serverPush was designed especially for dashboardSettings, because dashboardSettings can change in the front-end (via user action) which then need to be noticed and sent to the back-end, or can be sent to the front end from the back-end (plugin) in which case they should just be accepted but not sent back to the plugin.
393+
* pushFromServer was designed especially for dashboardSettings, because dashboardSettings can change in the front-end (via user action) which then need to be noticed and sent to the back-end, or can be sent to the front end from the back-end (plugin) in which case they should just be accepted but not sent back to the plugin.
393394
* Initially I was doing this with the lastChange message, and if that message started with a "_" it meant this is coming from the plugin and should not be sent back.
394-
* But that seemed too non-obvious. So I added this serverPush variable which is set when the plugin wants to send updates to the front-end but does not want those updates to be sent back erroneously.
395+
* But that seemed too non-obvious. So I added this pushFromServer variable which is set when the plugin wants to send updates to the front-end but does not want those updates to be sent back erroneously.
395396
* Specifically,
396-
* - the initial data send in reactMain or the clickHandlers in clickHandlers and perspectiveClickHandlers set data that is changed and then set pluginData.serverPush.dashboardData = true and send it to the front-end using setPluginData()
397+
* - the initial data send in reactMain or the clickHandlers in clickHandlers and perspectiveClickHandlers set data that is changed and then set pluginData.pushFromServer.dashboardData = true and send it to the front-end using setPluginData()
397398
* - the change is picked up by the first useEffect in useSyncDashboardSettingsWithPlugin and then that var is set to false and stored locally in pluginData without sending it back to the plugin
398399
*/
399400

0 commit comments

Comments
 (0)