Fixed beacons and locations content getting

This commit is contained in:
Alexander Cerutti
2019-06-28 00:18:55 +02:00
parent 75b22daf73
commit a981571c42
2 changed files with 16 additions and 15 deletions

View File

@@ -274,13 +274,13 @@ export class Pass implements PassIndexSignature {
*/
beacons(...data: schema.Beacon[]): PassWithLengthField | schema.Beacon[] {
if (data === undefined) {
return this._props["beacons"];
if (data === null) {
delete this._props["beacons"];
return assignLength<PassWithLengthField>(0, this);
}
if (!data.length) {
this._props["beacons"] = [];
return assignLength(0, this);
return this._props["beacons"];
}
const validBeacons = data.reduce<schema.Beacon[]>((acc, current) => {
@@ -307,13 +307,13 @@ export class Pass implements PassIndexSignature {
*/
locations(...data: schema.Location[]): PassWithLengthField | schema.Location[] {
if (data === undefined) {
return this._props["locations"];
if (data === null) {
delete this._props["locations"];
return assignLength<PassWithLengthField>(0, this);
}
if (!data.length) {
this._props["locations"] = [];
return assignLength(0, this);
return this._props["locations"];
}
const validLocations = data.reduce<schema.Location[]>((acc, current) => {
@@ -328,8 +328,6 @@ export class Pass implements PassIndexSignature {
return assignLength(0, this);
}
console.log("Locations:", this._props["locations"]);
(this._props["locations"] || (this._props["locations"] = [])).push(...validLocations);
return assignLength(this._props["locations"].length, this);
@@ -377,7 +375,6 @@ export class Pass implements PassIndexSignature {
*/
barcode(first?: string | schema.Barcode, ...data: schema.Barcode[]): PassWithBarcodeMethods | schema.Barcode[] {
console.log(first, data);
if (first === undefined && (data === undefined || !data.length)) {
return this._props["barcodes"];
}