mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-06 10:11:31 +00:00
forgot about the nested type
This commit is contained in:
1 parent
6848d0df60
commit
1fc5593dd9
5 files changed
+26
-9
No files matched your search
@@ -0,0 +1,10 @@
|
||||
|
||||
export enum BasicEventStatus {
|
||||
Success = "success",
|
||||
Failure = "failure",
|
||||
};
|
||||
|
||||
export interface BasicEventWrapper<T> {
|
||||
status: BasicEventStatus,
|
||||
data: T,
|
||||
};
|
||||
+3
-2
@@ -4,6 +4,7 @@ import { SoundRegistry } from "@storyteller/soundboard";
|
||||
import { GetAppPreferences } from "@storyteller/tauri-api";
|
||||
import { toast } from "@storyteller/ui-toaster";
|
||||
import { GenerationAction, GenerationModel, GenerationServiceProvider } from "./common";
|
||||
import { BasicEventWrapper } from "../BasicEventWrapper";
|
||||
|
||||
type GenerationCompleteEvent = {
|
||||
action: GenerationAction,
|
||||
@@ -17,7 +18,7 @@ export const useGenerationCompleteEvent = () => {
|
||||
let unlisten: Promise<UnlistenFn>;
|
||||
|
||||
const setup = async () => {
|
||||
unlisten = listen<GenerationCompleteEvent>('generation-complete-event', async (event) => {
|
||||
unlisten = listen<BasicEventWrapper<GenerationCompleteEvent>>('generation-complete-event', async (event) => {
|
||||
console.log("Generation complete event received:", event);
|
||||
const prefs = await GetAppPreferences();
|
||||
const soundName = prefs.preferences?.generation_success_sound;
|
||||
@@ -25,7 +26,7 @@ export const useGenerationCompleteEvent = () => {
|
||||
const registry = SoundRegistry.getInstance();
|
||||
registry.playSound(soundName);
|
||||
}
|
||||
const message = makeMessage(event.payload);
|
||||
const message = makeMessage(event.payload.data);
|
||||
toast.success(message);
|
||||
});
|
||||
|
||||
|
||||
+4
-3
@@ -4,6 +4,7 @@ import { SoundRegistry } from "@storyteller/soundboard";
|
||||
import { GetAppPreferences } from "@storyteller/tauri-api";
|
||||
import { toast } from "@storyteller/ui-toaster";
|
||||
import { GenerationAction, GenerationModel, GenerationServiceProvider } from "./common";
|
||||
import { BasicEventWrapper } from "../BasicEventWrapper";
|
||||
|
||||
type GenerationEnqueueFailureEvent = {
|
||||
action: GenerationAction,
|
||||
@@ -18,7 +19,7 @@ export const useGenerationEnqueueFailureEvent = () => {
|
||||
let unlisten: Promise<UnlistenFn>;
|
||||
|
||||
const setup = async () => {
|
||||
unlisten = listen<GenerationEnqueueFailureEvent>('generation-enqueue-failure-event', async (event) => {
|
||||
unlisten = listen<BasicEventWrapper<GenerationEnqueueFailureEvent>>('generation-enqueue-failure-event', async (event) => {
|
||||
console.log("Generation enqueue failure event received:", event);
|
||||
const prefs = await GetAppPreferences();
|
||||
const soundName = prefs.preferences?.enqueue_failure_sound;
|
||||
@@ -26,7 +27,7 @@ export const useGenerationEnqueueFailureEvent = () => {
|
||||
const registry = SoundRegistry.getInstance();
|
||||
registry.playSound(soundName);
|
||||
}
|
||||
const message = makeMessage(event.payload);
|
||||
const message = makeMessage(event.payload.data);
|
||||
toast.error(message);
|
||||
});
|
||||
|
||||
@@ -46,7 +47,7 @@ export const useGenerationEnqueueFailureEvent = () => {
|
||||
}
|
||||
|
||||
const makeMessage = (event: GenerationEnqueueFailureEvent) => {
|
||||
if (event.reason !== undefined) {
|
||||
if (!!event.reason) {
|
||||
return event.reason;
|
||||
}
|
||||
switch (event.action) {
|
||||
|
||||
+3
-2
@@ -4,6 +4,7 @@ import { SoundRegistry } from "@storyteller/soundboard";
|
||||
import { GetAppPreferences } from "@storyteller/tauri-api";
|
||||
import { toast } from "@storyteller/ui-toaster";
|
||||
import { GenerationAction, GenerationModel, GenerationServiceProvider } from "./common";
|
||||
import { BasicEventWrapper } from "../BasicEventWrapper";
|
||||
|
||||
type GenerationEnqueueSuccessEvent = {
|
||||
action: GenerationAction,
|
||||
@@ -17,7 +18,7 @@ export const useGenerationEnqueueSuccessEvent = () => {
|
||||
let unlisten: Promise<UnlistenFn>;
|
||||
|
||||
const setup = async () => {
|
||||
unlisten = listen<GenerationEnqueueSuccessEvent>('generation-enqueue-success-event', async (event) => {
|
||||
unlisten = listen<BasicEventWrapper<GenerationEnqueueSuccessEvent>>('generation-enqueue-success-event', async (event) => {
|
||||
console.log("Generation enqueue success event received:", event);
|
||||
const prefs = await GetAppPreferences();
|
||||
const soundName = prefs.preferences?.generation_success_sound;
|
||||
@@ -25,7 +26,7 @@ export const useGenerationEnqueueSuccessEvent = () => {
|
||||
const registry = SoundRegistry.getInstance();
|
||||
registry.playSound(soundName);
|
||||
}
|
||||
const message = makeMessage(event.payload);
|
||||
const message = makeMessage(event.payload.data);
|
||||
toast.success(message);
|
||||
});
|
||||
|
||||
|
||||
+6
-2
@@ -4,6 +4,7 @@ import { SoundRegistry } from "@storyteller/soundboard";
|
||||
import { GetAppPreferences } from "@storyteller/tauri-api";
|
||||
import { toast } from "@storyteller/ui-toaster";
|
||||
import { GenerationAction, GenerationModel, GenerationServiceProvider } from "./common";
|
||||
import { BasicEventWrapper } from "../BasicEventWrapper";
|
||||
|
||||
type GenerationFailedEvent = {
|
||||
action: GenerationAction,
|
||||
@@ -18,7 +19,7 @@ export const useGenerationFailedEvent = () => {
|
||||
let unlisten: Promise<UnlistenFn>;
|
||||
|
||||
const setup = async () => {
|
||||
unlisten = listen<GenerationFailedEvent>('generation-failed-event', async (event) => {
|
||||
unlisten = listen<BasicEventWrapper<GenerationFailedEvent>>('generation-failed-event', async (event) => {
|
||||
console.log("Generation failed event received:", event);
|
||||
const prefs = await GetAppPreferences();
|
||||
const soundName = prefs.preferences?.generation_failure_sound;
|
||||
@@ -26,7 +27,7 @@ export const useGenerationFailedEvent = () => {
|
||||
const registry = SoundRegistry.getInstance();
|
||||
registry.playSound(soundName);
|
||||
}
|
||||
const message = makeMessage(event.payload);
|
||||
const message = makeMessage(event.payload.data);
|
||||
toast.error(message);
|
||||
});
|
||||
|
||||
@@ -46,6 +47,9 @@ export const useGenerationFailedEvent = () => {
|
||||
}
|
||||
|
||||
const makeMessage = (event: GenerationFailedEvent) => {
|
||||
if (!!event.reason) {
|
||||
return event.reason;
|
||||
}
|
||||
switch (event.action) {
|
||||
case GenerationAction.GenerateImage:
|
||||
return "Image generation failed!";
|
||||
|
||||
Reference in new issue
Block a user