1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 22:00:31 +05:30
yattee/Model/UnwatchedFeedCountModel.swift

33 lines
830 B
Swift
Raw Normal View History

2022-12-17 02:56:14 +05:30
import Foundation
import SwiftUI
final class UnwatchedFeedCountModel: ObservableObject {
static let shared = UnwatchedFeedCountModel()
@Published var unwatched = [Account: Int]()
@Published var unwatchedByChannel = [Account: [Channel.ID: Int]]()
private var accounts = AccountsModel.shared
var unwatchedText: Text? {
if let account = accounts.current,
!account.anonymous,
let count = unwatched[account]
{
return Text(String(count))
}
return nil
}
func unwatchedByChannelText(_ channel: Channel) -> Text? {
if let account = accounts.current,
!account.anonymous,
let count = unwatchedByChannel[account]?[channel.id]
{
return Text(String(count))
}
return nil
}
}