mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-31 19:45:15 +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,
|
Check,
|
||||||
CheckCheck,
|
CheckCheck,
|
||||||
CheckCircle2,
|
CheckCircle2,
|
||||||
Copy,
|
|
||||||
History,
|
History,
|
||||||
Inbox,
|
Inbox,
|
||||||
LayoutGrid,
|
LayoutGrid,
|
||||||
|
|
@ -42,14 +41,7 @@ import { Spinner } from "@/components/ui/spinner";
|
||||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
import { getConnectorIcon } from "@/contracts/enums/connectorIcons";
|
import { getConnectorIcon } from "@/contracts/enums/connectorIcons";
|
||||||
import {
|
import { isConnectorIndexingMetadata, isNewMentionMetadata } from "@/contracts/types/inbox.types";
|
||||||
type ConnectorIndexingMetadata,
|
|
||||||
isChatClonedMetadata,
|
|
||||||
isChatCloneFailedMetadata,
|
|
||||||
isConnectorIndexingMetadata,
|
|
||||||
isNewMentionMetadata,
|
|
||||||
type NewMentionMetadata,
|
|
||||||
} from "@/contracts/types/inbox.types";
|
|
||||||
import type { InboxItem } from "@/hooks/use-inbox";
|
import type { InboxItem } from "@/hooks/use-inbox";
|
||||||
import { useMediaQuery } from "@/hooks/use-media-query";
|
import { useMediaQuery } from "@/hooks/use-media-query";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
@ -213,15 +205,11 @@ export function InboxSidebar({
|
||||||
[inboxItems]
|
[inboxItems]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Status tab includes: connector indexing, document processing, chat clone notifications
|
// Status tab includes: connector indexing, document processing
|
||||||
const statusItems = useMemo(
|
const statusItems = useMemo(
|
||||||
() =>
|
() =>
|
||||||
inboxItems.filter(
|
inboxItems.filter(
|
||||||
(item) =>
|
(item) => item.type === "connector_indexing" || item.type === "document_processing"
|
||||||
item.type === "connector_indexing" ||
|
|
||||||
item.type === "document_processing" ||
|
|
||||||
item.type === "chat_cloned" ||
|
|
||||||
item.type === "chat_clone_failed"
|
|
||||||
),
|
),
|
||||||
[inboxItems]
|
[inboxItems]
|
||||||
);
|
);
|
||||||
|
|
@ -342,17 +330,7 @@ export function InboxSidebar({
|
||||||
router.push(url);
|
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]
|
[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
|
// For status items (connector/document), show status icons
|
||||||
// Safely access status from metadata
|
// Safely access status from metadata
|
||||||
const metadata = item.metadata as Record<string, unknown>;
|
const metadata = item.metadata as Record<string, unknown>;
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ export const inboxItemTypeEnum = z.enum([
|
||||||
"connector_indexing",
|
"connector_indexing",
|
||||||
"document_processing",
|
"document_processing",
|
||||||
"new_mention",
|
"new_mention",
|
||||||
"chat_cloned",
|
|
||||||
"chat_clone_failed",
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -90,22 +88,6 @@ export const newMentionMetadata = z.object({
|
||||||
content_preview: z.string(),
|
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
|
* Union of all inbox item metadata types
|
||||||
* Use this when the inbox item type is unknown
|
* Use this when the inbox item type is unknown
|
||||||
|
|
@ -114,8 +96,6 @@ export const inboxItemMetadata = z.union([
|
||||||
connectorIndexingMetadata,
|
connectorIndexingMetadata,
|
||||||
documentProcessingMetadata,
|
documentProcessingMetadata,
|
||||||
newMentionMetadata,
|
newMentionMetadata,
|
||||||
chatClonedMetadata,
|
|
||||||
chatCloneFailedMetadata,
|
|
||||||
baseInboxItemMetadata,
|
baseInboxItemMetadata,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -153,16 +133,6 @@ export const newMentionInboxItem = inboxItem.extend({
|
||||||
metadata: newMentionMetadata,
|
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
|
// API Request/Response Schemas
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
@ -259,33 +229,13 @@ export function isNewMentionMetadata(metadata: unknown): metadata is NewMentionM
|
||||||
return newMentionMetadata.safeParse(metadata).success;
|
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
|
* Safe metadata parser - returns typed metadata or null
|
||||||
*/
|
*/
|
||||||
export function parseInboxItemMetadata(
|
export function parseInboxItemMetadata(
|
||||||
type: InboxItemTypeEnum,
|
type: InboxItemTypeEnum,
|
||||||
metadata: unknown
|
metadata: unknown
|
||||||
):
|
): ConnectorIndexingMetadata | DocumentProcessingMetadata | NewMentionMetadata | null {
|
||||||
| ConnectorIndexingMetadata
|
|
||||||
| DocumentProcessingMetadata
|
|
||||||
| NewMentionMetadata
|
|
||||||
| ChatClonedMetadata
|
|
||||||
| ChatCloneFailedMetadata
|
|
||||||
| null {
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "connector_indexing": {
|
case "connector_indexing": {
|
||||||
const result = connectorIndexingMetadata.safeParse(metadata);
|
const result = connectorIndexingMetadata.safeParse(metadata);
|
||||||
|
|
@ -299,14 +249,6 @@ export function parseInboxItemMetadata(
|
||||||
const result = newMentionMetadata.safeParse(metadata);
|
const result = newMentionMetadata.safeParse(metadata);
|
||||||
return result.success ? result.data : null;
|
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:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -323,15 +265,11 @@ export type BaseInboxItemMetadata = z.infer<typeof baseInboxItemMetadata>;
|
||||||
export type ConnectorIndexingMetadata = z.infer<typeof connectorIndexingMetadata>;
|
export type ConnectorIndexingMetadata = z.infer<typeof connectorIndexingMetadata>;
|
||||||
export type DocumentProcessingMetadata = z.infer<typeof documentProcessingMetadata>;
|
export type DocumentProcessingMetadata = z.infer<typeof documentProcessingMetadata>;
|
||||||
export type NewMentionMetadata = z.infer<typeof newMentionMetadata>;
|
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 InboxItemMetadata = z.infer<typeof inboxItemMetadata>;
|
||||||
export type InboxItem = z.infer<typeof inboxItem>;
|
export type InboxItem = z.infer<typeof inboxItem>;
|
||||||
export type ConnectorIndexingInboxItem = z.infer<typeof connectorIndexingInboxItem>;
|
export type ConnectorIndexingInboxItem = z.infer<typeof connectorIndexingInboxItem>;
|
||||||
export type DocumentProcessingInboxItem = z.infer<typeof documentProcessingInboxItem>;
|
export type DocumentProcessingInboxItem = z.infer<typeof documentProcessingInboxItem>;
|
||||||
export type NewMentionInboxItem = z.infer<typeof newMentionInboxItem>;
|
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
|
// API Request/Response types
|
||||||
export type GetNotificationsRequest = z.infer<typeof getNotificationsRequest>;
|
export type GetNotificationsRequest = z.infer<typeof getNotificationsRequest>;
|
||||||
|
|
|
||||||
|
|
@ -119,15 +119,6 @@ export function useInbox(
|
||||||
|
|
||||||
async function startSync() {
|
async function startSync() {
|
||||||
try {
|
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 cutoffDate = getSyncCutoffDate();
|
||||||
const userSyncKey = `inbox_${userId}_${cutoffDate}`;
|
const userSyncKey = `inbox_${userId}_${cutoffDate}`;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class BaseApiService {
|
||||||
noAuthEndpoints: string[] = ["/auth/jwt/login", "/auth/register", "/auth/refresh"];
|
noAuthEndpoints: string[] = ["/auth/jwt/login", "/auth/register", "/auth/refresh"];
|
||||||
|
|
||||||
// Prefixes that don't require auth (checked with startsWith)
|
// 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
|
// Use a getter to always read fresh token from localStorage
|
||||||
// This ensures the token is always up-to-date after login/logout
|
// This ensures the token is always up-to-date after login/logout
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue