Web: Rooms: Changed create/upload room logo

This commit is contained in:
Alexey Safronov 2022-08-22 18:51:16 +03:00
parent bc426aa1d2
commit 2fcfc19fae
2 changed files with 34 additions and 10 deletions

View File

@ -63,12 +63,24 @@ const CreateRoomEvent = ({
await addTagsToRoom(room.id, addTagsData);
if (roomParams.icon.uploadedFile)
await uploadRoomLogo(uploadLogoData).then((response) => {
const { x, y, width, height } = roomParams.icon;
addLogoToRoom({ tmpFile: response.data, x, y, width, height });
});
if (roomParams.icon.uploadedFile) {
const response = await uploadRoomLogo(uploadLogoData);
var img = new Image();
img.onload = function () {
const { x, y, width, height } = roomParams.icon;
const newX = Math.round(x * img.width - width / 2);
const newY = Math.round(y * img.height - height / 2);
addLogoToRoom(roomId, {
tmpFile: response.data,
x: newX,
y: newY,
width,
height,
});
};
img.src = response.data;
}
await updateCurrentFolder(null, currrentFolderId);
} catch (err) {
console.log(err);

View File

@ -77,12 +77,24 @@ const EditRoomEvent = ({
await addTagsToRoom(roomId, tags);
await removeTagsFromRoom(roomId, removedTags);
if (roomParams.icon.uploadedFile)
await uploadRoomLogo(uploadLogoData).then((response) => {
const { x, y, width, height } = roomParams.icon;
addLogoToRoom({ tmpFile: response.data, x, y, width, height });
});
if (roomParams.icon.uploadedFile) {
const response = await uploadRoomLogo(uploadLogoData);
var img = new Image();
img.onload = function () {
const { x, y, width, height } = roomParams.icon;
const newX = Math.round(x * img.width - width / 2);
const newY = Math.round(y * img.height - height / 2);
addLogoToRoom(roomId, {
tmpFile: response.data,
x: newX,
y: newY,
width,
height,
});
};
img.src = response.data;
}
await updateCurrentFolder(null, currrentFolderId);
} catch (err) {
console.log(err);