l-min-components 1.7.1474 → 1.7.1476

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.7.1474",
3
+ "version": "1.7.1476",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -38,21 +38,30 @@ const AccountDropdown = (props) => {
38
38
  }, [props?.selectedAccount]);
39
39
 
40
40
  const handleRedirectFunc = ({ type, id }) => {
41
+ // optimize the use of this base later because it's redeclared on multiple files
42
+ const base = `${
43
+ window.location.hostname.includes("localhost") ||
44
+ window.location.hostname.includes("staging")
45
+ ? `https://559staging.learngual.${
46
+ window.location.hostname.includes(".ca") ? "ca" : "com"
47
+ }`
48
+ : `https://www.learngual.${
49
+ window.location.hostname.includes(".ca") ? "ca" : "com"
50
+ }`
51
+ }`;
41
52
  if (window.location.port) {
42
53
  window.location.href = `${window.location.protocol}//${
43
54
  window.location.hostname
44
55
  }:${window.location.port}/${type?.toLowerCase()}`;
45
56
  } else {
46
- window.location.href = `${window.location.protocol}//${
47
- window.location.hostname
48
- }/${type?.toLowerCase()}`;
57
+ window.location.href = `${base}/${type?.toLowerCase()}`;
49
58
  }
50
59
  // //console.log(id, "bam");
51
60
  };
52
61
 
53
62
  // console.log(props?.selectedAccount, "selected");
54
63
 
55
- const [isLoading, setIsLoading] = useState(false)
64
+ const [isLoading, setIsLoading] = useState(false);
56
65
 
57
66
  return (
58
67
  <>
@@ -129,12 +138,12 @@ const AccountDropdown = (props) => {
129
138
  : ""
130
139
  }`}
131
140
  onClick={() => {
132
- setIsLoading(true)
141
+ setIsLoading(true);
133
142
 
134
143
  deleteCookies([
135
144
  "defaultAccountType",
136
145
  "defaultAccountID",
137
- "activeDeveloperAccount"
146
+ "activeDeveloperAccount",
138
147
  ]);
139
148
 
140
149
  props?.setSelectedAccount(developerItem);
@@ -185,12 +194,12 @@ const AccountDropdown = (props) => {
185
194
  : ""
186
195
  }`}
187
196
  onClick={() => {
188
- setIsLoading(true)
197
+ setIsLoading(true);
189
198
 
190
199
  deleteCookies([
191
200
  "defaultAccountType",
192
201
  "defaultAccountID",
193
- "activeDeveloperAccount"
202
+ "activeDeveloperAccount",
194
203
  ]);
195
204
  props?.setSelectedAccount(instructorItem);
196
205
  setTimeout(() => {
@@ -233,8 +242,12 @@ const AccountDropdown = (props) => {
233
242
  : ""
234
243
  }`}
235
244
  onClick={() => {
236
- setIsLoading(true)
237
- deleteCookies(["defaultAccountType", "defaultAccountID", "activeDeveloperAccount"]);
245
+ setIsLoading(true);
246
+ deleteCookies([
247
+ "defaultAccountType",
248
+ "defaultAccountID",
249
+ "activeDeveloperAccount",
250
+ ]);
238
251
  props?.setSelectedAccount(enterpriseItem);
239
252
  setTimeout(() => {
240
253
  handleRedirectFunc(enterpriseItem);
@@ -275,10 +288,11 @@ const AccountDropdown = (props) => {
275
288
  : ""
276
289
  }`}
277
290
  onClick={() => {
278
- setIsLoading(true)
291
+ setIsLoading(true);
279
292
  deleteCookies([
280
293
  "defaultAccountType",
281
- "defaultAccountID","activeDeveloperAccount"
294
+ "defaultAccountID",
295
+ "activeDeveloperAccount",
282
296
  ]);
283
297
  props?.setSelectedAccount(personalItem);
284
298
  setTimeout(() => {
@@ -323,7 +337,7 @@ const AccountDropdown = (props) => {
323
337
  </button>
324
338
  </AccountDropdownFooter>
325
339
  </AccountDropdownLayout>
326
- {isLoading&&<FullPageLoader hasBackground fixed={true} />}
340
+ {isLoading && <FullPageLoader hasBackground fixed={true} />}
327
341
  </>
328
342
  );
329
343
  };
@@ -44,6 +44,7 @@ const VideoPlayer2 = ({
44
44
 
45
45
  const playContainerRef = useRef();
46
46
  const videoRef = useRef();
47
+ const hlsRef = useRef(null);
47
48
  const { accessToken, generalData } = useContext(OutletContext);
48
49
 
49
50
  const accountId = generalData?.selectedAccount?.id;
@@ -154,8 +155,17 @@ const VideoPlayer2 = ({
154
155
  }
155
156
  };
156
157
 
158
+ const detachEvents = () => {
159
+ video?.removeEventListener("play", handlePlay);
160
+ video?.removeEventListener("pause", handlePause);
161
+ video?.removeEventListener("ended", handleEnded);
162
+ video?.removeEventListener("timeupdate", handleTimeUpdate);
163
+ video?.removeEventListener("waiting", handleWaiting);
164
+ video?.removeEventListener("canplay", handleCanPlay);
165
+ };
166
+
157
167
  if (!src && Hls.isSupported()) {
158
- hls = new Hls({
168
+ hlsRef.current = new Hls({
159
169
  xhrSetup: function (xhr, url) {
160
170
  const modifiedURL = `${url}?_account=${accountId}`;
161
171
  xhr.open("GET", modifiedURL, true);
@@ -164,48 +174,54 @@ const VideoPlayer2 = ({
164
174
  lowLatencyMode: true,
165
175
  });
166
176
 
167
- hls?.attachMedia(video);
168
- hls?.on(Hls.Events.MEDIA_ATTACHED, () => {
169
- hls?.loadSource(url);
177
+ hlsRef.current?.attachMedia(video);
178
+ hlsRef.current?.on(Hls.Events.MEDIA_ATTACHED, () => {
179
+ hlsRef.current?.loadSource(url);
170
180
  });
171
181
 
172
- hls?.on(Hls.Events.LEVEL_SWITCHED, (val) => {
182
+ hlsRef.current?.on(Hls.Events.LEVEL_SWITCHED, (val) => {
173
183
  if (val === "hlsLevelSwitched") {
174
184
  setIsReady(true);
175
185
  setError(null);
176
186
  }
177
187
  });
178
- hls?.on(Hls.Events.LEVEL_LOADING, (val) => {
188
+ hlsRef.current?.on(Hls.Events.LEVEL_LOADING, (val) => {
179
189
  if (val === "hlsLevelLoading") {
180
190
  setIsReady(false);
181
191
  }
182
192
  });
183
193
 
184
- hls?.on(Hls.Events.BUFFER_STALLED, () => setIsBuffering(true));
185
- hls?.on(Hls.Events.BUFFER_APPENDED, () => setIsBuffering(false));
186
- hls?.on(Hls.Events.BUFFER_CREATED, (val) => {
194
+ hlsRef.current?.on(Hls.Events.BUFFER_STALLED, () => setIsBuffering(true));
195
+ hlsRef.current?.on(Hls.Events.BUFFER_APPENDED, () =>
196
+ setIsBuffering(false)
197
+ );
198
+ hlsRef.current?.on(Hls.Events.BUFFER_CREATED, (val) => {
187
199
  if (val === "hlsBufferCreated") {
188
200
  setIsBuffering(true);
189
201
  }
190
202
  });
191
203
 
192
- hls?.on(Hls.Events.BUFFER_APPENDED, (val) => {
204
+ hlsRef.current?.on(Hls.Events.BUFFER_APPENDED, (val) => {
193
205
  if (val === "hlsBufferAppended") {
194
206
  setIsBuffering(false);
195
207
  }
196
208
  });
197
-
198
- hls?.on(Hls.Events.ERROR, (event, data) => {
209
+ hlsRef.current?.on(Hls.Events.ERROR, (event, data) => {
199
210
  console.warn("HLS error", data);
200
211
  if (data.fatal) {
201
212
  setError(data);
202
213
  setIsReady(false);
203
214
  if (data.type === Hls.ErrorTypes.NETWORK_ERROR) {
204
- hls?.startLoad();
215
+ hlsRef.current?.startLoad();
205
216
  } else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
206
- hls?.recoverMediaError();
217
+ hlsRef.current?.recoverMediaError();
207
218
  } else {
208
- hls?.destroy();
219
+ if (
220
+ hlsRef.current &&
221
+ typeof hlsRef.current.destroy === "function"
222
+ ) {
223
+ hlsRef.current?.destroy();
224
+ }
209
225
  }
210
226
  }
211
227
  });
@@ -221,12 +237,13 @@ const VideoPlayer2 = ({
221
237
  });
222
238
  video.load();
223
239
  }
224
-
225
240
  attachEvents();
226
241
  return () => {
227
- if (hls) {
228
- hls?.destroy();
242
+ if (hlsRef.current && typeof hlsRef.current.destroy === "function") {
243
+ hlsRef.current.destroy();
229
244
  }
245
+
246
+ detachEvents();
230
247
  };
231
248
  }, [url, accountId, accessToken, videoRef.current]);
232
249