mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-02 21:16:07 +02:00
improve feed performance
This commit is contained in:
+8
-10
@@ -5,7 +5,6 @@ import { database } from '../service/database';
|
|||||||
import { useFriendStore } from './friend';
|
import { useFriendStore } from './friend';
|
||||||
import { useNotificationStore } from './notification';
|
import { useNotificationStore } from './notification';
|
||||||
import { useSharedFeedStore } from './sharedFeed';
|
import { useSharedFeedStore } from './sharedFeed';
|
||||||
import { useUiStore } from './ui';
|
|
||||||
import { useVrcxStore } from './vrcx';
|
import { useVrcxStore } from './vrcx';
|
||||||
import { watchState } from '../service/watchState';
|
import { watchState } from '../service/watchState';
|
||||||
|
|
||||||
@@ -14,12 +13,11 @@ import configRepository from '../service/config';
|
|||||||
export const useFeedStore = defineStore('Feed', () => {
|
export const useFeedStore = defineStore('Feed', () => {
|
||||||
const friendStore = useFriendStore();
|
const friendStore = useFriendStore();
|
||||||
const notificationStore = useNotificationStore();
|
const notificationStore = useNotificationStore();
|
||||||
const UiStore = useUiStore();
|
|
||||||
const vrcxStore = useVrcxStore();
|
const vrcxStore = useVrcxStore();
|
||||||
const sharedFeedStore = useSharedFeedStore();
|
const sharedFeedStore = useSharedFeedStore();
|
||||||
|
|
||||||
|
const feedTableData = shallowReactive([]);
|
||||||
const feedTable = ref({
|
const feedTable = ref({
|
||||||
data: shallowReactive([]),
|
|
||||||
search: '',
|
search: '',
|
||||||
vip: false,
|
vip: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
@@ -31,7 +29,7 @@ export const useFeedStore = defineStore('Feed', () => {
|
|||||||
watch(
|
watch(
|
||||||
() => watchState.isLoggedIn,
|
() => watchState.isLoggedIn,
|
||||||
(isLoggedIn) => {
|
(isLoggedIn) => {
|
||||||
feedTable.value.data.length = 0;
|
feedTableData.length = 0;
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
initFeedTable();
|
initFeedTable();
|
||||||
}
|
}
|
||||||
@@ -151,7 +149,8 @@ export const useFeedStore = defineStore('Feed', () => {
|
|||||||
feedTable.value.filter,
|
feedTable.value.filter,
|
||||||
vipList
|
vipList
|
||||||
);
|
);
|
||||||
feedTable.value.data = shallowReactive(rows);
|
feedTableData.length = 0;
|
||||||
|
feedTableData.push(...rows.reverse());
|
||||||
feedTable.value.loading = false;
|
feedTable.value.loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,16 +172,14 @@ export const useFeedStore = defineStore('Feed', () => {
|
|||||||
if (!feedSearch(feed)) {
|
if (!feedSearch(feed)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
feedTable.value.data.push(feed);
|
feedTableData.unshift(feed);
|
||||||
sweepFeed();
|
sweepFeed();
|
||||||
// UiStore.notifyMenu('feed');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sweepFeed() {
|
function sweepFeed() {
|
||||||
const { data } = feedTable.value;
|
const j = feedTableData.length;
|
||||||
const j = data.length;
|
|
||||||
if (j > vrcxStore.maxTableSize + 50) {
|
if (j > vrcxStore.maxTableSize + 50) {
|
||||||
data.splice(0, 50);
|
feedTableData.splice(-50, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +190,7 @@ export const useFeedStore = defineStore('Feed', () => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
feedTable,
|
feedTable,
|
||||||
|
feedTableData,
|
||||||
initFeedTable,
|
initFeedTable,
|
||||||
feedTableLookup,
|
feedTableLookup,
|
||||||
addFeed
|
addFeed
|
||||||
|
|||||||
@@ -2273,7 +2273,8 @@ export const useNotificationStore = defineStore('Notification', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function queueFeedNoty(noty) {
|
function queueFeedNoty(feed) {
|
||||||
|
const noty = structuredClone(feed);
|
||||||
if (noty.type === 'Avatar') {
|
if (noty.type === 'Avatar') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,7 +241,8 @@ export const useSharedFeedStore = defineStore('SharedFeed', () => {
|
|||||||
rebuildOnPlayerJoining(); // also sends updated feed
|
rebuildOnPlayerJoining(); // also sends updated feed
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addEntry(ctx) {
|
async function addEntry(feed) {
|
||||||
|
const ctx = structuredClone(feed);
|
||||||
const userId = ctx.userId || ctx.senderUserId;
|
const userId = ctx.userId || ctx.senderUserId;
|
||||||
const wristFilter = notificationsSettingsStore.sharedFeedFilters.wrist;
|
const wristFilter = notificationsSettingsStore.sharedFeedFilters.wrist;
|
||||||
if (userId === userStore.currentUser.id) {
|
if (userId === userStore.currentUser.id) {
|
||||||
|
|||||||
@@ -68,13 +68,11 @@
|
|||||||
import { useDataTableScrollHeight } from '../../composables/useDataTableScrollHeight';
|
import { useDataTableScrollHeight } from '../../composables/useDataTableScrollHeight';
|
||||||
import { useVrcxVueTable } from '../../lib/table/useVrcxVueTable';
|
import { useVrcxVueTable } from '../../lib/table/useVrcxVueTable';
|
||||||
|
|
||||||
const { feedTable } = storeToRefs(useFeedStore());
|
const { feedTable, feedTableData } = storeToRefs(useFeedStore());
|
||||||
const { feedTableLookup } = useFeedStore();
|
const { feedTableLookup } = useFeedStore();
|
||||||
const appearanceSettingsStore = useAppearanceSettingsStore();
|
const appearanceSettingsStore = useAppearanceSettingsStore();
|
||||||
const vrcxStore = useVrcxStore();
|
const vrcxStore = useVrcxStore();
|
||||||
|
|
||||||
const feedDisplayData = computed(() => feedTable.value.data.slice().reverse());
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const feedRef = ref(null);
|
const feedRef = ref(null);
|
||||||
@@ -93,7 +91,7 @@
|
|||||||
|
|
||||||
const { table, pagination } = useVrcxVueTable({
|
const { table, pagination } = useVrcxVueTable({
|
||||||
persistKey: 'feed',
|
persistKey: 'feed',
|
||||||
data: feedDisplayData,
|
data: feedTableData,
|
||||||
columns: baseColumns,
|
columns: baseColumns,
|
||||||
getRowId: (row) => `${row.type}:${row.rowId}:${row.created_at ?? ''}`,
|
getRowId: (row) => `${row.type}:${row.rowId}:${row.created_at ?? ''}`,
|
||||||
enableExpanded: true,
|
enableExpanded: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user