fixed ts error

This commit is contained in:
nvrl committed 2026-02-17 18:25:35 +01:00
1 parent edd5d92939
commit 0e9ea23d98
2 files changed
+5 -2

No files matched your search

+1
View File
@@ -197,6 +197,7 @@ class ReplyViewSet(viewsets.ModelViewSet):
class NotificationViewSet(viewsets.ReadOnlyModelViewSet): class NotificationViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = NotificationSerializer serializer_class = NotificationSerializer
permission_classes = [permissions.IsAuthenticated] permission_classes = [permissions.IsAuthenticated]
pagination_class = None
def get_queryset(self): def get_queryset(self):
return self.request.user.notifications.select_related('actor', 'rating__flavor', 'reply__rating__flavor').order_by('-created_at') return self.request.user.notifications.select_related('actor', 'rating__flavor', 'reply__rating__flavor').order_by('-created_at')
+4 -2
View File
@@ -197,7 +197,8 @@ const App: React.FC = () => {
const fetchNotifications = async () => { const fetchNotifications = async () => {
try { try {
const res = await api.get('notifications/'); const res = await api.get('notifications/');
setNotifications(res.data); const data = Array.isArray(res.data) ? res.data : (res.data.results || []);
setNotifications(data);
} catch (err) { } catch (err) {
console.error('Failed to fetch notifications'); console.error('Failed to fetch notifications');
} }
@@ -220,7 +221,8 @@ const App: React.FC = () => {
// Also fetch following list for the mobile sidebar // Also fetch following list for the mobile sidebar
try { try {
const followRes = await api.get('users/following_list/'); const followRes = await api.get('users/following_list/');
setFollowing(followRes.data); const followData = Array.isArray(followRes.data) ? followRes.data : (followRes.data.results || []);
setFollowing(followData);
fetchNotifications(); fetchNotifications();
} catch (err) { } catch (err) {
console.error('Failed to fetch following list'); console.error('Failed to fetch following list');