You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
2 years ago
|
import { getClientColor } from "../clients";
|
||
4 years ago
|
import { Avatar } from "../components/Avatar";
|
||
4 years ago
|
import { centerScrollOn } from "../scene/scroll";
|
||
4 years ago
|
import { Collaborator } from "../types";
|
||
|
import { register } from "./register";
|
||
5 years ago
|
|
||
|
export const actionGoToCollaborator = register({
|
||
|
name: "goToCollaborator",
|
||
2 years ago
|
viewMode: true,
|
||
3 years ago
|
trackEvent: { category: "collab" },
|
||
5 years ago
|
perform: (_elements, appState, value) => {
|
||
|
const point = value as Collaborator["pointer"];
|
||
|
if (!point) {
|
||
|
return { appState, commitToHistory: false };
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
appState: {
|
||
|
...appState,
|
||
4 years ago
|
...centerScrollOn({
|
||
|
scenePoint: point,
|
||
|
viewportDimensions: {
|
||
|
width: appState.width,
|
||
|
height: appState.height,
|
||
|
},
|
||
|
zoom: appState.zoom,
|
||
|
}),
|
||
5 years ago
|
// Close mobile menu
|
||
|
openMenu: appState.openMenu === "canvas" ? null : appState.openMenu,
|
||
|
},
|
||
|
commitToHistory: false,
|
||
|
};
|
||
|
},
|
||
2 years ago
|
PanelComponent: ({ updateData, data }) => {
|
||
3 years ago
|
const [clientId, collaborator] = data as [string, Collaborator];
|
||
5 years ago
|
|
||
2 years ago
|
const background = getClientColor(clientId);
|
||
5 years ago
|
|
||
|
return (
|
||
|
<Avatar
|
||
|
color={background}
|
||
|
onClick={() => updateData(collaborator.pointer)}
|
||
3 years ago
|
name={collaborator.username || ""}
|
||
3 years ago
|
src={collaborator.avatarUrl}
|
||
3 years ago
|
/>
|
||
5 years ago
|
);
|
||
|
},
|
||
|
});
|