diff --git a/html/src/app.js b/html/src/app.js
index bf677971..2259e25c 100644
--- a/html/src/app.js
+++ b/html/src/app.js
@@ -3556,106 +3556,48 @@ speechSynthesis.getVoices();
setTimeout(() => this.updateLoop(), 500);
};
- $app.methods.updateSharedFeed = function () {
- var arr = [];
- // FIXME
- // 여러 개 켠다면 gameLogTable의 데이터가 시간순이 아닐 수도 있음
- var { data } = this.gameLogTable;
- var i = data.length;
- var j = 0;
- while (j < 100) {
- if (i <= 0) {
- break;
- }
- var ctx = data[--i];
- // Location, OnPlayerJoined, OnPlayerLeft
- if (ctx.type !== 'Notification') {
- // FIXME: 이거 존나 느릴거 같은데
- var isFriend = false;
- var isFavorite = false;
- for (var ref of API.cachedUsers.values()) {
- if (ref.displayName === ctx.data) {
- isFriend = this.friends.has(ref.id);
- isFavorite = API.cachedFavoritesByObjectId.has(ref.id);
- break;
- }
- }
- arr.push({
- ...ctx,
- isFriend,
- isFavorite
- });
- }
- ++j;
+ $app.data.sharedFeed = {
+ gameLog: {
+ wrist: [],
+ noty: [],
+ lastEntryDate: ''
+ },
+ feedTable: {
+ wrist: [],
+ noty: [],
+ lastEntryDate: ''
+ },
+ notificationTable: {
+ wrist: [],
+ noty: [],
+ lastEntryDate: ''
+ },
+ friendLogTable: {
+ wrist: [],
+ noty: [],
+ lastEntryDate: ''
+ },
+ playerModerationTable: {
+ wrist: [],
+ noty: [],
+ lastEntryDate: ''
+ },
+ pendingUpdate: false
+ };
+
+ $app.methods.updateSharedFeed = function (forceUpdate) {
+ this.updateSharedFeedGameLog(forceUpdate);
+ this.updateSharedFeedFeedTable(forceUpdate);
+ this.updateSharedFeedNotificationTable(forceUpdate);
+ this.updateSharedFeedFriendLogTable(forceUpdate);
+ this.updateSharedFeedPlayerModerationTable(forceUpdate);
+ var feeds = this.sharedFeed;
+ if (feeds.pendingUpdate === false) {
+ return;
}
- var { data } = this.feedTable;
- var i = data.length;
- var j = 0;
- while (j < 100) {
- if (i <= 0) {
- break;
- }
- var ctx = data[--i];
- // GPS, Online, Offline, Status, Avatar
- if (ctx.type !== 'Avatar') {
- arr.push({
- ...ctx,
- isFriend: this.friends.has(ctx.userId),
- isFavorite: API.cachedFavoritesByObjectId.has(ctx.userId)
- });
- ++j;
- }
- }
- var { data } = this.notificationTable;
- for (var i = 0; i < data.length; i++) {
- var ctx = data[i];
- // invite, requestInvite, friendRequest
- if (ctx.senderUserId !== API.currentUser.id) {
- arr.push({
- ...ctx,
- isFriend: this.friends.has(ctx.senderUserId),
- isFavorite: API.cachedFavoritesByObjectId.has(ctx.senderUserId)
- });
- }
- }
- var { data } = this.friendLogTable;
- var i = data.length;
- var j = 0;
- while (j < 10) {
- if (i <= 0) {
- break;
- }
- var ctx = data[--i];
- // TrustLevel, Friend, FriendRequest, Unfriend, DisplayName
- if (ctx.type !== 'FriendRequest') {
- arr.push({
- ...ctx,
- isFriend: this.friends.has(ctx.userId),
- isFavorite: API.cachedFavoritesByObjectId.has(ctx.userId)
- });
- ++j;
- }
- }
- var { data } = this.playerModerationTable;
- var i = data.length;
- var j = 0;
- while (j < 10) {
- if (i <= 0) {
- break;
- }
- var ctx = data[--i];
- // showAvatar, hideAvatar, block, mute, unmute
- if (ctx.sourceUserId !== API.currentUser.id) {
- arr.push({
- ...ctx,
- created_at: ctx.created,
- isFriend: this.friends.has(ctx.sourceUserId),
- isFavorite: API.cachedFavoritesByObjectId.has(ctx.sourceUserId)
- });
- ++j;
- }
- }
- arr.sort(function (a, b) {
+ var wristFeed = [];
+ wristFeed = wristFeed.concat(feeds.gameLog.wrist, feeds.feedTable.wrist, feeds.notificationTable.wrist, feeds.friendLogTable.wrist, feeds.playerModerationTable.wrist);
+ wristFeed.sort(function (a, b) {
if (a.created_at < b.created_at) {
return 1;
}
@@ -3664,7 +3606,382 @@ speechSynthesis.getVoices();
}
return 0;
});
- sharedRepository.setArray('feeds', arr);
+ wristFeed.splice(20);
+ var notyFeed = [];
+ notyFeed = notyFeed.concat(feeds.gameLog.noty, feeds.feedTable.noty, feeds.notificationTable.noty, feeds.friendLogTable.noty, feeds.playerModerationTable.noty);
+ // OnPlayerJoining
+ if ((this.isGameRunning) && ((this.sharedFeedFilters.wrist.OnPlayerJoining === 'Friends') || (this.sharedFeedFilters.wrist.OnPlayerJoining === 'VIP') ||
+ (this.sharedFeedFilters.noty.OnPlayerJoining === 'Friends') || (this.sharedFeedFilters.noty.OnPlayerJoining === 'VIP'))) {
+ var bias = new Date(Date.now() - 120000).toJSON();
+ for (var i = 0; i < wristFeed.length; i++) {
+ var ctx = wristFeed[i];
+ if ((ctx.created_at < bias) || (ctx.type === 'Location')) {
+ break;
+ }
+ if ((ctx.type === 'GPS') && (ctx.location[0] === this.lastLocation)) {
+ var joining = true;
+ for (var k = 0; k < wristFeed.length; k++) {
+ var feedItem = wristFeed[k];
+ if ((feedItem.data === ctx.displayName) ||
+ ((feedItem.type === 'Friend') && (feedItem.displayName === ctx.displayName))) {
+ joining = false;
+ break;
+ }
+ if ((feedItem.created_at < bias) || (feedItem.type === 'Location') ||
+ ((feedItem.type === 'GPS') && (feedItem.created_at !== ctx.created_at) &&
+ (feedItem.displayName === ctx.displayName))) {
+ break;
+ }
+ }
+ if (joining) {
+ var onPlayerJoining = {
+ ...ctx,
+ type: 'OnPlayerJoining'
+ };
+ if ((this.sharedFeedFilters.wrist.OnPlayerJoining === 'Friends') ||
+ ((this.sharedFeedFilters.wrist.OnPlayerJoining === 'VIP') && (ctx.isFavorite))) {
+ wristFeed.splice(i, 0, onPlayerJoining);
+ i++;
+ }
+ if ((this.sharedFeedFilters.noty.OnPlayerJoining === 'Friends') ||
+ ((this.sharedFeedFilters.noty.OnPlayerJoining === 'VIP') && (ctx.isFavorite))) {
+ notyFeed.push(onPlayerJoining);
+ }
+ }
+ }
+ }
+ }
+ notyFeed.sort(function (a, b) {
+ if (a.created_at < b.created_at) {
+ return 1;
+ }
+ if (a.created_at > b.created_at) {
+ return -1;
+ }
+ return 0;
+ });
+ notyFeed.splice(5);
+ sharedRepository.setArray('wristFeed', wristFeed);
+ sharedRepository.setArray('notyFeed', notyFeed);
+ feeds.pendingUpdate = false;
+ };
+
+ $app.methods.updateSharedFeedGameLog = function (forceUpdate) {
+ // Location, OnPlayerJoined, OnPlayerLeft
+ var { data } = this.gameLogTable;
+ var i = data.length;
+ if (i > 0) {
+ if ((data[i - 1].created_at === this.sharedFeed.gameLog.lastEntryDate) &&
+ (forceUpdate === false)) {
+ return;
+ }
+ this.sharedFeed.gameLog.lastEntryDate = data[i - 1].created_at;
+ }
+ var bias = new Date(Date.now() - 86400000).toJSON(); //24 hours
+ var wristArr = [];
+ var notyArr = [];
+ var w = 0;
+ var n = 0;
+ var wristFilter = this.sharedFeedFilters.wrist;
+ var notyFilter = this.sharedFeedFilters.noty;
+ var locationChange = false;
+ while ((w < 20) || (n < 5) || ((!locationChange) && (this.hideOnPlayerJoined))) {
+ var ctx = data[--i];
+ if ((i <= -1) || (ctx.created_at < bias)) {
+ break;
+ }
+ if (ctx.type === 'Notification') {
+ continue;
+ }
+ // on Location change remove OnPlayerJoined
+ if ((ctx.type === 'Location') && (this.hideOnPlayerJoined)) {
+ var locationBias = new Date(Date.parse(ctx.created_at) + 10000).toJSON(); //10 seconds
+ for (var k = w - 1; k > -1; k--) {
+ var feedItem = wristArr[k];
+ if (feedItem.type === 'OnPlayerJoined') {
+ wristArr.splice(k, 1);
+ w--;
+ }
+ if ((feedItem.created_at > locationBias) || (feedItem.type === 'Location')) {
+ break;
+ }
+ }
+ for (var k = n - 1; k > -1; k--) {
+ var feedItem = notyArr[k];
+ if (feedItem.type === 'OnPlayerJoined') {
+ notyArr.splice(k, 1);
+ n--;
+ }
+ if (feedItem.created_at > locationBias) {
+ break;
+ }
+ }
+ if (w >= 20) {
+ locationChange = true;
+ }
+ }
+ var isFriend = false;
+ var isFavorite = false;
+ for (var ref of API.cachedUsers.values()) {
+ if (ref.displayName === ctx.data) {
+ isFriend = this.friends.has(ref.id);
+ isFavorite = API.cachedFavoritesByObjectId.has(ref.id);
+ break;
+ }
+ }
+ if ((w < 20) && (wristFilter[ctx.type]) &&
+ ((wristFilter[ctx.type] === 'On') ||
+ (wristFilter[ctx.type] === 'Everyone') ||
+ ((wristFilter[ctx.type] === 'Friends') && (isFriend)) ||
+ ((wristFilter[ctx.type] === 'VIP') && (isFavorite)))) {
+ wristArr.push({
+ ...ctx,
+ isFriend,
+ isFavorite
+ });
+ ++w;
+ }
+ if ((n < 5) && (notyFilter[ctx.type]) &&
+ ((notyFilter[ctx.type] === 'On') ||
+ (notyFilter[ctx.type] === 'Everyone') ||
+ ((notyFilter[ctx.type] === 'Friends') && (isFriend)) ||
+ ((notyFilter[ctx.type] === 'VIP') && (isFavorite)))) {
+ notyArr.push({
+ ...ctx,
+ isFriend,
+ isFavorite
+ });
+ ++n;
+ }
+ }
+ this.sharedFeed.gameLog.wrist = wristArr;
+ this.sharedFeed.gameLog.noty = notyArr;
+ this.sharedFeed.pendingUpdate = true;
+ };
+
+ $app.methods.updateSharedFeedFeedTable = function (forceUpdate) {
+ // GPS, Online, Offline, Status, Avatar
+ var { data } = this.feedTable;
+ var i = data.length;
+ if (i > 0) {
+ if ((data[i - 1].created_at === this.sharedFeed.feedTable.lastEntryDate) &&
+ (forceUpdate === false)) {
+ return;
+ }
+ this.sharedFeed.feedTable.lastEntryDate = data[i - 1].created_at;
+ }
+ var bias = new Date(Date.now() - 86400000).toJSON(); //24 hours
+ var wristArr = [];
+ var notyArr = [];
+ var w = 0;
+ var n = 0;
+ var wristFilter = this.sharedFeedFilters.wrist;
+ var notyFilter = this.sharedFeedFilters.noty;
+ while ((w < 20) || (n < 5)) {
+ var ctx = data[--i];
+ if ((i <= -1) || (ctx.created_at < bias)) {
+ break;
+ }
+ if (ctx.type === 'Avatar') {
+ continue;
+ }
+ // hide private worlds from feeds
+ if ((this.hidePrivateFromFeed) &&
+ (ctx.type === 'GPS') && (ctx.location[0] === 'private')) {
+ continue;
+ }
+ var isFriend = this.friends.has(ctx.userId);
+ var isFavorite = API.cachedFavoritesByObjectId.has(ctx.userId);
+ if ((w < 20) && (wristFilter[ctx.type]) &&
+ ((wristFilter[ctx.type] === 'Friends') ||
+ ((wristFilter[ctx.type] === 'VIP') && (isFavorite)))) {
+ wristArr.push({
+ ...ctx,
+ isFriend,
+ isFavorite
+ });
+ ++w;
+ }
+ if ((n < 5) && (notyFilter[ctx.type]) &&
+ ((notyFilter[ctx.type] === 'Friends') ||
+ ((notyFilter[ctx.type] === 'VIP') && (isFavorite)))) {
+ notyArr.push({
+ ...ctx,
+ isFriend,
+ isFavorite
+ });
+ ++n;
+ }
+ }
+ this.sharedFeed.feedTable.wrist = wristArr;
+ this.sharedFeed.feedTable.noty = notyArr;
+ this.sharedFeed.pendingUpdate = true;
+ };
+
+ $app.methods.updateSharedFeedNotificationTable = function (forceUpdate) {
+ // invite, requestInvite, requestInviteResponse, inviteResponse, friendRequest
+ var { data } = this.notificationTable;
+ var i = data.length;
+ if (i > 0) {
+ if ((data[i - 1].created_at === this.sharedFeed.notificationTable.lastEntryDate) &&
+ (forceUpdate === false)) {
+ return;
+ }
+ this.sharedFeed.notificationTable.lastEntryDate = data[i - 1].created_at;
+ }
+ var bias = new Date(Date.now() - 86400000).toJSON(); //24 hours
+ var wristArr = [];
+ var notyArr = [];
+ var w = 0;
+ var n = 0;
+ var wristFilter = this.sharedFeedFilters.wrist;
+ var notyFilter = this.sharedFeedFilters.noty;
+ while ((w < 20) || (n < 5)) {
+ var ctx = data[--i];
+ if ((i <= -1) || (ctx.created_at < bias)) {
+ break;
+ }
+ if (ctx.senderUserId === API.currentUser.id) {
+ continue;
+ }
+ var isFriend = this.friends.has(ctx.senderUserId);
+ var isFavorite = API.cachedFavoritesByObjectId.has(ctx.senderUserId);
+ if ((w < 20) && (wristFilter[ctx.type]) &&
+ ((wristFilter[ctx.type] === 'On') ||
+ (wristFilter[ctx.type] === 'Friends') ||
+ ((wristFilter[ctx.type] === 'VIP') && (isFavorite)))) {
+ wristArr.push({
+ ...ctx,
+ isFriend,
+ isFavorite
+ });
+ ++w;
+ }
+ if ((n < 5) && (notyFilter[ctx.type]) &&
+ ((notyFilter[ctx.type] === 'On') ||
+ (notyFilter[ctx.type] === 'Friends') ||
+ ((notyFilter[ctx.type] === 'VIP') && (isFavorite)))) {
+ notyArr.push({
+ ...ctx,
+ isFriend,
+ isFavorite
+ });
+ ++n;
+ }
+ }
+ this.sharedFeed.notificationTable.wrist = wristArr;
+ this.sharedFeed.notificationTable.noty = notyArr;
+ this.sharedFeed.pendingUpdate = true;
+ };
+
+ $app.methods.updateSharedFeedFriendLogTable = function (forceUpdate) {
+ // TrustLevel, Friend, FriendRequest, Unfriend, DisplayName
+ var { data } = this.friendLogTable;
+ var i = data.length;
+ if (i > 0) {
+ if ((data[i - 1].created_at === this.sharedFeed.friendLogTable.lastEntryDate) &&
+ (forceUpdate === false)) {
+ return;
+ }
+ this.sharedFeed.friendLogTable.lastEntryDate = data[i - 1].created_at;
+ }
+ var bias = new Date(Date.now() - 86400000).toJSON(); //24 hours
+ var wristArr = [];
+ var notyArr = [];
+ var w = 0;
+ var n = 0;
+ var wristFilter = this.sharedFeedFilters.wrist;
+ var notyFilter = this.sharedFeedFilters.noty;
+ while ((w < 20) || (n < 5)) {
+ var ctx = data[--i];
+ if ((i <= -1) || (ctx.created_at < bias)) {
+ break;
+ }
+ if (ctx.type === 'FriendRequest') {
+ continue;
+ }
+ var isFriend = this.friends.has(ctx.userId);
+ var isFavorite = API.cachedFavoritesByObjectId.has(ctx.userId);
+ if ((w < 20) && (wristFilter[ctx.type]) &&
+ ((wristFilter[ctx.type] === 'On') ||
+ (wristFilter[ctx.type] === 'Friends') ||
+ ((wristFilter[ctx.type] === 'VIP') && (isFavorite)))) {
+ wristArr.push({
+ ...ctx,
+ isFriend,
+ isFavorite
+ });
+ ++w;
+ }
+ if ((n < 5) && (notyFilter[ctx.type]) &&
+ ((notyFilter[ctx.type] === 'On') ||
+ (notyFilter[ctx.type] === 'Friends') ||
+ ((notyFilter[ctx.type] === 'VIP') && (isFavorite)))) {
+ notyArr.push({
+ ...ctx,
+ isFriend,
+ isFavorite
+ });
+ ++n;
+ }
+ }
+ this.sharedFeed.friendLogTable.wrist = wristArr;
+ this.sharedFeed.friendLogTable.noty = notyArr;
+ this.sharedFeed.pendingUpdate = true;
+ };
+
+ $app.methods.updateSharedFeedPlayerModerationTable = function (forceUpdate) {
+ // showAvatar, hideAvatar, block, mute, unmute
+ var { data } = this.playerModerationTable;
+ var i = data.length;
+ if (i > 0) {
+ if ((data[i - 1].created === this.sharedFeed.playerModerationTable.lastEntryDate) &&
+ (forceUpdate === false)) {
+ return;
+ }
+ this.sharedFeed.playerModerationTable.lastEntryDate = data[i - 1].created;
+ }
+ var bias = new Date(Date.now() - 86400000).toJSON(); //24 hours
+ var wristArr = [];
+ var notyArr = [];
+ var w = 0;
+ var n = 0;
+ var wristFilter = this.sharedFeedFilters.wrist;
+ var notyFilter = this.sharedFeedFilters.noty;
+ while ((w < 20) || (n < 5)) {
+ var ctx = data[--i];
+ if ((i <= -1) || (ctx.created < bias)) {
+ break;
+ }
+ if (ctx.sourceUserId === API.currentUser.id) {
+ continue;
+ }
+ var isFriend = this.friends.has(ctx.sourceUserId);
+ var isFavorite = API.cachedFavoritesByObjectId.has(ctx.sourceUserId);
+ if ((w < 20) && (wristFilter[ctx.type]) &&
+ (wristFilter[ctx.type] === 'On')) {
+ wristArr.push({
+ ...ctx,
+ created_at: ctx.created,
+ isFriend,
+ isFavorite
+ });
+ ++w;
+ }
+ if ((n < 5) && (notyFilter[ctx.type]) &&
+ (notyFilter[ctx.type] === 'On')) {
+ notyArr.push({
+ ...ctx,
+ created_at: ctx.created,
+ isFriend,
+ isFavorite
+ });
+ ++n;
+ }
+ }
+ this.sharedFeed.playerModerationTable.wrist = wristArr;
+ this.sharedFeed.playerModerationTable.noty = notyArr;
+ this.sharedFeed.pendingUpdate = true;
};
$app.methods.notifyMenu = function (index) {
@@ -4666,6 +4983,7 @@ speechSynthesis.getVoices();
});
this.sweepFeed();
this.saveFeed();
+ this.updateSharedFeed(false);
this.notifyMenu('feed');
};
@@ -4785,12 +5103,12 @@ speechSynthesis.getVoices();
}
this.gameLogTable.lastEntryDate = this.gameLogTable.data[length - 1].created_at;
}
- this.updateSharedFeed();
+ this.updateSharedFeed(false);
}
} catch (err) {
console.error(err);
}
- setTimeout(() => this.updateGameLogLoop(), 1000);
+ setTimeout(() => this.updateGameLogLoop(), 500);
};
$app.methods.updateGameLog = async function () {
@@ -5469,6 +5787,7 @@ speechSynthesis.getVoices();
if (saveFriendLogTimer !== null) {
return;
}
+ this.updateSharedFeed(true);
saveFriendLogTimer = setTimeout(() => {
saveFriendLogTimer = null;
VRCXStorage.SetObject(`${API.currentUser.id}_friendLog`, this.friendLog);
@@ -5765,6 +6084,7 @@ speechSynthesis.getVoices();
$app.notificationTable.data.push(ref);
$app.notifyMenu('notification');
}
+ $app.updateSharedFeed(true);
});
API.$on('NOTIFICATION:@DELETE', function (args) {
@@ -6191,17 +6511,15 @@ speechSynthesis.getVoices();
notificationTTSVoice: this.notificationTTSVoice,
overlayNotifications: this.overlayNotifications,
desktopToast: this.desktopToast,
- hidePrivateFromFeed: this.hidePrivateFromFeed,
- hideOnPlayerJoined: this.hideOnPlayerJoined,
hideDevicesFromFeed: this.hideDevicesFromFeed,
minimalFeed: this.minimalFeed,
displayVRCPlusIconsAsAvatar: this.displayVRCPlusIconsAsAvatar,
- sharedFeedFilters: this.sharedFeedFilters,
notificationPosition: this.notificationPosition,
notificationTimeout: this.notificationTimeout,
notificationTheme
};
sharedRepository.setObject('VRConfigVars', VRConfigVars);
+ this.updateSharedFeed(true);
};
API.$on('LOGIN', function () {
diff --git a/html/src/vr.js b/html/src/vr.js
index 011228af..ca875738 100644
--- a/html/src/vr.js
+++ b/html/src/vr.js
@@ -695,7 +695,8 @@ speechSynthesis.getVoices();
isGameRunning: false,
isGameNoVR: false,
lastLocation: '',
- lastFeedEntry: [],
+ wristFeedLastEntry: '',
+ notyFeedLastEntry: '',
wristFeed: [],
notyMap: [],
devices: []
@@ -736,11 +737,17 @@ speechSynthesis.getVoices();
};
$app.methods.updateVRConfigVars = function () {
+ this.currentUserStatus = sharedRepository.getString('current_user_status');
+ this.isGameRunning = sharedRepository.getBool('is_game_running');
+ this.isGameNoVR = sharedRepository.getBool('is_Game_No_VR');
+ this.lastLocation = sharedRepository.getString('last_location');
var newConfig = sharedRepository.getObject('VRConfigVars');
if (newConfig) {
if (JSON.stringify(newConfig) !== JSON.stringify(this.config)) {
this.config = newConfig;
- this.lastFeedEntry = [];
+ this.notyFeedLastEntry = '';
+ this.wristFeedLastEntry = '';
+ this.initNotyMap();
}
} else {
throw 'config not set';
@@ -748,47 +755,34 @@ speechSynthesis.getVoices();
};
$app.methods.initNotyMap = function () {
- var feeds = sharedRepository.getArray('feeds');
- if (feeds === null) {
+ var notyFeed = sharedRepository.getArray('notyFeed');
+ if (notyFeed === null) {
return;
}
- var sharedFeedFilters = JSON.parse(configRepository.getString('sharedFeedFilters'));
- var filter = sharedFeedFilters.noty;
- feeds.forEach((feed) => {
- if (filter[feed.type]) {
- if ((filter[feed.type] !== 'Off') &&
- ((filter[feed.type] === 'Everyone') || (filter[feed.type] === 'On') ||
- ((filter[feed.type] === 'Friends') && (feed.isFriend)) ||
- ((filter[feed.type] === 'VIP') && (feed.isFavorite)))) {
- var displayName = '';
- if (feed.displayName) {
- displayName = feed.displayName;
- } else if (feed.senderUsername) {
- displayName = feed.senderUsername;
- } else if (feed.sourceDisplayName) {
- displayName = feed.sourceDisplayName;
- } else if (feed.data) {
- displayName = feed.data;
- } else {
- console.error('missing displayName');
- }
- if ((displayName) && (!this.notyMap[displayName]) ||
- (this.notyMap[displayName] < feed.created_at)) {
- this.notyMap[displayName] = feed.created_at;
- }
- }
+ notyFeed.forEach((feed) => {
+ var displayName = '';
+ if (feed.displayName) {
+ displayName = feed.displayName;
+ } else if (feed.senderUsername) {
+ displayName = feed.senderUsername;
+ } else if (feed.sourceDisplayName) {
+ displayName = feed.sourceDisplayName;
+ } else if (feed.data) {
+ displayName = feed.data;
+ } else {
+ console.error('missing displayName');
+ }
+ if ((displayName) && (!this.notyMap[displayName]) ||
+ (this.notyMap[displayName] < feed.created_at)) {
+ this.notyMap[displayName] = feed.created_at;
}
});
};
$app.methods.updateLoop = async function () {
try {
- this.updateVRConfigVars();
this.currentTime = new Date().toJSON();
- this.currentUserStatus = sharedRepository.getString('current_user_status');
- this.isGameRunning = sharedRepository.getBool('is_game_running');
- this.isGameNoVR = sharedRepository.getBool('is_Game_No_VR');
- this.lastLocation = sharedRepository.getString('last_location');
+ await this.updateVRConfigVars();
if ((!this.config.hideDevicesFromFeed) && (this.appType === '1')) {
AppApi.GetVRDevices().then((devices) => {
devices.forEach((device) => {
@@ -817,128 +811,18 @@ speechSynthesis.getVoices();
};
$app.methods.updateSharedFeeds = function () {
- var feeds = sharedRepository.getArray('feeds');
- if (feeds === null) {
- return;
- }
- if (typeof this.lastFeedEntry !== 'undefined' &&
- (feeds[0].created_at === this.lastFeedEntry.created_at)) {
- return;
- }
- this.lastFeedEntry = feeds[0];
-
- if (this.isGameRunning) {
- // OnPlayerJoining
- var bias = new Date(Date.now() - 120000).toJSON();
- for (var i = 0; i < feeds.length; i++) {
- var ctx = feeds[i];
- if ((ctx.created_at < bias) || (ctx.type === 'Location')) {
- break;
- }
- if ((ctx.type === 'GPS') && (ctx.location[0] === this.lastLocation)) {
- var joining = true;
- for (var k = 0; k < feeds.length; k++) {
- var feedItem = feeds[k];
- if ((feedItem.data === ctx.displayName) ||
- ((feedItem.type === 'Friend') && (feedItem.displayName === ctx.displayName))) {
- joining = false;
- break;
- }
- if ((feedItem.created_at < bias) || (feedItem.type === 'Location') ||
- ((feedItem.type === 'GPS') && (feedItem.created_at !== ctx.created_at) &&
- (feedItem.displayName === ctx.displayName))) {
- break;
- }
- }
- if (joining) {
- var onPlayerJoining = {
- created_at: ctx.created_at,
- data: ctx.displayName,
- isFavorite: ctx.isFavorite,
- isFriend: ctx.isFriend,
- userId: ctx.userId,
- type: 'OnPlayerJoining'
- };
- feeds.splice(i, 0, onPlayerJoining);
- i++;
- }
- }
- }
- }
-
- // on Location change remove OnPlayerJoined
- if (this.config.hideOnPlayerJoined) {
- for (i = 0; i < feeds.length; i++) {
- var ctx = feeds[i];
- if (ctx.type === 'Location') {
- var bias = new Date(Date.parse(ctx.created_at) + 10000).toJSON();
- for (var k = i - 1; k > 0; k--) {
- var feedItem = feeds[k];
- if (feedItem.type === 'OnPlayerJoined') {
- feeds.splice(k, 1);
- i--;
- }
- if ((feedItem.created_at > bias) || (feedItem.type === 'Location')) {
- break;
- }
- }
- }
- }
- }
-
- if (this.config.hidePrivateFromFeed) {
- for (var i = 0; i < feeds.length; i++) {
- var feed = feeds[i];
- if ((feed.type === 'GPS') && (feed.location[0] === 'private')) {
- feeds.splice(i, 1);
- i--;
- }
- }
- }
-
- feeds.splice(25);
if (this.appType === '1') {
- this.updateSharedFeedWrist(feeds);
+ this.wristFeed = sharedRepository.getArray('wristFeed');
}
if (this.appType === '2') {
- this.updateSharedFeedNoty(feeds);
+ var notyFeed = sharedRepository.getArray('notyFeed');
+ this.updateSharedFeedNoty(notyFeed);
}
};
- $app.methods.updateSharedFeedWrist = function (feeds) {
- var filter = this.config.sharedFeedFilters.wrist;
- var filtered = [];
- feeds.forEach((feed) => {
- if (filter[feed.type]) {
- if ((filter[feed.type] !== 'Off') &&
- ((filter[feed.type] === 'Everyone') || (filter[feed.type] === 'On') ||
- ((filter[feed.type] === 'Friends') && (feed.isFriend)) ||
- ((filter[feed.type] === 'VIP') && (feed.isFavorite)))) {
- filtered.push(feed);
- }
- } else {
- console.error(`missing feed filter for ${feed.type}`);
- filtered.push(feed);
- }
- });
- this.wristFeed = filtered;
- };
-
- $app.methods.updateSharedFeedNoty = async function (feeds) {
- var filter = this.config.sharedFeedFilters.noty;
- var filtered = [];
- feeds.forEach((feed) => {
- if (filter[feed.type]) {
- if ((filter[feed.type] !== 'Off') &&
- ((filter[feed.type] === 'Everyone') || (filter[feed.type] === 'On') ||
- ((filter[feed.type] === 'Friends') && (feed.isFriend)) ||
- ((filter[feed.type] === 'VIP') && (feed.isFavorite)))) {
- filtered.push(feed);
- }
- }
- });
+ $app.methods.updateSharedFeedNoty = async function (notyFeed) {
var notyToPlay = [];
- filtered.forEach((feed) => {
+ notyFeed.forEach((feed) => {
var displayName = '';
if (feed.displayName) {
displayName = feed.displayName;
@@ -986,7 +870,7 @@ speechSynthesis.getVoices();
text = `${noty.data} has left`;
break;
case 'OnPlayerJoining':
- text = `${noty.data} is joining`;
+ text = `${noty.displayName} is joining`;
break;
case 'GPS':
text = `${noty.displayName} is in ${await this.displayLocation(noty.location[0])}`;
@@ -1064,7 +948,7 @@ speechSynthesis.getVoices();
this.speak(`${noty.data} has left`);
break;
case 'OnPlayerJoining':
- this.speak(`${noty.data} is joining`);
+ this.speak(`${noty.displayName} is joining`);
break;
case 'GPS':
this.speak(`${noty.displayName} is in ${await this.displayLocation(noty.location[0])}`);
@@ -1148,7 +1032,7 @@ speechSynthesis.getVoices();
AppApi.DesktopNotification(noty.data, 'has left', imageURL);
break;
case 'OnPlayerJoining':
- AppApi.DesktopNotification(noty.data, 'is joining', imageURL);
+ AppApi.DesktopNotification(noty.displayName, 'is joining', imageURL);
break;
case 'GPS':
AppApi.DesktopNotification(noty.displayName, `is in ${await this.displayLocation(noty.location[0])}`, imageURL);
diff --git a/html/src/vr.pug b/html/src/vr.pug
index e29b6b4b..1adde4a8 100644
--- a/html/src/vr.pug
+++ b/html/src/vr.pug
@@ -52,7 +52,7 @@ html
span.extra
span.time {{ feed.created_at | formatDate('HH:MI') }}
span.spin ▶️
- span.name(v-text="feed.data" style="margin-left:20px")
+ span.name(v-text="feed.displayName" style="margin-left:20px")
div(v-else-if="feed.type === 'Location'" class="x-friend-item" :class="{ friend: feed.isFriend, favorite: feed.isFavorite }")
.detail
span.extra
@@ -164,7 +164,7 @@ html
.detail
span.extra
span.time {{ feed.created_at | formatDate('HH:MI') }}
- | #[span.name(v-text="feed.data")] is joining
+ | #[span.name(v-text="feed.displayName")] is joining
div(v-else-if="feed.type === 'Location'" class="x-friend-item" :class="{ friend: feed.isFriend, favorite: feed.isFavorite }")
.detail
span.extra