⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
Include collection name in table
Isaac Wise5665fbb412d8
diff --git a/hooks/store/rss.tsx b/hooks/store/rss.tsxindex 82cbbb1b..643da8cf 100644--- a/hooks/store/rss.tsx+++ b/hooks/store/rss.tsx@@ -2,6 +2,12 @@ import { RssSubscription } from "@prisma/client";import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";import { useSession } from "next-auth/react";+interface RssSubscriptionWithCollectionName extends RssSubscription {+ collection: {+ name: string; // Include only the name of the collection+ };+}+const useRssSubscriptions = () => {const { status } = useSession();@@ -12,7 +18,7 @@ const useRssSubscriptions = () => {if (!response.ok) throw new Error("Failed to fetch rss subscriptions.");const data = await response.json();- return data.response as RssSubscription[];+ return data.response as RssSubscriptionWithCollectionName[];},enabled: status === "authenticated",});diff --git a/pages/api/v1/user/rss/index.ts b/pages/api/v1/user/rss/index.tsindex ff7b7337..98e94679 100644--- a/pages/api/v1/user/rss/index.ts+++ b/pages/api/v1/user/rss/index.ts@@ -13,7 +13,15 @@ export default async function handler(if (!user) return;if (req.method === "GET") {- const response = await prisma.rssSubscription.findMany({});+ const response = await prisma.rssSubscription.findMany({+ include: {+ collection: {+ select: {+ name: true,+ }+ },+ },+ });return res.status(200).json({ response });}@@ -36,6 +44,7 @@ export default async function handler(name,url,ownerId: user.id,+ lastBuildDate: new Date(),collection: {connect: {id: collectionId,@@ -46,8 +55,4 @@ export default async function handler(return res.status(200).json({ response });}-- if (req.method === "DELETE") {-- }}\ No newline at end of filediff --git a/pages/settings/rss-subscriptions.tsx b/pages/settings/rss-subscriptions.tsxindex c55ea2f6..d77b7274 100644--- a/pages/settings/rss-subscriptions.tsx+++ b/pages/settings/rss-subscriptions.tsx@@ -5,6 +5,7 @@ import { useRssSubscriptions } from "@/hooks/store/rss";import DeleteRssSubscriptionModal from "@/components/ModalContent/DeleteRssSubscriptionModal";import { useState } from "react";import { RssSubscription } from "@prisma/client";+import Link from "next/link";export default function RssSubscriptions() {const { t } = useTranslation();@@ -42,25 +43,31 @@ export default function RssSubscriptions() {<tr><th>{t("name")}</th><th>{t("link")}</th>+ <th>{t("collection")}</th><th></th></tr></thead><tbody>- {rssSubscriptions.map((rssSubscription, i) => (- <tr key={i}>- <td>{rssSubscription.name}</td>- <td>{rssSubscription.url}</td>- <td>- <button- className="btn btn-sm btn-ghost btn-square hover:bg-red-500"- onClick={() => openDeleteModal(rssSubscription)}+ {rssSubscriptions.map((rssSubscription, i) => {+ return (+ <tr key={i}>+ <td>{rssSubscription.name}</td>+ <td>{rssSubscription.url}</td>+ <td>+ <Link className="hover:underline" href={`/collections/${rssSubscription.collectionId}`}>{rssSubscription.collection.name}</Link>+ </td>+ <td>+ <button+ className="btn btn-sm btn-ghost btn-square hover:bg-red-500"+ onClick={() => openDeleteModal(rssSubscription)}- >- <i className="bi-x text-lg"></i>- </button>- </td>- </tr>- ))}+ >+ <i className="bi-x text-lg"></i>+ </button>+ </td>+ </tr>+ );+ })}</tbody></table>)}diff --git a/scripts/worker.ts b/scripts/worker.tsindex b3ed9ba6..eb461b45 100644--- a/scripts/worker.ts+++ b/scripts/worker.ts@@ -144,34 +144,8 @@ async function fetchAndProcessRSS() {try {const feed = await parser.parseURL(rssSubscription.url);- // If there's no lastBuildDate, process all feed items- if (!rssSubscription.lastBuildDate) {- feed.items.forEach(async (item) => {- await prisma.link.create({- data: {- name: item.title,- url: item.link,- type: "link",- createdBy: {- connect: {- id: rssSubscription.ownerId- }- },- collection: {- connect: {- id: rssSubscription.collectionId- }- }- }- });- });-- await prisma.rssSubscription.update({- where: { id: rssSubscription.id },- data: { lastBuildDate: new Date(feed.lastBuildDate) }- });- } else if (rssSubscription.lastBuildDate && new Date(rssSubscription.lastBuildDate) < new Date(feed.lastBuildDate)) {- console.log(`Processing new feeds for ${rssSubscription.name}`);+ if (rssSubscription.lastBuildDate && new Date(rssSubscription.lastBuildDate) < new Date(feed.lastBuildDate)) {+ console.log(`Processing new RSS feed items for ${rssSubscription.name}`);const newItems = feed.items.filter(item => {const itemPubDate = item.pubDate ? new Date(item.pubDate) : null;