import {
ChannelDescriptionStatus,
ChannelDescriptionUiEvents
} from "tc-shared/ui/frames/side/ChannelDescriptionDefinitions";
import {Registry} from "tc-shared/events";
import * as React from "react";
import {useState} from "react";
import {Translatable, VariadicTranslatable} from "tc-shared/ui/react-elements/i18n";
import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots";
import {BBCodeRenderer} from "tc-shared/text/bbcode";
const cssStyle = require("./ChannelDescriptionRenderer.scss");
const CenteredTextRenderer = (props: { children?: React.ReactElement | (React.ReactElement | string)[], className?: string }) => {
return (
);
}
const DescriptionRenderer = React.memo((props: { description: string, handlerId: string }) => {
if(!props.description) {
return (
Channel has no description
)
}
return (
)
});
const DescriptionErrorRenderer = React.memo((props: { error: string }) => (
An error happened while fetching the channel description:
{props.error}
));
const PermissionErrorRenderer = React.memo((props: { failedPermission: string }) => (
You don't have the permission to watch the channel description.
{props.failedPermission}
));
export const ChannelDescriptionRenderer = React.memo((props: { events: Registry }) => {
const [ description, setDescription ] = useState(() => {
props.events.fire("query_description");
return { status: "loading" };
});
props.events.reactUse("notify_description", event => setDescription(event.status));
switch (description.status) {
case "success":
return (
);
case "error":
return (
);
case "no-permissions":
return (
);
case "loading":
default:
return (
loading channel description
);
}
});