119 lines
5.2 KiB
JavaScript
119 lines
5.2 KiB
JavaScript
import { l as loadGray, _ as _sfc_main$1 } from './gray-BanKC00A.mjs';
|
|
import { u as useRouter$1, a as useConfigStore, n as useIntersectionObserver, f as loading, x as getSupabaseStorageUrl, b as useUserStore } from './server.mjs';
|
|
import { defineComponent, ref, resolveDirective, mergeProps, unref, useSSRContext } from 'vue';
|
|
import { ssrRenderAttrs, ssrRenderList, ssrInterpolate, ssrGetDirectiveProps, ssrRenderAttr, ssrRenderStyle, ssrRenderComponent } from 'vue/server-renderer';
|
|
import { defineStore } from 'pinia';
|
|
import { g as getUserSaved } from './save-kY8A0w-Z.mjs';
|
|
|
|
const useSavedPostStore = defineStore("saved", () => {
|
|
const savedPosts = ref([]);
|
|
const endPage = ref(false);
|
|
useConfigStore();
|
|
const currentPage = ref(0);
|
|
const limit = ref(12);
|
|
const total = ref(0);
|
|
const user = useUserStore();
|
|
async function loadPosts() {
|
|
var _a2;
|
|
var _a, _b;
|
|
console.log("save");
|
|
try {
|
|
if (!endPage.value) {
|
|
loading.value = true;
|
|
const res = await getUserSaved((_a = user.user) == null ? void 0 : _a.id, ++currentPage.value, limit.value);
|
|
if (((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.length) < limit.value)
|
|
endPage.value = true;
|
|
const products = res == null ? void 0 : res.data.map((x) => x.products);
|
|
savedPosts.value.push(...products != null ? products : []);
|
|
total.value = (_a2 = res == null ? void 0 : res.count) != null ? _a2 : 0;
|
|
}
|
|
} catch (e) {
|
|
console.log(e);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
function reset() {
|
|
currentPage.value = 0;
|
|
savedPosts.value = [];
|
|
total.value = 0;
|
|
endPage.value = false;
|
|
}
|
|
return {
|
|
loadPosts,
|
|
savedPosts,
|
|
reset
|
|
};
|
|
});
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "SavedList",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
useRouter$1();
|
|
useConfigStore();
|
|
const userSavedPost = useSavedPostStore();
|
|
const videoThumbnails = ref({});
|
|
const observer = ref();
|
|
useIntersectionObserver(observer, ([{ isIntersecting }]) => {
|
|
if (isIntersecting) {
|
|
setTimeout(() => {
|
|
userSavedPost.loadPosts();
|
|
}, 100);
|
|
}
|
|
});
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
var _a;
|
|
const _component_SquarePostSkeleton = _sfc_main$1;
|
|
const _directive_lazy = resolveDirective("lazy");
|
|
let _temp0;
|
|
_push(`<div${ssrRenderAttrs(mergeProps({
|
|
class: ["flex flex-col gap-2 min-h-50vh", ((_a = unref(userSavedPost).savedPosts) == null ? void 0 : _a.length) > 0 ? "" : "justify-center"]
|
|
}, _attrs))}>`);
|
|
if (!("loading" in _ctx ? _ctx.loading : unref(loading))) {
|
|
_push(`<!--[--><div class="w-full grid grid-cols-3 gap-2px"><!--[-->`);
|
|
ssrRenderList(unref(userSavedPost).savedPosts, (post, i) => {
|
|
var _a3;
|
|
var _a2, _b, _c, _d, _e;
|
|
_push(`<div class="w-full aspect-square relative">`);
|
|
if ((_a2 = post.files) == null ? void 0 : _a2.length) {
|
|
_push(`<!--[-->`);
|
|
if (((_b = post.files[0]) == null ? void 0 : _b.type) === "image") {
|
|
_push(`<img${ssrRenderAttrs(_temp0 = mergeProps({
|
|
class: "w-full h-full object-cover",
|
|
alt: "Post Image"
|
|
}, ssrGetDirectiveProps(_ctx, _directive_lazy, { src: unref(getSupabaseStorageUrl)(post.files[0].url), loading: unref(loadGray), error: unref(loadGray) })))}>${"textContent" in _temp0 ? ssrInterpolate(_temp0.textContent) : (_a3 = _temp0.innerHTML) != null ? _a3 : ""}`);
|
|
} else if (((_c = post.files[0]) == null ? void 0 : _c.type) === "video") {
|
|
_push(`<div class="relative w-full h-full"><video${ssrRenderAttr("src", (_d = post.files[0]) == null ? void 0 : _d.url)} class="hidden"></video><img${ssrRenderAttr("src", videoThumbnails.value[(_e = post.files[0]) == null ? void 0 : _e.url])} class="w-full h-full object-cover" alt="Video Thumbnail"><div class="absolute inset-0 flex items-center justify-center bg-black bg-opacity-30"><svg class="w-12 h-12 text-white" fill="currentColor" viewBox="0 0 24 24"><path d="M8 5v14l11-7z"></path></svg></div></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<!--]-->`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div>`);
|
|
});
|
|
_push(`<!--]--></div><div style="${ssrRenderStyle(!("loading" in _ctx ? _ctx.loading : unref(loading)) ? null : { display: "none" })}" class="w-full opacity-0 relative"> load </div>`);
|
|
if ("loading" in _ctx ? _ctx.loading : unref(loading)) {
|
|
_push(ssrRenderComponent(_component_SquarePostSkeleton, null, null, _parent));
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<!--]-->`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div>`);
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup = _sfc_main.setup;
|
|
_sfc_main.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/statisticsList/components/SavedList.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
|
|
export { _sfc_main as _ };
|
|
//# sourceMappingURL=SavedList-BCcxR6p1.mjs.map
|