61f695b7c6
Closes: https://github.com/damus-io/damus/issues/2438 Changelog-Added: Add Timeline switcher button for NIP-81-favorites Signed-off-by: Askeew <askeew@hotmail.com>
27 lines
639 B
Swift
27 lines
639 B
Swift
import Foundation
|
|
|
|
class ContactCardManagerMock: ContactCard {
|
|
var event: NostrEvent?
|
|
var favorites: Set<Pubkey> = []
|
|
|
|
func isFavorite(_ pubkey: Pubkey) -> Bool {
|
|
favorites.contains(pubkey)
|
|
}
|
|
|
|
func toggleFavorite(_ pubkey: Pubkey, postbox: PostBox, keyPair: FullKeypair?) {
|
|
if favorites.contains(pubkey) {
|
|
favorites.remove(pubkey)
|
|
} else {
|
|
favorites.insert(pubkey)
|
|
}
|
|
}
|
|
|
|
func loadEvent(_ ev: NostrEvent, pubkey: Pubkey) {
|
|
event = ev
|
|
}
|
|
|
|
var filter: ((_ ev: NostrEvent) -> Bool) {
|
|
{ ev in self.favorites.contains(ev.pubkey) }
|
|
}
|
|
}
|