Skip to content

Commit

Permalink
feat: able to move call blips with game position attached
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Jul 8, 2023
1 parent cb518a9 commit 9eff341
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export class Calls911Controller {
typeId: data.type,
extraFields: data.extraFields || undefined,
status: (data.status as WhitelistStatus | null) || undefined,
gtaMapPositionId: data.gtaMapPosition === null ? null : undefined,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,19 @@ export function RenderActiveCalls() {
const latLng = e.target._latlng;
const data = {
...call,
gtaMapPosition: null,
gtaMapPositionId: null,
position: { id: call.positionId ?? "", ...latLng },
};

handleCallStateUpdate(call.id, { ...data });
handleCallStateUpdate(call.id, data);

const { json } = await execute<Put911CallByIdData>({
path: `/911-calls/${call.id}`,
method: "PUT",
data: {
gtaMapPosition: null,
gtaMapPositionId: null,
position: data.position,
},
});
Expand Down Expand Up @@ -107,9 +111,10 @@ export function RenderActiveCalls() {
<>
{!hiddenItems[MapItem.CALLS] &&
callsWithPosition.map((call) => {
const callGtaPosition = call.gtaMapPosition
? convertToMap(call.gtaMapPosition.x, call.gtaMapPosition.y, map)
: null;
const callGtaPosition =
call.gtaMapPosition && call.gtaMapPositionId
? convertToMap(call.gtaMapPosition.x, call.gtaMapPosition.y, map)
: null;
const callPosition = call.position as { lat: number; lng: number };
const position = callGtaPosition ?? callPosition;

Expand All @@ -118,15 +123,12 @@ export function RenderActiveCalls() {
eventHandlers={{
moveend: (e) => handleMoveEnd(e, call),
}}
// must be managed by in-game updates
draggable={!call.gtaMapPosition}
draggable
key={call.id}
position={position}
icon={CALL_ICON}
>
{!call.gtaMapPosition ? (
<Tooltip direction="top">{t("dragToMoveCallBlip")}</Tooltip>
) : null}
<Tooltip direction="top">{t("dragToMoveCallBlip")}</Tooltip>

<Popup minWidth={300}>
<p style={{ margin: 2, fontSize: 18 }}>
Expand Down

0 comments on commit 9eff341

Please sign in to comment.