mirror of
https://github.com/TxtDot/vigi.git
synced 2024-11-23 03:46:21 +03:00
fix: scroll to top when change input, update dependencies
This commit is contained in:
parent
a189ab1de6
commit
b821b2bb8b
9 changed files with 50 additions and 38 deletions
|
@ -14,7 +14,7 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^1",
|
||||
"@txtdot/dalet": "1.0.0-pre1"
|
||||
"@txtdot/dalet": "1.0.0-pre3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/svelte": "^4.0.2",
|
||||
|
|
23
src-tauri/Cargo.lock
generated
23
src-tauri/Cargo.lock
generated
|
@ -609,9 +609,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "dalet"
|
||||
version = "1.0.0-pre.10"
|
||||
version = "1.0.0-pre.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8cccea0b163fbc0bc06f125bf69dfff4518336b63b86462f8c711366eef9e3e3"
|
||||
checksum = "fcb1baee9a3c3f0f6aed8cb4cf29331717227cb92dd6204e2df963dd315d69c1"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"enum-procs",
|
||||
|
@ -656,6 +656,20 @@ dependencies = [
|
|||
"syn 2.0.72",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dashmap"
|
||||
version = "6.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
"hashbrown 0.14.5",
|
||||
"lock_api",
|
||||
"once_cell",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.3.11"
|
||||
|
@ -3724,12 +3738,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tokio-gemini"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bab37428a69ae0349cf6dd0182a6da06f065aa8c40ca18d9414a02e6fb49d875"
|
||||
checksum = "f7daf3995399caee7c8a2bd6de9e5f977443578b54130600f58a47409b90d360"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"bytes",
|
||||
"dashmap",
|
||||
"mime",
|
||||
"num_enum 0.7.3",
|
||||
"sha2",
|
||||
|
|
|
@ -26,7 +26,7 @@ tauri = { version = "1", features = [
|
|||
] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
dalet = "1.0.0-pre.10"
|
||||
dalet = "1.0.0-pre.12"
|
||||
|
||||
tokio = { version = "1.39.2", features = ["full"] }
|
||||
tokio-rustls = { version = "0.26.0", default-features = false, features = [
|
||||
|
@ -36,7 +36,7 @@ tokio-rustls = { version = "0.26.0", default-features = false, features = [
|
|||
bytes = "1.7.1"
|
||||
|
||||
reqwest = "0.12.5"
|
||||
tokio-gemini = "0.3.0"
|
||||
tokio-gemini = { version = "0.4.0", features = ["file-sscv"] }
|
||||
url = "2.5.2"
|
||||
mime = "0.3.17"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use bytes::Bytes;
|
||||
use dalet::{daletl::ToDaletlPage, parsers::gemtext::parse_gemtext, typed::Tag::*};
|
||||
use dalet::{daletl::DlPage, parsers::gemtext::parse_gemtext, typed::Tag::*};
|
||||
use mime::Mime;
|
||||
use std::str;
|
||||
|
||||
|
@ -23,19 +23,17 @@ async fn process_text(data: &str) -> VigiOutput {
|
|||
let mut truncated = data.to_owned();
|
||||
truncated.truncate(50);
|
||||
|
||||
VigiOutput::new(truncated, vec![El(data.into())].to_dl_page())
|
||||
VigiOutput::new(truncated, vec![El(data.into()).into()])
|
||||
}
|
||||
|
||||
async fn process_gemini(data: &str) -> Result<VigiOutput, VigiError> {
|
||||
let mut truncated = data.to_owned();
|
||||
truncated.truncate(50);
|
||||
|
||||
let res = VigiOutput::new(
|
||||
truncated,
|
||||
parse_gemtext(data)
|
||||
.map_err(|_| VigiError::Parse)?
|
||||
.to_dl_page(),
|
||||
);
|
||||
let page = parse_gemtext(data).map_err(|_| VigiError::Parse)?;
|
||||
let output = DlPage::from(page).data;
|
||||
|
||||
let res = VigiOutput::new(truncated, output);
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use dalet::daletl::{Tag, ToDaletlPage};
|
||||
use dalet::daletl::DlTag;
|
||||
use dalet::typed::Tag::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, fs, path::PathBuf};
|
||||
|
@ -41,18 +41,18 @@ pub struct VigiState {
|
|||
|
||||
// Temporary
|
||||
pub top_bar_input: String,
|
||||
pub current_data: Vec<Tag>,
|
||||
pub current_data: Vec<DlTag>,
|
||||
pub cached_inputs: HashMap<String, VigiOutput>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct VigiOutput {
|
||||
pub title: String,
|
||||
pub data: Vec<Tag>,
|
||||
pub data: Vec<DlTag>,
|
||||
}
|
||||
|
||||
impl VigiOutput {
|
||||
pub fn new(title: String, data: Vec<Tag>) -> Self {
|
||||
pub fn new(title: String, data: Vec<DlTag>) -> Self {
|
||||
Self { title, data }
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ pub struct VigiJsState {
|
|||
pub favorites_tabs: Vec<Tab>,
|
||||
|
||||
pub top_bar_input: String,
|
||||
pub current_data: Vec<Tag>,
|
||||
pub current_data: Vec<DlTag>,
|
||||
}
|
||||
|
||||
impl VigiState {
|
||||
|
@ -132,7 +132,7 @@ impl VigiState {
|
|||
} else if self.top_bar_input.is_empty() {
|
||||
VigiOutput::new(
|
||||
"Homepage".to_owned(),
|
||||
vec![El("Type something in the address bar".into())].to_dl_page(),
|
||||
vec![El("Type something in the address bar".into()).into()],
|
||||
)
|
||||
} else {
|
||||
process_input(&self.top_bar_input).await?
|
||||
|
|
|
@ -4,9 +4,12 @@
|
|||
|
||||
export let body: Body;
|
||||
export let ifNull: any = undefined;
|
||||
export let preformatted = false;
|
||||
</script>
|
||||
|
||||
{#if typeof body === "string"}
|
||||
{#if typeof body === "string" && preformatted}
|
||||
{body}
|
||||
{:else if typeof body === "string"}
|
||||
{#each body.split("\n") as line}
|
||||
{line} <br />
|
||||
{/each}
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
<script lang="ts">
|
||||
import TagRenderer from "./TagRenderer.svelte";
|
||||
import { state } from "$lib/stores";
|
||||
import ToTopScroller from "../ToTopScroller.svelte";
|
||||
</script>
|
||||
|
||||
{#each $state.current_data as tag, i}
|
||||
{#if i === 0}
|
||||
<ToTopScroller />
|
||||
{/if}
|
||||
<TagRenderer {tag} />
|
||||
{/each}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
|
||||
onMount(() => {
|
||||
document.getElementsByClassName("browser-window")[0]?.scrollTo(0, 0);
|
||||
});
|
||||
</script>
|
|
@ -13,8 +13,7 @@ export async function updateAndLoadInput(input: string, newTab?: boolean) {
|
|||
await invoke("update_input", { input, newTab: !!newTab });
|
||||
await updateVigiState();
|
||||
|
||||
await invoke("load_input_force");
|
||||
await updateVigiState();
|
||||
await loadInput(true);
|
||||
}
|
||||
|
||||
export async function addTab() {
|
||||
|
@ -29,13 +28,21 @@ export async function selectTab(index: number) {
|
|||
}
|
||||
|
||||
export async function removeTab(index: number) {
|
||||
let tabChanged = get(state).current_tab_index === index;
|
||||
|
||||
await invoke("remove_tab", { index });
|
||||
await updateVigiState();
|
||||
setTimeout(loadInput, 150);
|
||||
|
||||
if (tabChanged) setTimeout(loadInput, 150);
|
||||
}
|
||||
|
||||
export async function loadInput() {
|
||||
export async function loadInput(force = true) {
|
||||
document.getElementsByClassName("browser-window")[0]?.scrollTo(0, 0);
|
||||
if (force) {
|
||||
await invoke("load_input_force");
|
||||
} else {
|
||||
await invoke("load_input");
|
||||
}
|
||||
await updateVigiState();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue