searchUrlTimer.cancel();
// don't load stream here - the URL change will cause it to be reloaded
EventBus.getInstance().notifyObservers(
new UpdateHistoryEvent(new CreateUrlRequest("search", searchText, false)));
}
else if ((searchTextLength > 2 && searchTextLength != lastSearchLength)
|| searchTextLength < lastSearchLength)
{
lastSearchLength = searchTextLength;
searchTimer.schedule(SEARCH_UPDATE_DELAY);
}
}
});
searchBox.addBlurHandler(new BlurHandler()
{
public void onBlur(final BlurEvent inEvent)
{
updateUrlWithSearchTerm();
}
});
addBookmark.addClickHandler(new ClickHandler()
{
public void onClick(final ClickEvent event)
{
StreamBookmarksModel.getInstance().insert(currentScopeId);
addBookmark.setVisible(false);
EventBus.getInstance().notifyObservers(
new ShowNotificationEvent(new Notification("You have bookmarked this stream.")));
}
});
subscribeViaEmail.addClickHandler(new ClickHandler()
{
public void onClick(final ClickEvent event)
{
if (!isSubscribed)
{
if (currentStream.getScopeType().equals(ScopeType.GROUP))
{
Dialog.showCentered(new GroupEmailSubscribeOptionsDialogContent(currentStream.getUniqueKey()));
}
else if (currentStream.getScopeType().equals(ScopeType.PERSON))
{
PersonActivitySubscriptionModel.getInstance().insert(currentStream.getUniqueKey());
setSubscribeStatus(true);
}
}
else
{
Deletable<String> deletable = null;
if (currentStream.getScopeType().equals(ScopeType.GROUP))
{
deletable = GroupActivitySubscriptionModel.getInstance();
}
else if (currentStream.getScopeType().equals(ScopeType.PERSON))
{
deletable = PersonActivitySubscriptionModel.getInstance();
}
if (deletable != null)
{
deletable.delete(currentStream.getUniqueKey());
setSubscribeStatus(false);
}
}
}
});
addToStartPage.addClickHandler(new ClickHandler()
{
public void onClick(final ClickEvent event)
{
// For the app's location, use the current URL minus a few parameters we know we don't want. (They are
// used by other lists, but get left in the URL when switching tabs.)
// We don't build the URL from the stream id, since that doesn't take search terms into account.
HashMap<String, String> params = new HashMap<String, String>();
params.put("listId", null);
params.put("listFilter", null);
params.put("listSort", null);
params.put("startIndex", null);
params.put("endIndex", null);
String url = Session.getInstance().generateUrl(new CreateUrlRequest(params));
// make a version of the query that doesn't have the exclusion list
JSONObject request = currentRequestObj;
if (request.containsKey("exclude"))
{