mirror of
https://github.com/hoornet/vega.git
synced 2026-05-07 20:59:12 -07:00
Mark new followers with badge, sort to top of follows list
Track new follower pubkeys in notification store. When user opens the follows view, new followers are highlighted with an accent "new" badge and sorted to the top. Badge clears on view open (one-time).
This commit is contained in:
@@ -17,6 +17,7 @@ interface NotificationsState {
|
||||
dmLastSeen: Record<string, number>;
|
||||
dmUnreadCount: number;
|
||||
newFollowersCount: number;
|
||||
newFollowerPubkeys: Set<string>;
|
||||
|
||||
loadFromDb: (pubkey: string) => Promise<void>;
|
||||
fetchNotifications: (pubkey: string) => Promise<void>;
|
||||
@@ -25,7 +26,7 @@ interface NotificationsState {
|
||||
isRead: (eventId: string) => boolean;
|
||||
markDMRead: (partnerPubkey: string) => void;
|
||||
computeDMUnread: (conversations: Array<{ partnerPubkey: string; lastAt: number }>) => void;
|
||||
incrementNewFollowers: () => void;
|
||||
addNewFollower: (pubkey: string) => void;
|
||||
clearNewFollowers: () => void;
|
||||
}
|
||||
|
||||
@@ -76,6 +77,7 @@ export const useNotificationsStore = create<NotificationsState>((set, get) => ({
|
||||
dmLastSeen: loadDMLastSeen(),
|
||||
dmUnreadCount: 0,
|
||||
newFollowersCount: 0,
|
||||
newFollowerPubkeys: new Set<string>(),
|
||||
|
||||
loadFromDb: async (pubkey: string) => {
|
||||
const isNewAccount = pubkey !== get().currentPubkey;
|
||||
@@ -210,6 +212,9 @@ export const useNotificationsStore = create<NotificationsState>((set, get) => ({
|
||||
set({ dmUnreadCount });
|
||||
},
|
||||
|
||||
incrementNewFollowers: () => set((s) => ({ newFollowersCount: s.newFollowersCount + 1 })),
|
||||
clearNewFollowers: () => set({ newFollowersCount: 0 }),
|
||||
addNewFollower: (pubkey: string) => set((s) => ({
|
||||
newFollowersCount: s.newFollowersCount + 1,
|
||||
newFollowerPubkeys: new Set([...s.newFollowerPubkeys, pubkey]),
|
||||
})),
|
||||
clearNewFollowers: () => set({ newFollowersCount: 0, newFollowerPubkeys: new Set() }),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user