From eb0c8a48ec739410c67b36a505e622478b0002d5 Mon Sep 17 00:00:00 2001 From: oobjectt Date: Thu, 8 Dec 2022 16:07:20 +0100 Subject: [PATCH 1/2] Fix issue #11 - Report user photos --- src/common/card/NitroCardHeaderView.tsx | 9 ++- src/common/card/NitroCardView.scss | 56 +++++++++++++++++-- .../help/views/ReportSummaryView.tsx | 10 ++-- .../furniture/FurnitureExternalImageView.tsx | 7 ++- src/hooks/help/useHelp.ts | 3 +- 5 files changed, 70 insertions(+), 15 deletions(-) diff --git a/src/common/card/NitroCardHeaderView.tsx b/src/common/card/NitroCardHeaderView.tsx index 416a0167..6805427a 100644 --- a/src/common/card/NitroCardHeaderView.tsx +++ b/src/common/card/NitroCardHeaderView.tsx @@ -5,13 +5,15 @@ import { Base, Column, ColumnProps, Flex } from '..'; interface NitroCardHeaderViewProps extends ColumnProps { headerText: string; + isGalleryPhoto?: boolean; noCloseButton?: boolean; + onReportPhoto?: (event: MouseEvent) => void; onCloseClick: (event: MouseEvent) => void; } export const NitroCardHeaderView: FC = props => { - const { headerText = null, noCloseButton = false, onCloseClick = null, justifyContent = 'center', alignItems = 'center', classNames = [], children = null, ...rest } = props; + const { headerText = null, isGalleryPhoto = false, noCloseButton = false, onReportPhoto = null, onCloseClick = null, justifyContent = 'center', alignItems = 'center', classNames = [], children = null, ...rest } = props; const getClassNames = useMemo(() => { @@ -32,6 +34,11 @@ export const NitroCardHeaderView: FC = props => { headerText } + { isGalleryPhoto && + + + + } diff --git a/src/common/card/NitroCardView.scss b/src/common/card/NitroCardView.scss index e942d516..b5e7f21b 100644 --- a/src/common/card/NitroCardView.scss +++ b/src/common/card/NitroCardView.scss @@ -36,11 +36,34 @@ $nitro-card-tabs-height: 33px; rgba(194, 48, 39, 1) 50%, rgba(194, 48, 39, 1) 100% ); - + &:hover { filter: brightness(1.2); } - + + &:active { + filter: brightness(0.8); + } + } + + .nitro-card-header-report-camera { + cursor: pointer; + padding: 1px 3px; + line-height: 1; + border-radius: $border-radius; + box-shadow: 0 0 0 1.6px $white; + border: 2px solid #921911; + background: repeating-linear-gradient( + rgba(245, 80, 65, 1), + rgba(245, 80, 65, 1) 50%, + rgba(194, 48, 39, 1) 50%, + rgba(194, 48, 39, 1) 100% + ); + + &:hover { + filter: brightness(1.2); + } + &:active { filter: brightness(0.8); } @@ -101,7 +124,7 @@ $nitro-card-tabs-height: 33px; width: 100%; margin: 0; padding-top:2px; - + &:before { position: absolute; content: " "; @@ -137,7 +160,32 @@ $nitro-card-tabs-height: 33px; &:hover { filter: brightness(1.2); } - + + &:active { + filter: brightness(0.8); + } + } + + .nitro-card-header-report-camera { + cursor: pointer; + padding: 0px 2px; + margin-right: 4px; + line-height: 1; + @include font-size($h7-font-size); + border-radius: $border-radius; + box-shadow: 0 0 0 1.6px $white; + border: 2px solid #921911; + background: repeating-linear-gradient( + rgba(245, 80, 65, 1), + rgba(245, 80, 65, 1) 50%, + rgba(194, 48, 39, 1) 50%, + rgba(194, 48, 39, 1) 100% + ); + + &:hover { + filter: brightness(1.2); + } + &:active { filter: brightness(0.8); } diff --git a/src/components/help/views/ReportSummaryView.tsx b/src/components/help/views/ReportSummaryView.tsx index 1aa04031..ad07d3e4 100644 --- a/src/components/help/views/ReportSummaryView.tsx +++ b/src/components/help/views/ReportSummaryView.tsx @@ -1,6 +1,6 @@ -import { CallForHelpFromForumMessageMessageComposer, CallForHelpFromForumThreadMessageComposer, CallForHelpFromIMMessageComposer, CallForHelpFromPhotoMessageComposer, CallForHelpMessageComposer } from '@nitrots/nitro-renderer'; +import { CallForHelpFromForumMessageMessageComposer, CallForHelpFromForumThreadMessageComposer, CallForHelpFromIMMessageComposer, CallForHelpMessageComposer } from '@nitrots/nitro-renderer'; import { FC } from 'react'; -import { GetSessionDataManager, LocalizeText, ReportType, SendMessageComposer } from '../../../api'; +import { LocalizeText, ReportType, SendMessageComposer } from '../../../api'; import { Button, Column, Text } from '../../../common'; import { useHelp } from '../../../hooks'; @@ -16,7 +16,8 @@ export const ReportSummaryView: FC<{}> = props => { case ReportType.BULLY: case ReportType.EMERGENCY: - case ReportType.ROOM: { + case ReportType.ROOM: + case ReportType.PHOTO: { const reportedRoomId = ((activeReport.roomId <= 0) ? activeReport.reportedChats[0].roomId : activeReport.roomId); activeReport.reportedChats.forEach(entry => chats.push(entry.webId, entry.message)); @@ -35,9 +36,6 @@ export const ReportSummaryView: FC<{}> = props => case ReportType.MESSAGE: SendMessageComposer(new CallForHelpFromForumMessageMessageComposer(activeReport.groupId, activeReport.threadId, activeReport.messageId, activeReport.cfhTopic, activeReport.message)); break; - case ReportType.PHOTO: - SendMessageComposer(new CallForHelpFromPhotoMessageComposer(activeReport.extraData, activeReport.cfhTopic, activeReport.roomId, GetSessionDataManager().userId, activeReport.roomObjectId)); - break; } setActiveReport(null); diff --git a/src/components/room/widgets/furniture/FurnitureExternalImageView.tsx b/src/components/room/widgets/furniture/FurnitureExternalImageView.tsx index 301aac3f..722031a5 100644 --- a/src/components/room/widgets/furniture/FurnitureExternalImageView.tsx +++ b/src/components/room/widgets/furniture/FurnitureExternalImageView.tsx @@ -1,17 +1,20 @@ +import { GetSessionDataManager, ReportType } from 'api'; import { FC } from 'react'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; -import { useFurnitureExternalImageWidget } from '../../../../hooks'; +import { useFurnitureExternalImageWidget, useHelp, useNavigator } from '../../../../hooks'; import { CameraWidgetShowPhotoView } from '../../../camera/views/CameraWidgetShowPhotoView'; export const FurnitureExternalImageView: FC<{}> = props => { const { objectId = -1, currentPhotoIndex = -1, currentPhotos = null, onClose = null } = useFurnitureExternalImageWidget(); + const { navigatorData = null } = useNavigator(); + const { report = null } = useHelp(); if((objectId === -1) || (currentPhotoIndex === -1)) return null; return ( - + report(ReportType.PHOTO, { reportedUserId: GetSessionDataManager().userId, roomId: navigatorData.enteredGuestRoom.roomId, roomName: navigatorData.enteredGuestRoom.roomName }) } onCloseClick={ onClose } /> diff --git a/src/hooks/help/useHelp.ts b/src/hooks/help/useHelp.ts index 9a67fb7f..fd3b790a 100644 --- a/src/hooks/help/useHelp.ts +++ b/src/hooks/help/useHelp.ts @@ -39,6 +39,7 @@ const useHelpState = () => newReport.currentStep = ReportState.SELECT_CHATS; break; case ReportType.ROOM: + case ReportType.PHOTO: newReport.roomId = options.roomId; newReport.roomName = options.roomName; newReport.currentStep = ReportState.SELECT_TOPICS; @@ -54,8 +55,6 @@ const useHelpState = () => newReport.messageId = options.messageId; newReport.currentStep = ReportState.SELECT_TOPICS; break; - case ReportType.PHOTO: - break; case ReportType.GUIDE: break; } From 84032c62d812f3fe091060e906c5492abc906884 Mon Sep 17 00:00:00 2001 From: oobjectt Date: Sun, 11 Dec 2022 21:23:40 +0100 Subject: [PATCH 2/2] Changed requested changes --- src/components/help/views/ReportSummaryView.tsx | 8 +++++--- .../room/widgets/furniture/FurnitureExternalImageView.tsx | 5 ++--- src/hooks/help/useHelp.ts | 8 +++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/help/views/ReportSummaryView.tsx b/src/components/help/views/ReportSummaryView.tsx index ad07d3e4..aa78c7cb 100644 --- a/src/components/help/views/ReportSummaryView.tsx +++ b/src/components/help/views/ReportSummaryView.tsx @@ -1,4 +1,4 @@ -import { CallForHelpFromForumMessageMessageComposer, CallForHelpFromForumThreadMessageComposer, CallForHelpFromIMMessageComposer, CallForHelpMessageComposer } from '@nitrots/nitro-renderer'; +import { CallForHelpFromForumMessageMessageComposer, CallForHelpFromForumThreadMessageComposer, CallForHelpFromIMMessageComposer, CallForHelpFromPhotoMessageComposer, CallForHelpMessageComposer } from '@nitrots/nitro-renderer'; import { FC } from 'react'; import { LocalizeText, ReportType, SendMessageComposer } from '../../../api'; import { Button, Column, Text } from '../../../common'; @@ -16,8 +16,7 @@ export const ReportSummaryView: FC<{}> = props => { case ReportType.BULLY: case ReportType.EMERGENCY: - case ReportType.ROOM: - case ReportType.PHOTO: { + case ReportType.ROOM: { const reportedRoomId = ((activeReport.roomId <= 0) ? activeReport.reportedChats[0].roomId : activeReport.roomId); activeReport.reportedChats.forEach(entry => chats.push(entry.webId, entry.message)); @@ -36,6 +35,9 @@ export const ReportSummaryView: FC<{}> = props => case ReportType.MESSAGE: SendMessageComposer(new CallForHelpFromForumMessageMessageComposer(activeReport.groupId, activeReport.threadId, activeReport.messageId, activeReport.cfhTopic, activeReport.message)); break; + case ReportType.PHOTO: + SendMessageComposer(new CallForHelpFromPhotoMessageComposer(activeReport.extraData, activeReport.roomId, activeReport.reportedUserId, activeReport.cfhTopic, activeReport.roomObjectId)); + break; } setActiveReport(null); diff --git a/src/components/room/widgets/furniture/FurnitureExternalImageView.tsx b/src/components/room/widgets/furniture/FurnitureExternalImageView.tsx index 722031a5..7ae4173d 100644 --- a/src/components/room/widgets/furniture/FurnitureExternalImageView.tsx +++ b/src/components/room/widgets/furniture/FurnitureExternalImageView.tsx @@ -1,20 +1,19 @@ import { GetSessionDataManager, ReportType } from 'api'; import { FC } from 'react'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; -import { useFurnitureExternalImageWidget, useHelp, useNavigator } from '../../../../hooks'; +import { useFurnitureExternalImageWidget, useHelp } from '../../../../hooks'; import { CameraWidgetShowPhotoView } from '../../../camera/views/CameraWidgetShowPhotoView'; export const FurnitureExternalImageView: FC<{}> = props => { const { objectId = -1, currentPhotoIndex = -1, currentPhotos = null, onClose = null } = useFurnitureExternalImageWidget(); - const { navigatorData = null } = useNavigator(); const { report = null } = useHelp(); if((objectId === -1) || (currentPhotoIndex === -1)) return null; return ( - report(ReportType.PHOTO, { reportedUserId: GetSessionDataManager().userId, roomId: navigatorData.enteredGuestRoom.roomId, roomName: navigatorData.enteredGuestRoom.roomName }) } onCloseClick={ onClose } /> + report(ReportType.PHOTO, { extraData: currentPhotos[currentPhotoIndex].w, roomId: currentPhotos[currentPhotoIndex].s, reportedUserId: GetSessionDataManager().userId, roomObjectId: Number(currentPhotos[currentPhotoIndex].u) }) } onCloseClick={ onClose } /> diff --git a/src/hooks/help/useHelp.ts b/src/hooks/help/useHelp.ts index fd3b790a..1c74b626 100644 --- a/src/hooks/help/useHelp.ts +++ b/src/hooks/help/useHelp.ts @@ -39,7 +39,6 @@ const useHelpState = () => newReport.currentStep = ReportState.SELECT_CHATS; break; case ReportType.ROOM: - case ReportType.PHOTO: newReport.roomId = options.roomId; newReport.roomName = options.roomName; newReport.currentStep = ReportState.SELECT_TOPICS; @@ -55,6 +54,13 @@ const useHelpState = () => newReport.messageId = options.messageId; newReport.currentStep = ReportState.SELECT_TOPICS; break; + case ReportType.PHOTO: + newReport.extraData = options.extraData; + newReport.roomId = options.roomId; + newReport.reportedUserId = options.reportedUserId; + newReport.roomObjectId = options.roomObjectId; + newReport.currentStep = ReportState.SELECT_TOPICS; + break; case ReportType.GUIDE: break; }