feat: narrow a library page as the reader types in its search box
This commit is contained in:
parent
9d9f09ebc7
commit
95602ac623
5 changed files with 157 additions and 8 deletions
|
|
@ -254,6 +254,27 @@ class BrowserController {
|
|||
await _loadCurrent();
|
||||
}
|
||||
|
||||
/// Narrows the open page to what the reader has typed in a search box. The
|
||||
/// query rides in the address as it does when the box is submitted, but it
|
||||
/// replaces the step of the walk they are standing on instead of adding
|
||||
/// one, so a search of eight letters is one step back and not eight.
|
||||
///
|
||||
/// Only one of our own pages narrows this way. A form on a fetched page is
|
||||
/// sent when it is submitted, never while it is being filled in, and so is
|
||||
/// a form that changes something rather than going somewhere.
|
||||
Future<void> narrowWhileTyping(String action, Map<String, String> fields) async {
|
||||
if (!MewsUrls.isInternal(action) || MewsUrls.isAction(action)) return;
|
||||
if (_stackIndex < 0) return;
|
||||
final url = MewsUrls.page(Uri.parse(action), fields);
|
||||
if (url == _stack[_stackIndex]) return;
|
||||
// The page the reader was going to next belonged to the search they have
|
||||
// now changed, so it is dropped as it is on any other navigation.
|
||||
_stack.removeRange(_stackIndex + 1, _stack.length);
|
||||
_stack[_stackIndex] = url;
|
||||
_updateNeighbors();
|
||||
await _loadCurrent();
|
||||
}
|
||||
|
||||
Future<void> submitForm(String action, String method, Map<String, String> fields) async {
|
||||
// A form on one of our own pages is a navigation or an action, never a
|
||||
// network request; the fetch client cannot speak the mews scheme.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue