SDK: Fixed getting base room logo. Added requestToken to RoomSelector for opening public rooms.

This commit is contained in:
Ilya Oleshko 2023-12-04 12:25:26 +03:00
parent 0c2a0fe4c2
commit cb76a7e28b
2 changed files with 20 additions and 5 deletions

View File

@ -43,7 +43,7 @@ const convertToItems = (folders) => {
const icon = logo.medium ? logo.medium : getRoomLogo(roomType); const icon = logo.medium ? logo.medium : getRoomLogo(roomType);
const color = logo.color; const color = logo.color;
return { id, label: title, icon, color }; return { id, label: title, icon, color, logo, roomType };
}); });
return items; return items;

View File

@ -12,6 +12,7 @@ import {
createPasswordHash, createPasswordHash,
frameCallCommand, frameCallCommand,
} from "@docspace/common/utils"; } from "@docspace/common/utils";
import { RoomsType } from "@docspace/common/constants";
const Sdk = ({ const Sdk = ({
frameConfig, frameConfig,
@ -25,6 +26,8 @@ const Sdk = ({
getSettings, getSettings,
user, user,
updateProfileCulture, updateProfileCulture,
getRoomsIcon,
getPrimaryLink,
}) => { }) => {
useEffect(() => { useEffect(() => {
window.addEventListener("message", handleMessage, false); window.addEventListener("message", handleMessage, false);
@ -118,8 +121,17 @@ const Sdk = ({
}; };
const onSelectRoom = useCallback( const onSelectRoom = useCallback(
(data) => { async (data) => {
data[0].icon = toRelativeUrl(data[0].icon); if (data[0].logo.large !== "") {
data[0].icon = toRelativeUrl(data[0].logo.large);
} else {
data[0].icon = await getRoomsIcon(data[0].roomType, false, 32);
}
if (data[0].roomType === RoomsType.PublicRoom) {
const { sharedTo } = await getPrimaryLink(data[0].id);
data[0].requestToken = sharedTo?.requestToken;
}
frameCallEvent({ event: "onSelectCallback", data }); frameCallEvent({ event: "onSelectCallback", data });
}, },
@ -180,13 +192,14 @@ const Sdk = ({
return component; return component;
}; };
export default inject(({ auth, settingsStore, peopleStore }) => { export default inject(({ auth, settingsStore, peopleStore, filesStore }) => {
const { login, logout, userStore } = auth; const { login, logout, userStore } = auth;
const { theme, setFrameConfig, frameConfig, getSettings, isLoaded } = const { theme, setFrameConfig, frameConfig, getSettings, isLoaded } =
auth.settingsStore; auth.settingsStore;
const { loadCurrentUser, user } = userStore; const { loadCurrentUser, user } = userStore;
const { updateProfileCulture } = peopleStore.targetUserStore; const { updateProfileCulture } = peopleStore.targetUserStore;
const { getIcon } = settingsStore; const { getIcon, getRoomsIcon } = settingsStore;
const { getPrimaryLink } = filesStore;
return { return {
theme, theme,
@ -197,8 +210,10 @@ export default inject(({ auth, settingsStore, peopleStore }) => {
getSettings, getSettings,
loadCurrentUser, loadCurrentUser,
getIcon, getIcon,
getRoomsIcon,
isLoaded, isLoaded,
updateProfileCulture, updateProfileCulture,
user, user,
getPrimaryLink,
}; };
})(observer(Sdk)); })(observer(Sdk));