Skip to content

Commit

Permalink
SWC-7109, SWC-7093
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson committed Oct 15, 2024
1 parent fd8ad0b commit a524ea1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.sagebionetworks.web.client.jsinterop.SRC;
import org.sagebionetworks.web.client.mvp.AppActivityMapper;
import org.sagebionetworks.web.client.mvp.AppPlaceHistoryMapper;
import org.sagebionetworks.web.client.place.Home;
import org.sagebionetworks.web.client.place.LoginPlace;
import org.sagebionetworks.web.client.utils.Callback;
import org.sagebionetworks.web.client.utils.CallbackP;
Expand Down Expand Up @@ -263,6 +264,9 @@ public void setLastPlace(Place lastPlace) {
public Place getCurrentPlace() {
// get the current place based on the current browser window history token
String token = gwt.getCurrentHistoryToken();
if (token == null || token.isEmpty()) {
return new Home(ClientProperties.DEFAULT_PLACE_TOKEN);
}
if (appPlaceHistoryMapper != null) {
return appPlaceHistoryMapper.getPlace(token);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ public Activity getActivity(Place place) {
LoginPlace loginPlace = new LoginPlace(
ClientProperties.DEFAULT_PLACE_TOKEN
);
// SWC-7093: before redirecting to the login place, set the last place to the intended target!
if (!excludeFromLastPlace.contains(place.getClass())) {
globalApplicationState.setLastPlace(place);
}
return getActivity(loginPlace);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.inject.Inject;
import org.sagebionetworks.web.client.GWTWrapper;
import org.sagebionetworks.web.client.place.ChatPlace;
import org.sagebionetworks.web.client.view.ChatView;

Expand All @@ -13,10 +14,12 @@ public class ChatPresenter

private ChatPlace place;
private ChatView view;
private GWTWrapper gwt;

@Inject
public ChatPresenter(ChatView view) {
public ChatPresenter(ChatView view, GWTWrapper gwt) {
this.view = view;
this.gwt = gwt;
view.scrollToTop();
}

Expand All @@ -29,9 +32,14 @@ public void start(AcceptsOneWidget panel, EventBus eventBus) {
@Override
public void setPlace(ChatPlace place) {
this.place = place;
String initialMessage = place.getParam(ChatPlace.INITIAL_MESSAGE);
// SWC-7109: Decode place parameters
String initialMessage = gwt.decodeQueryString(
place.getParam(ChatPlace.INITIAL_MESSAGE)
);
String agentId = place.getParam(ChatPlace.AGENT_ID);
String chatbotName = place.getParam(ChatPlace.CHATBOT_NAME);
String chatbotName = gwt.decodeQueryString(
place.getParam(ChatPlace.CHATBOT_NAME)
);

view.render(initialMessage, agentId, chatbotName);
}
Expand Down

0 comments on commit a524ea1

Please sign in to comment.