mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-13 01:46:51 +01:00
37 lines
879 B
Swift
37 lines
879 B
Swift
//
|
|
// SidebarModel.swift
|
|
// NetNewsWire
|
|
//
|
|
// Created by Maurice Parker on 6/28/20.
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import Account
|
|
|
|
protocol SidebarModelDelegate: class {
|
|
func sidebarSelectionDidChange(_: SidebarModel, feeds: [Feed]?)
|
|
func unreadCount(for: Feed) -> Int
|
|
}
|
|
|
|
class SidebarModel: ObservableObject {
|
|
|
|
weak var delegate: SidebarModelDelegate?
|
|
|
|
@Published var sidebarItems = [SidebarItem]()
|
|
|
|
func rebuildSidebarItems() {
|
|
guard let delegate = delegate else { return }
|
|
var items = [SidebarItem]()
|
|
|
|
var smartFeedControllerItem = SidebarItem(SmartFeedsController.shared)
|
|
for feed in SmartFeedsController.shared.smartFeeds {
|
|
smartFeedControllerItem.addChild(SidebarItem(feed, unreadCount: delegate.unreadCount(for: feed)))
|
|
}
|
|
items.append(smartFeedControllerItem)
|
|
|
|
sidebarItems = items
|
|
}
|
|
|
|
}
|