Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
fix: treat carrierJump the same as location event
Browse files Browse the repository at this point in the history
This should fix a bug where we were sending the wrong star pos to EDDN
  • Loading branch information
chrisbruford committed Jun 27, 2020
1 parent f40339d commit fe6da7b
Show file tree
Hide file tree
Showing 8 changed files with 1,346 additions and 1,316 deletions.
2,440 changes: 1,228 additions & 1,212 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@
},
"devDependencies": {
"@types/jasmine": "^2.8.14",
"@types/node": "^8.10.39",
"@types/node": "^12.12.47",
"@types/semver": "^5.5.0",
"angular2-template-loader": "^0.6.2",
"awesome-typescript-loader": "^5.2.1",
"cmdr-journal": "^4.1.0",
"cmdr-journal": "^6.2.1",
"copy-webpack-plugin": "^5.1.1",
"cross-env": "^5.2.0",
"css-loader": "^1.0.1",
"css-to-string-loader": "^0.1.2",
"dotenv": "^6.2.0",
"electron": "^8.1.1",
"electron-builder": "^22.4.1",
"electron": "^9.0.5",
"electron-builder": "^22.7.0",
"electron-connect": "^0.6.3",
"electron-connect-webpack-plugin": "^0.1.1",
"extract-text-webpack-plugin": "3.0.2",
Expand All @@ -73,7 +73,7 @@
"rimraf": "^2.6.2",
"sass-loader": "^7.1.0",
"style-loader": "^0.21.0",
"ts-loader": "^4.5.0",
"ts-loader": "^7.0.5",
"typescript": "^3.8.3",
"webpack": "^4.28.3",
"webpack-cli": "^3.1.2",
Expand Down
5 changes: 3 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component } from "@angular/core";
import { Router, RouterStateSnapshot } from "@angular/router";
import { Router } from "@angular/router";
import { AppErrorService } from "./core/services/app-error.service";
import { UserService } from "./core/services/user.service";
import { LoggerService } from "./core/services/logger.service";
import { ipcRenderer, IpcMessageEvent, Event } from "electron";
import { ipcRenderer, Event } from "electron";
import { UpdateCheckResult } from "electron-updater";
import { NgZone } from "@angular/core";
import { takeWhile } from "rxjs/operators";
Expand Down Expand Up @@ -33,6 +33,7 @@ export class AppComponent {
private snackBar: MatSnackBar,
private journalService: JournalService
) {

this.journalProgress = journalService.initialLoadProgress;
ipcRenderer.on("logout", () => {
zone.run(this.logout.bind(this));
Expand Down
52 changes: 27 additions & 25 deletions src/app/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
JournalEvent,
MissionCompleted,
LoadGame,
NewCommander
} from "cmdr-journal/dist";
NewCommander,
} from "cmdr-journal";
import { Observable, combineLatest, of } from "rxjs";
import { map, merge, tap, takeWhile, debounceTime, take } from "rxjs/operators";
import { FactionService } from "../core/services/faction.service";
Expand All @@ -31,7 +31,7 @@ import { SettingsService } from "./settings/settings.service";
@Component({
templateUrl: "dashboard.component.html",
styleUrls: ["dashboard.component.scss"],
selector: "app-dashboard"
selector: "app-dashboard",
})
export class DashboardComponent implements OnDestroy, OnInit {
missionsCompleted: MissionCompleted[] = [];
Expand Down Expand Up @@ -79,24 +79,26 @@ export class DashboardComponent implements OnDestroy, OnInit {
//username/cmdrname check
this.journalService.cmdrName
.pipe(takeWhile(() => this.alive))
.subscribe(cmdrName => (this.cmdrName = cmdrName));
.subscribe((cmdrName) => (this.cmdrName = cmdrName));

this.userService.user.pipe(takeWhile(() => this.alive)).subscribe(user => {
if (user) {
this.username = user.username;
this.userService.user
.pipe(takeWhile(() => this.alive))
.subscribe((user) => {
if (user) {
this.username = user.username;

if (!user.discordID || !user.discordID.length) {
this.appErrorService.addError(AppErrorTitle.noDiscord, {
message: `️️️️️️️⚠️️️️Your account has not been linked with Discord`
});
if (!user.discordID || !user.discordID.length) {
this.appErrorService.addError(AppErrorTitle.noDiscord, {
message: `️️️️️️️⚠️️️️Your account has not been linked with Discord`,
});
} else {
this.appErrorService.removeError(AppErrorTitle.noDiscord);
}
} else {
this.appErrorService.removeError(AppErrorTitle.noDiscord);
this.appErrorService.removeError(AppErrorTitle.cmdrUsernameMismatch);
}
} else {
this.appErrorService.removeError(AppErrorTitle.noDiscord);
this.appErrorService.removeError(AppErrorTitle.cmdrUsernameMismatch);
}
});
});

this.journalService.on("ready", () => {
combineLatest(
Expand All @@ -114,16 +116,16 @@ export class DashboardComponent implements OnDestroy, OnInit {
});
});

this.trackedFaction.faction.pipe(take(1)).subscribe(faction => {
this.trackedFaction.faction.pipe(take(1)).subscribe((faction) => {
this.trackingFaction.setValue(faction);
this.trackingFaction.valueChanges
.pipe(
debounceTime(500),
tap(inputValue => {
tap((inputValue) => {
this.trackedFaction.setFaction(inputValue);
}),
map(inputValue => {
let outputArray = this.knownFactions.filter(faction => {
map((inputValue) => {
let outputArray = this.knownFactions.filter((faction) => {
let escapedInputValue = inputValue.replace(
/[-\/\\^$*+?.()|[\]{}]/g,
"\\$&"
Expand All @@ -135,20 +137,20 @@ export class DashboardComponent implements OnDestroy, OnInit {
}),
takeWhile(() => this.alive)
)
.subscribe(filteredKnownFactions => {
.subscribe((filteredKnownFactions) => {
this.filteredKnownFactions = filteredKnownFactions;
});
});

this.factionService
.getAllFactions()
.then(factions => {
.then((factions) => {
this.knownFactions = factions;
})
.catch(err =>
.catch((err) =>
this.logger.error({
originalError: err,
message: "Error fetching all known factions in dashboard component"
message: "Error fetching all known factions in dashboard component",
})
);
}
Expand All @@ -157,7 +159,7 @@ export class DashboardComponent implements OnDestroy, OnInit {
this.zone.run(() => {
if (cmdrName.toLowerCase() !== username.toLowerCase()) {
this.appErrorService.addError(AppErrorTitle.cmdrUsernameMismatch, {
message: `⚠️️️️You are logged in as ${username.toUpperCase()} but appear to be playing as ${cmdrName.toUpperCase()}`
message: `⚠️️️️You are logged in as ${username.toUpperCase()} but appear to be playing as ${cmdrName.toUpperCase()}`,
});
} else {
this.appErrorService.removeError(AppErrorTitle.cmdrUsernameMismatch);
Expand Down
102 changes: 57 additions & 45 deletions src/app/dashboard/missions/missions.component.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,61 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { JournalService } from '../../journal/journal.service';
import { DBService } from '../../core/services/db.service';
import { JournalEvents, JournalEvent, MissionCompleted, MissionAccepted, MissionAbandoned, MissionFailed, LoadGame, NewCommander } from 'cmdr-journal/dist';
import { Subscription, Observable } from 'rxjs';
import { OriginatedMission } from './originatedMission';
import { MissionService } from './mission.service';
import { takeWhile } from 'rxjs/operators';
import { TrackingFaction } from '../tracking-faction.service';
import { Component, Input, OnDestroy, OnInit } from "@angular/core";
import { JournalService } from "../../journal/journal.service";
import { DBService } from "../../core/services/db.service";
import {
JournalEvents,
JournalEvent,
MissionCompleted,
MissionAccepted,
MissionAbandoned,
MissionFailed,
LoadGame,
NewCommander,
} from "cmdr-journal";
import { Subscription, Observable } from "rxjs";
import { OriginatedMission } from "./originatedMission";
import { MissionService } from "./mission.service";
import { takeWhile } from "rxjs/operators";
import { TrackingFaction } from "../tracking-faction.service";

@Component({
templateUrl: 'missions.component.html',
styleUrls: ['missions.component.scss'],
selector: 'app-missions'
templateUrl: "missions.component.html",
styleUrls: ["missions.component.scss"],
selector: "app-missions",
})
export class MissionsComponent implements OnInit, OnDestroy {

missionsCompleted: OriginatedMission[];
factionMissionsCompleted: OriginatedMission[];
trackedFaction: string;

private alive = true;

constructor(
private journalService: JournalService,
private journalDB: DBService,
private missionService: MissionService,
private trackingFaction: TrackingFaction
) { }

ngOnInit() {
this.missionService.factionMissionsCompleted
.pipe(takeWhile(() => this.alive))
.subscribe(factionMissionsCompleted => this.factionMissionsCompleted = factionMissionsCompleted);

this.missionService.missionsCompleted
.pipe(takeWhile(() => this.alive))
.subscribe(missionsCompleted => this.missionsCompleted = missionsCompleted);

this.trackingFaction.faction
.pipe(takeWhile(() => this.alive))
.subscribe(trackedFaction => this.trackedFaction = trackedFaction);

}

ngOnDestroy() {
this.alive = false;
}
}
missionsCompleted: OriginatedMission[];
factionMissionsCompleted: OriginatedMission[];
trackedFaction: string;

private alive = true;

constructor(
private journalService: JournalService,
private journalDB: DBService,
private missionService: MissionService,
private trackingFaction: TrackingFaction
) {}

ngOnInit() {
this.missionService.factionMissionsCompleted
.pipe(takeWhile(() => this.alive))
.subscribe(
(factionMissionsCompleted) =>
(this.factionMissionsCompleted = factionMissionsCompleted)
);

this.missionService.missionsCompleted
.pipe(takeWhile(() => this.alive))
.subscribe(
(missionsCompleted) => (this.missionsCompleted = missionsCompleted)
);

this.trackingFaction.faction
.pipe(takeWhile(() => this.alive))
.subscribe((trackedFaction) => (this.trackedFaction = trackedFaction));
}

ngOnDestroy() {
this.alive = false;
}
}
18 changes: 9 additions & 9 deletions src/app/journal/eddn.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export class EDDNService {
}

Object.assign(evt, {
StarPos: starPos
StarPos: starPos,
});

delete evt.CockpitBreached;
delete evt.CockpitBreach;
delete evt.ActiveFine;
delete evt.Wanted;
} else if (evt instanceof FSDJump) {
Expand All @@ -53,7 +53,7 @@ export class EDDNService {
delete evt.JumpDist;
delete evt.Wanted;

evt.Factions?.forEach(faction => {
evt.Factions?.forEach((faction) => {
delete faction.HappiestSystem;
delete faction.HomeSystem;
delete faction.MyReputation;
Expand All @@ -69,13 +69,13 @@ export class EDDNService {
Object.assign(evt, {
StarSystem: starSystem,
StarPos: starPos,
SystemAddress: systemAddress
SystemAddress: systemAddress,
});
} else if (evt instanceof Location) {
delete evt.Latitude;
delete evt.Longitude;
delete evt.Wanted;
evt.Factions?.forEach(faction => {
evt.Factions?.forEach((faction) => {
delete faction.HappiestSystem;
delete faction.HomeSystem;
delete faction.MyReputation;
Expand All @@ -88,15 +88,15 @@ export class EDDNService {
header: {
uploaderID: cmdrName,
softwareName: "Knights of Karma Companion",
softwareVersion: remote.app.getVersion()
softwareVersion: remote.app.getVersion(),
},
message: removeLocalised(evt)
message: removeLocalised(evt),
};

this.http
.post("https://eddn.edcd.io:4430/upload/", submission, {
responseType: "text"
responseType: "text",
})
.subscribe(console.log, err => this.logger.error(err));
.subscribe(console.log, (err) => this.logger.error(err));
}
}
Loading

0 comments on commit fe6da7b

Please sign in to comment.