TM-SGNL-iOS/SignalServiceKit/PinnedThreadManager/PinnedThreadManager.swift
TeleMessage developers dde0620daf initial commit
2025-05-03 12:28:28 -07:00

48 lines
1.2 KiB
Swift

//
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
public enum PinnedThreads {
public static let maxPinnedThreads = 4
}
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: SDSAnyWriteTransaction) {
DependenciesBridge.shared.pinnedThreadManager.handleUpdatedThread(thread, tx: transaction.asV2Write)
}
}