Skip to content

Commit

Permalink
refactor:[torrust#533] pass description from TorrentList
Browse files Browse the repository at this point in the history
  • Loading branch information
hungfnt committed Apr 22, 2024
1 parent aeb345d commit fac4204
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
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

0 comments on commit fac4204

Please sign in to comment.