incyclist-services 1.7.24 → 1.7.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,15 +87,16 @@ let ActiveRideListMessageQueue = (() => {
87
87
  }
88
88
  if (!existing)
89
89
  this.subscribed.push({ topic, filter, handler });
90
- this.getMessageQueue().subscribe(topic);
90
+ this.getMessageQueue()?.subscribe(topic);
91
91
  }
92
92
  unsubscribe(topic) {
93
93
  const mq = this.getMessageQueue();
94
- if (!mq?.enabled())
94
+ if (!mq || !mq?.enabled())
95
95
  return;
96
- const s = this.subscribed.find(s => s.topic === topic);
96
+ const subscribed = this.subscribed ?? [];
97
+ const s = subscribed.find(s => s.topic === topic);
97
98
  mq.unsubscribe(s.topic);
98
- this.subscribed.splice(this.subscribed.indexOf(s), 1);
99
+ subscribed.splice(subscribed.indexOf(s), 1);
99
100
  }
100
101
  unsubscribeAll() {
101
102
  const topics = this.subscribed ?? [];
@@ -108,7 +109,7 @@ let ActiveRideListMessageQueue = (() => {
108
109
  }
109
110
  sendMessage(topic, payload) {
110
111
  const mq = this.getMessageQueue();
111
- if (!mq?.enabled())
112
+ if (!mq || !mq?.enabled())
112
113
  return;
113
114
  try {
114
115
  mq.publish(topic, payload);
@@ -124,6 +125,8 @@ let ActiveRideListMessageQueue = (() => {
124
125
  if (this.subscribeEnabled)
125
126
  return;
126
127
  const mq = this.getMessageQueue();
128
+ if (!mq)
129
+ return;
127
130
  mq.on('mq-subscribed', this.onTopicSubscribedHandler);
128
131
  mq.on('mq-message', this.onTopicMessageHandler);
129
132
  this.subscribeEnabled = true;
@@ -132,6 +135,8 @@ let ActiveRideListMessageQueue = (() => {
132
135
  if (!this.subscribeEnabled)
133
136
  return;
134
137
  const mq = this.getMessageQueue();
138
+ if (!mq)
139
+ return;
135
140
  mq.off('mq-subscribed', this.onTopicSubscribedHandler);
136
141
  mq.off('mq-message', this.onTopicMessageHandler);
137
142
  this.subscribeEnabled = false;
@@ -610,9 +610,9 @@ let ActiveRidesService = (() => {
610
610
  const hash = this.current?.ride.routeHash;
611
611
  const session = this.current?.sessionId;
612
612
  const updateTopic = `incyclist/activity/+/${hash}/+`;
613
- this.getMessageQueue().subscribe(updateTopic, this.onActivityEvent.bind(this), 'incyclist/activity');
613
+ this.getMessageQueue()?.subscribe(updateTopic, this.onActivityEvent.bind(this), 'incyclist/activity');
614
614
  const infoTopic = `incyclist/session/${session}/info`;
615
- this.getMessageQueue().subscribe(infoTopic, this.onInfoEvent.bind(this), 'incyclist/session');
615
+ this.getMessageQueue()?.subscribe(infoTopic, this.onInfoEvent.bind(this), 'incyclist/session');
616
616
  this.isSubscribed = true;
617
617
  }
618
618
  onInfoEvent(topic) {
@@ -97,7 +97,7 @@ let RouteDisplayService = (() => {
97
97
  getDeviceStartSettings() {
98
98
  const startSettings = this.getRouteList().getStartSettings();
99
99
  const route = this.getRouteList().getSelected();
100
- const { realityFactor, startPos } = startSettings;
100
+ const { realityFactor = 100, startPos = 0 } = startSettings;
101
101
  return { realityFactor, startPos, route };
102
102
  }
103
103
  onActivityUpdate(activityPos, data) {
@@ -256,6 +256,8 @@ let RouteDisplayService = (() => {
256
256
  get startSettings() {
257
257
  const prev = this._startSettings;
258
258
  this._startSettings = this.getRouteList().getStartSettings() ?? prev;
259
+ this._startSettings.startPos = this._startSettings.startPos ?? 0;
260
+ this._startSettings.realityFactor = this._startSettings.realityFactor ?? 100;
259
261
  return this._startSettings;
260
262
  }
261
263
  buildRequest(props = {}) {
@@ -152,7 +152,7 @@ class XMLParser {
152
152
  const { data, route, fileInfo } = context;
153
153
  const filePath = data['video-file-path'];
154
154
  let file, url;
155
- if (filePath.startsWith('http:') || filePath.startsWith('file:') || filePath.startsWith('video:')) {
155
+ if (filePath.startsWith('http') || filePath.startsWith('file:') || filePath.startsWith('video:')) {
156
156
  url = filePath;
157
157
  }
158
158
  else {