mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
draft suggestion autocomplete feature
This commit is contained in:
parent
1c4bde4004
commit
5b0de227c0
7 changed files with 201 additions and 4 deletions
|
|
@ -63,8 +63,13 @@ impl Bookmark {
|
|||
// Getters
|
||||
|
||||
/// Check `request` exists in the memory index
|
||||
pub fn contains_request(&self, request: &str) -> bool {
|
||||
self.memory.borrow_mut().contains_request(request)
|
||||
pub fn is_match_request(&self, request: &str) -> bool {
|
||||
self.memory.borrow_mut().is_match_request(request)
|
||||
}
|
||||
|
||||
/// Find Items match `request`
|
||||
pub fn contains_request(&self, request: &str, limit: Option<usize>) -> Vec<Item> {
|
||||
self.memory.borrow_mut().contains_request(request, limit)
|
||||
}
|
||||
|
||||
/// Get recent Items vector from `memory`, sorted by `ID` DESC
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ impl Memory {
|
|||
}
|
||||
|
||||
/// Check `request` exists in the memory index
|
||||
pub fn contains_request(&self, request: &str) -> bool {
|
||||
pub fn is_match_request(&self, request: &str) -> bool {
|
||||
for item in self.0.iter() {
|
||||
if item.request == request {
|
||||
return true;
|
||||
|
|
@ -39,6 +39,20 @@ impl Memory {
|
|||
false
|
||||
}
|
||||
|
||||
/// Get Items match `request`
|
||||
pub fn contains_request(&self, request: &str, limit: Option<usize>) -> Vec<Item> {
|
||||
let mut items: Vec<Item> = Vec::new();
|
||||
for (i, item) in self.0.iter().enumerate() {
|
||||
if limit.is_some_and(|l| i > l) {
|
||||
break;
|
||||
}
|
||||
if item.request.contains(request) {
|
||||
items.push(item.clone())
|
||||
}
|
||||
}
|
||||
items
|
||||
}
|
||||
|
||||
/// Get recent Items vector sorted by `ID` DESC
|
||||
pub fn recent(&self, limit: Option<usize>) -> Vec<Item> {
|
||||
let mut recent: Vec<Item> = Vec::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue