@shaxpir/duiduidui-models 1.9.29 → 1.9.30
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/models/Device.d.ts +4 -3
- package/dist/models/Device.js +34 -11
- package/package.json +1 -1
package/dist/models/Device.d.ts
CHANGED
|
@@ -89,11 +89,12 @@ export declare class Device extends Content {
|
|
|
89
89
|
get currentSearchState(): SearchState | undefined;
|
|
90
90
|
/**
|
|
91
91
|
* Returns true if back navigation is possible.
|
|
92
|
-
*
|
|
92
|
+
* Skips over empty entries to find a non-empty one.
|
|
93
93
|
*/
|
|
94
94
|
get canGoBack(): boolean;
|
|
95
95
|
/**
|
|
96
96
|
* Returns true if forward navigation is possible.
|
|
97
|
+
* Skips over empty entries to find a non-empty one.
|
|
97
98
|
*/
|
|
98
99
|
get canGoForward(): boolean;
|
|
99
100
|
/**
|
|
@@ -106,12 +107,12 @@ export declare class Device extends Content {
|
|
|
106
107
|
*/
|
|
107
108
|
pushSearchState(state: SearchState): SearchState | undefined;
|
|
108
109
|
/**
|
|
109
|
-
* Navigates back in search history.
|
|
110
|
+
* Navigates back in search history, skipping over empty entries.
|
|
110
111
|
* @returns The search state at the new cursor position, or undefined if can't go back
|
|
111
112
|
*/
|
|
112
113
|
goBack(): SearchState | undefined;
|
|
113
114
|
/**
|
|
114
|
-
* Navigates forward in search history.
|
|
115
|
+
* Navigates forward in search history, skipping over empty entries.
|
|
115
116
|
* @returns The search state at the new cursor position, or undefined if can't go forward
|
|
116
117
|
*/
|
|
117
118
|
goForward(): SearchState | undefined;
|
package/dist/models/Device.js
CHANGED
|
@@ -267,24 +267,33 @@ class Device extends Content_1.Content {
|
|
|
267
267
|
}
|
|
268
268
|
/**
|
|
269
269
|
* Returns true if back navigation is possible.
|
|
270
|
-
*
|
|
270
|
+
* Skips over empty entries to find a non-empty one.
|
|
271
271
|
*/
|
|
272
272
|
get canGoBack() {
|
|
273
273
|
this.checkDisposed("Device.canGoBack");
|
|
274
274
|
const history = this.searchHistory;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
275
|
+
// Look for any non-empty entry before the cursor
|
|
276
|
+
for (let i = history.cursor - 1; i >= 0; i--) {
|
|
277
|
+
if (!(0, SearchState_1.isEmptySearchState)(history.entries[i])) {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return false;
|
|
280
282
|
}
|
|
281
283
|
/**
|
|
282
284
|
* Returns true if forward navigation is possible.
|
|
285
|
+
* Skips over empty entries to find a non-empty one.
|
|
283
286
|
*/
|
|
284
287
|
get canGoForward() {
|
|
285
288
|
this.checkDisposed("Device.canGoForward");
|
|
286
289
|
const history = this.searchHistory;
|
|
287
|
-
|
|
290
|
+
// Look for any non-empty entry after the cursor
|
|
291
|
+
for (let i = history.cursor + 1; i < history.entries.length; i++) {
|
|
292
|
+
if (!(0, SearchState_1.isEmptySearchState)(history.entries[i])) {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return false;
|
|
288
297
|
}
|
|
289
298
|
/**
|
|
290
299
|
* Pushes a new search state onto the history stack.
|
|
@@ -328,7 +337,7 @@ class Device extends Content_1.Content {
|
|
|
328
337
|
return state;
|
|
329
338
|
}
|
|
330
339
|
/**
|
|
331
|
-
* Navigates back in search history.
|
|
340
|
+
* Navigates back in search history, skipping over empty entries.
|
|
332
341
|
* @returns The search state at the new cursor position, or undefined if can't go back
|
|
333
342
|
*/
|
|
334
343
|
goBack() {
|
|
@@ -337,14 +346,21 @@ class Device extends Content_1.Content {
|
|
|
337
346
|
return undefined;
|
|
338
347
|
}
|
|
339
348
|
const history = this.searchHistory;
|
|
340
|
-
|
|
349
|
+
// Find the first non-empty entry before the cursor
|
|
350
|
+
let newCursor = history.cursor - 1;
|
|
351
|
+
while (newCursor >= 0 && (0, SearchState_1.isEmptySearchState)(history.entries[newCursor])) {
|
|
352
|
+
newCursor--;
|
|
353
|
+
}
|
|
354
|
+
if (newCursor < 0) {
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
341
357
|
const batch = new Operation_1.BatchOperation(this);
|
|
342
358
|
batch.setPathValue(['payload', 'search_history', 'cursor'], newCursor);
|
|
343
359
|
batch.commit();
|
|
344
360
|
return history.entries[newCursor];
|
|
345
361
|
}
|
|
346
362
|
/**
|
|
347
|
-
* Navigates forward in search history.
|
|
363
|
+
* Navigates forward in search history, skipping over empty entries.
|
|
348
364
|
* @returns The search state at the new cursor position, or undefined if can't go forward
|
|
349
365
|
*/
|
|
350
366
|
goForward() {
|
|
@@ -353,7 +369,14 @@ class Device extends Content_1.Content {
|
|
|
353
369
|
return undefined;
|
|
354
370
|
}
|
|
355
371
|
const history = this.searchHistory;
|
|
356
|
-
|
|
372
|
+
// Find the first non-empty entry after the cursor
|
|
373
|
+
let newCursor = history.cursor + 1;
|
|
374
|
+
while (newCursor < history.entries.length && (0, SearchState_1.isEmptySearchState)(history.entries[newCursor])) {
|
|
375
|
+
newCursor++;
|
|
376
|
+
}
|
|
377
|
+
if (newCursor >= history.entries.length) {
|
|
378
|
+
return undefined;
|
|
379
|
+
}
|
|
357
380
|
const batch = new Operation_1.BatchOperation(this);
|
|
358
381
|
batch.setPathValue(['payload', 'search_history', 'cursor'], newCursor);
|
|
359
382
|
batch.commit();
|