@cloudflare/realtimekit-ui 1.1.0-staging.7 → 1.1.0-staging.9

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.
@@ -70,12 +70,18 @@ export class RtkPaginatedList {
70
70
  * @param {DataNode} node - The data node to add to the beginning of the list
71
71
  */
72
72
  async onNewNode(node) {
73
- // if there are no pages, load the first page
73
+ // if there are no pages, append to the first page
74
74
  if (this.pages.length < 1) {
75
- this.oldTS = node.timeMs + 1;
76
- this.loadPrevPage();
75
+ this.oldTS = node.timeMs;
76
+ this.pages.unshift([node]);
77
+ this.newTS = node.timeMs;
78
+ this.maxTS = node.timeMs;
79
+ this.rerender();
80
+ if (this.autoScroll)
81
+ this.$bottomRef.scrollIntoView({ behavior: 'smooth' });
77
82
  }
78
- else {
83
+ else if (this.maxTS === this.newTS) {
84
+ this.maxTS = node.timeMs;
79
85
  // append messages to the page if page has not reached full capacity
80
86
  if (this.pages[0].length < this.pageSize) {
81
87
  this.pages[0].unshift(node);
@@ -84,14 +90,25 @@ export class RtkPaginatedList {
84
90
  }
85
91
  else {
86
92
  // if page is at full capacity, load next page
87
- this.loadNextPage();
93
+ this.pages.unshift([node]);
94
+ this.newTS = node.timeMs;
95
+ // remove pages if out of bounds
96
+ if (this.pages.length > this.pagesAllowed)
97
+ this.pages.pop();
98
+ // update timestamps
99
+ const lastPage = this.pages[this.pages.length - 1];
100
+ this.oldTS = lastPage[lastPage.length - 1].timeMs;
101
+ this.newTS = this.pages[0][0].timeMs;
102
+ this.rerender();
88
103
  }
104
+ if (this.autoScroll)
105
+ this.$bottomRef.scrollIntoView({ behavior: 'smooth' });
89
106
  }
90
- // If autoscroll is enabled, scroll to the bottom
91
- if (this.autoScroll) {
92
- this.shouldScrollToBottom = true;
93
- this.scrollToBottom();
107
+ else {
108
+ if (this.autoScroll)
109
+ this.scrollToBottom();
94
110
  }
111
+ this.pendingScrollAnchor = null;
95
112
  }
96
113
  /**
97
114
  * Deletes a node anywhere from the list
@@ -99,7 +116,6 @@ export class RtkPaginatedList {
99
116
  * */
100
117
  async onNodeDelete(id) {
101
118
  var _a, _b;
102
- let didDelete = false;
103
119
  for (let i = this.pages.length - 1; i >= 0; i--) {
104
120
  const index = this.pages[i].findIndex((node) => node.id === id);
105
121
  // if message not found, move on
@@ -110,24 +126,35 @@ export class RtkPaginatedList {
110
126
  // if page is empty, delete it
111
127
  if (this.pages[i].length === 0)
112
128
  this.pages.splice(i, 1);
113
- didDelete = true;
129
+ // update timestamps
130
+ const firstPage = this.pages[0];
131
+ const lastPage = this.pages[this.pages.length - 1];
132
+ this.newTS = (_a = firstPage === null || firstPage === void 0 ? void 0 : firstPage[0]) === null || _a === void 0 ? void 0 : _a.timeMs;
133
+ this.oldTS = (_b = lastPage === null || lastPage === void 0 ? void 0 : lastPage[lastPage.length - 1]) === null || _b === void 0 ? void 0 : _b.timeMs;
134
+ // if I have deleted the latest message, update maxTS
135
+ if (index === 0 && i === 0)
136
+ this.maxTS = this.newTS;
137
+ this.rerender();
114
138
  break;
115
139
  }
116
- if (!didDelete)
117
- return;
118
- // update timestamps
119
- const firstPage = this.pages[0];
120
- const lastPage = this.pages[this.pages.length - 1];
121
- this.newTS = (_a = firstPage === null || firstPage === void 0 ? void 0 : firstPage[0]) === null || _a === void 0 ? void 0 : _a.timeMs;
122
- this.oldTS = (_b = lastPage === null || lastPage === void 0 ? void 0 : lastPage[lastPage.length - 1]) === null || _b === void 0 ? void 0 : _b.timeMs;
123
- this.rerender();
124
140
  }
125
141
  /**
126
142
  * Updates a new node anywhere in the list
127
- * @param {string} _id - The id of the node to update
128
- * @param {DataNode} _node - The updated data node
143
+ * @param {string} id - The id of the node to update
144
+ * @param {DataNode} node - The updated data node
129
145
  * */
130
- async onNodeUpdate(_id, _node) { }
146
+ async onNodeUpdate(id, node) {
147
+ for (let i = this.pages.length - 1; i >= 0; i--) {
148
+ const index = this.pages[i].findIndex((node) => node.id === id);
149
+ // if message not found, move on
150
+ if (index === -1)
151
+ continue;
152
+ // edit message
153
+ this.pages[i][index] = node;
154
+ this.rerender();
155
+ break;
156
+ }
157
+ }
131
158
  connectedCallback() {
132
159
  this.rerender = debounce(this.rerender.bind(this), 50, { maxWait: 200 });
133
160
  }
@@ -136,6 +163,10 @@ export class RtkPaginatedList {
136
163
  this.loadPrevPage();
137
164
  if (this.$containerRef) {
138
165
  this.$containerRef.onscrollend = async () => {
166
+ // do not do anything if we are scrolling to bottom
167
+ if (this.shouldScrollToBottom)
168
+ return;
169
+ // handle top and bottom scroll
139
170
  if (this.isInView(this.$bottomRef)) {
140
171
  await this.loadNextPage();
141
172
  }
@@ -178,6 +209,8 @@ export class RtkPaginatedList {
178
209
  const lastPage = this.pages[this.pages.length - 1];
179
210
  this.oldTS = lastPage[lastPage.length - 1].timeMs;
180
211
  this.newTS = this.pages[0][0].timeMs;
212
+ if (!this.maxTS)
213
+ this.maxTS = this.newTS;
181
214
  this.rerender();
182
215
  // fix scroll position
183
216
  if (scrollAnchor)
@@ -185,53 +218,47 @@ export class RtkPaginatedList {
185
218
  }
186
219
  async loadNextPage() {
187
220
  if (this.isLoading)
188
- return;
221
+ return [];
189
222
  // Do nothing. New timestamp needs to be assigned by loadPrevPage method
190
223
  if (!this.newTS) {
191
224
  this.showNewMessagesCTR = false;
192
- this.shouldScrollToBottom = false;
193
- return;
225
+ return [];
194
226
  }
195
- // for autoscroll or scroll to bottom button
196
- const maxAutoLoads = 200;
197
- let loads = 0;
198
- let prevNewTS = this.newTS;
199
227
  this.isLoading = true;
200
228
  this.isLoadingBottom = true;
201
- while (loads < maxAutoLoads) {
202
- const scrollAnchor = this.getScrollAnchor('bottom');
203
- const data = await this.fetchData(this.newTS + 1, this.pageSize, false);
204
- this.isLoading = false;
205
- this.isLoadingBottom = false;
206
- // no more new messages to load
207
- if (!data.length) {
208
- this.showNewMessagesCTR = false;
209
- this.shouldScrollToBottom = false;
210
- break;
211
- }
212
- // load new messages and append to the start
213
- this.pages.unshift(data.reverse());
214
- // remove pages if out of bounds
215
- if (this.pages.length > this.pagesAllowed)
216
- this.pages.pop();
217
- // update timestamps
218
- const lastPage = this.pages[this.pages.length - 1];
219
- this.oldTS = lastPage[lastPage.length - 1].timeMs;
220
- this.newTS = this.pages[0][0].timeMs;
221
- this.rerender();
222
- this.pendingScrollAnchor = scrollAnchor;
223
- if (!this.shouldScrollToBottom)
224
- break;
225
- // if should scroll to bottom then retrigger
226
- await this.waitForNextFrame();
227
- this.scrollToBottom();
228
- await this.waitForNextFrame();
229
- // if no new messages, break
230
- if (this.newTS === prevNewTS)
231
- break;
232
- prevNewTS = this.newTS;
233
- loads++;
229
+ const scrollAnchor = this.getScrollAnchor('bottom');
230
+ const data = await this.fetchData(this.newTS + 1, this.pageSize, false);
231
+ this.isLoading = false;
232
+ this.isLoadingBottom = false;
233
+ // no more new messages to load
234
+ if (!data.length) {
235
+ this.maxTS = this.newTS;
236
+ this.showNewMessagesCTR = false;
237
+ return [];
238
+ }
239
+ // load new messages and append to the start
240
+ const incoming = [...data].reverse();
241
+ if (this.pages.length === 0)
242
+ this.pages.unshift([]);
243
+ const firstPage = this.pages[0];
244
+ const spaceInFirstPage = this.pageSize - firstPage.length;
245
+ if (spaceInFirstPage > 0) {
246
+ const toFill = incoming.splice(0, spaceInFirstPage);
247
+ firstPage.unshift(...toFill);
234
248
  }
249
+ while (incoming.length > 0) {
250
+ this.pages.unshift(incoming.splice(0, this.pageSize));
251
+ }
252
+ // remove pages if out of bounds
253
+ if (this.pages.length > this.pagesAllowed)
254
+ this.pages.pop();
255
+ // update timestamps
256
+ const lastPage = this.pages[this.pages.length - 1];
257
+ this.oldTS = lastPage[lastPage.length - 1].timeMs;
258
+ this.newTS = this.pages[0][0].timeMs;
259
+ this.rerender();
260
+ this.pendingScrollAnchor = scrollAnchor;
261
+ return data;
235
262
  }
236
263
  // Find the element that is closest to the top/bottom of the container
237
264
  getScrollAnchor(edge = 'top') {
@@ -287,11 +314,14 @@ export class RtkPaginatedList {
287
314
  }
288
315
  }
289
316
  // this method is called recursively based on shouldScrollToBottom (see loadNextPage)
290
- scrollToBottom() {
291
- this.$bottomRef.scrollIntoView({ behavior: 'smooth' });
292
- }
293
- waitForNextFrame() {
294
- return new Promise((resolve) => requestAnimationFrame(() => resolve()));
317
+ async scrollToBottom() {
318
+ this.shouldScrollToBottom = true;
319
+ while (this.shouldScrollToBottom) {
320
+ const response = await this.loadNextPage();
321
+ this.$bottomRef.scrollIntoView({ behavior: 'smooth' });
322
+ if (response.length === 0)
323
+ this.shouldScrollToBottom = false;
324
+ }
295
325
  }
296
326
  rerender() {
297
327
  this.rerenderBoolean = !this.rerenderBoolean;
@@ -300,10 +330,9 @@ export class RtkPaginatedList {
300
330
  /**
301
331
  * div.container is flex=column-reversewhich is why div#bottom-scroll comes before div#top-scroll
302
332
  */
303
- return (h(Host, { key: 'e0f806cccdcba162d0c834476863b34630cb1a1e' }, h("div", { key: '6d54d50ed703a59df8d26399499533e3cb0d70fe', class: "scrollbar container", part: "container", ref: (el) => (this.$containerRef = el) }, h("div", { key: '4e9fcbed725fb55d9fbb67eca94b0e770662d51b', class: { 'show-new-messages-ctr': true, active: this.showNewMessagesCTR } }, h("rtk-button", { key: '7db0236d35db3fb9856fea7a4f62c1fbd421829e', class: "show-new-messages", kind: "icon", variant: "secondary", part: "show-new-messages", onClick: () => {
304
- this.shouldScrollToBottom = true;
333
+ return (h(Host, { key: '3e7a77a4254ea0c75513edeaf72a5a77cee0e913' }, h("div", { key: 'f61e72e7a447048fe17ed8321a077841f991bfc5', class: "scrollbar container", part: "container", ref: (el) => (this.$containerRef = el) }, h("div", { key: '9efd0543b48b5ad5e147a763d258f7ef1a5024c5', class: { 'show-new-messages-ctr': true, active: this.showNewMessagesCTR } }, h("rtk-button", { key: '4b9bfda38538ceb89f31f317ddcb15d24f75ae8e', class: "show-new-messages", kind: "icon", variant: "secondary", part: "show-new-messages", onClick: () => {
305
334
  this.scrollToBottom();
306
- } }, h("rtk-icon", { key: '6e247e86029560601080e0b4d6dcfccbd90fcdd6', icon: this.iconPack.chevron_down }))), h("div", { key: '01d1ba7eacc67ece70b805fb2dfb493cdf1c9d23', class: "smallest-dom-element", id: "bottom-scroll", ref: (el) => (this.$bottomRef = el) }), this.isLoadingBottom && this.pages.length > 0 && h("rtk-spinner", { key: '24391bfc34914675cbfd0c287332bfdf3f5f5000', size: "sm" }), this.isLoading && this.pages.length < 1 && h("rtk-spinner", { key: 'e6c2cb44fce52ca54c9f1e543d91a29648745408', size: "lg" }), !this.isLoading && this.pages.flat().length === 0 ? (h("div", { class: "empty-list" }, this.t('list.empty'))) : (h("div", { class: "page-wrapper" }, this.pages.map((page, pageIndex) => (h("div", { class: "page", "data-page-index": pageIndex }, this.createNodes([...page].reverse())))))), this.isLoadingTop && this.pages.length > 0 && h("rtk-spinner", { key: 'd90a15494bcd7ec6c9c7ffc5e9a55054252a4258', size: "sm" }), h("div", { key: '2a65f98c3c4e6f2510c6cf1b4e2bcf1e607a7552', class: "smallest-dom-element", id: "top-scroll", ref: (el) => (this.$topRef = el) }))));
335
+ } }, h("rtk-icon", { key: 'fbcbc895940c8046916a2382806fb403e83a0a53', icon: this.iconPack.chevron_down }))), h("div", { key: 'fe2e51385216cba1905c75db783f037953e4831e', class: "smallest-dom-element", id: "bottom-scroll", ref: (el) => (this.$bottomRef = el) }), this.isLoadingBottom && this.pages.length > 0 && h("rtk-spinner", { key: '548899e797bbf139526208df3c7696b5859cc884', size: "sm" }), this.isLoading && this.pages.length < 1 && h("rtk-spinner", { key: '6353d5970e284369c274c28fc3c774d03fd555cc', size: "lg" }), !this.isLoading && this.pages.flat().length === 0 ? (h("div", { class: "empty-list" }, this.t('list.empty'))) : (h("div", { class: "page-wrapper" }, this.pages.map((page, pageIndex) => (h("div", { class: "page", "data-page-index": pageIndex }, this.createNodes([...page].reverse())))))), this.isLoadingTop && this.pages.length > 0 && h("rtk-spinner", { key: 'ff7b4e80f27610c0b73b63ea32fa5331b0cf4630', size: "sm" }), h("div", { key: '8729bf082cde39f7b154fa5816a70b6fb2c7f7df', class: "smallest-dom-element", id: "top-scroll", ref: (el) => (this.$topRef = el) }))));
307
336
  }
308
337
  static get is() { return "rtk-paginated-list"; }
309
338
  static get encapsulation() { return "shadow"; }
@@ -576,13 +605,13 @@ export class RtkPaginatedList {
576
605
  },
577
606
  "onNodeUpdate": {
578
607
  "complexType": {
579
- "signature": "(_id: string, _node: DataNode) => Promise<void>",
608
+ "signature": "(id: string, node: DataNode) => Promise<void>",
580
609
  "parameters": [{
581
- "name": "_id",
610
+ "name": "id",
582
611
  "type": "string",
583
612
  "docs": "- The id of the node to update"
584
613
  }, {
585
- "name": "_node",
614
+ "name": "node",
586
615
  "type": "DataNode",
587
616
  "docs": "- The updated data node"
588
617
  }],
@@ -603,10 +632,10 @@ export class RtkPaginatedList {
603
632
  "text": "Updates a new node anywhere in the list",
604
633
  "tags": [{
605
634
  "name": "param",
606
- "text": "_id - The id of the node to update"
635
+ "text": "id - The id of the node to update"
607
636
  }, {
608
637
  "name": "param",
609
- "text": "_node - The updated data node"
638
+ "text": "node - The updated data node"
610
639
  }]
611
640
  }
612
641
  }
@@ -7,7 +7,7 @@ import { d as defineCustomElement$m } from './p-241a8245.js';
7
7
  import { d as defineCustomElement$l } from './p-1391bef0.js';
8
8
  import { d as defineCustomElement$k } from './p-a73665b4.js';
9
9
  import { d as defineCustomElement$j } from './p-28170a8d.js';
10
- import { d as defineCustomElement$i } from './p-7be71567.js';
10
+ import { d as defineCustomElement$i } from './p-c0db1a83.js';
11
11
  import { d as defineCustomElement$h } from './p-1f5a4682.js';
12
12
  import { d as defineCustomElement$g } from './p-598dc3f2.js';
13
13
  import { d as defineCustomElement$f } from './p-0e5cc539.js';
@@ -20,7 +20,7 @@ import { d as defineCustomElement$9 } from './p-2447a26f.js';
20
20
  import { d as defineCustomElement$8 } from './p-819cb785.js';
21
21
  import { d as defineCustomElement$7 } from './p-7148ec6a.js';
22
22
  import { d as defineCustomElement$6 } from './p-0f2de0f8.js';
23
- import { d as defineCustomElement$5 } from './p-7f8d9afc.js';
23
+ import { d as defineCustomElement$5 } from './p-fbc02b1f.js';
24
24
  import { d as defineCustomElement$4 } from './p-4ebf9684.js';
25
25
  import { d as defineCustomElement$3 } from './p-4902c5cf.js';
26
26
  import { d as defineCustomElement$2 } from './p-6739a399.js';
@@ -306,6 +306,13 @@ const RtkChat = /*@__PURE__*/ proxyCustomElement(class RtkChat extends H {
306
306
  const message = event.detail;
307
307
  this.meeting.chat.deleteMessage(message.id);
308
308
  };
309
+ this.onMessageEdit = (event) => {
310
+ const message = event.detail;
311
+ if (message.type !== 'text')
312
+ return;
313
+ this.replyMessage = null;
314
+ this.editingMessage = message;
315
+ };
309
316
  this.getPrivateChatRecipients = () => {
310
317
  const participants = this.getFilteredParticipants().map((participant) => {
311
318
  const key = generateChatGroupKey([participant.userId, this.meeting.self.userId]);
@@ -490,14 +497,21 @@ const RtkChat = /*@__PURE__*/ proxyCustomElement(class RtkChat extends H {
490
497
  const uiProps = { iconPack: this.iconPack, t: this.t, size: this.size };
491
498
  const message = this.editingMessage ? this.editingMessage.message : '';
492
499
  const quotedMessage = this.replyMessage ? this.replyMessage.message : '';
493
- return (h("rtk-chat-composer-view", Object.assign({ message: message, storageKey: (_a = this.selectedChannelId) !== null && _a !== void 0 ? _a : `draft-${this.selectedChannelId}`, quotedMessage: quotedMessage, isEditing: !!this.editingMessage, canSendTextMessage: this.isTextMessagingAllowed(), canSendFiles: this.isFileMessagingAllowed(), disableEmojiPicker: this.overrides.disableEmojiPicker, maxLength: this.meeting.chat.maxTextLimit, rateLimits: this.meeting.chat.rateLimits, inputTextPlaceholder: this.t('chat.message_placeholder'), onNewMessage: this.onNewMessageHandler, onEditMessage: this.onEditMessageHandler, onEditCancel: this.onEditCancel, onQuotedMessageDismiss: this.onQuotedMessageDismiss }, uiProps), h("slot", { name: "chat-addon", slot: "chat-addon" })));
500
+ const draftStorageKey = this.selectedChannelId
501
+ ? `rtk-chat-draft-${this.selectedChannelId}`
502
+ : 'rtk-chat-draft';
503
+ const editStorageKey = this.editingMessage
504
+ ? `rtk-chat-edit-${(_a = this.selectedChannelId) !== null && _a !== void 0 ? _a : 'no-channel'}-${this.editingMessage.id}`
505
+ : 'rtk-chat-edit';
506
+ const storageKey = this.editingMessage ? editStorageKey : draftStorageKey;
507
+ return (h("rtk-chat-composer-view", Object.assign({ message: message, storageKey: storageKey, quotedMessage: quotedMessage, isEditing: !!this.editingMessage, canSendTextMessage: this.isTextMessagingAllowed(), canSendFiles: this.isFileMessagingAllowed(), disableEmojiPicker: this.overrides.disableEmojiPicker, maxLength: this.meeting.chat.maxTextLimit, rateLimits: this.meeting.chat.rateLimits, inputTextPlaceholder: this.t('chat.message_placeholder'), onNewMessage: this.onNewMessageHandler, onEditMessage: this.onEditMessageHandler, onEditCancel: this.onEditCancel, onQuotedMessageDismiss: this.onQuotedMessageDismiss }, uiProps), h("slot", { name: "chat-addon", slot: "chat-addon" })));
494
508
  }
495
509
  render() {
496
510
  var _a;
497
511
  if (!this.meeting) {
498
512
  return null;
499
513
  }
500
- return (h(Host, null, h("div", { class: "chat-container" }, h("div", { class: "chat" }, this.isFileMessagingAllowed() && (h("div", { id: "dropzone", class: { active: this.dropzoneActivated }, part: "dropzone" }, h("rtk-icon", { icon: this.iconPack.attach }), h("p", null, this.t('chat.send_attachment')))), this.renderPinnedMessagesHeader(), this.isPrivateChatSupported() && (h("rtk-channel-selector-view", { channels: this.getPrivateChatRecipients(), selectedChannelId: ((_a = this.selectedParticipant) === null || _a === void 0 ? void 0 : _a.userId) || 'everyone', onChannelChange: this.updateRecipients, t: this.t, viewAs: "dropdown" })), h("rtk-chat-messages-ui-paginated", { meeting: this.meeting, onPinMessage: this.onPinMessage, onDeleteMessage: this.onDeleteMessage, size: this.size, iconPack: this.iconPack, t: this.t }), this.renderComposerUI()))));
514
+ return (h(Host, null, h("div", { class: "chat-container" }, h("div", { class: "chat" }, this.isFileMessagingAllowed() && (h("div", { id: "dropzone", class: { active: this.dropzoneActivated }, part: "dropzone" }, h("rtk-icon", { icon: this.iconPack.attach }), h("p", null, this.t('chat.send_attachment')))), this.renderPinnedMessagesHeader(), this.isPrivateChatSupported() && (h("rtk-channel-selector-view", { channels: this.getPrivateChatRecipients(), selectedChannelId: ((_a = this.selectedParticipant) === null || _a === void 0 ? void 0 : _a.userId) || 'everyone', onChannelChange: this.updateRecipients, t: this.t, viewAs: "dropdown" })), h("rtk-chat-messages-ui-paginated", { meeting: this.meeting, onPinMessage: this.onPinMessage, onEditMessage: this.onMessageEdit, onDeleteMessage: this.onDeleteMessage, size: this.size, iconPack: this.iconPack, t: this.t }), this.renderComposerUI()))));
501
515
  }
502
516
  get host() { return this; }
503
517
  static get watchers() { return {
@@ -11,7 +11,7 @@ import { d as defineCustomElement$7 } from './p-2447a26f.js';
11
11
  import { d as defineCustomElement$6 } from './p-819cb785.js';
12
12
  import { d as defineCustomElement$5 } from './p-7148ec6a.js';
13
13
  import { d as defineCustomElement$4 } from './p-0f2de0f8.js';
14
- import { d as defineCustomElement$3 } from './p-7f8d9afc.js';
14
+ import { d as defineCustomElement$3 } from './p-fbc02b1f.js';
15
15
  import { d as defineCustomElement$2 } from './p-4ebf9684.js';
16
16
  import { d as defineCustomElement$1 } from './p-6739a399.js';
17
17
 
@@ -35,6 +35,7 @@ const RtkChatMessagesUiPaginated = /*@__PURE__*/ proxyCustomElement(class RtkCha
35
35
  this.__attachShadow();
36
36
  this.editMessageInit = createEvent(this, "editMessageInit", 7);
37
37
  this.onPinMessage = createEvent(this, "pinMessage", 7);
38
+ this.onEditMessage = createEvent(this, "editMessage", 7);
38
39
  this.onDeleteMessage = createEvent(this, "deleteMessage", 7);
39
40
  this.stateUpdate = createEvent(this, "rtkStateUpdate", 7);
40
41
  /** Icon pack */
@@ -85,22 +86,18 @@ const RtkChatMessagesUiPaginated = /*@__PURE__*/ proxyCustomElement(class RtkCha
85
86
  };
86
87
  this.getMessageActions = (message) => {
87
88
  const actions = [];
88
- // const isSelf = this.meeting.self.userId === message.userId;
89
- // const chatMessagePermissions = this.meeting.self.permissions?.chatMessage;
90
- // const canEdit =
91
- // chatMessagePermissions === undefined
92
- // ? isSelf
93
- // : chatMessagePermissions.canEdit === 'ALL' ||
94
- // (chatMessagePermissions.canEdit === 'SELF' && isSelf);
95
- const canDelete = message.userId === this.meeting.self.userId;
96
- if (this.meeting.self.permissions.pinParticipant) {
89
+ const messageBelongsToSelf = message.userId === this.meeting.self.userId;
90
+ actions.push({
91
+ id: 'pin_message',
92
+ label: message.pinned ? this.t('unpin') : this.t('pin'),
93
+ icon: this.iconPack.pin,
94
+ });
95
+ if (messageBelongsToSelf) {
97
96
  actions.push({
98
- id: 'pin_message',
99
- label: message.pinned ? this.t('unpin') : this.t('pin'),
100
- icon: this.iconPack.pin,
97
+ id: 'edit_message',
98
+ label: this.t('chat.edit_msg'),
99
+ icon: this.iconPack.edit,
101
100
  });
102
- }
103
- if (canDelete) {
104
101
  actions.push({
105
102
  id: 'delete_message',
106
103
  label: this.t('chat.delete_msg'),
@@ -114,6 +111,9 @@ const RtkChatMessagesUiPaginated = /*@__PURE__*/ proxyCustomElement(class RtkCha
114
111
  case 'pin_message':
115
112
  this.onPinMessage.emit(message);
116
113
  break;
114
+ case 'edit_message':
115
+ this.onEditMessage.emit(message);
116
+ break;
117
117
  case 'delete_message':
118
118
  this.onDeleteMessage.emit(message);
119
119
  break;
@@ -190,7 +190,7 @@ const RtkChatMessagesUiPaginated = /*@__PURE__*/ proxyCustomElement(class RtkCha
190
190
  this.lastReadMessageIndex = -1;
191
191
  }
192
192
  render() {
193
- return (h(Host, { key: 'c710da6e2fda420146905a2ed75d3444dd6d2c0b' }, h("rtk-paginated-list", { key: '51a36437e38e9c0242cca34bfda39f6d8309bee3', ref: (el) => (this.$paginatedListRef = el), pageSize: this.pageSize, pagesAllowed: 3, fetchData: this.getChatMessages, createNodes: this.createChatNodes, selectedItemId: this.selectedChannelId, emptyListLabel: this.t('chat.empty_channel') }, h("slot", { key: '69b54a41263510b425ce3e39af055321c4e2deb8' }))));
193
+ return (h(Host, { key: '55b594d1fad2c164a70b71e297f63273ece0bc4f' }, h("rtk-paginated-list", { key: '1554ee896643feec72a02672f156f95c988813ce', ref: (el) => (this.$paginatedListRef = el), pageSize: this.pageSize, pagesAllowed: 3, fetchData: this.getChatMessages, createNodes: this.createChatNodes, selectedItemId: this.selectedChannelId, emptyListLabel: this.t('chat.empty_channel') }, h("slot", { key: '03aeb2069b87cb217b9759cabd3835c9bac81f11' }))));
194
194
  }
195
195
  get host() { return this; }
196
196
  static get watchers() { return {