l-min-components 1.0.862 → 1.0.871

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.0.862",
3
+ "version": "1.0.871",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import { Img } from "react-image";
3
3
  import { ImageFallbackContainer } from "./index.styled";
4
4
 
@@ -19,17 +19,37 @@ const ImageComponents = ({
19
19
  alt,
20
20
  className,
21
21
  }) => {
22
+ const [imgSrc, setImgSrc] = useState(src);
23
+ const [loading, setLoading] = useState(true);
24
+
25
+ useEffect(() => {
26
+ setImgSrc(src); // Reset to primary src when the src prop changes
27
+ setLoading(true); // Reset loading state when src changes
28
+ }, [src]);
29
+
30
+ const handleError = () => {
31
+ setLoading(false); // Stop showing the loading placeholder
32
+ };
33
+
34
+ const handleLoad = () => {
35
+ setLoading(false); // Image has loaded successfully
36
+ };
22
37
  return (
23
- <Img
24
- className={className}
25
- src={src}
26
- width={width}
27
- height={height}
28
- alt={alt}
29
- loader={
38
+ <>
39
+ {loading ? (
30
40
  <FallbackImage size={fallbackLogoSize} width={width} height={height} />
31
- }
32
- />
41
+ ) : (
42
+ <img
43
+ className={className}
44
+ src={imgSrc}
45
+ alt={alt}
46
+ onError={handleError}
47
+ onLoad={handleLoad}
48
+ style={{ display: loading ? "none" : "block", width, height }} // Hide the image while loading
49
+ {...props}
50
+ />
51
+ )}
52
+ </>
33
53
  );
34
54
  };
35
55
 
@@ -30,6 +30,7 @@ import LanguageDropdown from "./languageDropdown";
30
30
  import { getCookie } from "./getCookies";
31
31
  import { data } from "../GraphMap/data";
32
32
  import { languagesData } from "./languages";
33
+ import loadTranslations, { preLoadWords } from "../../hooks/utils/translation";
33
34
  /**
34
35
  * @param {{
35
36
  * type: string,
@@ -379,7 +380,7 @@ const HeaderComponent = (props) => {
379
380
  websocket2.addEventListener("message", handler, { passive: true });
380
381
 
381
382
  return () => {
382
- websocket2.removeEventListener("message", handler);
383
+ websocket2.removeEventListener("message", handler);
383
384
  //console.log("room websocket closed");
384
385
  };
385
386
  }, []);
@@ -393,17 +394,7 @@ const HeaderComponent = (props) => {
393
394
 
394
395
  const value = JSON?.parse(localStorage.getItem("defaultLang"));
395
396
  const currentFlag = value?.flag;
396
- const selectedLanguage = languagesData.find((lang) => lang?.slug === defaultLang);
397
-
398
- useEffect(() => {
399
- if (value) {
400
- setDefaultLang(value?.slug);
401
-
402
- } else if (generalData?.defaultAccount?.language) {
403
- localStorage.setItem("defaultLang", JSON.stringify(selectedLanguage));
404
- setDefaultLang(generalData?.defaultAccount?.language);
405
- }
406
- }, [generalData, defaultLang]);
397
+ const selectedLanguage = languagesData?.find((lang) => lang?.slug === defaultLang);
407
398
 
408
399
  // When Developer and on staging
409
400
  const isDeveloper =
@@ -53,3 +53,4 @@ export { default as MobileLayout } from "./mobileLayout";
53
53
  export { default as useTranslation } from "../hooks/useTranslation";
54
54
  export { default as preLoadWords } from "../hooks/utils/translation";
55
55
  export { default as ImageComponent } from "./ImageComponent";
56
+
@@ -80,7 +80,7 @@ export async function preLoadWords(cb) {
80
80
  */
81
81
  const data = response.data;
82
82
  db.words.bulkPut(
83
- Object.keys(data).map((x) => ({ text: x, screenId, updatedAt }))
83
+ Object?.keys(data).map((x) => ({ text: x, screenId, updatedAt }))
84
84
  );
85
85
  if (typeof cb === "function") cb(data);
86
86
  return true;