Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor:[#533] pass description from TorrentList #534

Merged
merged 3 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/torrent/TorrentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</div>
<template v-if="isOpenList[index]">
<div class="flex flex-row items-start justify-start w-full px-4 pt-2 pb-4 duration-1000 flex-nowrap">
<TorrentListTorrentDetails :info-hash="torrent.info_hash" />
<TorrentListTorrentDetails :description="torrent.description" />
</div>
</template>
</a>
Expand Down
31 changes: 3 additions & 28 deletions components/torrent/TorrentListTorrentDetails.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<template>
<div
class="flex flex-col items-center w-full group/details rounded-2xl"
@click.stop="$router.push(`/torrent/${props.infoHash}/${slug}`)"
>
<div class="flex justify-center w-full p-4 overflow-y-auto duration-500 border-2 max-h-96 border-base-content/20 hover:border-primary text-base-content/75 rounded-2xl">
<template v-if="torrent?.description">
<Markdown :source="torrent.description" />
<template v-if="description !== null">
<Markdown :source="description" />
</template>
<template v-else>
<span class="italic">No description.</span>
Expand All @@ -15,38 +14,14 @@
</template>

<script setup lang="ts">
import { type Ref } from "vue";
import { type TorrentResponse } from "torrust-index-types-lib";
import { notify } from "notiwind-ts";
import { onMounted, ref, useRestApi } from "#imports";
import { generateSlug } from "~/src/domain/services/slug";

const rest = useRestApi();

const torrent: Ref<TorrentResponse> = ref(null);

const props = defineProps({
infoHash: {
description: {
type: String,
required: true
}
});

const slug = computed(() => generateSlug(torrent.value.title));

onMounted(() => {
rest.value.torrent.getTorrentInfo(props.infoHash)
.then((data: TorrentResponse) => {
torrent.value = data;
})
.catch((err: { message: any; }) => {
notify({
group: "error",
title: "Error",
text: `Trying to get the torrent information. ${err.message}.`
}, 10000);
});
});
</script>

<style scoped>
Expand Down