Skip to content

Commit

Permalink
Update 2.10.0: values jumping between sources
Browse files Browse the repository at this point in the history
Fixes #420
  • Loading branch information
godind committed Jun 4, 2024
1 parent 61cfbd3 commit 0562900
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# V 2.10.1
## Fixes
* Values jumping between sources. Fixes #420
# V 2.10.0
## BREAKING CHANGE
* Requires Signal K v2.8+
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mxtommy/kip",
"version": "2.10.0",
"version": "2.10.1",
"description": "An advanced and versatile marine instrumentation package to display Signal K data.",
"license": "MIT",
"author": {
Expand Down
29 changes: 19 additions & 10 deletions src/app/core/services/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ export class DataService implements OnDestroy {
}

public subscribePath(path: string, source: string): Observable<IPathUpdate> {
const entry = this._pathRegister.find(entry => entry.path == path);
if (entry) {
return entry.pathDataUpdate$;
const matchingPaths = this._pathRegister.find(item => item.path === path && item.source === source);
if (matchingPaths) {
return matchingPaths.pathDataUpdate$;
}

let currentValue: string = null;
Expand Down Expand Up @@ -301,13 +301,22 @@ export class DataService implements OnDestroy {
}

// Update path register Subjects with new data
const item = this._pathRegister.find(item => item.path == updatePath);
if (item) {
const pathData: IPathData = {
value: pathItem.pathValue,
timestamp: new Date(pathItem.pathTimestamp)
};
item._pathData$.next(pathData);
const pathRegisterItems = this._pathRegister.filter(item => item.path === updatePath);
if (pathRegisterItems.length) {
const pathData: IPathData = {
value: pathItem.pathValue,
timestamp: new Date(pathItem.pathTimestamp)
};

const defaultSource = pathRegisterItems.find(item => item.source === "default");
if (defaultSource) {
defaultSource._pathData$.next(pathData);
}

const thisSource = pathRegisterItems.find(item => item.source === dataPath.source);
if (thisSource) {
thisSource._pathData$.next(pathData);
}
}

// Push full tree if data-browser or Zones component are observing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export class ModalPathControlConfigComponent implements OnInit, OnChanges, OnDes
this.pathFormGroup.controls['source'].setValue('default', {onlySelf: true});
}
}
else if (this.pathFormGroup.controls['source'].value != 'default') {
this.pathFormGroup.controls['source'].setValue('', {onlySelf: true});
}
} else if (Object.keys(pathObject.sources).length > 1) {
this.availableSources = Object.keys(pathObject.sources);
if (this.pathFormGroup.controls['source'].value == 'default') {
Expand Down

0 comments on commit 0562900

Please sign in to comment.