@social-mail/social-mail-client 1.2.64 → 1.2.65

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.
@@ -1,10 +1,16 @@
1
1
  import InjectProperty from "@web-atoms/core/dist/core/InjectProperty";
2
2
  import { AtomControl } from "@web-atoms/core/dist/web/controls/AtomControl";
3
3
  import BlogService from "./BlogService";
4
+ import XNode from "@web-atoms/core/dist/core/XNode";
5
+ import { DateFormats } from "../../common/date/DateFormats";
6
+ import { renderMail } from "../../web/page/mails/service/ConversationService";
4
7
 
5
8
  const url = (window as any).pageUrl as URL;
6
9
 
7
- const {1: channelID = 1, 2: emailID = 1 } = /^\/channels\/(\d+)\/(\d+)\//.exec(url.pathname) ?? {} as any;
10
+ let {1: channelID = 1, 2: emailID = 82 } = /^\/channels\/([^\/]+)\/([^\/]+)\//.exec(url.pathname) ?? {} as any;
11
+
12
+ channelID = parseInt(channelID, 36);
13
+ emailID = parseInt(emailID, 36);
8
14
 
9
15
  export default class ChannelMessage extends AtomControl {
10
16
 
@@ -13,6 +19,18 @@ export default class ChannelMessage extends AtomControl {
13
19
 
14
20
  async init() {
15
21
  const { items: [ email ]} = await this.blogService.getEmails({ channelID, start: 0, size: 1, cancelToken: null});
22
+
23
+ this.renderer = <section data-element="blog-item">
24
+ <h4 data-element="title">
25
+ <label text={email.subject}/>
26
+ </h4>
27
+ <h6 data-element="date" text={DateFormats.relative.short(email.dateSent)}/>
28
+ <h6 text={email.senderName}/>
29
+ <section
30
+ data-element="content">
31
+ <section { ... renderMail({ email })}/>
32
+ </section>
33
+ </section>;
16
34
  }
17
35
 
18
36
  }
@@ -10,6 +10,7 @@ import { IMailbox, IEmail } from "../../model/model";
10
10
  import { renderMail } from "../../web/page/mails/service/ConversationService";
11
11
  import BlogService from "./BlogService";
12
12
  import { channelViewStyle } from "./channelViewStyle";
13
+ import { UrlService } from "./UrlService";
13
14
 
14
15
  export default class ChannelView extends AtomControl {
15
16
 
@@ -68,7 +69,7 @@ export default class ChannelView extends AtomControl {
68
69
  itemRenderer={(email: IEmail) => {
69
70
  return <section data-element="blog-item">
70
71
  <h4 data-element="title">
71
- <a href={`/channels/${this.channel.mailboxID}/${email.emailID}/${email.subject?.trim() ?? ""}`} text={email.subject}></a>
72
+ <a href={UrlService.toBlogUrl(channelID, email.emailID, email.subject)} text={email.subject}></a>
72
73
  </h4>
73
74
  <h6 data-element="date" text={DateFormats.relative.short(email.dateSent)}/>
74
75
  <h6 text={email.senderName}/>
@@ -0,0 +1,12 @@
1
+ export const UrlService = {
2
+
3
+ toBlogUrl: (channelID: number, emailID: number, subject: string ) => {
4
+ subject ||= "";
5
+ if(subject.length > 400) {
6
+ subject = subject.substring(0, 400);
7
+ }
8
+ subject = subject.replace(/[^\p{L}\p{N}]+/ug, "-");
9
+ subject = encodeURIComponent(subject).replace(/\%20/g, "-");
10
+ return `/channels/${Number(channelID).toString(36)}/${Number(emailID).toString(36)}/${subject}`;
11
+ }
12
+ };