import SwiftUI
import VoiceCatCore

struct UserListView: View {
    @Bindable var session: SessionState

    var body: some View {
        let channelUsers = session.currentChannelId == 0
            ? session.users
            : session.users.filter { $0.channelId == session.currentChannelId }

        List(channelUsers) { user in
            UserRow(user: user, session: session)
        }
        .listStyle(.plain)
        .overlay {
            if channelUsers.isEmpty {
                ContentUnavailableView(
                    "No Users",
                    systemImage: "person.slash",
                    description: Text(session.currentChannelId == 0 ? "Join a channel to see users." : "No one else here yet.")
                )
            }
        }
    }
}
