Rewrite shared feed

This commit is contained in:
Natsumi
2026-01-17 11:44:09 +13:00
parent 56bf69f64e
commit 9f80d5e64a
22 changed files with 534 additions and 841 deletions
+13 -21
View File
@@ -174,15 +174,11 @@
groupName.value = props.grouphint; groupName.value = props.grouphint;
} else if (L.groupId) { } else if (L.groupId) {
groupName.value = L.groupId; groupName.value = L.groupId;
getGroupName(instanceId) getGroupName(instanceId).then((name) => {
.then((name) => { if (!isDisposed && name && currentInstanceId() === L.tag) {
if (!isDisposed && name && currentInstanceId() === L.tag) { groupName.value = name;
groupName.value = name; }
} });
})
.catch((e) => {
console.error(e);
});
} }
region.value = ''; region.value = '';
if (!L.isOffline && !L.isPrivate && !L.isTraveling) { if (!L.isOffline && !L.isPrivate && !L.isTraveling) {
@@ -217,19 +213,15 @@
} }
const ref = cachedWorlds.get(L.worldId); const ref = cachedWorlds.get(L.worldId);
if (typeof ref === 'undefined') { if (typeof ref === 'undefined') {
getWorldName(L.worldId) getWorldName(L.worldId).then((name) => {
.then((name) => { if (!isDisposed && name && currentInstanceId() === L.tag) {
if (!isDisposed && name && currentInstanceId() === L.tag) { if (L.instanceId) {
if (L.instanceId) { text.value = `${name} · ${translateAccessType(L.accessTypeName)}`;
text.value = `${name} · ${translateAccessType(L.accessTypeName)}`; } else {
} else { text.value = name;
text.value = name;
}
} }
}) }
.catch((e) => { });
console.error(e);
});
} else if (L.instanceId) { } else if (L.instanceId) {
text.value = `${ref.name} · ${accessTypeLabel}`; text.value = `${ref.name} · ${accessTypeLabel}`;
} else { } else {
+5 -9
View File
@@ -84,15 +84,11 @@
groupName.value = props.grouphint; groupName.value = props.grouphint;
} else if (locObj.groupId) { } else if (locObj.groupId) {
groupName.value = locObj.groupId; groupName.value = locObj.groupId;
getGroupName(locObj.groupId) getGroupName(locObj.groupId).then((name) => {
.then((name) => { if (name && props.locationobject.tag === locObj.tag) {
if (name && props.locationobject.tag === locObj.tag) { groupName.value = name;
groupName.value = name; }
} });
})
.catch((e) => {
console.error(e);
});
} else { } else {
groupName.value = ''; groupName.value = '';
} }
+13 -8
View File
@@ -177,7 +177,12 @@ const feed = {
); );
}, },
async lookupFeedDatabase(search, filters, vipList) { async lookupFeedDatabase(
search,
filters,
vipList,
maxEntries = dbVars.maxTableSize
) {
search = search.replaceAll("'", "''"); search = search.replaceAll("'", "''");
if (search.startsWith('wrld_') || search.startsWith('grp_')) { if (search.startsWith('wrld_') || search.startsWith('grp_')) {
return this.getFeedByInstanceId(search, filters, vipList); return this.getFeedByInstanceId(search, filters, vipList);
@@ -247,7 +252,7 @@ const feed = {
groupName: dbRow[8] groupName: dbRow[8]
}; };
feedDatabase.push(row); feedDatabase.push(row);
}, `SELECT * FROM ${dbVars.userPrefix}_feed_gps WHERE (display_name LIKE '%${search}%' OR world_name LIKE '%${search}%' OR group_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM ${dbVars.userPrefix}_feed_gps WHERE (display_name LIKE '%${search}%' OR world_name LIKE '%${search}%' OR group_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
} }
if (status) { if (status) {
await sqliteService.execute((dbRow) => { await sqliteService.execute((dbRow) => {
@@ -263,7 +268,7 @@ const feed = {
previousStatusDescription: dbRow[7] previousStatusDescription: dbRow[7]
}; };
feedDatabase.push(row); feedDatabase.push(row);
}, `SELECT * FROM ${dbVars.userPrefix}_feed_status WHERE (display_name LIKE '%${search}%' OR status LIKE '%${search}%' OR status_description LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM ${dbVars.userPrefix}_feed_status WHERE (display_name LIKE '%${search}%' OR status LIKE '%${search}%' OR status_description LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
} }
if (bio) { if (bio) {
await sqliteService.execute((dbRow) => { await sqliteService.execute((dbRow) => {
@@ -277,7 +282,7 @@ const feed = {
previousBio: dbRow[5] previousBio: dbRow[5]
}; };
feedDatabase.push(row); feedDatabase.push(row);
}, `SELECT * FROM ${dbVars.userPrefix}_feed_bio WHERE (display_name LIKE '%${search}%' OR bio LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM ${dbVars.userPrefix}_feed_bio WHERE (display_name LIKE '%${search}%' OR bio LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
} }
if (avatar) { if (avatar) {
var avatarQuery = ''; var avatarQuery = '';
@@ -301,7 +306,7 @@ const feed = {
previousCurrentAvatarThumbnailImageUrl: dbRow[9] previousCurrentAvatarThumbnailImageUrl: dbRow[9]
}; };
feedDatabase.push(row); feedDatabase.push(row);
}, `SELECT * FROM ${dbVars.userPrefix}_feed_avatar WHERE ((display_name LIKE '%${search}%' OR avatar_name LIKE '%${search}%') ${avatarQuery}) ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM ${dbVars.userPrefix}_feed_avatar WHERE ((display_name LIKE '%${search}%' OR avatar_name LIKE '%${search}%') ${avatarQuery}) ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
} }
if (online || offline) { if (online || offline) {
var query = ''; var query = '';
@@ -325,7 +330,7 @@ const feed = {
groupName: dbRow[8] groupName: dbRow[8]
}; };
feedDatabase.push(row); feedDatabase.push(row);
}, `SELECT * FROM ${dbVars.userPrefix}_feed_online_offline WHERE ((display_name LIKE '%${search}%' OR world_name LIKE '%${search}%' OR group_name LIKE '%${search}%') ${query}) ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM ${dbVars.userPrefix}_feed_online_offline WHERE ((display_name LIKE '%${search}%' OR world_name LIKE '%${search}%' OR group_name LIKE '%${search}%') ${query}) ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
} }
var compareByCreatedAt = function (a, b) { var compareByCreatedAt = function (a, b) {
var A = a.created_at; var A = a.created_at;
@@ -339,8 +344,8 @@ const feed = {
return 0; return 0;
}; };
feedDatabase.sort(compareByCreatedAt); feedDatabase.sort(compareByCreatedAt);
if (feedDatabase.length > dbVars.maxTableSize) { if (feedDatabase.length > maxEntries) {
feedDatabase.splice(0, feedDatabase.length - dbVars.maxTableSize); feedDatabase.splice(0, feedDatabase.length - maxEntries);
} }
return feedDatabase; return feedDatabase;
}, },
+16 -9
View File
@@ -671,7 +671,12 @@ const gameLog = {
* @returns {Promise<any[]>} The game log data * @returns {Promise<any[]>} The game log data
*/ */
async lookupGameLogDatabase(search, filters, vipList = []) { async lookupGameLogDatabase(
search,
filters,
vipList,
maxEntries = dbVars.maxTableSize
) {
search = search.replaceAll("'", "''"); search = search.replaceAll("'", "''");
if (search.startsWith('wrld_') || search.startsWith('grp_')) { if (search.startsWith('wrld_') || search.startsWith('grp_')) {
return this.getGameLogByLocation(search, filters); return this.getGameLogByLocation(search, filters);
@@ -752,7 +757,7 @@ const gameLog = {
groupName: dbRow[6] groupName: dbRow[6]
}; };
gamelogDatabase.push(row); gamelogDatabase.push(row);
}, `SELECT * FROM gamelog_location WHERE world_name LIKE '%${search}%' OR group_name LIKE '%${search}%' ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM gamelog_location WHERE world_name LIKE '%${search}%' OR group_name LIKE '%${search}%' ORDER BY id DESC LIMIT ${maxEntries}`);
} }
if (onplayerjoined || onplayerleft) { if (onplayerjoined || onplayerleft) {
var query = ''; var query = '';
@@ -774,7 +779,7 @@ const gameLog = {
time: dbRow[6] time: dbRow[6]
}; };
gamelogDatabase.push(row); gamelogDatabase.push(row);
}, `SELECT * FROM gamelog_join_leave WHERE (display_name LIKE '%${search}%' AND user_id != '${dbVars.userId}') ${vipQuery} ${query} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM gamelog_join_leave WHERE (display_name LIKE '%${search}%' AND user_id != '${dbVars.userId}') ${vipQuery} ${query} ORDER BY id DESC LIMIT ${maxEntries}`);
} }
if (portalspawn) { if (portalspawn) {
await sqliteService.execute((dbRow) => { await sqliteService.execute((dbRow) => {
@@ -789,7 +794,7 @@ const gameLog = {
worldName: dbRow[6] worldName: dbRow[6]
}; };
gamelogDatabase.push(row); gamelogDatabase.push(row);
}, `SELECT * FROM gamelog_portal_spawn WHERE (display_name LIKE '%${search}%' OR world_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM gamelog_portal_spawn WHERE (display_name LIKE '%${search}%' OR world_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
} }
if (msgevent) { if (msgevent) {
await sqliteService.execute((dbRow) => { await sqliteService.execute((dbRow) => {
@@ -800,7 +805,7 @@ const gameLog = {
data: dbRow[2] data: dbRow[2]
}; };
gamelogDatabase.push(row); gamelogDatabase.push(row);
}, `SELECT * FROM gamelog_event WHERE data LIKE '%${search}%' ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM gamelog_event WHERE data LIKE '%${search}%' ORDER BY id DESC LIMIT ${maxEntries}`);
} }
if (external) { if (external) {
await sqliteService.execute((dbRow) => { await sqliteService.execute((dbRow) => {
@@ -814,7 +819,7 @@ const gameLog = {
location: dbRow[5] location: dbRow[5]
}; };
gamelogDatabase.push(row); gamelogDatabase.push(row);
}, `SELECT * FROM gamelog_external WHERE (display_name LIKE '%${search}%' OR message LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM gamelog_external WHERE (display_name LIKE '%${search}%' OR message LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
} }
if (videoplay) { if (videoplay) {
await sqliteService.execute((dbRow) => { await sqliteService.execute((dbRow) => {
@@ -830,7 +835,7 @@ const gameLog = {
userId: dbRow[7] userId: dbRow[7]
}; };
gamelogDatabase.push(row); gamelogDatabase.push(row);
}, `SELECT * FROM gamelog_video_play WHERE (video_url LIKE '%${search}%' OR video_name LIKE '%${search}%' OR display_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM gamelog_video_play WHERE (video_url LIKE '%${search}%' OR video_name LIKE '%${search}%' OR display_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
} }
if (resourceload_string || resourceload_image) { if (resourceload_string || resourceload_image) {
var checkString = ''; var checkString = '';
@@ -850,7 +855,7 @@ const gameLog = {
location: dbRow[4] location: dbRow[4]
}; };
gamelogDatabase.push(row); gamelogDatabase.push(row);
}, `SELECT * FROM gamelog_resource_load WHERE resource_url LIKE '%${search}%' ${checkString} ${checkImage} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM gamelog_resource_load WHERE resource_url LIKE '%${search}%' ${checkString} ${checkImage} ORDER BY id DESC LIMIT ${maxEntries}`);
} }
var compareByCreatedAt = function (a, b) { var compareByCreatedAt = function (a, b) {
var A = a.created_at; var A = a.created_at;
@@ -864,7 +869,9 @@ const gameLog = {
return 0; return 0;
}; };
gamelogDatabase.sort(compareByCreatedAt); gamelogDatabase.sort(compareByCreatedAt);
gamelogDatabase.splice(0, gamelogDatabase.length - dbVars.maxTableSize); if (gamelogDatabase.length > maxEntries) {
gamelogDatabase.splice(0, gamelogDatabase.length - maxEntries);
}
return gamelogDatabase; return gamelogDatabase;
}, },
+51 -5
View File
@@ -21,17 +21,63 @@ const notifications = {
inviteMessage: dbRow[10], inviteMessage: dbRow[10],
requestMessage: dbRow[11], requestMessage: dbRow[11],
responseMessage: dbRow[12] responseMessage: dbRow[12]
} },
$isExpired: dbRow[13] === 1
}; };
row.$isExpired = false;
if (dbRow[13] === 1) {
row.$isExpired = true;
}
notifications.unshift(row); notifications.unshift(row);
}, `SELECT * FROM ${dbVars.userPrefix}_notifications ORDER BY created_at DESC LIMIT ${dbVars.maxTableSize}`); }, `SELECT * FROM ${dbVars.userPrefix}_notifications ORDER BY created_at DESC LIMIT ${dbVars.maxTableSize}`);
return notifications; return notifications;
}, },
async lookupNotificationDatabase(
search,
filters,
vipList,
maxEntries = dbVars.maxTableSize
) {
search = search.replaceAll("'", "''");
let notifications = [];
let vipQuery = '';
if (vipList.length > 0) {
const vipIds = vipList.map(
(userId) => `'${userId.replaceAll("'", "''")}'`
);
vipQuery = `AND sender_user_id IN (${vipIds.join(',')})`;
}
let filterQuery = '';
if (filters.length > 0) {
const filterTypes = filters.map(
(type) => `'${type.replaceAll("'", "''")}'`
);
filterQuery = `AND type IN (${filterTypes.join(',')})`;
}
await sqliteService.execute((dbRow) => {
let row = {
id: dbRow[0],
created_at: dbRow[1],
type: dbRow[2],
senderUserId: dbRow[3],
senderUsername: dbRow[4],
receiverUserId: dbRow[5],
message: dbRow[6],
details: {
worldId: dbRow[7],
worldName: dbRow[8],
imageUrl: dbRow[9],
inviteMessage: dbRow[10],
requestMessage: dbRow[11],
responseMessage: dbRow[12]
},
$isExpired: dbRow[13] === 1
};
notifications.unshift(row);
}, `SELECT * FROM ${dbVars.userPrefix}_notifications WHERE (sender_username LIKE '%${search}%' OR message LIKE '%${search}%' OR world_name LIKE '%${search}%') ${vipQuery} ${filterQuery} ORDER BY created_at DESC LIMIT ${maxEntries}`);
return notifications;
},
addNotificationToDatabase(row) { addNotificationToDatabase(row) {
var entry = { var entry = {
id: '', id: '',
+1 -1
View File
@@ -573,7 +573,7 @@ function handlePipeline(args) {
} }
notificationStore.queueNotificationNoty(noty); notificationStore.queueNotificationNoty(noty);
notificationStore.notificationTable.data.push(noty); notificationStore.notificationTable.data.push(noty);
sharedFeedStore.updateSharedFeed(true); sharedFeedStore.addEntry(noty);
break; break;
default: default:
+8 -4
View File
@@ -12,10 +12,14 @@ async function getWorldName(location) {
const L = parseLocation(location); const L = parseLocation(location);
if (L.isRealInstance && L.worldId) { if (L.isRealInstance && L.worldId) {
const args = await worldRequest.getCachedWorld({ try {
worldId: L.worldId const args = await worldRequest.getCachedWorld({
}); worldId: L.worldId
worldName = args.ref.name; });
worldName = args.ref.name;
} catch (e) {
console.error('getWorldName failed location', location, e);
}
} }
return worldName; return worldName;
+1 -50
View File
@@ -28,13 +28,10 @@ export const useFeedStore = defineStore('Feed', () => {
pageSizeLinked: true pageSizeLinked: true
}); });
const feedSessionTable = ref([]);
watch( watch(
() => watchState.isLoggedIn, () => watchState.isLoggedIn,
(isLoggedIn) => { (isLoggedIn) => {
feedTable.value.data.length = 0; feedTable.value.data.length = 0;
feedSessionTable.value = [];
if (isLoggedIn) { if (isLoggedIn) {
initFeedTable(); initFeedTable();
} }
@@ -160,9 +157,7 @@ export const useFeedStore = defineStore('Feed', () => {
function addFeed(feed) { function addFeed(feed) {
notificationStore.queueFeedNoty(feed); notificationStore.queueFeedNoty(feed);
feedSessionTable.value.push(feed); sharedFeedStore.addEntry(feed);
sweepFeedSessionTable();
sharedFeedStore.updateSharedFeed(false);
if ( if (
feedTable.value.filter.length > 0 && feedTable.value.filter.length > 0 &&
!feedTable.value.filter.includes(feed.type) !feedTable.value.filter.includes(feed.type)
@@ -183,65 +178,21 @@ export const useFeedStore = defineStore('Feed', () => {
UiStore.notifyMenu('feed'); UiStore.notifyMenu('feed');
} }
function sweepFeedSessionTable() {
const data = feedSessionTable.value;
const k = data.length;
if (!k) {
return;
}
// 24 hour limit
const date = new Date();
date.setDate(date.getDate() - 1);
const limit = date.toJSON();
if (data[0].created_at < limit) {
let i = 0;
while (i < k && data[i].created_at < limit) {
++i;
}
if (i === k) {
feedSessionTable.value = [];
return;
}
if (i) {
data.splice(0, i);
}
}
const maxLen = Math.floor(vrcxStore.maxTableSize * 1.5);
if (maxLen > 0 && data.length > maxLen + 100) {
data.splice(0, 100);
}
}
function sweepFeed() { function sweepFeed() {
const { data } = feedTable.value; const { data } = feedTable.value;
const j = data.length; const j = data.length;
if (j > vrcxStore.maxTableSize + 50) { if (j > vrcxStore.maxTableSize + 50) {
data.splice(0, 50); data.splice(0, 50);
} }
sweepFeedSessionTable();
} }
async function initFeedTable() { async function initFeedTable() {
feedTable.value.loading = true; feedTable.value.loading = true;
feedTableLookup(); feedTableLookup();
const getFeedDatabaseResult = await database.getFeedDatabase();
if (getFeedDatabaseResult && getFeedDatabaseResult.length > 0) {
// rough, maybe 100 is enough
feedSessionTable.value = getFeedDatabaseResult.slice(-100);
} else {
feedSessionTable.value = [];
}
} }
return { return {
feedTable, feedTable,
feedSessionTable,
initFeedTable, initFeedTable,
feedTableLookup, feedTableLookup,
addFeed addFeed
+4 -4
View File
@@ -993,6 +993,7 @@ export const useFriendStore = defineStore('Friend', () => {
friendLogTable.value.data.push(friendLogHistory); friendLogTable.value.data.push(friendLogHistory);
database.addFriendLogHistory(friendLogHistory); database.addFriendLogHistory(friendLogHistory);
notificationStore.queueFriendLogNoty(friendLogHistory); notificationStore.queueFriendLogNoty(friendLogHistory);
sharedFeedStore.addEntry(friendLogHistory);
const friendLogCurrent = { const friendLogCurrent = {
userId: id, userId: id,
displayName: ref.displayName, displayName: ref.displayName,
@@ -1003,7 +1004,6 @@ export const useFriendStore = defineStore('Friend', () => {
database.setFriendLogCurrent(friendLogCurrent); database.setFriendLogCurrent(friendLogCurrent);
uiStore.notifyMenu('friend-log'); uiStore.notifyMenu('friend-log');
deleteFriendRequest(id); deleteFriendRequest(id);
sharedFeedStore.updateSharedFeed(true);
userRequest userRequest
.getUser({ .getUser({
userId: id userId: id
@@ -1067,13 +1067,13 @@ export const useFriendStore = defineStore('Friend', () => {
friendLogTable.value.data.push(friendLogHistory); friendLogTable.value.data.push(friendLogHistory);
database.addFriendLogHistory(friendLogHistory); database.addFriendLogHistory(friendLogHistory);
notificationStore.queueFriendLogNoty(friendLogHistory); notificationStore.queueFriendLogNoty(friendLogHistory);
sharedFeedStore.addEntry(friendLogHistory);
friendLog.delete(id); friendLog.delete(id);
database.deleteFriendLogCurrent(id); database.deleteFriendLogCurrent(id);
favoriteStore.handleFavoriteDelete(id); favoriteStore.handleFavoriteDelete(id);
if (!appearanceSettingsStore.hideUnfriends) { if (!appearanceSettingsStore.hideUnfriends) {
uiStore.notifyMenu('friend-log'); uiStore.notifyMenu('friend-log');
} }
sharedFeedStore.updateSharedFeed(true);
deleteFriend(id); deleteFriend(id);
} }
}); });
@@ -1130,6 +1130,7 @@ export const useFriendStore = defineStore('Friend', () => {
notificationStore.queueFriendLogNoty( notificationStore.queueFriendLogNoty(
friendLogHistoryDisplayName friendLogHistoryDisplayName
); );
sharedFeedStore.addEntry(friendLogHistoryDisplayName);
const friendLogCurrent = { const friendLogCurrent = {
userId: ref.id, userId: ref.id,
displayName: ref.displayName, displayName: ref.displayName,
@@ -1140,7 +1141,6 @@ export const useFriendStore = defineStore('Friend', () => {
database.setFriendLogCurrent(friendLogCurrent); database.setFriendLogCurrent(friendLogCurrent);
ctx.displayName = ref.displayName; ctx.displayName = ref.displayName;
uiStore.notifyMenu('friend-log'); uiStore.notifyMenu('friend-log');
sharedFeedStore.updateSharedFeed(true);
} }
} }
if ( if (
@@ -1176,6 +1176,7 @@ export const useFriendStore = defineStore('Friend', () => {
friendLogTable.value.data.push(friendLogHistoryTrustLevel); friendLogTable.value.data.push(friendLogHistoryTrustLevel);
database.addFriendLogHistory(friendLogHistoryTrustLevel); database.addFriendLogHistory(friendLogHistoryTrustLevel);
notificationStore.queueFriendLogNoty(friendLogHistoryTrustLevel); notificationStore.queueFriendLogNoty(friendLogHistoryTrustLevel);
sharedFeedStore.addEntry(friendLogHistoryTrustLevel);
const friendLogCurrent2 = { const friendLogCurrent2 = {
userId: ref.id, userId: ref.id,
displayName: ref.displayName, displayName: ref.displayName,
@@ -1185,7 +1186,6 @@ export const useFriendStore = defineStore('Friend', () => {
friendLog.set(ref.id, friendLogCurrent2); friendLog.set(ref.id, friendLogCurrent2);
database.setFriendLogCurrent(friendLogCurrent2); database.setFriendLogCurrent(friendLogCurrent2);
uiStore.notifyMenu('friend-log'); uiStore.notifyMenu('friend-log');
sharedFeedStore.updateSharedFeed(true);
} }
ctx.trustLevel = ref.$trustLevel; ctx.trustLevel = ref.$trustLevel;
} }
+6 -75
View File
@@ -15,7 +15,6 @@ import {
import { AppDebug } from '../service/appConfig'; import { AppDebug } from '../service/appConfig';
import { database } from '../service/database'; import { database } from '../service/database';
import { useAdvancedSettingsStore } from './settings/advanced'; import { useAdvancedSettingsStore } from './settings/advanced';
import { useAppearanceSettingsStore } from './settings/appearance';
import { useFriendStore } from './friend'; import { useFriendStore } from './friend';
import { useGalleryStore } from './gallery'; import { useGalleryStore } from './gallery';
import { useGameStore } from './game'; import { useGameStore } from './game';
@@ -49,7 +48,6 @@ export const useGameLogStore = defineStore('GameLog', () => {
const vrcxStore = useVrcxStore(); const vrcxStore = useVrcxStore();
const advancedSettingsStore = useAdvancedSettingsStore(); const advancedSettingsStore = useAdvancedSettingsStore();
const gameStore = useGameStore(); const gameStore = useGameStore();
const appearanceSettingsStore = useAppearanceSettingsStore();
const generalSettingsStore = useGeneralSettingsStore(); const generalSettingsStore = useGeneralSettingsStore();
const galleryStore = useGalleryStore(); const galleryStore = useGalleryStore();
const photonStore = usePhotonStore(); const photonStore = usePhotonStore();
@@ -70,8 +68,6 @@ export const useGameLogStore = defineStore('GameLog', () => {
vip: false vip: false
}); });
const gameLogSessionTable = ref([]);
const nowPlaying = ref({ const nowPlaying = ref({
url: '', url: '',
name: '', name: '',
@@ -93,7 +89,6 @@ export const useGameLogStore = defineStore('GameLog', () => {
() => watchState.isLoggedIn, () => watchState.isLoggedIn,
(isLoggedIn) => { (isLoggedIn) => {
gameLogTable.value.data.length = 0; gameLogTable.value.data.length = 0;
gameLogSessionTable.value = [];
if (isLoggedIn) { if (isLoggedIn) {
// wait for friends to load, silly but works // wait for friends to load, silly but works
setTimeout(() => { setTimeout(() => {
@@ -225,14 +220,15 @@ export const useGameLogStore = defineStore('GameLog', () => {
workerTimers.setTimeout(() => updateNowPlaying(), 1000); workerTimers.setTimeout(() => updateNowPlaying(), 1000);
} }
function tryLoadPlayerList() { async function tryLoadPlayerList() {
// TODO: make this work again
if (!gameStore.isGameRunning) { if (!gameStore.isGameRunning) {
return; return;
} }
console.log('Loading player list from game log...'); console.log('Loading player list from game log...');
let ctx; let ctx;
let i; let i;
const data = gameLogSessionTable.value; const data = await database.getGamelogDatabase();
if (data.length === 0) { if (data.length === 0) {
return; return;
} }
@@ -358,13 +354,6 @@ export const useGameLogStore = defineStore('GameLog', () => {
function addGameLog(entry) { function addGameLog(entry) {
entry.isFriend = gameLogIsFriend(entry); entry.isFriend = gameLogIsFriend(entry);
entry.isFavorite = gameLogIsFavorite(entry); entry.isFavorite = gameLogIsFavorite(entry);
gameLogSessionTable.value.push(entry);
sweepGameLogSessionTable();
sharedFeedStore.updateSharedFeed(false);
if (entry.type === 'VideoPlay') {
// event time can be before last gameLog entry
sharedFeedStore.updateSharedFeed(true);
}
// If the VIP friend filter is enabled, logs from other friends will be ignored. // If the VIP friend filter is enabled, logs from other friends will be ignored.
if ( if (
@@ -402,38 +391,6 @@ export const useGameLogStore = defineStore('GameLog', () => {
uiStore.notifyMenu('game-log'); uiStore.notifyMenu('game-log');
} }
function sweepGameLogSessionTable() {
const data = gameLogSessionTable.value;
const k = data.length;
if (!k) {
return;
}
// 24 hour limit
const date = new Date();
date.setDate(date.getDate() - 1);
const limit = date.toJSON();
if (data[0].created_at < limit) {
let i = 0;
while (i < k && data[i].created_at < limit) {
++i;
}
if (i === k) {
gameLogSessionTable.value = [];
return;
}
if (i) {
data.splice(0, i);
}
}
const maxLen = Math.floor(vrcxStore.maxTableSize * 1.5);
if (maxLen > 0 && data.length > maxLen + 100) {
data.splice(0, 100);
}
}
async function addGamelogLocationToDatabase(input) { async function addGamelogLocationToDatabase(input) {
const groupName = await getGroupName(input.location); const groupName = await getGroupName(input.location);
const entry = { const entry = {
@@ -518,8 +475,6 @@ export const useGameLogStore = defineStore('GameLog', () => {
if (j > vrcxStore.maxTableSize + 50) { if (j > vrcxStore.maxTableSize + 50) {
data.splice(0, 50); data.splice(0, 50);
} }
sweepGameLogSessionTable();
} }
function addGameLogEntry(gameLog, location) { function addGameLogEntry(gameLog, location) {
@@ -657,22 +612,6 @@ export const useGameLogStore = defineStore('GameLog', () => {
if (typeof ref1 === 'undefined') { if (typeof ref1 === 'undefined') {
break; break;
} }
const friendRef = friendStore.friends.get(userId);
if (typeof friendRef?.ref !== 'undefined') {
friendRef.ref.$joinCount++;
friendRef.ref.$lastSeen = new Date().toJSON();
friendRef.ref.$timeSpent +=
dayjs(gameLog.dt) - ref1.joinTime;
if (
appearanceSettingsStore.sidebarSortMethods.includes(
'Sort by Last Seen'
)
) {
// TODO: remove
friendStore.sortVIPFriends = true;
friendStore.sortOnlineFriends = true;
}
}
const time = dayjs(gameLog.dt) - ref1.joinTime; const time = dayjs(gameLog.dt) - ref1.joinTime;
locationStore.lastLocation.playerList.delete(userId); locationStore.lastLocation.playerList.delete(userId);
locationStore.lastLocation.friendList.delete(userId); locationStore.lastLocation.friendList.delete(userId);
@@ -958,13 +897,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
break; break;
} }
if (typeof entry !== 'undefined') { if (typeof entry !== 'undefined') {
// add tag colour sharedFeedStore.addEntry(entry);
if (entry.userId) {
const tagRef = userStore.customUserTags.get(entry.userId);
if (typeof tagRef !== 'undefined') {
entry.tagColour = tagRef.colour;
}
}
notificationStore.queueGameLogNoty(entry); notificationStore.queueGameLogNoty(entry);
addGameLog(entry); addGameLog(entry);
} }
@@ -1368,8 +1301,6 @@ export const useGameLogStore = defineStore('GameLog', () => {
async function getGameLogTable() { async function getGameLogTable() {
await database.initTables(); await database.initTables();
gameLogSessionTable.value = await database.getGamelogDatabase();
sweepGameLogSessionTable();
const dateTill = await database.getLastDateGameLogDatabase(); const dateTill = await database.getLastDateGameLogDatabase();
updateGameLog(dateTill); updateGameLog(dateTill);
} }
@@ -1433,7 +1364,8 @@ export const useGameLogStore = defineStore('GameLog', () => {
async function initGameLogTable() { async function initGameLogTable() {
const rows = await database.lookupGameLogDatabase( const rows = await database.lookupGameLogDatabase(
gameLogTable.value.search, gameLogTable.value.search,
gameLogTable.value.filter gameLogTable.value.filter,
[]
); );
for (const row of rows) { for (const row of rows) {
row.isFriend = gameLogIsFriend(row); row.isFriend = gameLogIsFriend(row);
@@ -1447,7 +1379,6 @@ export const useGameLogStore = defineStore('GameLog', () => {
nowPlaying, nowPlaying,
gameLogTable, gameLogTable,
gameLogSessionTable,
lastVideoUrl, lastVideoUrl,
lastResourceloadUrl, lastResourceloadUrl,
+2 -3
View File
@@ -73,8 +73,7 @@ async function registerSentryPiniaPlugin() {
GameLog: { GameLog: {
// @ts-ignore // @ts-ignore
...state.GameLog, ...state.GameLog,
gameLogTable: null, gameLogTable: null
gameLogSessionTable: null
}, },
Notification: { Notification: {
// @ts-ignore // @ts-ignore
@@ -92,7 +91,7 @@ async function registerSentryPiniaPlugin() {
SharedFeed: { SharedFeed: {
// @ts-ignore // @ts-ignore
...state.SharedFeed, ...state.SharedFeed,
sharedFeed: null sharedFeedData: null
}, },
Group: { Group: {
// @ts-ignore // @ts-ignore
+10 -6
View File
@@ -387,11 +387,15 @@ export const useInstanceStore = defineStore('Instance', () => {
const L = parseLocation(location); const L = parseLocation(location);
if (L.isRealInstance && L.worldId && L.instanceId) { if (L.isRealInstance && L.worldId && L.instanceId) {
const args = await instanceRequest.getCachedInstance({ try {
worldId: L.worldId, const args = await instanceRequest.getCachedInstance({
instanceId: L.instanceId worldId: L.worldId,
}); instanceId: L.instanceId
instanceName = args.ref.displayName; });
instanceName = args.ref.displayName;
} catch (e) {
console.error('getInstanceName failed location', location, e);
}
} }
return instanceName; return instanceName;
@@ -976,8 +980,8 @@ export const useInstanceStore = defineStore('Instance', () => {
uiStore.notifyMenu('notification'); uiStore.notifyMenu('notification');
} }
notificationStore.queueNotificationNoty(noty); notificationStore.queueNotificationNoty(noty);
sharedFeedStore.addEntry(noty);
notificationStore.notificationTable.data.push(noty); notificationStore.notificationTable.data.push(noty);
sharedFeedStore.updateSharedFeed(true);
} }
/** /**
+8 -8
View File
@@ -95,14 +95,14 @@ export const useLocationStore = defineStore('Location', () => {
// with the current state of things, lets not run this if we don't need to // with the current state of things, lets not run this if we don't need to
return; return;
} }
let lastLocationTemp = ''; const lastLocationArray = await database.lookupGameLogDatabase(
for (let i = gameLogStore.gameLogSessionTable.length - 1; i > -1; i--) { '',
const item = gameLogStore.gameLogSessionTable[i]; ['Location'],
if (item.type === 'Location') { [],
lastLocationTemp = item.location; 1
break; );
} const lastLocationTemp =
} lastLocationArray.length > 0 ? lastLocationArray[0].location : '';
if (lastLocationTemp === location) { if (lastLocationTemp === location) {
return; return;
} }
+1 -1
View File
@@ -146,10 +146,10 @@ export const useNotificationStore = defineStore('Notification', () => {
} }
unseenNotifications.value.push(ref.id); unseenNotifications.value.push(ref.id);
queueNotificationNoty(ref); queueNotificationNoty(ref);
sharedFeedStore.addEntry(ref);
} }
} }
notificationTable.value.data.push(ref); notificationTable.value.data.push(ref);
sharedFeedStore.updateSharedFeed(true);
const D = userStore.userDialog; const D = userStore.userDialog;
if ( if (
D.visible === false || D.visible === false ||
+1 -3
View File
@@ -1645,6 +1645,7 @@ export const usePhotonStore = defineStore('Photon', () => {
type type
}; };
notificationStore.queueModerationNoty(noty); notificationStore.queueModerationNoty(noty);
sharedFeedStore.addEntry(noty);
const entry = { const entry = {
created_at: gameLogDate, created_at: gameLogDate,
userId: ref.id, userId: ref.id,
@@ -1653,9 +1654,6 @@ export const usePhotonStore = defineStore('Photon', () => {
}; };
moderationAgainstTable.value.push(entry); moderationAgainstTable.value.push(entry);
} }
if (block || mute || block !== row.block || mute !== row.mute) {
sharedFeedStore.updateSharedFeed(true);
}
if (block || mute) { if (block || mute) {
database.setModeration({ database.setModeration({
userId: ref.id, userId: ref.id,
+5
View File
@@ -1,11 +1,15 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { ref } from 'vue'; import { ref } from 'vue';
import { useSharedFeedStore } from '../sharedFeed';
import configRepository from '../../service/config'; import configRepository from '../../service/config';
export const useWristOverlaySettingsStore = defineStore( export const useWristOverlaySettingsStore = defineStore(
'WristOverlaySettings', 'WristOverlaySettings',
() => { () => {
const sharedFeed = useSharedFeedStore();
const overlayWrist = ref(true); const overlayWrist = ref(true);
const hidePrivateFromFeed = ref(false); const hidePrivateFromFeed = ref(false);
const openVRAlways = ref(false); const openVRAlways = ref(false);
@@ -68,6 +72,7 @@ export const useWristOverlaySettingsStore = defineStore(
'VRCX_hidePrivateFromFeed', 'VRCX_hidePrivateFromFeed',
hidePrivateFromFeed.value hidePrivateFromFeed.value
); );
sharedFeed.loadSharedFeed();
} }
function setOpenVRAlways() { function setOpenVRAlways() {
openVRAlways.value = !openVRAlways.value; openVRAlways.value = !openVRAlways.value;
+382 -612
View File
File diff suppressed because it is too large Load Diff
+2 -8
View File
@@ -630,17 +630,11 @@ export const useUserStore = defineStore('User', () => {
...ref ...ref
}); });
currentTravelers.set(ref.id, travelRef); currentTravelers.set(ref.id, travelRef);
sharedFeedStore.sharedFeed.pendingUpdate = true;
sharedFeedStore.updateSharedFeed(false);
onPlayerTraveling(travelRef); onPlayerTraveling(travelRef);
} }
} else { } else {
ref.$location = parseLocation(ref.location); ref.$location = parseLocation(ref.location);
if (currentTravelers.has(ref.id)) { currentTravelers.delete(ref.id);
currentTravelers.delete(ref.id);
sharedFeedStore.sharedFeed.pendingUpdate = true;
sharedFeedStore.updateSharedFeed(false);
}
} }
if ( if (
!instanceStore.cachedInstances.has(ref.$location.tag) && !instanceStore.cachedInstances.has(ref.$location.tag) &&
@@ -1651,7 +1645,7 @@ export const useUserStore = defineStore('User', () => {
ref.$customTag = data.Tag; ref.$customTag = data.Tag;
ref.$customTagColour = data.TagColour; ref.$customTagColour = data.TagColour;
} }
sharedFeedStore.updateSharedFeed(true); sharedFeedStore.addTag(data.UserId, data.TagColour);
} }
async function initUserNotes() { async function initUserNotes() {
+1 -2
View File
@@ -44,12 +44,11 @@ export const useVrStore = defineStore('Vr', () => {
updateVRLastLocation(); updateVRLastLocation();
updateVrNowPlaying(); updateVrNowPlaying();
// run these methods again to send data to the overlay // run these methods again to send data to the overlay
sharedFeedStore.updateSharedFeed(true); sharedFeedStore.sendSharedFeed();
friendStore.updateOnlineFriendCounter(true); // force an update friendStore.updateOnlineFriendCounter(true); // force an update
} }
async function saveOpenVROption() { async function saveOpenVROption() {
sharedFeedStore.updateSharedFeed(true);
updateVRConfigVars(); updateVRConfigVars();
updateVRLastLocation(); updateVRLastLocation();
AppApi.ExecuteVrOverlayFunction('notyClear', ''); AppApi.ExecuteVrOverlayFunction('notyClear', '');
@@ -30,15 +30,7 @@ export function useInstanceActivityData() {
async function getWorldNameData() { async function getWorldNameData() {
worldNameArray.value = await Promise.all( worldNameArray.value = await Promise.all(
activityData.value.map(async (item) => { activityData.value.map(async (item) => {
try { return await getWorldName(item.location);
return await getWorldName(item.location);
} catch {
console.error(
'getWorldName failed location',
item.location
);
return 'Unknown world';
}
}) })
); );
} }
@@ -65,7 +65,7 @@
padding: `${16 * props.cardScale * props.cardSpacing}px` padding: `${16 * props.cardScale * props.cardSpacing}px`
})); }));
const avatarFallback = computed(() => props.friend.name.charAt(0) ?? '?'); const avatarFallback = computed(() => props.friend?.name?.charAt(0) ?? '?');
const statusDotClass = computed(() => { const statusDotClass = computed(() => {
const status = userStatusClass(props.friend.ref, props.friend.pendingOffline); const status = userStatusClass(props.friend.ref, props.friend.pendingOffline);
@@ -100,7 +100,7 @@
const { photonLoggingEnabled } = storeToRefs(usePhotonStore()); const { photonLoggingEnabled } = storeToRefs(usePhotonStore());
const { notyFeedFiltersOptions, wristFeedFiltersOptions, photonFeedFiltersOptions } = feedFiltersOptions(); const { notyFeedFiltersOptions, wristFeedFiltersOptions, photonFeedFiltersOptions } = feedFiltersOptions();
const { sharedFeedFilters } = storeToRefs(useNotificationsSettingsStore()); const { sharedFeedFilters } = storeToRefs(useNotificationsSettingsStore());
const { updateSharedFeed } = useSharedFeedStore(); const { loadSharedFeed } = useSharedFeedStore();
const props = defineProps({ const props = defineProps({
feedFiltersDialogMode: { feedFiltersDialogMode: {
@@ -136,7 +136,7 @@
function saveSharedFeedFilters() { function saveSharedFeedFilters() {
configRepository.setString('sharedFeedFilters', JSON.stringify(sharedFeedFilters.value)); configRepository.setString('sharedFeedFilters', JSON.stringify(sharedFeedFilters.value));
updateSharedFeed(true); loadSharedFeed();
} }
function resetNotyFeedFilters() { function resetNotyFeedFilters() {