mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 03:40:20 +02:00
Merge pull request #4129 from ctrlaltdavid/notifications-startup
Stop notifications of all users at startup
This commit is contained in:
commit
4a2a9f92a7
1 changed files with 33 additions and 10 deletions
|
@ -259,14 +259,16 @@ function checkSize(){
|
||||||
|
|
||||||
// Triggers notification if a user logs on or off
|
// Triggers notification if a user logs on or off
|
||||||
function onOnlineUsersChanged(users) {
|
function onOnlineUsersChanged(users) {
|
||||||
for (user in users) {
|
if (!isStartingUp()) { // Skip user notifications at startup.
|
||||||
if (last_users.indexOf(users[user]) == -1.0) {
|
for (user in users) {
|
||||||
createNotification(users[user] + " has joined");
|
if (last_users.indexOf(users[user]) == -1.0) {
|
||||||
|
createNotification(users[user] + " has joined");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
for (user in last_users) {
|
||||||
for (user in last_users) {
|
if (users.indexOf(last_users[user]) == -1.0) {
|
||||||
if (users.indexOf(last_users[user]) == -1.0) {
|
createNotification(last_users[user] + " has left");
|
||||||
createNotification(last_users[user] + " has left");
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_users = users;
|
last_users = users;
|
||||||
|
@ -348,17 +350,38 @@ function dismiss(firstNoteOut, firstButOut, firstOut) {
|
||||||
myAlpha.splice(firstOut,1);
|
myAlpha.splice(firstOut,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is meant to show users online at startup but currently shows 0 users.
|
// This reports the number of users online at startup
|
||||||
function onConnected() {
|
function reportUsers() {
|
||||||
var numUsers = GlobalServices.onlineUsers.length;
|
var numUsers = GlobalServices.onlineUsers.length;
|
||||||
var welcome = "Welcome! There are " + numUsers + " users online now.";
|
var welcome = "Welcome! There are " + numUsers + " users online now.";
|
||||||
createNotification(welcome);
|
createNotification(welcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var STARTUP_TIMEOUT = 500, // ms
|
||||||
|
startingUp = true,
|
||||||
|
startupTimer = null;
|
||||||
|
|
||||||
|
function finishStartup() {
|
||||||
|
startingUp = false;
|
||||||
|
Script.clearTimeout(startupTimer);
|
||||||
|
reportUsers();
|
||||||
|
}
|
||||||
|
|
||||||
|
function isStartingUp() {
|
||||||
|
// Is starting up until get no checks that it is starting up for STARTUP_TIMEOUT
|
||||||
|
if (startingUp) {
|
||||||
|
if (startupTimer) {
|
||||||
|
Script.clearTimeout(startupTimer);
|
||||||
|
}
|
||||||
|
startupTimer = Script.setTimeout(finishStartup, STARTUP_TIMEOUT);
|
||||||
|
}
|
||||||
|
return startingUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AudioDevice.muteToggled.connect(onMuteStateChanged);
|
AudioDevice.muteToggled.connect(onMuteStateChanged);
|
||||||
Controller.keyPressEvent.connect(keyPressEvent);
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
Controller.mousePressEvent.connect(mousePressEvent);
|
Controller.mousePressEvent.connect(mousePressEvent);
|
||||||
GlobalServices.connected.connect(onConnected);
|
|
||||||
GlobalServices.onlineUsersChanged.connect(onOnlineUsersChanged);
|
GlobalServices.onlineUsersChanged.connect(onOnlineUsersChanged);
|
||||||
GlobalServices.incomingMessage.connect(onIncomingMessage);
|
GlobalServices.incomingMessage.connect(onIncomingMessage);
|
||||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||||
|
|
Loading…
Reference in a new issue