diff --git a/src/chat/ChatDrawer.tsx b/src/chat/ChatDrawer.tsx index 69ba35f..9b02649 100644 --- a/src/chat/ChatDrawer.tsx +++ b/src/chat/ChatDrawer.tsx @@ -5,6 +5,8 @@ import { useMobile } from "hooks"; import { Team } from "models"; import Chat from "./Chat"; import { pond } from "protobuf-ts/pond"; +import { useEffect, useState } from "react"; +import { useTeamAPI } from "providers"; const useStyles = makeStyles((theme: Theme) => ({ chatDrawer: { @@ -25,8 +27,8 @@ const useStyles = makeStyles((theme: Theme) => ({ backgroundColor: theme.palette.background.default, height: "100vh", width: "100%", - display: "flex", // add this - flexDirection: "column", // add this + display: "flex", + flexDirection: "column", }, drawerHeader: { display: "flex", @@ -46,9 +48,17 @@ interface Props { export function ChatDrawer(props: Props) { const { open, onClose, team } = props; const isMobile = useMobile(); - const classes = useStyles() + const classes = useStyles(); + const teamAPI = useTeamAPI(); - // console.log(team.settings.avatar) + const [selectedTeam, setSelectedTeam] = useState(team); + const [teams, setTeams] = useState([]) + + useEffect(() => { + teamAPI.listTeams(10, 0, "desc", "name", undefined, false, undefined).then(resp => { + setTeams(resp.data.teams) + }) + }, [teamAPI]) return ( - + setSelectedTeam(team)} + sx={{ + border: selectedTeam.settings?.key === team.settings.key ? "1px solid white" : "1px solid transparent", + borderRadius: "50%", + }} + > + {teams.map((t, i)=> { + if (t.settings?.key === team.key()) return null; + return ( + setSelectedTeam(Team.create(t))} + sx={{ + border: selectedTeam.key() === t.settings?.key ? "1px solid white" : "1px solid transparent", + borderRadius: "50%", + }} + key={"chat-team-"+i} + > + + + ) + })} {/* Main chat area */} @@ -85,13 +116,13 @@ export function ChatDrawer(props: Props) { - {team.name()} Chat + {selectedTeam.name()} Chat - + - ) + ); } \ No newline at end of file diff --git a/src/providers/pond/teamAPI.tsx b/src/providers/pond/teamAPI.tsx index 9d84091..32f8a4a 100644 --- a/src/providers/pond/teamAPI.tsx +++ b/src/providers/pond/teamAPI.tsx @@ -117,9 +117,11 @@ export default function TeamProvider(props: PropsWithChildren) { asRoot?: boolean, otherTeam?: string, prefixSearch?: string, + useImitation?: boolean, ) => { //let asText = team ? "&as=" + team.key() : ""; - const view = otherTeam ? otherTeam : (as.length > 0 ? as : undefined) + let view = otherTeam ? otherTeam : (as.length > 0 ? as : undefined) + if (useImitation === undefined || useImitation === false) view = "" let url = pondURL( "/teams" + "?limit=" +