@social-mail/social-mail-client 1.2.87 → 1.2.89

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.
Files changed (64) hide show
  1. package/component.js +6 -0
  2. package/dist/admin/AdminAppIndex.pack.js +142 -69
  3. package/dist/admin/AdminAppIndex.pack.js.map +1 -1
  4. package/dist/admin/AdminAppIndex.pack.min.js +9 -9
  5. package/dist/admin/AdminAppIndex.pack.min.js.map +1 -1
  6. package/dist/common/controls/html/InlineHtmlEditorWithToolbar.d.ts +3 -0
  7. package/dist/common/controls/html/InlineHtmlEditorWithToolbar.d.ts.map +1 -1
  8. package/dist/common/controls/html/InlineHtmlEditorWithToolbar.js +15 -1
  9. package/dist/common/controls/html/InlineHtmlEditorWithToolbar.js.map +1 -1
  10. package/dist/public/channel/BlogService.d.ts +1 -1
  11. package/dist/public/channel/BlogService.d.ts.map +1 -1
  12. package/dist/public/channel/BlogService.js +2 -2
  13. package/dist/public/channel/BlogService.js.map +1 -1
  14. package/dist/public/channel/ChannelMessageList.d.ts.map +1 -1
  15. package/dist/public/channel/ChannelMessageList.js +15 -2
  16. package/dist/public/channel/ChannelMessageList.js.map +1 -1
  17. package/dist/public/channel/ChannelView.pack.js +46 -32
  18. package/dist/public/channel/ChannelView.pack.js.map +1 -1
  19. package/dist/public/channel/ChannelView.pack.min.js +4 -4
  20. package/dist/public/channel/ChannelView.pack.min.js.map +1 -1
  21. package/dist/services/files/LocalFileService.js +1 -1
  22. package/dist/services/files/LocalFileService.js.map +1 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/dist/web/AppIndex.pack.js +142 -69
  25. package/dist/web/AppIndex.pack.js.map +1 -1
  26. package/dist/web/AppIndex.pack.min.js +9 -9
  27. package/dist/web/AppIndex.pack.min.js.map +1 -1
  28. package/dist/web/page/mails/ComposeMailPage.d.ts.map +1 -1
  29. package/dist/web/page/mails/ComposeMailPage.js +5 -2
  30. package/dist/web/page/mails/ComposeMailPage.js.map +1 -1
  31. package/dist/web/page/mails/mini-compose/MiniComposeBox.d.ts +9 -2
  32. package/dist/web/page/mails/mini-compose/MiniComposeBox.d.ts.map +1 -1
  33. package/dist/web/page/mails/mini-compose/MiniComposeBox.js +89 -32
  34. package/dist/web/page/mails/mini-compose/MiniComposeBox.js.map +1 -1
  35. package/dist/web/page/mails/service/ConversationService.d.ts.map +1 -1
  36. package/dist/web/page/mails/service/ConversationService.js +10 -2
  37. package/dist/web/page/mails/service/ConversationService.js.map +1 -1
  38. package/index.js +6 -1
  39. package/node_modules/@web-atoms/core/dist/tsconfig.tsbuildinfo +1 -1
  40. package/node_modules/@web-atoms/core/dist/web/WebApp.d.ts +1 -0
  41. package/node_modules/@web-atoms/core/dist/web/WebApp.d.ts.map +1 -1
  42. package/node_modules/@web-atoms/core/dist/web/WebApp.js +3 -0
  43. package/node_modules/@web-atoms/core/dist/web/WebApp.js.map +1 -1
  44. package/node_modules/@web-atoms/core/package.json +1 -1
  45. package/node_modules/@web-atoms/core/src/web/WebApp.ts +6 -0
  46. package/node_modules/@web-atoms/module-loader/package.json +1 -1
  47. package/node_modules/@web-atoms/module-loader/umd/src/System.ts +3 -0
  48. package/node_modules/@web-atoms/module-loader/umd/src/UMDClass.ts +13 -27
  49. package/node_modules/@web-atoms/module-loader/umd.js +16 -26
  50. package/node_modules/@web-atoms/module-loader/umd.js.map +1 -1
  51. package/node_modules/@web-atoms/web-controls/dist/html-editor/InlineHtmlEditor.d.ts.map +1 -1
  52. package/node_modules/@web-atoms/web-controls/dist/html-editor/InlineHtmlEditor.js +3 -5
  53. package/node_modules/@web-atoms/web-controls/dist/html-editor/InlineHtmlEditor.js.map +1 -1
  54. package/node_modules/@web-atoms/web-controls/dist/tsconfig.tsbuildinfo +1 -1
  55. package/node_modules/@web-atoms/web-controls/package.json +1 -1
  56. package/node_modules/@web-atoms/web-controls/src/html-editor/InlineHtmlEditor.tsx +3 -9
  57. package/package.json +4 -4
  58. package/src/common/controls/html/InlineHtmlEditorWithToolbar.tsx +18 -2
  59. package/src/public/channel/BlogService.ts +2 -2
  60. package/src/public/channel/ChannelMessageList.tsx +16 -2
  61. package/src/services/files/LocalFileService.tsx +1 -1
  62. package/src/web/page/mails/ComposeMailPage.tsx +3 -0
  63. package/src/web/page/mails/mini-compose/MiniComposeBox.tsx +79 -18
  64. package/src/web/page/mails/service/ConversationService.tsx +10 -2
package/component.js CHANGED
@@ -1,6 +1,9 @@
1
1
  (function () {
2
2
  let id = 1;
3
3
  const currentScript = document.currentScript;
4
+
5
+
6
+
4
7
  setTimeout(() => {
5
8
  for(const e of Array.from(document.querySelectorAll(`[styler-layout="component"]`))) {
6
9
  e.id ||= `web_atoms_uid_${id++}`;
@@ -25,6 +28,9 @@
25
28
  if (v = e.getAttribute("data-replace")) {
26
29
  script.setAttribute("data-replace", v);
27
30
  }
31
+ if (v = e.getAttribute("data-json-args")) {
32
+ script.setAttribute("data-json-args");
33
+ }
28
34
  e.setAttribute("data-ready", "yes");
29
35
  document.body.appendChild(script);
30
36
  }
@@ -1828,6 +1828,9 @@ class System {
1828
1828
  setup = importsOrSetup;
1829
1829
  }
1830
1830
  const module = instance.get(name);
1831
+ if (module.isLoaded) {
1832
+ return;
1833
+ }
1831
1834
  module.dependencies.push(...imports.map((x) => instance.get(module.require.resolve(x))));
1832
1835
  module.isLoaded = true;
1833
1836
  const postResolve = new Promise((resolve, reject) => {
@@ -1928,17 +1931,12 @@ class UMDClass {
1928
1931
  AmdLoader.instance.get(path);
1929
1932
  const m = yield this.load(this.defaultApp, designMode);
1930
1933
  const app = ((_a = globalNS.webApp) !== null && _a !== void 0 ? _a : (globalNS.webApp = new (m.default)()));
1931
- app.onReady(() => __awaiter(this, void 0, void 0, function* () {
1932
- try {
1933
- const viewClass = yield AmdLoader.instance.import(path);
1934
- const view = new (viewClass.default)(app);
1935
- const element = typeof id === "string" ? document.getElementById(id) : id;
1936
- element.appendChild(view.element);
1937
- }
1938
- catch (e) {
1939
- console.error(e);
1940
- }
1941
- }));
1934
+ yield app.initPromise;
1935
+ const viewClass = yield AmdLoader.instance.import(path);
1936
+ const view = new (viewClass.default)(app);
1937
+ const element = typeof id === "string" ? document.getElementById(id) : id;
1938
+ element.appendChild(view.element);
1939
+ return view;
1942
1940
  }
1943
1941
  catch (e) {
1944
1942
  console.error(e);
@@ -1947,26 +1945,18 @@ class UMDClass {
1947
1945
  }
1948
1946
  loadView(path, designMode, appPath) {
1949
1947
  return __awaiter(this, void 0, void 0, function* () {
1948
+ var _a;
1950
1949
  try {
1951
1950
  this.mock = designMode;
1952
1951
  appPath = appPath || this.defaultApp;
1953
1952
  AmdLoader.instance.get(path);
1954
1953
  const m = yield this.load(appPath, designMode);
1955
- const app = new (m.default)();
1956
- return yield new Promise((resolve, reject) => {
1957
- app.onReady(() => __awaiter(this, void 0, void 0, function* () {
1958
- try {
1959
- const viewClass = yield AmdLoader.instance.import(path);
1960
- const view = new (viewClass.default)(app);
1961
- app.root = view;
1962
- resolve(view);
1963
- }
1964
- catch (e) {
1965
- console.error(e);
1966
- reject(e);
1967
- }
1968
- }));
1969
- });
1954
+ const app = ((_a = globalNS.webApp) !== null && _a !== void 0 ? _a : (globalNS.webApp = new (m.default)()));
1955
+ yield app.initPromise;
1956
+ const viewClass = yield AmdLoader.instance.import(path);
1957
+ const view = new (viewClass.default)(app);
1958
+ app.root = view;
1959
+ return view;
1970
1960
  }
1971
1961
  catch (er) {
1972
1962
  console.error(er);
@@ -18606,7 +18596,7 @@ System.register(["tslib", "@web-atoms/core/dist/App", "@web-atoms/core/dist/core
18606
18596
  extra = JSON.parse(extra);
18607
18597
  }
18608
18598
  const sha256 = yield this.sha256(file);
18609
- if (extra.parentID) {
18599
+ if (extra === null || extra === void 0 ? void 0 : extra.parentID) {
18610
18600
  const existing = yield this.entityService.query(AppFile, "children", extra.parentID, folder ? folder + "/" + file.name : file.name, sha256).firstOrDefault();
18611
18601
  if (existing) {
18612
18602
  const {
@@ -22411,11 +22401,19 @@ System.register(["tslib", "@web-atoms/core/dist/di/DISingleton", "@web-atoms/cor
22411
22401
  }
22412
22402
  msg.innerHTML = html;
22413
22403
  for (const iterator of descendentElementIterator(msg)) {
22414
- if (iterator.tagName === "IMG") {
22404
+ let cid = iterator.getAttribute("data-content-id");
22405
+ if (cid) {
22406
+ const a = mail.attachments.find(x => x.contentID === cid);
22407
+ if (a) {
22408
+ iterator.setAttribute("src", a.url);
22409
+ continue;
22410
+ }
22411
+ }
22412
+ if (/^(IMG|VIDEO)$/.test(iterator.tagName)) {
22415
22413
  const src = iterator.getAttribute("src");
22416
22414
  if (src) {
22417
22415
  if (src.startsWith("cid:")) {
22418
- const cid = src.substring(4);
22416
+ cid = src.substring(4);
22419
22417
  const a = mail.attachments.find(x => x.contentID === cid);
22420
22418
  if (a) {
22421
22419
  iterator.setAttribute("src", `/api/files/${a.appFileID}/${a.fileContentID}/${a.name}`);
@@ -23075,11 +23073,9 @@ System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/core/di
23075
23073
  }
23076
23074
  onContentSet() {
23077
23075
  var _a;
23078
- const start = (_a = Array.from(this.editor.querySelectorAll(this.editableSelector))) !== null && _a !== void 0 ? _a : [this.editor.firstElementChild];
23079
- if (start.length) {
23080
- for (const iterator of start) {
23081
- iterator.contentEditable = "true";
23082
- }
23076
+ const start = (_a = Array.from(this.editor.querySelectorAll(this.editableSelector))[0]) !== null && _a !== void 0 ? _a : this.editor.firstElementChild;
23077
+ if (start) {
23078
+ start.contentEditable = "true";
23083
23079
  }
23084
23080
  this.editor.dispatchEvent(new CustomEvent("contentReady", {
23085
23081
  detail: this.editor.innerHTML,
@@ -25571,8 +25567,22 @@ System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/web-con
25571
25567
  _export("MailHtmlEditor", MailHtmlEditor = class MailHtmlEditor extends InlineHtmlEditor {
25572
25568
  constructor() {
25573
25569
  super(...arguments);
25570
+ this.files = [];
25571
+ this.attachments = [];
25574
25572
  this.autofocus = false;
25575
25573
  }
25574
+ onContentSet() {
25575
+ super.onContentSet();
25576
+ const files = this.attachments;
25577
+ const items = Array.from(this.editor.querySelectorAll(`*[data-content-id]`));
25578
+ for (const iterator of items) {
25579
+ const file = files.find(x => x.contentID === iterator.getAttribute("data-content-id"));
25580
+ if (!file) {
25581
+ continue;
25582
+ }
25583
+ iterator.setAttribute("src", file.url);
25584
+ }
25585
+ }
25576
25586
  onPasteEvent(e) {
25577
25587
  if (e.clipboardData.files.length) {
25578
25588
  e.preventDefault();
@@ -25598,7 +25608,7 @@ System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/web-con
25598
25608
  super.preCreate();
25599
25609
  this.element.className = css;
25600
25610
  this.sanitizeHtml = node => {
25601
- const images = Array.from(node.querySelectorAll(`img[data-content-id]`));
25611
+ const images = Array.from(node.querySelectorAll(`*[data-content-id]`));
25602
25612
  for (const image of images) {
25603
25613
  image.setAttribute("src", `cid:${image.getAttribute("data-content-id")}`);
25604
25614
  }
@@ -26874,7 +26884,8 @@ System.register(["tslib", "@web-atoms/web-controls/dist/mobile-app/MobileApp", "
26874
26884
  `.installGlobal("[data-html-editor=email-editor]");
26875
26885
  _export("default", ComposeMailPage = class ComposeMailPage extends PopupWindowPage {
26876
26886
  init() {
26877
- var _a, _b, _c;
26887
+ var _a, _b, _c, _d;
26888
+ var _e;
26878
26889
  return __awaiter(this, void 0, void 0, function* () {
26879
26890
  if (this.parameters.subject) {
26880
26891
  this.title = "Reply: " + this.parameters.subject;
@@ -26888,6 +26899,7 @@ System.register(["tslib", "@web-atoms/web-controls/dist/mobile-app/MobileApp", "
26888
26899
  recipients: [],
26889
26900
  attachments: []
26890
26901
  });
26902
+ (_c = (_e = this.model).attachments) !== null && _c !== void 0 ? _c : _e.attachments = [];
26891
26903
  if (this.parameters.social) {
26892
26904
  const senderName = this.parameters.mailbox.emailAddress.name;
26893
26905
  const senderEmail = this.parameters.mailbox.emailAddress.emailAddress;
@@ -26899,7 +26911,7 @@ System.register(["tslib", "@web-atoms/web-controls/dist/mobile-app/MobileApp", "
26899
26911
  if (this.parameters.emailAddress) {
26900
26912
  this.model.recipients.add(EmailRecipient.create({
26901
26913
  emailAddressText: this.parameters.emailAddress,
26902
- emailAddressID: (_c = this.parameters.emailAddressID) !== null && _c !== void 0 ? _c : void 0
26914
+ emailAddressID: (_d = this.parameters.emailAddressID) !== null && _d !== void 0 ? _d : void 0
26903
26915
  }));
26904
26916
  }
26905
26917
  this.renderer = XNode.create("div", null, XNode.create(Form, null, XNode.create(HorizontalFormField, {
@@ -26917,6 +26929,7 @@ System.register(["tslib", "@web-atoms/web-controls/dist/mobile-app/MobileApp", "
26917
26929
  "data-html-editor": "email-editor",
26918
26930
  presenter: Bind.presenter(c => this.editor = c),
26919
26931
  content: this.model.htmlBody,
26932
+ attachments: this.model.attachments,
26920
26933
  "style-min-height": "200px"
26921
26934
  }), XNode.create(AtomRepeater, {
26922
26935
  items: this.model.attachments,
@@ -33486,10 +33499,10 @@ System.register(["@web-atoms/core/dist/core/XNode", "@web-atoms/web-controls/dis
33486
33499
 
33487
33500
  AmdLoader.instance.setup("@social-mail/social-mail-client/dist/web/page/mails/mini-compose/Atttach");
33488
33501
 
33489
- System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/core/dist/style/styled", "@web-atoms/core/dist/web/controls/AtomControl", "../../../../model/model", "@web-atoms/core/dist/core/Bind", "@web-atoms/core/dist/view-model/Action", "../../../../common/controls/audio/AudioRecorder", "../service/ConversationService", "@web-atoms/web-controls/dist/basic/AtomRepeater", "@web-atoms/core/dist/core/InjectProperty", "@web-atoms/core/dist/core/AtomBinder", "../../../../common/events/CommonEvents", "../service/MailService", "@web-atoms/date-time/dist/DateTime", "@web-atoms/core/dist/core/sleep", "../../../../common/controls/html/InlineHtmlEditorWithToolbar", "@web-atoms/web-controls/dist/html-editor/AtomHtmlEditor", "@web-atoms/web-controls/dist/html-editor/commands/Align", "@web-atoms/web-controls/dist/html-editor/commands/Bold", "@web-atoms/web-controls/dist/html-editor/commands/Italic", "@web-atoms/web-controls/dist/html-editor/commands/StrikeThrough", "@web-atoms/web-controls/dist/html-editor/commands/Underline", "@web-atoms/web-controls/dist/html-editor/commands/AddLink", "@web-atoms/web-controls/dist/html-editor/commands/Unlink", "@web-atoms/web-controls/dist/html-editor/commands/Separator", "./Insert", "@web-atoms/date-time/dist/TimeSpan", "./Atttach"], function (_export, _context) {
33502
+ System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/core/dist/style/styled", "@web-atoms/core/dist/web/controls/AtomControl", "../../../../model/model", "@web-atoms/core/dist/core/Bind", "@web-atoms/core/dist/view-model/Action", "../../../../common/controls/audio/AudioRecorder", "../service/ConversationService", "@web-atoms/web-controls/dist/basic/AtomRepeater", "@web-atoms/core/dist/core/InjectProperty", "../../../../common/events/CommonEvents", "../service/MailService", "@web-atoms/date-time/dist/DateTime", "@web-atoms/core/dist/core/sleep", "../../../../common/controls/html/InlineHtmlEditorWithToolbar", "@web-atoms/web-controls/dist/html-editor/AtomHtmlEditor", "@web-atoms/web-controls/dist/html-editor/commands/Align", "@web-atoms/web-controls/dist/html-editor/commands/Bold", "@web-atoms/web-controls/dist/html-editor/commands/Italic", "@web-atoms/web-controls/dist/html-editor/commands/StrikeThrough", "@web-atoms/web-controls/dist/html-editor/commands/Underline", "@web-atoms/web-controls/dist/html-editor/commands/AddLink", "@web-atoms/web-controls/dist/html-editor/commands/Unlink", "@web-atoms/web-controls/dist/html-editor/commands/Separator", "./Insert", "@web-atoms/date-time/dist/TimeSpan", "./Atttach"], function (_export, _context) {
33490
33503
  "use strict";
33491
33504
 
33492
- var __awaiter, __decorate, __metadata, XNode, styled, AtomControl, AppFile, Email, Bind, Action, AudioRecorder, ConversationService, AtomRepeater, InjectProperty, AtomBinder, CommonEvents, MailService, DateTime, sleep, MailHtmlEditor, Toolbar, Align, Bold, Italic, StrikeThrough, Underline, AddLink, Unlink, Separator, Insert, TimeSpan, Attach, MiniComposeBox, css;
33505
+ var __awaiter, __decorate, __metadata, XNode, styled, AtomControl, AppFile, Email, Bind, Action, AudioRecorder, ConversationService, AtomRepeater, InjectProperty, CommonEvents, MailService, DateTime, sleep, MailHtmlEditor, Toolbar, Align, Bold, Italic, StrikeThrough, Underline, AddLink, Unlink, Separator, Insert, TimeSpan, Attach, MiniComposeBox, css;
33493
33506
  _export("default", void 0);
33494
33507
  return {
33495
33508
  setters: [function (_tslib) {
@@ -33517,8 +33530,6 @@ System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/core/di
33517
33530
  AtomRepeater = _webAtomsWebControlsDistBasicAtomRepeater.default;
33518
33531
  }, function (_webAtomsCoreDistCoreInjectProperty) {
33519
33532
  InjectProperty = _webAtomsCoreDistCoreInjectProperty.default;
33520
- }, function (_webAtomsCoreDistCoreAtomBinder) {
33521
- AtomBinder = _webAtomsCoreDistCoreAtomBinder.AtomBinder;
33522
33533
  }, function (_commonEventsCommonEvents) {
33523
33534
  CommonEvents = _commonEventsCommonEvents.CommonEvents;
33524
33535
  }, function (_serviceMailService) {
@@ -33632,7 +33643,8 @@ System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/core/di
33632
33643
  "data-html-editor": "email-editor",
33633
33644
  presenter: Bind.presenter(c => this.editor = c),
33634
33645
  content: this.typedMessage,
33635
- "style-min-height": "50px"
33646
+ "style-min-height": "50px",
33647
+ attachments: Bind.oneWay(() => this.draft.attachments)
33636
33648
  }), XNode.create("i", {
33637
33649
  "data-element": "send",
33638
33650
  class: "fa-solid fa-microphone-lines mic",
@@ -33669,10 +33681,59 @@ System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/core/di
33669
33681
  extra
33670
33682
  }) {
33671
33683
  return __awaiter(this, void 0, void 0, function* () {
33672
- if (extra.insert) {}
33673
- this.addFiles(...files);
33684
+ if (extra.stream) {
33685
+ yield this.streamFiles({
33686
+ files,
33687
+ extra
33688
+ });
33689
+ return;
33690
+ }
33691
+ const size = files.reduce((pv, cv) => pv + cv.file.size, 0);
33692
+ if (size > 20 * 1024 * 1024) {
33693
+ if (!extra.stream) {
33694
+ throw new Error(`Total size of attachments cannot be more than 20MB.`);
33695
+ }
33696
+ }
33697
+ if (extra.insert) {
33698
+ this.ensureDraft();
33699
+ const firstChild = this.editor.editor.firstElementChild;
33700
+ for (const iterator of files) {
33701
+ if (/^image\//.test(iterator.contentType)) {
33702
+ const af = this.createAppFile(iterator);
33703
+ const img = firstChild.ownerDocument.createElement("img");
33704
+ img.src = iterator.url;
33705
+ img.setAttribute("data-content-id", af.contentID);
33706
+ this.draft.attachments.add(af);
33707
+ firstChild.appendChild(img);
33708
+ const newLine = document.createElement("div");
33709
+ newLine.appendChild(document.createElement("br"));
33710
+ firstChild.appendChild(newLine);
33711
+ continue;
33712
+ }
33713
+ if (/^(video|audio)\//.test(iterator.contentType)) {
33714
+ const af = this.createAppFile(iterator);
33715
+ const img = firstChild.ownerDocument.createElement("video");
33716
+ img.src = iterator.url;
33717
+ img.setAttribute("data-content-id", af.contentID);
33718
+ this.draft.attachments.add(af);
33719
+ firstChild.appendChild(img);
33720
+ const newLine = document.createElement("div");
33721
+ newLine.appendChild(document.createElement("br"));
33722
+ firstChild.appendChild(newLine);
33723
+ continue;
33724
+ }
33725
+ }
33726
+ return;
33727
+ }
33728
+ yield this.addFiles(...files);
33674
33729
  });
33675
33730
  }
33731
+ streamFiles({
33732
+ files,
33733
+ extra
33734
+ }) {
33735
+ return __awaiter(this, void 0, void 0, function* () {});
33736
+ }
33676
33737
  deleteAttachment(file) {
33677
33738
  var _a;
33678
33739
  return __awaiter(this, void 0, void 0, function* () {
@@ -33680,12 +33741,16 @@ System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/core/di
33680
33741
  (_a = this.draft) === null || _a === void 0 ? void 0 : _a.attachments.remove(file);
33681
33742
  });
33682
33743
  }
33683
- refreshDraft() {
33684
- var _a;
33744
+ recreateDraft() {
33745
+ var _a, _b;
33746
+ var _c;
33685
33747
  return __awaiter(this, void 0, void 0, function* () {
33748
+ this.draft = null;
33686
33749
  (_a = this.draft) !== null && _a !== void 0 ? _a : this.draft = Email.create({
33750
+ subject: "",
33687
33751
  attachments: []
33688
33752
  });
33753
+ (_b = (_c = this.draft).attachments) !== null && _b !== void 0 ? _b : _c.attachments = [];
33689
33754
  });
33690
33755
  }
33691
33756
  onChanged() {
@@ -33743,35 +33808,40 @@ System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/core/di
33743
33808
  });
33744
33809
  }
33745
33810
  sendAudioMessage() {
33746
- var _a;
33747
33811
  return __awaiter(this, void 0, void 0, function* () {
33748
33812
  const uploadedFile = yield AudioRecorder.show();
33749
- (_a = this.draft) !== null && _a !== void 0 ? _a : this.draft = Email.create({
33750
- attachments: []
33751
- });
33813
+ this.ensureDraft();
33752
33814
  this.draft.mdBody = this.typedMessage;
33753
- this.addFiles(uploadedFile);
33815
+ yield this.addFiles(uploadedFile);
33754
33816
  yield this.save();
33755
33817
  });
33756
33818
  }
33757
33819
  addFiles(...files) {
33758
- var _a;
33759
- var _b;
33760
- const attachments = (_a = (_b = this.draft).attachments) !== null && _a !== void 0 ? _a : _b.attachments = [];
33761
- AtomBinder.refreshValue(this, "draft");
33762
- for (const {
33763
- appFileID,
33764
- url,
33765
- file
33766
- } of files) {
33767
- attachments.add(AppFile.create({
33768
- appFileID,
33769
- contentType: file.type,
33770
- name: file.name,
33771
- contentID: appFileID.toString(36),
33772
- url
33773
- }));
33774
- }
33820
+ return __awaiter(this, void 0, void 0, function* () {
33821
+ this.ensureDraft();
33822
+ const attachments = this.draft.attachments;
33823
+ for (const file of files) {
33824
+ attachments.add(this.createAppFile(file));
33825
+ }
33826
+ });
33827
+ }
33828
+ createAppFile(file) {
33829
+ return AppFile.create({
33830
+ appFileID: file.appFileID,
33831
+ contentType: file.file.type,
33832
+ name: file.file.name,
33833
+ contentID: file.appFileID.toString(36),
33834
+ url: file.url
33835
+ });
33836
+ }
33837
+ ensureDraft() {
33838
+ var _a, _b;
33839
+ var _c;
33840
+ (_a = this.draft) !== null && _a !== void 0 ? _a : this.draft = Email.create({
33841
+ subject: "",
33842
+ attachments: []
33843
+ });
33844
+ (_b = (_c = this.draft).attachments) !== null && _b !== void 0 ? _b : _c.attachments = [];
33775
33845
  }
33776
33846
  save() {
33777
33847
  return __awaiter(this, void 0, void 0, function* () {
@@ -33792,7 +33862,7 @@ System.register(["tslib", "@web-atoms/core/dist/core/XNode", "@web-atoms/core/di
33792
33862
  }), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], MiniComposeBox.prototype, "deleteAttachment", null);
33793
33863
  __decorate([Action({
33794
33864
  onEvent: CommonEvents.onDraftDeleted
33795
- }), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MiniComposeBox.prototype, "refreshDraft", null);
33865
+ }), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MiniComposeBox.prototype, "recreateDraft", null);
33796
33866
  __decorate([Action({
33797
33867
  onEvent: "input",
33798
33868
  defer: 500,
@@ -35754,6 +35824,9 @@ System.register(["../App", "../core/AtomOnce", "../core/AtomUri", "../di/Service
35754
35824
  this.url = new AtomUri(location.href);
35755
35825
  });
35756
35826
  });
35827
+ this.initPromise = new Promise((resolve, reject) => {
35828
+ this.onReady(resolve);
35829
+ });
35757
35830
  }
35758
35831
  updateDefaultStyle(textContent) {
35759
35832
  if (this.styleElement) {