//
//  LNRoomSeatItem.swift
//  Gami
//
//  Created by OneeChan on 2026/3/12.
//

import Foundation
import AtomicXCore

class LNRoomSeatItem {
    let index: Int
    var avatar: String = ""
    var nickname: String = ""
    var isLocked: Bool = false
    var uid: String = ""
    var isMute: Bool = false
    var isLocalMute: Bool = false
    
    init(index: Int) {
        self.index = index
    }
    
    @discardableResult
    func update(_ item: SeatInfo) -> Bool {
        if avatar != item.userInfo.avatarURL
            || nickname != item.userInfo.userName
            || isLocked != item.isLocked
            || uid != item.userInfo.userID
            || isMute != !item.userInfo.allowOpenMicrophone
            || isLocalMute != (item.userInfo.microphoneStatus == .off) {
            avatar = item.userInfo.avatarURL
            nickname = item.userInfo.userName
            isLocked = item.isLocked
            uid = item.userInfo.userID
            isMute = !item.userInfo.allowOpenMicrophone
            isLocalMute = item.userInfo.microphoneStatus == .off
            
            return true
        }
        return false
    }
}
