Merge branch 'master' of github.com:highfidelity/hifi into textToSpeech

This commit is contained in:
Zach Fox 2018-10-19 09:42:06 -07:00
commit 2df9d28c5b
17 changed files with 214 additions and 127 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 175 KiB

View file

@ -39,6 +39,7 @@ Item {
property string sendingPubliclyEffectImage;
property var http;
property var listModelName;
property var keyboardContainer: nil;
// This object is always used in a popup or full-screen Wallet section.
// This MouseArea is used to prevent a user from being
@ -1125,8 +1126,7 @@ Item {
checked: Settings.getValue("sendAssetsNearbyPublicly", true);
text: "Show Effect"
// Anchors
anchors.top: messageContainer.bottom;
anchors.topMargin: 16;
anchors.verticalCenter: bottomBarContainer.verticalCenter;
anchors.left: parent.left;
anchors.leftMargin: 20;
width: 130;
@ -1168,6 +1168,9 @@ Item {
lightboxPopup.visible = false;
}
lightboxPopup.visible = true;
if (keyboardContainer) {
keyboardContainer.keyboardRaised = false;
}
}
}
}
@ -1178,8 +1181,8 @@ Item {
anchors.leftMargin: 20;
anchors.right: parent.right;
anchors.rightMargin: 20;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 20;
anchors.top: messageContainer.bottom;
anchors.topMargin: 20;
height: 60;
// "CANCEL" button
@ -1187,11 +1190,11 @@ Item {
id: cancelButton_sendAssetStep;
color: root.assetName === "" ? hifi.buttons.noneBorderlessWhite : hifi.buttons.noneBorderlessGray;
colorScheme: hifi.colorSchemes.dark;
anchors.left: parent.left;
anchors.leftMargin: 24;
anchors.right: sendButton.left;
anchors.rightMargin: 24;
anchors.verticalCenter: parent.verticalCenter;
height: 40;
width: 150;
width: 100;
text: "CANCEL";
onClicked: {
resetSendAssetData();
@ -1205,10 +1208,10 @@ Item {
color: hifi.buttons.blue;
colorScheme: root.assetName === "" ? hifi.colorSchemes.dark : hifi.colorSchemes.light;
anchors.right: parent.right;
anchors.rightMargin: 24;
anchors.rightMargin: 0;
anchors.verticalCenter: parent.verticalCenter;
height: 40;
width: 150;
width: 100;
text: "SUBMIT";
onClicked: {
if (root.assetName === "" && parseInt(amountTextField.text) > parseInt(balanceText.text)) {

View file

@ -158,6 +158,7 @@ Rectangle {
listModelName: "Gift Connections";
z: 998;
visible: root.activeView === "giftAsset";
keyboardContainer: root;
anchors.fill: parent;
parentAppTitleBarHeight: 70;
parentAppNavBarHeight: 0;
@ -585,7 +586,7 @@ Rectangle {
visible: purchasesModel.count !== 0;
clip: true;
model: purchasesModel;
snapMode: ListView.SnapToItem;
snapMode: ListView.NoSnap;
// Anchors
anchors.top: separator.bottom;
anchors.left: parent.left;

View file

@ -354,6 +354,7 @@ Rectangle {
listModelName: "Send Money Connections";
z: 997;
visible: root.activeView === "sendMoney";
keyboardContainer: root;
anchors.fill: parent;
parentAppTitleBarHeight: titleBarContainer.height;
parentAppNavBarHeight: tabButtonsContainer.height;

View file

@ -108,6 +108,9 @@ AvatarBookmarks::AvatarBookmarks() {
if (!QFile::copy(defaultBookmarksFilename, _bookmarksFilename)) {
qDebug() << "failed to copy" << defaultBookmarksFilename << "to" << _bookmarksFilename;
} else {
QFile bookmarksFile(_bookmarksFilename);
bookmarksFile.setPermissions(bookmarksFile.permissions() | QFile::WriteUser);
}
}
readFromFile();

View file

@ -629,8 +629,6 @@ public:
const MyHead* getMyHead() const;
Q_INVOKABLE void toggleSmoothPoleVectors() { _skeletonModel->getRig().toggleSmoothPoleVectors(); };
/**jsdoc
* Get the current position of the avatar's "Head" joint.
* @function MyAvatar.getHeadPosition

View file

@ -46,7 +46,7 @@ static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) {
}
glm::mat4 hipsMat;
if (myAvatar->getCenterOfGravityModelEnabled() && !isFlying && !(myAvatar->getIsInWalkingState())) {
if (myAvatar->getCenterOfGravityModelEnabled() && !isFlying && !(myAvatar->getIsInWalkingState()) && myAvatar->getHMDLeanRecenterEnabled()) {
// then we use center of gravity model
hipsMat = myAvatar->deriveBodyUsingCgModel();
} else {

View file

@ -1253,7 +1253,6 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab
const glm::mat4& rigToSensorMatrix, const glm::mat4& sensorToRigMatrix) {
const bool ENABLE_POLE_VECTORS = true;
const float ELBOW_POLE_VECTOR_BLEND_FACTOR = 0.95f;
if (leftHandEnabled) {
@ -1279,33 +1278,16 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab
bool usePoleVector = calculateElbowPoleVector(handJointIndex, elbowJointIndex, armJointIndex, oppositeArmJointIndex, poleVector);
if (usePoleVector) {
glm::vec3 sensorPoleVector = transformVectorFast(rigToSensorMatrix, poleVector);
if (_smoothPoleVectors) {
// smooth toward desired pole vector from previous pole vector... to reduce jitter
if (!_prevLeftHandPoleVectorValid) {
_prevLeftHandPoleVectorValid = true;
_prevLeftHandPoleVector = sensorPoleVector;
}
glm::quat deltaRot = rotationBetween(_prevLeftHandPoleVector, sensorPoleVector);
glm::quat smoothDeltaRot = safeMix(deltaRot, Quaternions::IDENTITY, ELBOW_POLE_VECTOR_BLEND_FACTOR);
_prevLeftHandPoleVector = smoothDeltaRot * _prevLeftHandPoleVector;
} else {
_prevLeftHandPoleVector = sensorPoleVector;
}
_animVars.set("leftHandPoleVectorEnabled", true);
_animVars.set("leftHandPoleReferenceVector", Vectors::UNIT_X);
_animVars.set("leftHandPoleVector", transformVectorFast(sensorToRigMatrix, _prevLeftHandPoleVector));
_animVars.set("leftHandPoleVector", transformVectorFast(sensorToRigMatrix, sensorPoleVector));
} else {
_prevLeftHandPoleVectorValid = false;
_animVars.set("leftHandPoleVectorEnabled", false);
}
} else {
_prevLeftHandPoleVectorValid = false;
_animVars.set("leftHandPoleVectorEnabled", false);
}
} else {
_prevLeftHandPoleVectorValid = false;
_animVars.set("leftHandPoleVectorEnabled", false);
_animVars.unset("leftHandPosition");
@ -1344,33 +1326,16 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab
bool usePoleVector = calculateElbowPoleVector(handJointIndex, elbowJointIndex, armJointIndex, oppositeArmJointIndex, poleVector);
if (usePoleVector) {
glm::vec3 sensorPoleVector = transformVectorFast(rigToSensorMatrix, poleVector);
if (_smoothPoleVectors) {
// smooth toward desired pole vector from previous pole vector... to reduce jitter
if (!_prevRightHandPoleVectorValid) {
_prevRightHandPoleVectorValid = true;
_prevRightHandPoleVector = sensorPoleVector;
}
glm::quat deltaRot = rotationBetween(_prevRightHandPoleVector, sensorPoleVector);
glm::quat smoothDeltaRot = safeMix(deltaRot, Quaternions::IDENTITY, ELBOW_POLE_VECTOR_BLEND_FACTOR);
_prevRightHandPoleVector = smoothDeltaRot * _prevRightHandPoleVector;
} else {
_prevRightHandPoleVector = sensorPoleVector;
}
_animVars.set("rightHandPoleVectorEnabled", true);
_animVars.set("rightHandPoleReferenceVector", -Vectors::UNIT_X);
_animVars.set("rightHandPoleVector", transformVectorFast(sensorToRigMatrix, _prevRightHandPoleVector));
_animVars.set("rightHandPoleVector", transformVectorFast(sensorToRigMatrix, sensorPoleVector));
} else {
_prevRightHandPoleVectorValid = false;
_animVars.set("rightHandPoleVectorEnabled", false);
}
} else {
_prevRightHandPoleVectorValid = false;
_animVars.set("rightHandPoleVectorEnabled", false);
}
} else {
_prevRightHandPoleVectorValid = false;
_animVars.set("rightHandPoleVectorEnabled", false);
_animVars.unset("rightHandPosition");

View file

@ -227,7 +227,6 @@ public:
const AnimVariantMap& getAnimVars() const { return _lastAnimVars; }
const AnimContext::DebugStateMachineMap& getStateMachineMap() const { return _lastContext.getStateMachineMap(); }
void toggleSmoothPoleVectors() { _smoothPoleVectors = !_smoothPoleVectors; };
signals:
void onLoadComplete();
@ -381,14 +380,6 @@ protected:
glm::vec3 _prevLeftFootPoleVector { Vectors::UNIT_Z }; // sensor space
bool _prevLeftFootPoleVectorValid { false };
glm::vec3 _prevRightHandPoleVector{ -Vectors::UNIT_Z }; // sensor space
bool _prevRightHandPoleVectorValid{ false };
glm::vec3 _prevLeftHandPoleVector{ -Vectors::UNIT_Z }; // sensor space
bool _prevLeftHandPoleVectorValid{ false };
bool _smoothPoleVectors { false };
int _rigId;
bool _headEnabled { false };

View file

@ -140,8 +140,10 @@ void DomainHandler::hardReset() {
}
bool DomainHandler::isHardRefusal(int reasonCode) {
return (reasonCode == (int)ConnectionRefusedReason::ProtocolMismatch || reasonCode == (int)ConnectionRefusedReason::NotAuthorized ||
reasonCode == (int)ConnectionRefusedReason::TimedOut);
return (reasonCode == (int)ConnectionRefusedReason::ProtocolMismatch ||
reasonCode == (int)ConnectionRefusedReason::TooManyUsers ||
reasonCode == (int)ConnectionRefusedReason::NotAuthorized ||
reasonCode == (int)ConnectionRefusedReason::TimedOut);
}
bool DomainHandler::getInterstitialModeEnabled() const {
@ -473,7 +475,7 @@ bool DomainHandler::reasonSuggestsLogin(ConnectionRefusedReason reasonCode) {
case ConnectionRefusedReason::LoginError:
case ConnectionRefusedReason::NotAuthorized:
return true;
default:
case ConnectionRefusedReason::Unknown:
case ConnectionRefusedReason::ProtocolMismatch:

View file

@ -1409,7 +1409,6 @@ Script.scriptEnding.connect(function () {
Settings.setValue(SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE, Menu.isOptionChecked(MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE));
Settings.setValue(SETTING_SHOW_ZONES_IN_EDIT_MODE, Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
Settings.setValue(SETTING_EDIT_PREFIX + MENU_CREATE_ENTITIES_GRABBABLE, Menu.isOptionChecked(MENU_CREATE_ENTITIES_GRABBABLE));
Settings.setValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_LARGE, Menu.isOptionChecked(MENU_ALLOW_SELECTION_LARGE));
Settings.setValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_SMALL, Menu.isOptionChecked(MENU_ALLOW_SELECTION_SMALL));
Settings.setValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_LIGHTS, Menu.isOptionChecked(MENU_ALLOW_SELECTION_LIGHTS));
@ -1710,7 +1709,7 @@ function onPromptTextChanged(prompt) {
}
}
function handeMenuEvent(menuItem) {
function handleMenuEvent(menuItem) {
if (menuItem === "Allow Selecting of Small Models") {
allowSmallModels = Menu.isOptionChecked("Allow Selecting of Small Models");
} else if (menuItem === "Allow Selecting of Large Models") {
@ -1750,6 +1749,8 @@ function handeMenuEvent(menuItem) {
entityIconOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE));
} else if (menuItem === MENU_SHOW_ZONES_IN_EDIT_MODE) {
Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
} else if (menuItem === MENU_CREATE_ENTITIES_GRABBABLE) {
Settings.setValue(SETTING_EDIT_PREFIX + menuItem, Menu.isOptionChecked(menuItem));
}
tooltip.show(false);
}
@ -1875,7 +1876,7 @@ function importSVO(importURL) {
}
Window.svoImportRequested.connect(importSVO);
Menu.menuItemEvent.connect(handeMenuEvent);
Menu.menuItemEvent.connect(handleMenuEvent);
var keyPressEvent = function (event) {
if (isActive) {

View file

@ -23,12 +23,17 @@
miniState = null,
// Hands.
NO_HAND = -1,
LEFT_HAND = 0,
RIGHT_HAND = 1,
HAND_NAMES = ["LeftHand", "RightHand"],
// Miscellaneous.
// Track controller grabbing state.
HIFI_OBJECT_MANIPULATION_CHANNEL = "Hifi-Object-Manipulation",
grabbingHand = NO_HAND,
grabbedItem = null,
// Miscellaneous.
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"),
DEBUG = false;
@ -737,37 +742,11 @@
setState(MINI_VISIBLE);
}
function enterMiniShowing(hand) {
miniHand = hand;
ui.show(miniHand);
miniScaleStart = Date.now();
miniScaleTimer = Script.setTimeout(scaleMiniUp, MINI_SCALE_TIMEOUT);
}
function updateMiniShowing() {
if (HMD.showTablet) {
setState(MINI_HIDDEN);
}
}
function exitMiniShowing() {
if (miniScaleTimer) {
Script.clearTimeout(miniScaleTimer);
miniScaleTimer = null;
}
}
function updateMiniVisible() {
function checkMiniVisibility() {
var showLeft,
showRight;
// Hide mini tablet if tablet proper has been displayed by other means.
if (HMD.showTablet) {
setState(MINI_HIDDEN);
return;
}
// Check that the mini tablet should still be visible and if so then ensure it's on the hand that the camera is
// Check that the mini tablet should still be visible and if so then ensure it's on the hand that the camera is
// gazing at.
showLeft = shouldShowMini(LEFT_HAND);
showRight = shouldShowMini(RIGHT_HAND);
@ -790,8 +769,47 @@
setState(MINI_HIDING);
}
} else {
setState(MINI_HIDING);
if (grabbedItem === null || grabbingHand !== miniHand) {
setState(MINI_HIDING);
} else {
setState(MINI_HIDDEN);
}
}
}
function enterMiniShowing(hand) {
miniHand = hand;
ui.show(miniHand);
miniScaleStart = Date.now();
miniScaleTimer = Script.setTimeout(scaleMiniUp, MINI_SCALE_TIMEOUT);
}
function updateMiniShowing() {
// Hide mini tablet if tablet proper has been displayed by other means.
if (HMD.showTablet) {
setState(MINI_HIDDEN);
}
// Hide mini tablet if it should no longer be visible.
checkMiniVisibility();
}
function exitMiniShowing() {
if (miniScaleTimer) {
Script.clearTimeout(miniScaleTimer);
miniScaleTimer = null;
}
}
function updateMiniVisible() {
// Hide mini tablet if tablet proper has been displayed by other means.
if (HMD.showTablet) {
setState(MINI_HIDDEN);
return;
}
// Hide mini tablet if it should no longer be visible.
checkMiniVisibility();
// If state hasn't changed, update mini tablet rotation.
if (miniState === MINI_VISIBLE) {
@ -973,6 +991,21 @@
return;
}
// Track grabbed state and item.
switch (message.action) {
case "grab":
grabbingHand = HAND_NAMES.indexOf(message.joint);
grabbedItem = message.grabbedEntity;
break;
case "release":
grabbingHand = NO_HAND;
grabbedItem = null;
break;
default:
error("Unexpected grab message!");
return;
}
if (message.grabbedEntity !== HMD.tabletID && message.grabbedEntity !== ui.getMiniTabletID()) {
return;
}

View file

@ -5,14 +5,20 @@
"Oops! Protocol version mismatch.",
"Oops! Not authorized to join domain.",
"Oops! Connection timed out.",
"Oops! The domain is full.",
"Oops! Something went wrong."
];
var PROTOCOL_VERSION_MISMATCH = 1;
var NOT_AUTHORIZED = 3;
var DOMAIN_FULL = 4;
var TIMEOUT = 5;
var hardRefusalErrors = [PROTOCOL_VERSION_MISMATCH,
NOT_AUTHORIZED, TIMEOUT];
var hardRefusalErrors = [
PROTOCOL_VERSION_MISMATCH,
NOT_AUTHORIZED,
TIMEOUT,
DOMAIN_FULL
];
var timer = null;
var isErrorState = false;
@ -26,7 +32,7 @@
return ERROR_MESSAGE_MAP[errorMessageMapIndex];
} else {
// some other text.
return ERROR_MESSAGE_MAP[4];
return ERROR_MESSAGE_MAP[ERROR_MESSAGE_MAP.length - 1];
}
};

View file

@ -44,7 +44,10 @@ try {
}
function removeFromStoryIDsToMaybeDelete(story_id) {
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(story_id), 1);
story_id = parseInt(story_id);
if (storyIDsToMaybeDelete.indexOf(story_id) > -1) {
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(story_id), 1);
}
print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete));
}
@ -258,6 +261,7 @@ function onMessage(message) {
}
break;
case 'removeFromStoryIDsToMaybeDelete':
console.log("Facebook OR Twitter button clicked for story_id " + message.story_id);
removeFromStoryIDsToMaybeDelete(message.story_id);
break;
default:
@ -333,11 +337,13 @@ function fillImageDataFromPrevious() {
var previousAnimatedSnapStoryID = Settings.getValue("previousAnimatedSnapStoryID");
var previousAnimatedSnapBlastingDisabled = Settings.getValue("previousAnimatedSnapBlastingDisabled");
var previousAnimatedSnapHifiSharingDisabled = Settings.getValue("previousAnimatedSnapHifiSharingDisabled");
snapshotOptions = {
containsGif: previousAnimatedSnapPath !== "",
processingGif: false,
shouldUpload: false,
canBlast: snapshotDomainID === Settings.getValue("previousSnapshotDomainID"),
canBlast: snapshotDomainID === Settings.getValue("previousSnapshotDomainID") &&
snapshotDomainID === location.domainID,
isLoggedIn: isLoggedIn
};
imageData = [];
@ -369,7 +375,8 @@ function snapshotUploaded(isError, reply) {
isGif = fileExtensionMatches(imageURL, "gif"),
ignoreGifSnapshotData = false,
ignoreStillSnapshotData = false;
storyIDsToMaybeDelete.push(storyID);
storyIDsToMaybeDelete.push(parseInt(storyID));
print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete));
if (isGif) {
if (mostRecentGifSnapshotFilename !== replyJson.user_story.details.original_image_file_name) {
ignoreGifSnapshotData = true;

View file

@ -338,13 +338,15 @@ const HifiNotificationType = hfNotifications.NotificationType;
var pendingNotifications = {}
var notificationState = NotificationState.UNNOTIFIED;
function setNotificationState (notificationType, pending = true) {
pendingNotifications[notificationType] = pending;
notificationState = NotificationState.UNNOTIFIED;
for (var key in pendingNotifications) {
if (pendingNotifications[key]) {
notificationState = NotificationState.NOTIFIED;
break;
function setNotificationState (notificationType, pending = undefined) {
if (pending !== undefined) {
pendingNotifications[notificationType] = pending;
notificationState = NotificationState.UNNOTIFIED;
for (var key in pendingNotifications) {
if (pendingNotifications[key]) {
notificationState = NotificationState.NOTIFIED;
break;
}
}
}
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
@ -568,7 +570,42 @@ function updateLabels(serverState) {
labels.people.icon = pendingNotifications[HifiNotificationType.PEOPLE] ? menuNotificationIcon : null;
labels.wallet.icon = pendingNotifications[HifiNotificationType.WALLET] ? menuNotificationIcon : null;
labels.marketplace.icon = pendingNotifications[HifiNotificationType.MARKETPLACE] ? menuNotificationIcon : null;
var onlineUsers = trayNotifications.getOnlineUsers();
delete labels.people.submenu;
if (onlineUsers) {
for (var name in onlineUsers) {
if(labels.people.submenu == undefined) {
labels.people.submenu = [];
}
labels.people.submenu.push({
label: name,
enabled: (onlineUsers[name].location != undefined),
click: function (item) {
setNotificationState(HifiNotificationType.PEOPLE, false);
if(onlineUsers[item.label] && onlineUsers[item.label].location) {
StartInterface("hifi://" + onlineUsers[item.label].location.root.name + onlineUsers[item.label].location.path);
}
}
});
}
}
var currentStories = trayNotifications.getCurrentStories();
delete labels.goto.submenu;
if (currentStories) {
for (var location in currentStories) {
if(labels.goto.submenu == undefined) {
labels.goto.submenu = [];
}
labels.goto.submenu.push({
label: "event in " + location,
location: location,
click: function (item) {
setNotificationState(HifiNotificationType.GOTO, false);
StartInterface("hifi://" + item.location + currentStories[item.location].path);
}
});
}
}
}
function updateTrayMenu(serverState) {
@ -919,6 +956,8 @@ app.on('ready', function() {
trayNotifications.startPolling();
}
updateTrayMenu(ProcessGroupStates.STOPPED);
maybeInstallDefaultContentSet(onContentLoaded);
if (isServerInstalled()) {
maybeInstallDefaultContentSet(onContentLoaded);
}
});

View file

@ -73,11 +73,17 @@ HifiNotification.prototype = {
text = this.data + " of your connections are online."
}
message = "Click to open PEOPLE.";
url="hifiapp:PEOPLE"
url="hifiapp:PEOPLE";
} else {
text = this.data.username + " is available in " + this.data.location.root.name + ".";
message = "Click to join them.";
url="hifi://" + this.data.location.root.name + this.data.location.path;
if (this.data.location) {
text = this.data.username + " is available in " + this.data.location.root.name + ".";
message = "Click to join them.";
url="hifi://" + this.data.location.root.name + this.data.location.path;
} else {
text = this.data.username + " is online.";
message = "Click to open PEOPLE.";
url="hifiapp:PEOPLE";
}
}
break;
@ -136,7 +142,8 @@ HifiNotification.prototype = {
function HifiNotifications(config, menuNotificationCallback) {
this.config = config;
this.menuNotificationCallback = menuNotificationCallback;
this.onlineUsers = new Set([]);
this.onlineUsers = {};
this.currentStories = {};
this.storiesSince = new Date(this.config.get("storiesNotifySince", "1970-01-01T00:00:00.000Z"));
this.peopleSince = new Date(this.config.get("peopleNotifySince", "1970-01-01T00:00:00.000Z"));
this.walletSince = new Date(this.config.get("walletNotifySince", "1970-01-01T00:00:00.000Z"));
@ -213,6 +220,12 @@ HifiNotifications.prototype = {
clearInterval(this.marketplacePollTimer);
}
},
getOnlineUsers: function () {
return this.onlineUsers;
},
getCurrentStories: function () {
return this.currentStories;
},
_showNotification: function () {
var _this = this;
@ -225,7 +238,7 @@ HifiNotifications.prototype = {
// previous notification immediately when a
// new one is submitted
_this.pendingNotifications.shift();
if(_this.pendingNotifications.length > 0) {
if (_this.pendingNotifications.length > 0) {
_this._showNotification();
}
});
@ -289,7 +302,6 @@ HifiNotifications.prototype = {
finished(false);
return;
}
console.log(content);
if (!content.total_entries) {
finished(true, token);
return;
@ -313,7 +325,6 @@ HifiNotifications.prototype = {
notifyData = content.data.updates;
break;
}
notifyData.forEach(function (notifyDataEntry) {
_this._addNotification(new HifiNotification(notifyType, notifyDataEntry));
});
@ -346,7 +357,7 @@ HifiNotifications.prototype = {
'include_actions=announcement',
'restriction=open,hifi',
'require_online=true',
'per_page=1'
'per_page=' + MAX_NOTIFICATION_ITEMS
];
var url = METAVERSE_SERVER_URL + STORIES_URL + '?' + options.join('&');
// call a second time to determine if there are no more stories and we should
@ -357,7 +368,34 @@ HifiNotifications.prototype = {
'bearer': token
}
}, function (error, data) {
_this._pollToDisableHighlight(NotificationType.GOTO, error, data);
if (error || !data.body) {
console.log("Error: unable to get " + url);
finished(false);
return;
}
var content = JSON.parse(data.body);
if (!content || content.status != 'success') {
console.log("Error: unable to get " + url);
finished(false);
return;
}
if (!content.total_entries) {
finished(true, token);
return;
}
if (!content.total_entries) {
_this.menuNotificationCallback(NotificationType.GOTO, false);
}
_this.currentStories = {};
content.user_stories.forEach(function (story) {
// only show a single instance of each story location
// in the menu. This may cause issues with domains
// where the story locations are significantly different
// for each story.
_this.currentStories[story.place_name] = story;
});
_this.menuNotificationCallback(NotificationType.GOTO);
});
}
});
@ -400,20 +438,19 @@ HifiNotifications.prototype = {
console.log("Error: unable to get " + url);
return false;
}
console.log(content);
if (!content.total_entries) {
_this.menuNotificationCallback(NotificationType.PEOPLE, false);
_this.onlineUsers = new Set([]);
_this.onlineUsers = {};
return;
}
var currentUsers = new Set([]);
var currentUsers = {};
var newUsers = new Set([]);
content.data.users.forEach(function (user) {
currentUsers.add(user.username);
if (!_this.onlineUsers.has(user.username)) {
currentUsers[user.username] = user;
if (!(user.username in _this.onlineUsers)) {
newUsers.add(user);
_this.onlineUsers.add(user.username);
_this.onlineUsers[user.username] = user;
}
});
_this.onlineUsers = currentUsers;