@cloudflare/realtimekit-ui 1.1.0-staging.8 → 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.
- package/dist/browser.js +1 -1
- package/dist/cjs/rtk-avatar_24.cjs.entry.js +81 -67
- package/dist/collection/components/rtk-paginated-list/rtk-paginated-list.js +81 -67
- package/dist/components/{p-7e90e964.js → p-b64798ac.js} +2 -2
- package/dist/components/{p-9213c3fc.js → p-c0db1a83.js} +1 -1
- package/dist/components/{p-ad8282dc.js → p-fbc02b1f.js} +81 -67
- package/dist/components/rtk-chat-messages-ui-paginated.js +1 -1
- package/dist/components/rtk-chat-search-results.js +1 -1
- package/dist/components/rtk-chat.js +1 -1
- package/dist/components/rtk-meeting.js +3 -3
- package/dist/components/rtk-paginated-list.js +1 -1
- package/dist/docs/docs-components.json +1 -1
- package/dist/esm/loader.js +81 -67
- package/dist/esm/rtk-avatar_24.entry.js +81 -67
- package/dist/realtimekit-ui/{p-8f4f3160.entry.js → p-ea21ec0c.entry.js} +1 -1
- package/dist/realtimekit-ui/realtimekit-ui.esm.js +1 -1
- package/dist/types/components/rtk-paginated-list/rtk-paginated-list.d.ts +0 -1
- package/package.json +1 -1
|
@@ -2139,10 +2139,15 @@ const RtkPaginatedList = class {
|
|
|
2139
2139
|
* @param {DataNode} node - The data node to add to the beginning of the list
|
|
2140
2140
|
*/
|
|
2141
2141
|
async onNewNode(node) {
|
|
2142
|
-
// if there are no pages,
|
|
2142
|
+
// if there are no pages, append to the first page
|
|
2143
2143
|
if (this.pages.length < 1) {
|
|
2144
|
-
this.oldTS = node.timeMs
|
|
2145
|
-
this.
|
|
2144
|
+
this.oldTS = node.timeMs;
|
|
2145
|
+
this.pages.unshift([node]);
|
|
2146
|
+
this.newTS = node.timeMs;
|
|
2147
|
+
this.maxTS = node.timeMs;
|
|
2148
|
+
this.rerender();
|
|
2149
|
+
if (this.autoScroll)
|
|
2150
|
+
this.$bottomRef.scrollIntoView({ behavior: 'smooth' });
|
|
2146
2151
|
}
|
|
2147
2152
|
else if (this.maxTS === this.newTS) {
|
|
2148
2153
|
this.maxTS = node.timeMs;
|
|
@@ -2154,14 +2159,25 @@ const RtkPaginatedList = class {
|
|
|
2154
2159
|
}
|
|
2155
2160
|
else {
|
|
2156
2161
|
// if page is at full capacity, load next page
|
|
2157
|
-
this.
|
|
2162
|
+
this.pages.unshift([node]);
|
|
2163
|
+
this.newTS = node.timeMs;
|
|
2164
|
+
// remove pages if out of bounds
|
|
2165
|
+
if (this.pages.length > this.pagesAllowed)
|
|
2166
|
+
this.pages.pop();
|
|
2167
|
+
// update timestamps
|
|
2168
|
+
const lastPage = this.pages[this.pages.length - 1];
|
|
2169
|
+
this.oldTS = lastPage[lastPage.length - 1].timeMs;
|
|
2170
|
+
this.newTS = this.pages[0][0].timeMs;
|
|
2171
|
+
this.rerender();
|
|
2158
2172
|
}
|
|
2173
|
+
if (this.autoScroll)
|
|
2174
|
+
this.$bottomRef.scrollIntoView({ behavior: 'smooth' });
|
|
2159
2175
|
}
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
this.scrollToBottom();
|
|
2176
|
+
else {
|
|
2177
|
+
if (this.autoScroll)
|
|
2178
|
+
this.scrollToBottom();
|
|
2164
2179
|
}
|
|
2180
|
+
this.pendingScrollAnchor = null;
|
|
2165
2181
|
}
|
|
2166
2182
|
/**
|
|
2167
2183
|
* Deletes a node anywhere from the list
|
|
@@ -2169,7 +2185,6 @@ const RtkPaginatedList = class {
|
|
|
2169
2185
|
* */
|
|
2170
2186
|
async onNodeDelete(id) {
|
|
2171
2187
|
var _a, _b;
|
|
2172
|
-
let didDelete = false;
|
|
2173
2188
|
for (let i = this.pages.length - 1; i >= 0; i--) {
|
|
2174
2189
|
const index = this.pages[i].findIndex((node) => node.id === id);
|
|
2175
2190
|
// if message not found, move on
|
|
@@ -2180,17 +2195,17 @@ const RtkPaginatedList = class {
|
|
|
2180
2195
|
// if page is empty, delete it
|
|
2181
2196
|
if (this.pages[i].length === 0)
|
|
2182
2197
|
this.pages.splice(i, 1);
|
|
2183
|
-
|
|
2198
|
+
// update timestamps
|
|
2199
|
+
const firstPage = this.pages[0];
|
|
2200
|
+
const lastPage = this.pages[this.pages.length - 1];
|
|
2201
|
+
this.newTS = (_a = firstPage === null || firstPage === void 0 ? void 0 : firstPage[0]) === null || _a === void 0 ? void 0 : _a.timeMs;
|
|
2202
|
+
this.oldTS = (_b = lastPage === null || lastPage === void 0 ? void 0 : lastPage[lastPage.length - 1]) === null || _b === void 0 ? void 0 : _b.timeMs;
|
|
2203
|
+
// if I have deleted the latest message, update maxTS
|
|
2204
|
+
if (index === 0 && i === 0)
|
|
2205
|
+
this.maxTS = this.newTS;
|
|
2206
|
+
this.rerender();
|
|
2184
2207
|
break;
|
|
2185
2208
|
}
|
|
2186
|
-
if (!didDelete)
|
|
2187
|
-
return;
|
|
2188
|
-
// update timestamps
|
|
2189
|
-
const firstPage = this.pages[0];
|
|
2190
|
-
const lastPage = this.pages[this.pages.length - 1];
|
|
2191
|
-
this.newTS = (_a = firstPage === null || firstPage === void 0 ? void 0 : firstPage[0]) === null || _a === void 0 ? void 0 : _a.timeMs;
|
|
2192
|
-
this.oldTS = (_b = lastPage === null || lastPage === void 0 ? void 0 : lastPage[lastPage.length - 1]) === null || _b === void 0 ? void 0 : _b.timeMs;
|
|
2193
|
-
this.rerender();
|
|
2194
2209
|
}
|
|
2195
2210
|
/**
|
|
2196
2211
|
* Updates a new node anywhere in the list
|
|
@@ -2217,6 +2232,10 @@ const RtkPaginatedList = class {
|
|
|
2217
2232
|
this.loadPrevPage();
|
|
2218
2233
|
if (this.$containerRef) {
|
|
2219
2234
|
this.$containerRef.onscrollend = async () => {
|
|
2235
|
+
// do not do anything if we are scrolling to bottom
|
|
2236
|
+
if (this.shouldScrollToBottom)
|
|
2237
|
+
return;
|
|
2238
|
+
// handle top and bottom scroll
|
|
2220
2239
|
if (this.isInView(this.$bottomRef)) {
|
|
2221
2240
|
await this.loadNextPage();
|
|
2222
2241
|
}
|
|
@@ -2268,54 +2287,47 @@ const RtkPaginatedList = class {
|
|
|
2268
2287
|
}
|
|
2269
2288
|
async loadNextPage() {
|
|
2270
2289
|
if (this.isLoading)
|
|
2271
|
-
return;
|
|
2290
|
+
return [];
|
|
2272
2291
|
// Do nothing. New timestamp needs to be assigned by loadPrevPage method
|
|
2273
2292
|
if (!this.newTS) {
|
|
2274
2293
|
this.showNewMessagesCTR = false;
|
|
2275
|
-
|
|
2276
|
-
return;
|
|
2294
|
+
return [];
|
|
2277
2295
|
}
|
|
2278
|
-
// for autoscroll or scroll to bottom button
|
|
2279
|
-
const maxAutoLoads = 200;
|
|
2280
|
-
let loads = 0;
|
|
2281
|
-
let prevNewTS = this.newTS;
|
|
2282
2296
|
this.isLoading = true;
|
|
2283
2297
|
this.isLoadingBottom = true;
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
this.pages.unshift(
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
this.oldTS = lastPage[lastPage.length - 1].timeMs;
|
|
2304
|
-
this.newTS = this.pages[0][0].timeMs;
|
|
2305
|
-
this.rerender();
|
|
2306
|
-
this.pendingScrollAnchor = scrollAnchor;
|
|
2307
|
-
if (!this.shouldScrollToBottom)
|
|
2308
|
-
break;
|
|
2309
|
-
// if should scroll to bottom then retrigger
|
|
2310
|
-
await this.waitForNextFrame();
|
|
2311
|
-
this.scrollToBottom();
|
|
2312
|
-
await this.waitForNextFrame();
|
|
2313
|
-
// if no new messages, break
|
|
2314
|
-
if (this.newTS === prevNewTS)
|
|
2315
|
-
break;
|
|
2316
|
-
prevNewTS = this.newTS;
|
|
2317
|
-
loads++;
|
|
2298
|
+
const scrollAnchor = this.getScrollAnchor('bottom');
|
|
2299
|
+
const data = await this.fetchData(this.newTS + 1, this.pageSize, false);
|
|
2300
|
+
this.isLoading = false;
|
|
2301
|
+
this.isLoadingBottom = false;
|
|
2302
|
+
// no more new messages to load
|
|
2303
|
+
if (!data.length) {
|
|
2304
|
+
this.maxTS = this.newTS;
|
|
2305
|
+
this.showNewMessagesCTR = false;
|
|
2306
|
+
return [];
|
|
2307
|
+
}
|
|
2308
|
+
// load new messages and append to the start
|
|
2309
|
+
const incoming = [...data].reverse();
|
|
2310
|
+
if (this.pages.length === 0)
|
|
2311
|
+
this.pages.unshift([]);
|
|
2312
|
+
const firstPage = this.pages[0];
|
|
2313
|
+
const spaceInFirstPage = this.pageSize - firstPage.length;
|
|
2314
|
+
if (spaceInFirstPage > 0) {
|
|
2315
|
+
const toFill = incoming.splice(0, spaceInFirstPage);
|
|
2316
|
+
firstPage.unshift(...toFill);
|
|
2318
2317
|
}
|
|
2318
|
+
while (incoming.length > 0) {
|
|
2319
|
+
this.pages.unshift(incoming.splice(0, this.pageSize));
|
|
2320
|
+
}
|
|
2321
|
+
// remove pages if out of bounds
|
|
2322
|
+
if (this.pages.length > this.pagesAllowed)
|
|
2323
|
+
this.pages.pop();
|
|
2324
|
+
// update timestamps
|
|
2325
|
+
const lastPage = this.pages[this.pages.length - 1];
|
|
2326
|
+
this.oldTS = lastPage[lastPage.length - 1].timeMs;
|
|
2327
|
+
this.newTS = this.pages[0][0].timeMs;
|
|
2328
|
+
this.rerender();
|
|
2329
|
+
this.pendingScrollAnchor = scrollAnchor;
|
|
2330
|
+
return data;
|
|
2319
2331
|
}
|
|
2320
2332
|
// Find the element that is closest to the top/bottom of the container
|
|
2321
2333
|
getScrollAnchor(edge = 'top') {
|
|
@@ -2371,11 +2383,14 @@ const RtkPaginatedList = class {
|
|
|
2371
2383
|
}
|
|
2372
2384
|
}
|
|
2373
2385
|
// this method is called recursively based on shouldScrollToBottom (see loadNextPage)
|
|
2374
|
-
scrollToBottom() {
|
|
2375
|
-
this
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2386
|
+
async scrollToBottom() {
|
|
2387
|
+
this.shouldScrollToBottom = true;
|
|
2388
|
+
while (this.shouldScrollToBottom) {
|
|
2389
|
+
const response = await this.loadNextPage();
|
|
2390
|
+
this.$bottomRef.scrollIntoView({ behavior: 'smooth' });
|
|
2391
|
+
if (response.length === 0)
|
|
2392
|
+
this.shouldScrollToBottom = false;
|
|
2393
|
+
}
|
|
2379
2394
|
}
|
|
2380
2395
|
rerender() {
|
|
2381
2396
|
this.rerenderBoolean = !this.rerenderBoolean;
|
|
@@ -2384,10 +2399,9 @@ const RtkPaginatedList = class {
|
|
|
2384
2399
|
/**
|
|
2385
2400
|
* div.container is flex=column-reversewhich is why div#bottom-scroll comes before div#top-scroll
|
|
2386
2401
|
*/
|
|
2387
|
-
return (index$1.h(index$1.Host, { key: '
|
|
2388
|
-
this.shouldScrollToBottom = true;
|
|
2402
|
+
return (index$1.h(index$1.Host, { key: '3e7a77a4254ea0c75513edeaf72a5a77cee0e913' }, index$1.h("div", { key: 'f61e72e7a447048fe17ed8321a077841f991bfc5', class: "scrollbar container", part: "container", ref: (el) => (this.$containerRef = el) }, index$1.h("div", { key: '9efd0543b48b5ad5e147a763d258f7ef1a5024c5', class: { 'show-new-messages-ctr': true, active: this.showNewMessagesCTR } }, index$1.h("rtk-button", { key: '4b9bfda38538ceb89f31f317ddcb15d24f75ae8e', class: "show-new-messages", kind: "icon", variant: "secondary", part: "show-new-messages", onClick: () => {
|
|
2389
2403
|
this.scrollToBottom();
|
|
2390
|
-
} }, index$1.h("rtk-icon", { key: '
|
|
2404
|
+
} }, index$1.h("rtk-icon", { key: 'fbcbc895940c8046916a2382806fb403e83a0a53', icon: this.iconPack.chevron_down }))), index$1.h("div", { key: 'fe2e51385216cba1905c75db783f037953e4831e', class: "smallest-dom-element", id: "bottom-scroll", ref: (el) => (this.$bottomRef = el) }), this.isLoadingBottom && this.pages.length > 0 && index$1.h("rtk-spinner", { key: '548899e797bbf139526208df3c7696b5859cc884', size: "sm" }), this.isLoading && this.pages.length < 1 && index$1.h("rtk-spinner", { key: '6353d5970e284369c274c28fc3c774d03fd555cc', size: "lg" }), !this.isLoading && this.pages.flat().length === 0 ? (index$1.h("div", { class: "empty-list" }, this.t('list.empty'))) : (index$1.h("div", { class: "page-wrapper" }, this.pages.map((page, pageIndex) => (index$1.h("div", { class: "page", "data-page-index": pageIndex }, this.createNodes([...page].reverse())))))), this.isLoadingTop && this.pages.length > 0 && index$1.h("rtk-spinner", { key: 'ff7b4e80f27610c0b73b63ea32fa5331b0cf4630', size: "sm" }), index$1.h("div", { key: '8729bf082cde39f7b154fa5816a70b6fb2c7f7df', class: "smallest-dom-element", id: "top-scroll", ref: (el) => (this.$topRef = el) }))));
|
|
2391
2405
|
}
|
|
2392
2406
|
};
|
|
2393
2407
|
__decorate$2([
|
|
@@ -70,10 +70,15 @@ 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,
|
|
73
|
+
// if there are no pages, append to the first page
|
|
74
74
|
if (this.pages.length < 1) {
|
|
75
|
-
this.oldTS = node.timeMs
|
|
76
|
-
this.
|
|
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
83
|
else if (this.maxTS === this.newTS) {
|
|
79
84
|
this.maxTS = node.timeMs;
|
|
@@ -85,14 +90,25 @@ export class RtkPaginatedList {
|
|
|
85
90
|
}
|
|
86
91
|
else {
|
|
87
92
|
// if page is at full capacity, load next page
|
|
88
|
-
this.
|
|
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();
|
|
89
103
|
}
|
|
104
|
+
if (this.autoScroll)
|
|
105
|
+
this.$bottomRef.scrollIntoView({ behavior: 'smooth' });
|
|
90
106
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.scrollToBottom();
|
|
107
|
+
else {
|
|
108
|
+
if (this.autoScroll)
|
|
109
|
+
this.scrollToBottom();
|
|
95
110
|
}
|
|
111
|
+
this.pendingScrollAnchor = null;
|
|
96
112
|
}
|
|
97
113
|
/**
|
|
98
114
|
* Deletes a node anywhere from the list
|
|
@@ -100,7 +116,6 @@ export class RtkPaginatedList {
|
|
|
100
116
|
* */
|
|
101
117
|
async onNodeDelete(id) {
|
|
102
118
|
var _a, _b;
|
|
103
|
-
let didDelete = false;
|
|
104
119
|
for (let i = this.pages.length - 1; i >= 0; i--) {
|
|
105
120
|
const index = this.pages[i].findIndex((node) => node.id === id);
|
|
106
121
|
// if message not found, move on
|
|
@@ -111,17 +126,17 @@ export class RtkPaginatedList {
|
|
|
111
126
|
// if page is empty, delete it
|
|
112
127
|
if (this.pages[i].length === 0)
|
|
113
128
|
this.pages.splice(i, 1);
|
|
114
|
-
|
|
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();
|
|
115
138
|
break;
|
|
116
139
|
}
|
|
117
|
-
if (!didDelete)
|
|
118
|
-
return;
|
|
119
|
-
// update timestamps
|
|
120
|
-
const firstPage = this.pages[0];
|
|
121
|
-
const lastPage = this.pages[this.pages.length - 1];
|
|
122
|
-
this.newTS = (_a = firstPage === null || firstPage === void 0 ? void 0 : firstPage[0]) === null || _a === void 0 ? void 0 : _a.timeMs;
|
|
123
|
-
this.oldTS = (_b = lastPage === null || lastPage === void 0 ? void 0 : lastPage[lastPage.length - 1]) === null || _b === void 0 ? void 0 : _b.timeMs;
|
|
124
|
-
this.rerender();
|
|
125
140
|
}
|
|
126
141
|
/**
|
|
127
142
|
* Updates a new node anywhere in the list
|
|
@@ -148,6 +163,10 @@ export class RtkPaginatedList {
|
|
|
148
163
|
this.loadPrevPage();
|
|
149
164
|
if (this.$containerRef) {
|
|
150
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
|
|
151
170
|
if (this.isInView(this.$bottomRef)) {
|
|
152
171
|
await this.loadNextPage();
|
|
153
172
|
}
|
|
@@ -199,54 +218,47 @@ export class RtkPaginatedList {
|
|
|
199
218
|
}
|
|
200
219
|
async loadNextPage() {
|
|
201
220
|
if (this.isLoading)
|
|
202
|
-
return;
|
|
221
|
+
return [];
|
|
203
222
|
// Do nothing. New timestamp needs to be assigned by loadPrevPage method
|
|
204
223
|
if (!this.newTS) {
|
|
205
224
|
this.showNewMessagesCTR = false;
|
|
206
|
-
|
|
207
|
-
return;
|
|
225
|
+
return [];
|
|
208
226
|
}
|
|
209
|
-
// for autoscroll or scroll to bottom button
|
|
210
|
-
const maxAutoLoads = 200;
|
|
211
|
-
let loads = 0;
|
|
212
|
-
let prevNewTS = this.newTS;
|
|
213
227
|
this.isLoading = true;
|
|
214
228
|
this.isLoadingBottom = true;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.pages.unshift(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.oldTS = lastPage[lastPage.length - 1].timeMs;
|
|
235
|
-
this.newTS = this.pages[0][0].timeMs;
|
|
236
|
-
this.rerender();
|
|
237
|
-
this.pendingScrollAnchor = scrollAnchor;
|
|
238
|
-
if (!this.shouldScrollToBottom)
|
|
239
|
-
break;
|
|
240
|
-
// if should scroll to bottom then retrigger
|
|
241
|
-
await this.waitForNextFrame();
|
|
242
|
-
this.scrollToBottom();
|
|
243
|
-
await this.waitForNextFrame();
|
|
244
|
-
// if no new messages, break
|
|
245
|
-
if (this.newTS === prevNewTS)
|
|
246
|
-
break;
|
|
247
|
-
prevNewTS = this.newTS;
|
|
248
|
-
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);
|
|
249
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;
|
|
250
262
|
}
|
|
251
263
|
// Find the element that is closest to the top/bottom of the container
|
|
252
264
|
getScrollAnchor(edge = 'top') {
|
|
@@ -302,11 +314,14 @@ export class RtkPaginatedList {
|
|
|
302
314
|
}
|
|
303
315
|
}
|
|
304
316
|
// this method is called recursively based on shouldScrollToBottom (see loadNextPage)
|
|
305
|
-
scrollToBottom() {
|
|
306
|
-
this
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
+
}
|
|
310
325
|
}
|
|
311
326
|
rerender() {
|
|
312
327
|
this.rerenderBoolean = !this.rerenderBoolean;
|
|
@@ -315,10 +330,9 @@ export class RtkPaginatedList {
|
|
|
315
330
|
/**
|
|
316
331
|
* div.container is flex=column-reversewhich is why div#bottom-scroll comes before div#top-scroll
|
|
317
332
|
*/
|
|
318
|
-
return (h(Host, { key: '
|
|
319
|
-
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: () => {
|
|
320
334
|
this.scrollToBottom();
|
|
321
|
-
} }, h("rtk-icon", { key: '
|
|
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) }))));
|
|
322
336
|
}
|
|
323
337
|
static get is() { return "rtk-paginated-list"; }
|
|
324
338
|
static get encapsulation() { return "shadow"; }
|
|
@@ -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-
|
|
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-
|
|
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';
|
|
@@ -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-
|
|
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
|
|