Skip to content

Commit

Permalink
fix: multiple dashboard status messages
Browse files Browse the repository at this point in the history
Every save of plugin configuration would create
an additional entry in the dashboard message.
  • Loading branch information
tkurki committed Mar 28, 2024
1 parent 3b4f085 commit e3db414
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ describe('Plugin', () => {
new Promise<ValuesResponse>((resolve) => {
const to = ZonedDateTime.now(ZoneId.UTC)
getValues(
plugin.skInfluxes[0],
plugin.skInfluxes()[0],
TESTCONTEXT as Context,
from,
to,
Expand Down
8 changes: 4 additions & 4 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface InfluxPlugin {
getValues: (params: QueryParams) => Promise<Array<unknown>>
getSelfValues: (params: Omit<QueryParams, 'context'>) => Promise<Array<unknown>>
flush: () => Promise<unknown>
skInfluxes: SKInflux[]
skInfluxes: () => SKInflux[]
}

export interface PluginConfig {
Expand All @@ -71,7 +71,7 @@ export default function InfluxPluginFactory(app: App): Plugin & InfluxPlugin {
delete writeOptionsProps.writeSuccess
const selfContext = 'vessels.' + app.selfId

const skInfluxes: SKInflux[] = []
let skInfluxes: SKInflux[] = []
let onStop: (() => void)[] = []
return {
start: function (config: PluginConfig) {
Expand All @@ -85,7 +85,7 @@ export default function InfluxPluginFactory(app: App): Plugin & InfluxPlugin {
.join(';'),
)
}
skInfluxes.push(...config.influxes.map((config: SKInfluxConfig) => new SKInflux(config, app, updatePluginStatus)))
skInfluxes = config.influxes.map((config: SKInfluxConfig) => new SKInflux(config, app, updatePluginStatus))
registerHistoryApiRoute(app, skInfluxes[0], app.selfId, app.debug)

onStop = []
Expand Down Expand Up @@ -136,6 +136,6 @@ export default function InfluxPluginFactory(app: App): Plugin & InfluxPlugin {
name: packageInfo.description,
description: 'Signal K integration with InfluxDb 2',
schema,
skInfluxes,
skInfluxes: () => skInfluxes,
}
}

0 comments on commit e3db414

Please sign in to comment.