mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
fix(frontend): remove clone notifications, allow public podcast access
This commit is contained in:
parent
9a4da10b12
commit
3c835bdf7e
4 changed files with 5 additions and 116 deletions
|
|
@ -7,7 +7,6 @@ import {
|
|||
Check,
|
||||
CheckCheck,
|
||||
CheckCircle2,
|
||||
Copy,
|
||||
History,
|
||||
Inbox,
|
||||
LayoutGrid,
|
||||
|
|
@ -42,14 +41,7 @@ import { Spinner } from "@/components/ui/spinner";
|
|||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { getConnectorIcon } from "@/contracts/enums/connectorIcons";
|
||||
import {
|
||||
type ConnectorIndexingMetadata,
|
||||
isChatClonedMetadata,
|
||||
isChatCloneFailedMetadata,
|
||||
isConnectorIndexingMetadata,
|
||||
isNewMentionMetadata,
|
||||
type NewMentionMetadata,
|
||||
} from "@/contracts/types/inbox.types";
|
||||
import { isConnectorIndexingMetadata, isNewMentionMetadata } from "@/contracts/types/inbox.types";
|
||||
import type { InboxItem } from "@/hooks/use-inbox";
|
||||
import { useMediaQuery } from "@/hooks/use-media-query";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
|
@ -213,15 +205,11 @@ export function InboxSidebar({
|
|||
[inboxItems]
|
||||
);
|
||||
|
||||
// Status tab includes: connector indexing, document processing, chat clone notifications
|
||||
// Status tab includes: connector indexing, document processing
|
||||
const statusItems = useMemo(
|
||||
() =>
|
||||
inboxItems.filter(
|
||||
(item) =>
|
||||
item.type === "connector_indexing" ||
|
||||
item.type === "document_processing" ||
|
||||
item.type === "chat_cloned" ||
|
||||
item.type === "chat_clone_failed"
|
||||
(item) => item.type === "connector_indexing" || item.type === "document_processing"
|
||||
),
|
||||
[inboxItems]
|
||||
);
|
||||
|
|
@ -342,17 +330,7 @@ export function InboxSidebar({
|
|||
router.push(url);
|
||||
}
|
||||
}
|
||||
} else if (item.type === "chat_cloned") {
|
||||
// Navigate to the cloned chat
|
||||
if (isChatClonedMetadata(item.metadata)) {
|
||||
const { search_space_id, thread_id } = item.metadata;
|
||||
const url = `/dashboard/${search_space_id}/new-chat/${thread_id}`;
|
||||
onOpenChange(false);
|
||||
onCloseMobileSidebar?.();
|
||||
router.push(url);
|
||||
}
|
||||
}
|
||||
// chat_clone_failed: just mark as read, no navigation
|
||||
},
|
||||
[markAsRead, router, onOpenChange, onCloseMobileSidebar]
|
||||
);
|
||||
|
|
@ -412,24 +390,6 @@ export function InboxSidebar({
|
|||
);
|
||||
}
|
||||
|
||||
// For chat cloned success, show green copy icon
|
||||
if (item.type === "chat_cloned") {
|
||||
return (
|
||||
<div className="h-8 w-8 flex items-center justify-center rounded-full bg-green-500/10">
|
||||
<Copy className="h-4 w-4 text-green-500" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// For chat clone failed, show red alert icon
|
||||
if (item.type === "chat_clone_failed") {
|
||||
return (
|
||||
<div className="h-8 w-8 flex items-center justify-center rounded-full bg-red-500/10">
|
||||
<AlertCircle className="h-4 w-4 text-red-500" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// For status items (connector/document), show status icons
|
||||
// Safely access status from metadata
|
||||
const metadata = item.metadata as Record<string, unknown>;
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ export const inboxItemTypeEnum = z.enum([
|
|||
"connector_indexing",
|
||||
"document_processing",
|
||||
"new_mention",
|
||||
"chat_cloned",
|
||||
"chat_clone_failed",
|
||||
]);
|
||||
|
||||
/**
|
||||
|
|
@ -90,22 +88,6 @@ export const newMentionMetadata = z.object({
|
|||
content_preview: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Chat cloned success metadata schema
|
||||
*/
|
||||
export const chatClonedMetadata = z.object({
|
||||
thread_id: z.number(),
|
||||
search_space_id: z.number(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Chat clone failed metadata schema
|
||||
*/
|
||||
export const chatCloneFailedMetadata = z.object({
|
||||
share_token: z.string(),
|
||||
error: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Union of all inbox item metadata types
|
||||
* Use this when the inbox item type is unknown
|
||||
|
|
@ -114,8 +96,6 @@ export const inboxItemMetadata = z.union([
|
|||
connectorIndexingMetadata,
|
||||
documentProcessingMetadata,
|
||||
newMentionMetadata,
|
||||
chatClonedMetadata,
|
||||
chatCloneFailedMetadata,
|
||||
baseInboxItemMetadata,
|
||||
]);
|
||||
|
||||
|
|
@ -153,16 +133,6 @@ export const newMentionInboxItem = inboxItem.extend({
|
|||
metadata: newMentionMetadata,
|
||||
});
|
||||
|
||||
export const chatClonedInboxItem = inboxItem.extend({
|
||||
type: z.literal("chat_cloned"),
|
||||
metadata: chatClonedMetadata,
|
||||
});
|
||||
|
||||
export const chatCloneFailedInboxItem = inboxItem.extend({
|
||||
type: z.literal("chat_clone_failed"),
|
||||
metadata: chatCloneFailedMetadata,
|
||||
});
|
||||
|
||||
// =============================================================================
|
||||
// API Request/Response Schemas
|
||||
// =============================================================================
|
||||
|
|
@ -259,33 +229,13 @@ export function isNewMentionMetadata(metadata: unknown): metadata is NewMentionM
|
|||
return newMentionMetadata.safeParse(metadata).success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for ChatClonedMetadata
|
||||
*/
|
||||
export function isChatClonedMetadata(metadata: unknown): metadata is ChatClonedMetadata {
|
||||
return chatClonedMetadata.safeParse(metadata).success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for ChatCloneFailedMetadata
|
||||
*/
|
||||
export function isChatCloneFailedMetadata(metadata: unknown): metadata is ChatCloneFailedMetadata {
|
||||
return chatCloneFailedMetadata.safeParse(metadata).success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe metadata parser - returns typed metadata or null
|
||||
*/
|
||||
export function parseInboxItemMetadata(
|
||||
type: InboxItemTypeEnum,
|
||||
metadata: unknown
|
||||
):
|
||||
| ConnectorIndexingMetadata
|
||||
| DocumentProcessingMetadata
|
||||
| NewMentionMetadata
|
||||
| ChatClonedMetadata
|
||||
| ChatCloneFailedMetadata
|
||||
| null {
|
||||
): ConnectorIndexingMetadata | DocumentProcessingMetadata | NewMentionMetadata | null {
|
||||
switch (type) {
|
||||
case "connector_indexing": {
|
||||
const result = connectorIndexingMetadata.safeParse(metadata);
|
||||
|
|
@ -299,14 +249,6 @@ export function parseInboxItemMetadata(
|
|||
const result = newMentionMetadata.safeParse(metadata);
|
||||
return result.success ? result.data : null;
|
||||
}
|
||||
case "chat_cloned": {
|
||||
const result = chatClonedMetadata.safeParse(metadata);
|
||||
return result.success ? result.data : null;
|
||||
}
|
||||
case "chat_clone_failed": {
|
||||
const result = chatCloneFailedMetadata.safeParse(metadata);
|
||||
return result.success ? result.data : null;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
@ -323,15 +265,11 @@ export type BaseInboxItemMetadata = z.infer<typeof baseInboxItemMetadata>;
|
|||
export type ConnectorIndexingMetadata = z.infer<typeof connectorIndexingMetadata>;
|
||||
export type DocumentProcessingMetadata = z.infer<typeof documentProcessingMetadata>;
|
||||
export type NewMentionMetadata = z.infer<typeof newMentionMetadata>;
|
||||
export type ChatClonedMetadata = z.infer<typeof chatClonedMetadata>;
|
||||
export type ChatCloneFailedMetadata = z.infer<typeof chatCloneFailedMetadata>;
|
||||
export type InboxItemMetadata = z.infer<typeof inboxItemMetadata>;
|
||||
export type InboxItem = z.infer<typeof inboxItem>;
|
||||
export type ConnectorIndexingInboxItem = z.infer<typeof connectorIndexingInboxItem>;
|
||||
export type DocumentProcessingInboxItem = z.infer<typeof documentProcessingInboxItem>;
|
||||
export type NewMentionInboxItem = z.infer<typeof newMentionInboxItem>;
|
||||
export type ChatClonedInboxItem = z.infer<typeof chatClonedInboxItem>;
|
||||
export type ChatCloneFailedInboxItem = z.infer<typeof chatCloneFailedInboxItem>;
|
||||
|
||||
// API Request/Response types
|
||||
export type GetNotificationsRequest = z.infer<typeof getNotificationsRequest>;
|
||||
|
|
|
|||
|
|
@ -119,15 +119,6 @@ export function useInbox(
|
|||
|
||||
async function startSync() {
|
||||
try {
|
||||
// Check for force resync flag (e.g., after clone from public page)
|
||||
if (localStorage.getItem("surfsense_force_notif_resync") === "true") {
|
||||
console.log("[useInbox] Force resync flag detected, clearing notifications");
|
||||
await client.db.exec("DELETE FROM notifications");
|
||||
localStorage.removeItem("surfsense_force_notif_resync");
|
||||
// Reset sync key to force a fresh sync
|
||||
userSyncKeyRef.current = null;
|
||||
}
|
||||
|
||||
const cutoffDate = getSyncCutoffDate();
|
||||
const userSyncKey = `inbox_${userId}_${cutoffDate}`;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class BaseApiService {
|
|||
noAuthEndpoints: string[] = ["/auth/jwt/login", "/auth/register", "/auth/refresh"];
|
||||
|
||||
// Prefixes that don't require auth (checked with startsWith)
|
||||
noAuthPrefixes: string[] = ["/api/v1/public/"];
|
||||
noAuthPrefixes: string[] = ["/api/v1/public/", "/api/v1/podcasts/"];
|
||||
|
||||
// Use a getter to always read fresh token from localStorage
|
||||
// This ensures the token is always up-to-date after login/logout
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue