From 49fecd91223a6c7f87aa7c2d41c6d93e6f18fd70 Mon Sep 17 00:00:00 2001 From: Srihari Krishnaswamy Date: Fri, 11 Oct 2024 12:30:00 -0700 Subject: [PATCH 1/2] 3680 Fixed Neighborhood Complete Screen Early --- .../SVLabel/src/SVLabel/navigation/Compass.js | 1 + .../src/SVLabel/navigation/MapService.js | 15 ++++-- .../SVLabel/src/SVLabel/task/TaskContainer.js | 48 +++++++++++++++++-- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/public/javascripts/SVLabel/src/SVLabel/navigation/Compass.js b/public/javascripts/SVLabel/src/SVLabel/navigation/Compass.js index 9aceff0d50..e7818272b7 100644 --- a/public/javascripts/SVLabel/src/SVLabel/navigation/Compass.js +++ b/public/javascripts/SVLabel/src/SVLabel/navigation/Compass.js @@ -76,6 +76,7 @@ function Compass (svl, mapService, taskContainer, uiCompass) { mapService.preparePovReset(); mapService.setPosition(coordinate.lat, coordinate.lng); mapService.setPovToRouteDirection(); + svl.taskContainer.showNeighborhoodCompleteOverlayIfRequired(); } function enableCompassClick() { diff --git a/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js b/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js index 4fe242addd..821afa4b1a 100644 --- a/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js +++ b/public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js @@ -661,8 +661,7 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { * @private */ function _endTheCurrentTask(task, mission) { - - if (!status.labelBeforeJumpListenerSet) { + if (!status.labelBeforeJumpListenerSet) { missionJump = mission; var nextTask = svl.taskContainer.nextTask(task); @@ -673,7 +672,8 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { // Check if the user will jump to another discontinuous location or if this is the last street in their // route/neighborhood. If either is the case, let the user know to label the location before proceeding. - if (svl.neighborhoodModel.isRouteOrNeighborhoodComplete() || !task.isConnectedTo(nextTask)) { + if (svl.neighborhoodModel.isRouteOrNeighborhoodComplete() || (!task.isConnectedTo(nextTask) + && !svl.taskContainer.isLastIncompleteTaskInNeighborhood(task))) { // If jumping to a new place, set the newTask before jumping. if (nextTask && !task.isConnectedTo(nextTask)) { nextTask.eraseFromMinimap(); @@ -690,6 +690,11 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { "pano_changed", trackBeforeJumpActions); } catch (err) {} } else { + // As soon as we jump to the next task, we'll show the neighborhood complete overlay + if (svl.taskContainer.isLastIncompleteTaskInNeighborhood(task)) { + svl.taskContainer.setShowNeighborhoodCompleteOverlayStatus(true); + } + finishCurrentTaskBeforeJumping(missionJump, nextTask); // Move to the new task if the route/neighborhood has not finished. @@ -794,7 +799,7 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { svl.compass.update(); } if (!isOnboarding && "taskContainer" in svl && svl.taskContainer.tasksLoaded()) { - + svl.taskContainer.showNeighborhoodCompleteOverlayIfRequired(); // End of the task if the user is close enough to the end point and we aren't in the tutorial. var task = svl.taskContainer.getCurrentTask(); if (!isOnboarding && task && task.isAtEnd(position.lat(), position.lng(), END_OF_STREET_THRESHOLD)) { @@ -1497,7 +1502,7 @@ function MapService (canvas, neighborhoodModel, uiMap, params) { self.restrictViewPort = restrictViewPort; self.setBeforeJumpLocation = setBeforeJumpLocation; self.setHeadingRange = setHeadingRange; - self.setLabelBeforeJumpListenerStatus = setLabelBeforeJumpListenerStatus; + self.setLabelBeforeJumpListenerStatus = setLabelBeforeJumpListenerStatus; self.setPano = setPano; self.setPosition = setPosition; self.setPositionByIdAndLatLng = setPositionByIdAndLatLng; diff --git a/public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js b/public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js index 3a7fd78483..2453a2cb5a 100644 --- a/public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js +++ b/public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js @@ -18,12 +18,14 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s var tasksFinishedLoading = false; self._tasks = []; + self._showNeighborhoodCompleteOverlayStatus = false; self.tasksLoaded = function() { return tasksFinishedLoading; } self.getFinishedAndInitNextTask = function (finished) { + self.showNeighborhoodCompleteOverlayIfRequired(); var newTask = self.nextTask(finished); if (!newTask) { svl.neighborhoodModel.setComplete(); @@ -335,6 +337,7 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s /** * Checks if finishedTask makes the neighborhood complete across all users; if so, it displays the relevant overlay. + * UPDATE: THIS FUNCTION IS NOW UNUSED * * @param finishedTask */ @@ -378,10 +381,6 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s */ this.nextTask = function (finishedTask) { var newTask; - - // Check if this task finishes the neighborhood across all users, if so, shows neighborhood complete overlay. - updateNeighborhoodCompleteAcrossAllUsersStatus(finishedTask); - // Check if user has audited entire region or route. var tasksNotCompletedByUser = self.getTasks().filter(function (t) { return !t.isComplete() && t.getStreetEdgeId() !== (finishedTask ? finishedTask.getStreetEdgeId() : null); @@ -450,6 +449,19 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s return newTask; }; + /** + * Check if a task is the last incomplete task in the neighborhood. + * @param task + */ + function isLastIncompleteTaskInNeighborhood(task) { + // If this is the last incomplete task in the neighborhood, it should be the only task in the + // incompleteTasksAcrossAllUsers list and should have priority = 1. + var incompleteTasksAcrossAllUsers = self.getIncompleteTasksAcrossAllUsersUsingPriority(); + return incompleteTasksAcrossAllUsers.length === 1 && + incompleteTasksAcrossAllUsers[0].getStreetEdgeId() === task.getStreetEdgeId() && + task.getProperty('priority') === 1; + } + /** * Push a task to previousTasks * @param task @@ -491,6 +503,33 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s } }; + /** + * Display the neighborhood complete overlay if state permits it to be shown. + * Reset the corresponding state afterwards. + */ + this.showNeighborhoodCompleteOverlayIfRequired = function () { + if (self.getShowNeighborhoodCompleteOverlayStatus()) { + neighborhoodModel.setNeighborhoodCompleteAcrossAllUsers(); + svl.ui.areaComplete.overlay.show(); + } + self.setShowNeighborhoodCompleteOverlayStatus(false); + } + + /** + * Get the show neighborhood overlay status boolean. + */ + this.getShowNeighborhoodCompleteOverlayStatus = function () { + return self._showNeighborhoodCompleteOverlayStatus; + } + + /** + * Set the show neighborhood overlay status boolean to a given value. + * @param value + */ + this.setShowNeighborhoodCompleteOverlayStatus = function (value) { + self._showNeighborhoodCompleteOverlayStatus = value; + } + /** * Get the street id of the current task. */ @@ -577,6 +616,7 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s self.getAfterJumpNewTask = getAfterJumpNewTask; self.isFirstTask = isFirstTask; self.length = length; + self.isLastIncompleteTaskInNeighborhood = isLastIncompleteTaskInNeighborhood; self.push = pushATask; self.renderAllTasks = renderAllTasks; self.hasMaxPriorityTask = hasMaxPriorityTask; From 6f094d450eab70ccddefaceccc83b0475ac91b57 Mon Sep 17 00:00:00 2001 From: Srihari Krishnaswamy Date: Fri, 11 Oct 2024 12:43:18 -0700 Subject: [PATCH 2/2] Added tracker push for neighborhood complete overlay in new method --- public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js b/public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js index 2453a2cb5a..e513d8d61f 100644 --- a/public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js +++ b/public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js @@ -511,6 +511,7 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s if (self.getShowNeighborhoodCompleteOverlayStatus()) { neighborhoodModel.setNeighborhoodCompleteAcrossAllUsers(); svl.ui.areaComplete.overlay.show(); + tracker.push("NeighborhoodComplete_AcrossAllUsers", { 'RegionId': currentNeighborhood.getRegionId() }); } self.setShowNeighborhoodCompleteOverlayStatus(false); }