2021-06-19 10:29:04 -04:00
|
|
|
import { User } from "revolt.js";
|
|
|
|
import { Users } from "revolt.js/dist/api/objects";
|
|
|
|
|
2021-07-05 06:23:23 -04:00
|
|
|
import { Text } from "preact-i18n";
|
2021-07-06 17:58:45 -04:00
|
|
|
import Tooltip from "../Tooltip";
|
2021-07-05 06:23:23 -04:00
|
|
|
|
2021-06-19 10:29:04 -04:00
|
|
|
interface Props {
|
2021-07-09 17:15:36 -04:00
|
|
|
user?: User;
|
2021-07-06 17:58:45 -04:00
|
|
|
tooltip?: boolean;
|
2021-06-19 10:29:04 -04:00
|
|
|
}
|
|
|
|
|
2021-07-06 17:58:45 -04:00
|
|
|
export default function UserStatus({ user, tooltip }: Props) {
|
2021-07-09 17:15:36 -04:00
|
|
|
if (user?.online) {
|
2021-07-05 06:25:20 -04:00
|
|
|
if (user.status?.text) {
|
2021-07-06 17:58:45 -04:00
|
|
|
if (tooltip) {
|
|
|
|
return (
|
|
|
|
<Tooltip arrow={undefined} content={ user.status.text }>
|
|
|
|
{ user.status.text }
|
|
|
|
</Tooltip>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return <>{user.status.text}</>;
|
2021-07-05 06:25:20 -04:00
|
|
|
}
|
2021-06-19 10:29:04 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
if (user.status?.presence === Users.Presence.Busy) {
|
|
|
|
return <Text id="app.status.busy" />;
|
|
|
|
}
|
2021-06-19 10:29:04 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
if (user.status?.presence === Users.Presence.Idle) {
|
|
|
|
return <Text id="app.status.idle" />;
|
|
|
|
}
|
2021-06-19 10:29:04 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
if (user.status?.presence === Users.Presence.Invisible) {
|
|
|
|
return <Text id="app.status.offline" />;
|
|
|
|
}
|
2021-06-19 10:29:04 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
return <Text id="app.status.online" />;
|
|
|
|
}
|
2021-06-19 10:29:04 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
return <Text id="app.status.offline" />;
|
2021-06-19 10:29:04 -04:00
|
|
|
}
|