Skip to content

Commit

Permalink
Merge #534: refactor:[#533] pass description from TorrentList
Browse files Browse the repository at this point in the history
fac4204 refactor:[#533] pass description from TorrentList (ngthhu)

Pull request description:

ACKs for top commit:
  josecelano:
    ACK 356784a

Tree-SHA512: e3d6174bb95fec5df2b8fb57b1ff4342dde7f63308fb319a88c43b8fdef90ca629eaa64c74628141b30b6117551a597c81885af8c7a88513708bb503a4b61643
  • Loading branch information
josecelano committed Apr 27, 2024
2 parents 0d834cc + 356784a commit 5efc487
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 5efc487

Please sign in to comment.