@social-mail/social-mail-client 1.8.402 → 1.8.403

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": "@social-mail/social-mail-client",
3
- "version": "1.8.402",
3
+ "version": "1.8.403",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  import { AtomControl } from "@web-atoms/core/dist/web/controls/AtomControl";
2
- import svg from "@social-mail/social-mail-client/content/svg/blank.svg";
2
+ import FetchBuilder from "@web-atoms/core/dist/services/FetchBuilder";
3
3
 
4
4
  export interface IFileUrl {
5
5
  name?: string;
@@ -45,36 +45,22 @@ export const FileUrlService = {
45
45
 
46
46
  };
47
47
 
48
- document.addEventListener("load", (e) => {
49
- const img = e.target as HTMLImageElement;
50
- if (!img.isConnected) {
51
- return;
52
- }
53
- if(img.getAttribute("animated") !== "true") {
48
+ export const AnimatedImgSrc = AtomControl.registerProperty("animated", "src", (c, e, v) => {
49
+ e.setAttribute("src", v);
50
+ if (!v) {
54
51
  return;
55
52
  }
56
- const src = img.getAttribute("src");
57
- setTimeout(() => {
58
- if (!img.isConnected) {
59
- return;
60
- }
61
- const { parentElement } = img;
62
- const blank = img.cloneNode() as HTMLImageElement;
63
- blank.setAttribute("src", svg);
64
- blank.removeAttribute("animated");
65
- parentElement.replaceChild(blank, img);
66
- setTimeout(() => {
67
- const newImg = document.createElement("img");
68
- for (const key of img.getAttributeNames()) {
69
- newImg.setAttribute(key, img.getAttribute(key));
53
+ const i = setInterval(() => {
54
+ const f = FetchBuilder.get(v).asBlob().then((svg) => {
55
+ const url = URL.createObjectURL(svg);
56
+ const lastUrl = e.getAttribute("src");
57
+ if (lastUrl.startsWith("blob:")) {
58
+ URL.revokeObjectURL(lastUrl);
70
59
  }
71
- newImg.setAttribute("src", src);
72
- parentElement.replaceChild(newImg, blank);
73
- }, 100);
74
- }, 5000);
75
- }, { capture: true });
76
-
77
- export const AnimatedImgSrc = AtomControl.registerProperty("animated", "src", (c, e, v) => {
78
- e.setAttribute("animated", "true");
79
- e.setAttribute("src", v);
60
+ e.setAttribute("src", url);
61
+ });
62
+ },5000);
63
+ c.disposables.add(() => {
64
+ clearInterval(i);
65
+ });
80
66
  });