Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
a5huynh committed May 1, 2022
2 parents e708c16 + 4779436 commit 4c8753c
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 113 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
releaseName: "App v__VERSION__"
tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
releaseName: "Spyglass v__VERSION__"
releaseBody: "See the assets to download this version and install."
releaseDraft: true
prerelease: false
87 changes: 42 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions crates/client/public/glue.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export async function onClearSearch(callback) {
await listen('clear_search', callback);
}

export async function onFocus(callback) {
await listen('focus_window', callback);
}

export async function searchDocs(lenses, query) {
return await invoke("search_docs", { lenses, query });
}
Expand All @@ -25,6 +29,6 @@ export async function openResult(url) {
return await invoke("open_result", { url });
}

export function resizeWindow(height) {
return invoke("resize_window", { height });
export async function resizeWindow(height) {
return await invoke("resize_window", { height });
}
26 changes: 26 additions & 0 deletions crates/client/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use js_sys::Date;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::spawn_local;
Expand All @@ -6,6 +7,7 @@ use yew::prelude::*;

use super::{clear_results, escape, open};
use crate::components::ResultListData;
use crate::constants;

pub fn handle_global_key_down(
event: &Event,
Expand Down Expand Up @@ -66,3 +68,27 @@ pub fn handle_global_key_down(
}
}
}

pub fn handle_query_change(
query: &str,
query_debounce: UseStateHandle<f64>,
node_ref: UseStateHandle<NodeRef>,
lens: UseStateHandle<Vec<String>>,
search_results: UseStateHandle<Vec<ResultListData>>,
selected_idx: UseStateHandle<usize>,
) {
// Was the last char typed > 1 sec ago?
let is_debounced = *query_debounce >= constants::DEBOUNCE_TIME_MS;

if is_debounced && query.len() >= constants::MIN_CHARS {
let el = node_ref.cast::<Element>().unwrap();
if query.starts_with(constants::LENS_SEARCH_PREFIX) {
// show lens search
super::show_lens_results(search_results, el, selected_idx, query.to_string());
} else {
super::show_doc_results(search_results, &lens, el, selected_idx, query.to_string());
}
}

query_debounce.set(Date::now());
}
Loading

0 comments on commit 4c8753c

Please sign in to comment.