feat(processing-image): displaying initial status from response

This commit is contained in:
2025-04-26 11:41:44 +01:00
parent e2a4b85d15
commit b27e191e5c
4 changed files with 41 additions and 21 deletions

View File

@ -43,8 +43,6 @@ func ListenNewImageEvents(db *sql.DB, eventManager *EventManager) {
databaseEventLog.Debug("Starting processing image", "ImageID", imageId)
time.Sleep(10 * time.Second)
ctx := context.Background()
go func() {

View File

@ -1,22 +1,18 @@
import { Route, Router } from "@solidjs/router";
import { listen } from "@tauri-apps/api/event";
import { createEffect, createSignal, For, onCleanup, Show } from "solid-js";
import { createEffect, createSignal, onCleanup } from "solid-js";
import { Login } from "./Login";
import { ProtectedRoute } from "./ProtectedRoute";
import { Search } from "./Search";
import { Settings } from "./Settings";
import { ImageViewer } from "./components/ImageViewer";
import { ShareTarget } from "./components/share-target/ShareTarget";
import type { PluginListener } from "@tauri-apps/api/core";
import {
listenForShareEvents,
type ShareEvent,
} from "tauri-plugin-sharetarget-api";
import { readFile } from "@tauri-apps/plugin-fs";
import type { sendImage } from "./network";
import { ImageStatus } from "./components/image-status/ImageStatus";
export const App = () => {
const [logs, setLogs] = createSignal<string[]>([]);
const [file, setFile] = createSignal<File>();
const [processingImage, setProcessingImage] =
createSignal<Awaited<ReturnType<typeof sendImage>>>();
createEffect(() => {
// TODO: Don't use window.location.href
@ -57,7 +53,8 @@ export const App = () => {
return (
<>
<ImageViewer />
<ImageViewer onSendImage={setProcessingImage} />
<ImageStatus processingImage={processingImage} />
<ShareTarget />
<Router>
<Route path="/login" component={Login} />

View File

@ -1,14 +1,14 @@
import { listen } from "@tauri-apps/api/event";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { createEffect, createSignal } from "solid-js";
import { type Component, createEffect } from "solid-js";
import { sendImage } from "../network";
// TODO: This component should focus the window and show preview of screenshot,
// before we send it to backend, potentially we could draw and annotate
// OR we kill this and do stuff siltently
// anyhow keeping it like this for now
export function ImageViewer() {
type ImageViewerProps = {
onSendImage: (
processingImage: Awaited<ReturnType<typeof sendImage>>,
) => void;
};
export const ImageViewer: Component<ImageViewerProps> = (props) => {
// const [latestImage, setLatestImage] = createSignal<string | null>(null);
createEffect(async () => {
@ -26,6 +26,9 @@ export function ImageViewer() {
const result = await sendImage("test-image.png", base64Data);
props.onSendImage(result);
window.location.reload();
console.log("DBG: ", result);
});
@ -50,4 +53,4 @@ export function ImageViewer() {
// )}
// </div>
// );
}
};

View File

@ -0,0 +1,22 @@
import { Show, type Accessor, type Component } from "solid-js";
import type { sendImage } from "../../network";
type ImageStatusProps = {
processingImage: Accessor<
Awaited<ReturnType<typeof sendImage>> | undefined
>;
};
export const ImageStatus: Component<ImageStatusProps> = (props) => {
return (
<Show when={props.processingImage()}>
{(image) => (
<div>
<p>
{image().ImageID} - {image().Status}
</p>
</div>
)}
</Show>
);
};