bug fixes and support new media

This commit is contained in:
2023-04-10 14:49:53 +10:00
parent 359698d54f
commit 7ad73f3c84
13 changed files with 362 additions and 341 deletions

View File

@@ -96,6 +96,7 @@ import { toTitleCase } from "../helpers/string";
import { isEmpty } from "../helpers/utils";
import { isUUID } from "../helpers/uuid";
import SMDialogMedia from "./dialogs/SMDialogMedia.vue";
import { mediaGetVariantUrl } from "../helpers/media";
const props = defineProps({
modelValue: {
@@ -226,25 +227,30 @@ watch(
watch(
() => value.value,
async (newValue) => {
inputActive.value = newValue.length > 0;
if (newValue) {
inputActive.value = newValue.length > 0;
if (props.type == "media") {
if (isUUID(newValue)) {
try {
const result = await api.get({
url: "/media/{id}",
params: {
id: newValue,
},
});
if (props.type == "media") {
if (isUUID(newValue)) {
try {
const result = await api.get({
url: "/media/{id}",
params: {
id: newValue,
},
});
const data = result.data as MediaResponse;
const data = result.data as MediaResponse;
if (data && data.medium) {
mediaUrl.value = imageMedium(data.medium.url);
if (data && data.medium) {
mediaUrl.value = mediaGetVariantUrl(
data.medium,
"small"
);
}
} catch (error) {
/* empty */
}
} catch (error) {
/* empty */
}
}
}