Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Neighborhood Complete Screen Rendering Early #3690

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
15 changes: 10 additions & 5 deletions public/javascripts/SVLabel/src/SVLabel/navigation/MapService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
Expand All @@ -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.
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down
49 changes: 45 additions & 4 deletions public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -491,6 +503,34 @@ 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();
tracker.push("NeighborhoodComplete_AcrossAllUsers", { 'RegionId': currentNeighborhood.getRegionId() });
}
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.
*/
Expand Down Expand Up @@ -577,6 +617,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;
Expand Down