import * as React from "react"; import {LocalIcon} from "tc-shared/FileManager"; export interface IconProperties { icon: string | LocalIcon; title?: string; } export class IconRenderer extends React.Component { render() { if(!this.props.icon) return
; else if(typeof this.props.icon === "string") return
; else if(this.props.icon instanceof LocalIcon) return ; else throw "JQuery icons are not longer supported"; } } export interface LoadedIconRenderer { icon: LocalIcon; title?: string; } export class LocalIconRenderer extends React.Component { private readonly callback_state_update; constructor(props) { super(props); this.callback_state_update = () => { const icon = this.props.icon; if(icon.status !== "destroyed") this.forceUpdate(); }; } render() { const icon = this.props.icon; if(icon.status === "loaded") { if(icon.icon_id >= 0 && icon.icon_id <= 1000) { if(icon.icon_id === 0) return
; return
; } return
{this.props.title
; } else if(icon.status === "loading") return
; else if(icon.status === "error") return
; else if(icon.status === "empty" || icon.status === "destroyed") return
; } componentDidMount(): void { this.props.icon.status_change_callbacks.push(this.callback_state_update); } componentWillUnmount(): void { this.props.icon.status_change_callbacks.remove(this.callback_state_update); } }