mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-17 15:15:17 +00:00
- success toast default to last for 10 seconds instead of a minute - pop toast regarding polling movie and audio only when it's called by job completion - polling movie/audio functions now has a promise return to give information to its invoker Co-authored-by: wil <wil@storyteller.ai>
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { FilterMediaClasses, ToastTypes } from "~/enums";
|
|
|
|
import { MediaFilesApi } from "~/Classes/ApiManager/MediaFilesApi";
|
|
|
|
import {
|
|
addToast,
|
|
authentication,
|
|
setUserAudioItems,
|
|
setUserMovies,
|
|
isRetreivingAudioItems,
|
|
isRetreivingUserMovies,
|
|
} from "~/signals";
|
|
const { userInfo } = authentication;
|
|
|
|
export async function PollUserMovies(): Promise<boolean> {
|
|
if (!userInfo.value || isRetreivingUserMovies.value) {
|
|
//do nothing return if login info does not exist
|
|
return true;
|
|
}
|
|
|
|
isRetreivingUserMovies.value = true;
|
|
const mediaFilesApi = new MediaFilesApi();
|
|
const response = await mediaFilesApi.ListUserMediaFiles({
|
|
filter_media_classes: [FilterMediaClasses.VIDEO],
|
|
});
|
|
isRetreivingUserMovies.value = false;
|
|
if (response.success && response.data) {
|
|
setUserMovies(response.data);
|
|
return true;
|
|
}
|
|
addToast(
|
|
ToastTypes.ERROR,
|
|
response.errorMessage || "Unknown Error in Loading My Movies",
|
|
);
|
|
return false;
|
|
}
|
|
|
|
export async function PollUserAudioItems(): Promise<boolean> {
|
|
if (!userInfo.value) {
|
|
//do nothing return if login info does not exist
|
|
return true;
|
|
}
|
|
isRetreivingAudioItems.value = true;
|
|
const mediaFilesApi = new MediaFilesApi();
|
|
const response = await mediaFilesApi.ListUserMediaFiles({
|
|
page_size: 100,
|
|
filter_media_classes: [FilterMediaClasses.AUDIO],
|
|
});
|
|
isRetreivingAudioItems.value = false;
|
|
if (response.success && response.data) {
|
|
setUserAudioItems(response.data);
|
|
return true;
|
|
}
|
|
addToast(
|
|
ToastTypes.ERROR,
|
|
response.errorMessage || "Unknown Error in Loading My Audio Items",
|
|
);
|
|
return false;
|
|
}
|