diff options
author | Chocobozzz <me@florianbigard.com> | 2022-06-27 11:28:22 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-06-27 11:28:22 +0200 |
commit | 88edc66edadcab1b0372679e23bf2a7a6ff50131 (patch) | |
tree | f17c12cf95d47a96eadddef149c8ce3f23cce2aa | |
parent | 87fdea2fbf486f056dd24bfd416841813bd41c58 (diff) | |
download | PeerTube-88edc66edadcab1b0372679e23bf2a7a6ff50131.tar.gz PeerTube-88edc66edadcab1b0372679e23bf2a7a6ff50131.tar.zst PeerTube-88edc66edadcab1b0372679e23bf2a7a6ff50131.zip |
Optimize emoji markup list
-rw-r--r-- | client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html | 4 | ||||
-rw-r--r-- | client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts | 32 |
2 files changed, 18 insertions, 18 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html index 135dc8b6e..6bc201f32 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html | |||
@@ -88,8 +88,8 @@ | |||
88 | </div> | 88 | </div> |
89 | <div class="modal-body"> | 89 | <div class="modal-body"> |
90 | <div class="emoji-flex"> | 90 | <div class="emoji-flex"> |
91 | <div class="emoji-flex-item" *ngFor="let emojiMarkup of emojiMarkupList"> | 91 | <div class="emoji-flex-item" *ngFor="let emojiMarkup of getEmojiMarkupList()"> |
92 | {{ emojiMarkup[0] }} <code>:{{ emojiMarkup[1] }}:</code> | 92 | {{ emojiMarkup.emoji }} <code>:{{ emojiMarkup.name }}:</code> |
93 | </div> | 93 | </div> |
94 | </div> | 94 | </div> |
95 | </div> | 95 | </div> |
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts index 6e7f434b3..fd3614297 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts | |||
@@ -45,6 +45,8 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, | |||
45 | addingComment = false | 45 | addingComment = false |
46 | addingCommentButtonValue: string | 46 | addingCommentButtonValue: string |
47 | 47 | ||
48 | private emojiMarkupList: { emoji: string, name: string }[] | ||
49 | |||
48 | constructor ( | 50 | constructor ( |
49 | protected formValidatorService: FormValidatorService, | 51 | protected formValidatorService: FormValidatorService, |
50 | private notifier: Notifier, | 52 | private notifier: Notifier, |
@@ -56,22 +58,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, | |||
56 | super() | 58 | super() |
57 | } | 59 | } |
58 | 60 | ||
59 | get emojiMarkupList () { | ||
60 | console.log('hi') | ||
61 | const emojiMarkupObjectList = require('markdown-it-emoji/lib/data/light.json') | ||
62 | |||
63 | // Populate emoji-markup-list from object to array to avoid keys alphabetical order | ||
64 | const emojiMarkupArrayList = [] | ||
65 | for (const emojiMarkupName in emojiMarkupObjectList) { | ||
66 | if (emojiMarkupName) { | ||
67 | const emoji = emojiMarkupObjectList[emojiMarkupName] | ||
68 | emojiMarkupArrayList.push([ emoji, emojiMarkupName ]) | ||
69 | } | ||
70 | } | ||
71 | |||
72 | return emojiMarkupArrayList | ||
73 | } | ||
74 | |||
75 | ngOnInit () { | 61 | ngOnInit () { |
76 | this.buildForm({ | 62 | this.buildForm({ |
77 | text: VIDEO_COMMENT_TEXT_VALIDATOR | 63 | text: VIDEO_COMMENT_TEXT_VALIDATOR |
@@ -97,6 +83,20 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, | |||
97 | } | 83 | } |
98 | } | 84 | } |
99 | 85 | ||
86 | getEmojiMarkupList () { | ||
87 | if (this.emojiMarkupList) return this.emojiMarkupList | ||
88 | |||
89 | const emojiMarkupObjectList = require('markdown-it-emoji/lib/data/light.json') | ||
90 | |||
91 | this.emojiMarkupList = [] | ||
92 | for (const name of Object.keys(emojiMarkupObjectList)) { | ||
93 | const emoji = emojiMarkupObjectList[name] | ||
94 | this.emojiMarkupList.push({ emoji, name }) | ||
95 | } | ||
96 | |||
97 | return this.emojiMarkupList | ||
98 | } | ||
99 | |||
100 | onValidKey () { | 100 | onValidKey () { |
101 | this.forceCheck() | 101 | this.forceCheck() |
102 | if (!this.form.valid) return | 102 | if (!this.form.valid) return |