Signal-iOS/SignalServiceKit/PinnedThreadManager/PinnedThreadManager.swift

51 lines
1.2 KiB
Swift

//
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
public enum PinnedThreads {
public static var maxPinnedThreads: UInt {
RemoteConfig.current.pinnedThreadLimit
}
}
public protocol PinnedThreadManager {
func pinnedThreadIds(tx: DBReadTransaction) -> [String]
func pinnedThreads(tx: DBReadTransaction) -> [TSThread]
func isThreadPinned(_ thread: TSThread, tx: DBReadTransaction) -> Bool
func updatePinnedThreadIds(
_ pinnedThreadIds: [String],
updateStorageService: Bool,
tx: DBWriteTransaction,
)
func pinThread(
_ thread: TSThread,
updateStorageService: Bool,
tx: DBWriteTransaction,
) throws
func unpinThread(
_ thread: TSThread,
updateStorageService: Bool,
tx: DBWriteTransaction,
) throws
func handleUpdatedThread(_ thread: TSThread, tx: DBWriteTransaction)
}
@objc
public class PinnedThreadManagerObjcBridge: NSObject {
@objc
static func handleUpdatedThread(_ thread: TSThread, transaction: DBWriteTransaction) {
DependenciesBridge.shared.pinnedThreadManager.handleUpdatedThread(thread, tx: transaction)
}
}