Revert notification endpoint URL for dev

This commit is contained in:
Gregory Schier
2025-06-27 11:58:04 -07:00
parent bb0cc16a70
commit 25d50246c0
5 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -1302,7 +1302,7 @@ pub fn run() {
tokio::time::sleep(Duration::from_millis(4000)).await; tokio::time::sleep(Duration::from_millis(4000)).await;
let val: State<'_, Mutex<YaakNotifier>> = w.state(); let val: State<'_, Mutex<YaakNotifier>> = w.state();
let mut n = val.lock().await; let mut n = val.lock().await;
if let Err(e) = n.check(&w).await { if let Err(e) = n.maybe_check(&w).await {
warn!("Failed to check for notifications {}", e) warn!("Failed to check for notifications {}", e)
} }
}); });
+2 -2
View File
@@ -63,7 +63,7 @@ impl YaakNotifier {
Ok(()) Ok(())
} }
pub async fn check<R: Runtime>(&mut self, window: &WebviewWindow<R>) -> Result<()> { pub async fn maybe_check<R: Runtime>(&mut self, window: &WebviewWindow<R>) -> Result<()> {
let app_handle = window.app_handle(); let app_handle = window.app_handle();
let ignore_check = self.last_check.elapsed().unwrap().as_secs() < MAX_UPDATE_CHECK_SECONDS; let ignore_check = self.last_check.elapsed().unwrap().as_secs() < MAX_UPDATE_CHECK_SECONDS;
@@ -83,7 +83,7 @@ impl YaakNotifier {
let num_launches = get_num_launches(app_handle).await; let num_launches = get_num_launches(app_handle).await;
let info = app_handle.package_info().clone(); let info = app_handle.package_info().clone();
let req = yaak_api_client(app_handle)? let req = yaak_api_client(app_handle)?
.request(Method::GET, "http://localhost:9444/notifications") .request(Method::GET, "https://notify.yaak.app/notifications")
.query(&[ .query(&[
("version", info.version.to_string().as_str()), ("version", info.version.to_string().as_str()),
("launches", num_launches.to_string().as_str()), ("launches", num_launches.to_string().as_str()),
+1 -1
View File
@@ -22,7 +22,7 @@ impl<'a> DbContext<'a> {
let x = self.upsert_workspace(&v, source)?; let x = self.upsert_workspace(&v, source)?;
imported_resources.workspaces.push(x.clone()); imported_resources.workspaces.push(x.clone());
} }
info!("Upserted {} workspaces", imported_resources.environments.len()); info!("Upserted {} workspaces", imported_resources.workspaces.len());
} }
if http_requests.len() > 0 { if http_requests.len() > 0 {
+5 -5
View File
@@ -17,7 +17,7 @@ pub async fn get_plugin<R: Runtime>(
version: Option<String>, version: Option<String>,
) -> Result<PluginVersion> { ) -> Result<PluginVersion> {
info!("Getting plugin: {name} {version:?}"); info!("Getting plugin: {name} {version:?}");
let mut url = base_url(&format!("/{name}")); let mut url = build_url(&format!("/{name}"));
if let Some(version) = version { if let Some(version) = version {
let mut query_pairs = url.query_pairs_mut(); let mut query_pairs = url.query_pairs_mut();
query_pairs.append_pair("version", &version); query_pairs.append_pair("version", &version);
@@ -36,7 +36,7 @@ pub async fn download_plugin_archive<R: Runtime>(
let name = plugin_version.name.clone(); let name = plugin_version.name.clone();
let version = plugin_version.version.clone(); let version = plugin_version.version.clone();
info!("Downloading plugin: {name} {version}"); info!("Downloading plugin: {name} {version}");
let mut url = base_url(&format!("/{}/download", name)); let mut url = build_url(&format!("/{}/download", name));
{ {
let mut query_pairs = url.query_pairs_mut(); let mut query_pairs = url.query_pairs_mut();
query_pairs.append_pair("version", &version); query_pairs.append_pair("version", &version);
@@ -67,7 +67,7 @@ pub async fn check_plugin_updates<R: Runtime>(
}) })
.collect(); .collect();
let url = base_url("/updates"); let url = build_url("/updates");
let body = serde_json::to_vec(&PluginUpdatesResponse { let body = serde_json::to_vec(&PluginUpdatesResponse {
plugins: name_versions, plugins: name_versions,
})?; })?;
@@ -84,7 +84,7 @@ pub async fn search_plugins<R: Runtime>(
app_handle: &AppHandle<R>, app_handle: &AppHandle<R>,
query: &str, query: &str,
) -> Result<PluginSearchResponse> { ) -> Result<PluginSearchResponse> {
let mut url = base_url("/search"); let mut url = build_url("/search");
{ {
let mut query_pairs = url.query_pairs_mut(); let mut query_pairs = url.query_pairs_mut();
query_pairs.append_pair("query", query); query_pairs.append_pair("query", query);
@@ -93,7 +93,7 @@ pub async fn search_plugins<R: Runtime>(
Ok(resp.json().await?) Ok(resp.json().await?)
} }
fn base_url(path: &str) -> Url { fn build_url(path: &str) -> Url {
let base_url = if is_dev() { let base_url = if is_dev() {
"http://localhost:9444/api/v1/plugins" "http://localhost:9444/api/v1/plugins"
} else { } else {
@@ -2,7 +2,7 @@ import type { DecorationSet, ViewUpdate } from '@codemirror/view';
import { Decoration, EditorView, hoverTooltip, MatchDecorator, ViewPlugin } from '@codemirror/view'; import { Decoration, EditorView, hoverTooltip, MatchDecorator, ViewPlugin } from '@codemirror/view';
const REGEX = const REGEX =
/(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+*~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+*.~#?&/={}[\]]*))/g; /(https?:\/\/([-a-zA-Z0-9@:%._+*~#=]{1,256})+(\.[a-zA-Z0-9()]{1,6})?\b([-a-zA-Z0-9()@:%_+*.~#?&/={}[\]]*))/g;
const tooltip = hoverTooltip( const tooltip = hoverTooltip(
(view, pos, side) => { (view, pos, side) => {