fix: load userdata of photos better
This commit is contained in:
parent
1666e350a6
commit
7cb0a7629a
|
@ -1,7 +1,8 @@
|
||||||
|
import {RoomObjectCategory, RoomObjectVariable} from "@nitro/renderer";
|
||||||
import {FC, useEffect, useState} from "react";
|
import {FC, useEffect, useState} from "react";
|
||||||
import {FaArrowLeft, FaArrowRight} from "react-icons/fa";
|
import {FaArrowLeft, FaArrowRight} from "react-icons/fa";
|
||||||
|
|
||||||
import {GetUserProfile, IPhotoData, LocalizeText} from "../../../api";
|
import {GetRoomEngine, GetUserProfile, IPhotoData, LocalizeText} from "../../../api";
|
||||||
import {Flex, Grid, Text} from "../../../common";
|
import {Flex, Grid, Text} from "../../../common";
|
||||||
|
|
||||||
export interface CameraWidgetShowPhotoViewProps {
|
export interface CameraWidgetShowPhotoViewProps {
|
||||||
|
@ -35,6 +36,16 @@ export const CameraWidgetShowPhotoView: FC<CameraWidgetShowPhotoViewProps> = pro
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getUserData = (roomId: number, objectId: number, type: string): number | string => {
|
||||||
|
const roomObject = GetRoomEngine().getRoomObject(roomId, objectId, RoomObjectCategory.WALL);
|
||||||
|
|
||||||
|
if (!roomObject) return;
|
||||||
|
|
||||||
|
return type == "username"
|
||||||
|
? roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_NAME)
|
||||||
|
: roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_ID);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setImageIndex(currentIndex);
|
setImageIndex(currentIndex);
|
||||||
}, [currentIndex]);
|
}, [currentIndex]);
|
||||||
|
@ -54,8 +65,8 @@ export const CameraWidgetShowPhotoView: FC<CameraWidgetShowPhotoViewProps> = pro
|
||||||
{currentPhotos.length > 1 && (
|
{currentPhotos.length > 1 && (
|
||||||
<Flex className="picture-preview-buttons">
|
<Flex className="picture-preview-buttons">
|
||||||
<FaArrowLeft className="cursor-pointer picture-preview-buttons-previous fa-icon" onClick={previous} />
|
<FaArrowLeft className="cursor-pointer picture-preview-buttons-previous fa-icon" onClick={previous} />
|
||||||
<Text underline className="cursor-pointer" onClick={event => GetUserProfile(currentImage.oi)}>
|
<Text underline className="cursor-pointer" onClick={() => GetUserProfile(Number(getUserData(currentImage.s, Number(currentImage.u), "id")))}>
|
||||||
{currentImage.o}
|
{getUserData(currentImage.s, Number(currentImage.u), "username")}
|
||||||
</Text>
|
</Text>
|
||||||
<FaArrowRight className="cursor-pointer picture-preview-buttons-next fa-icon" onClick={next} />
|
<FaArrowRight className="cursor-pointer picture-preview-buttons-next fa-icon" onClick={next} />
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
Loading…
Reference in New Issue