TM-SGNL-iOS/SignalServiceKit/Subscriptions/Donations/ProfileBadgesSnapshot+Constructors.swift
TeleMessage developers dde0620daf initial commit
2025-05-03 12:28:28 -07:00

21 lines
717 B
Swift

//
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
public extension ProfileBadgesSnapshot {
static func current() -> ProfileBadgesSnapshot {
let profileSnapshot = SSKEnvironment.shared.profileManagerImplRef.localProfileSnapshot(shouldIncludeAvatar: false)
return forSnapshot(profileSnapshot: profileSnapshot)
}
static func forSnapshot(profileSnapshot: OWSProfileSnapshot) -> ProfileBadgesSnapshot {
ProfileBadgesSnapshot(
existingBadges: (profileSnapshot.profileBadgeInfo ?? []).map {
ProfileBadgesSnapshot.Badge(id: $0.badgeId, isVisible: $0.isVisible ?? false)
}
)
}
}