mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-02 00:18:17 +00:00
API2.5/ useBackgroundMedia now uses the API Manager (#497)
ready to go as long as QA is done Co-authored-by: wil <wil@storyteller.ai>
This commit is contained in:
1 parent
a627cddbdc
commit
78acfcff8c
4 files changed
+36
-44
No files matched your search
@@ -6,8 +6,9 @@ import {
|
||||
} from "~/pages/PageEnigma/models";
|
||||
import { ApiManager, ApiResponse } from "./ApiManager";
|
||||
import { authentication } from "~/signals";
|
||||
import { Property } from "csstype";
|
||||
import Visibility = Property.Visibility;
|
||||
import type { Property } from "csstype";
|
||||
type Visibility = Property.Visibility;
|
||||
|
||||
import {
|
||||
FilterEngineCategories,
|
||||
FilterMediaClasses,
|
||||
|
||||
@@ -1,63 +1,53 @@
|
||||
import { MediaFileType } from "~/pages/PageEnigma/enums";
|
||||
import { FilterMediaClasses, ToastTypes } from "~/enums";
|
||||
|
||||
import { ToastTypes } from "~/enums";
|
||||
|
||||
import {
|
||||
GetMediaByUser,
|
||||
GetMediaListResponse,
|
||||
} from "~/api/media_files/GetMediaByUser";
|
||||
import { MediaFilesApi } from "~/Classes/ApiManager/MediaFilesApi";
|
||||
|
||||
import {
|
||||
addToast,
|
||||
authentication,
|
||||
setUserAudioItems,
|
||||
setUserMovies,
|
||||
userMovies,
|
||||
isRetreivingAudioItems,
|
||||
} from "~/signals";
|
||||
const { userInfo } = authentication;
|
||||
|
||||
export function PollUserMovies() {
|
||||
export async function PollUserMovies() {
|
||||
if (!userInfo.value) {
|
||||
//do nothing return if login info does not exist
|
||||
return;
|
||||
}
|
||||
return GetMediaByUser(
|
||||
userInfo.value.username,
|
||||
{},
|
||||
{
|
||||
filter_media_type: MediaFileType.Video,
|
||||
},
|
||||
)
|
||||
.then((res: GetMediaListResponse) => {
|
||||
if (userMovies.value && res.results.length !== userMovies.value.length) {
|
||||
setUserMovies(res.results);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
addToast(ToastTypes.ERROR, "Unknown Error in Loading My Movies");
|
||||
});
|
||||
|
||||
const mediaFilesApi = new MediaFilesApi();
|
||||
const response = await mediaFilesApi.ListUserMediaFiles({
|
||||
filter_media_classes: [FilterMediaClasses.VIDEO],
|
||||
});
|
||||
if (response.success && response.data) {
|
||||
setUserMovies(response.data);
|
||||
return;
|
||||
}
|
||||
addToast(
|
||||
ToastTypes.ERROR,
|
||||
response.errorMessage || "Unknown Error in Loading My Movies",
|
||||
);
|
||||
}
|
||||
|
||||
export function PollUserAudioItems() {
|
||||
export async function PollUserAudioItems() {
|
||||
if (!userInfo.value) {
|
||||
//do nothing return if login info does not exist
|
||||
return;
|
||||
}
|
||||
isRetreivingAudioItems.value = true;
|
||||
return GetMediaByUser(
|
||||
userInfo.value.username,
|
||||
{},
|
||||
{
|
||||
filter_media_type: MediaFileType.Audio,
|
||||
},
|
||||
)
|
||||
.then((res: GetMediaListResponse) => {
|
||||
isRetreivingAudioItems.value = false;
|
||||
setUserAudioItems(res.results);
|
||||
})
|
||||
.catch(() => {
|
||||
isRetreivingAudioItems.value = false;
|
||||
addToast(ToastTypes.ERROR, "Unknown Error in Loading My Audio Items");
|
||||
});
|
||||
const mediaFilesApi = new MediaFilesApi();
|
||||
const response = await mediaFilesApi.ListUserMediaFiles({
|
||||
filter_media_classes: [FilterMediaClasses.AUDIO],
|
||||
});
|
||||
isRetreivingAudioItems.value = false;
|
||||
if (response.success && response.data) {
|
||||
setUserAudioItems(response.data);
|
||||
return;
|
||||
}
|
||||
addToast(
|
||||
ToastTypes.ERROR,
|
||||
response.errorMessage || "Unknown Error in Loading My Audio Items",
|
||||
);
|
||||
}
|
||||
Generated
+2
-2
@@ -27,6 +27,7 @@
|
||||
"@tweenjs/tween.js": "^18.6.4",
|
||||
"ccapture.js": "github:aceslowman/ccapture.js#npm-fix",
|
||||
"common": "file:common",
|
||||
"csstype": "^3.1.3",
|
||||
"dayjs": "^1.11.10",
|
||||
"isbot": "^4.1.0",
|
||||
"react": "^18.2.0",
|
||||
@@ -12058,8 +12059,7 @@
|
||||
"node_modules/csstype": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
|
||||
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="
|
||||
},
|
||||
"node_modules/damerau-levenshtein": {
|
||||
"version": "1.0.8",
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
"@tweenjs/tween.js": "^18.6.4",
|
||||
"ccapture.js": "github:aceslowman/ccapture.js#npm-fix",
|
||||
"common": "file:common",
|
||||
"csstype": "^3.1.3",
|
||||
"dayjs": "^1.11.10",
|
||||
"isbot": "^4.1.0",
|
||||
"react": "^18.2.0",
|
||||
|
||||
Reference in new issue
Block a user