This commit is contained in:
parent
db9711cf12
commit
650b31c42a
1 changed files with 7 additions and 25 deletions
|
@ -25,32 +25,11 @@ import {useState} from "react";
|
||||||
const clientStyle = require("./Client.scss");
|
const clientStyle = require("./Client.scss");
|
||||||
const viewStyle = require("./View.scss");
|
const viewStyle = require("./View.scss");
|
||||||
|
|
||||||
const IconUpdateKeys: (keyof ClientProperties)[] = [
|
const ClientStatusIndicator = (props: { client: ClientEntryController }) => {
|
||||||
"client_away",
|
const [ icon, setIcon ] = useState<ClientIcon>(props.client.getStatusIcon());
|
||||||
"client_input_hardware",
|
props.client.events.reactUse("notify_status_icon_changed", event => setIcon(event.newIcon));
|
||||||
"client_output_hardware",
|
|
||||||
"client_output_muted",
|
|
||||||
"client_input_muted",
|
|
||||||
"client_is_channel_commander",
|
|
||||||
"client_talk_power"
|
|
||||||
];
|
|
||||||
|
|
||||||
export const ClientStatusIndicator = (props: { client: ClientEntryController, renderer?: (icon: ClientIcon) => React.ReactElement }) => {
|
return <ClientIconRenderer icon={icon} />;
|
||||||
const [ revision, setRevision ] = useState(0);
|
|
||||||
|
|
||||||
props.client.events.reactUse("notify_properties_updated", event => {
|
|
||||||
for (const key of IconUpdateKeys) {
|
|
||||||
if (key in event.updated_properties) {
|
|
||||||
setRevision(revision + 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
props.client.events.reactUse("notify_mute_state_change", () => setRevision(revision + 1));
|
|
||||||
props.client.events.reactUse("notify_speak_state_change", () => setRevision(revision + 1));
|
|
||||||
|
|
||||||
return props.renderer ? props.renderer(props.client.getStatusIcon()) : <ClientIconRenderer icon={props.client.getStatusIcon()} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ClientServerGroupIconsProperties {
|
interface ClientServerGroupIconsProperties {
|
||||||
|
@ -252,6 +231,9 @@ class ClientName extends ReactComponentBase<ClientNameProperties, ClientNameStat
|
||||||
|
|
||||||
state.group_prefix = suffix_groups.map(e => "[" + e + "]").join("");
|
state.group_prefix = suffix_groups.map(e => "[" + e + "]").join("");
|
||||||
state.group_suffix = prefix_groups.map(e => "[" + e + "]").join("");
|
state.group_suffix = prefix_groups.map(e => "[" + e + "]").join("");
|
||||||
|
|
||||||
|
state.group_prefix = state.group_prefix ? " " + state.group_prefix : "";
|
||||||
|
state.group_suffix = state.group_suffix ? " " + state.group_suffix : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateAwayMessage(state: ClientNameState) {
|
private updateAwayMessage(state: ClientNameState) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue