refactor: remove archived functionality from notifications and related components

- Removed the archived column from the Notification model and database schema, simplifying the notification structure.
- Deleted ArchiveRequest and ArchiveResponse models, along with associated API endpoints for archiving notifications.
- Updated InboxSidebar and related components to eliminate archiving functionality, streamlining the user experience.
- Adjusted filtering logic in the InboxSidebar to focus solely on unread notifications, enhancing clarity and usability.
This commit is contained in:
Anish Sarkar 2026-01-21 22:47:39 +05:30
parent 8dcdd27d10
commit 112f6ec4cc
8 changed files with 24 additions and 279 deletions

View file

@ -784,9 +784,6 @@ class Notification(BaseModel, TimestampMixin):
read = Column(
Boolean, nullable=False, default=False, server_default=text("false"), index=True
)
archived = Column(
Boolean, nullable=False, default=False, server_default=text("false"), index=True
)
notification_metadata = Column("metadata", JSONB, nullable=True, default={})
updated_at = Column(
TIMESTAMP(timezone=True),

View file

@ -30,19 +30,6 @@ class MarkAllReadResponse(BaseModel):
updated_count: int
class ArchiveRequest(BaseModel):
"""Request body for archive/unarchive operations."""
archived: bool
class ArchiveResponse(BaseModel):
"""Response for archive operations."""
success: bool
message: str
@router.patch("/{notification_id}/read", response_model=MarkReadResponse)
async def mark_notification_as_read(
notification_id: int,
@ -113,41 +100,3 @@ async def mark_all_notifications_as_read(
message=f"Marked {updated_count} notification(s) as read",
updated_count=updated_count,
)
@router.patch("/{notification_id}/archive", response_model=ArchiveResponse)
async def archive_notification(
notification_id: int,
request: ArchiveRequest,
user: User = Depends(current_active_user),
session: AsyncSession = Depends(get_async_session),
) -> ArchiveResponse:
"""
Archive or unarchive a notification.
Electric SQL will automatically sync this change to all connected clients.
"""
# Verify the notification belongs to the user
result = await session.execute(
select(Notification).where(
Notification.id == notification_id,
Notification.user_id == user.id,
)
)
notification = result.scalar_one_or_none()
if not notification:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Notification not found",
)
# Update the notification
notification.archived = request.archived
await session.commit()
action = "archived" if request.archived else "unarchived"
return ArchiveResponse(
success=True,
message=f"Notification {action}",
)