mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
feat: add Exclude home world for activity tab
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
getMyTopWorlds: vi.fn()
|
||||
}));
|
||||
|
||||
vi.mock('../../services/database', () => ({
|
||||
database: {
|
||||
getMyTopWorlds: mocks.getMyTopWorlds
|
||||
}
|
||||
}));
|
||||
vi.mock('../../workers/activityWorkerRunner', () => ({
|
||||
runActivityWorkerTask: vi.fn()
|
||||
}));
|
||||
|
||||
import { useActivityStore } from '../activity';
|
||||
|
||||
describe('useActivityStore', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia());
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
test('forwards excludeWorldId to top worlds query', async () => {
|
||||
mocks.getMyTopWorlds.mockResolvedValue([{ worldId: 'wrld_1' }]);
|
||||
const store = useActivityStore();
|
||||
|
||||
const result = await store.loadTopWorldsView({
|
||||
userId: 'usr_me',
|
||||
rangeDays: 30,
|
||||
limit: 5,
|
||||
sortBy: 'time',
|
||||
excludeWorldId: 'wrld_home'
|
||||
});
|
||||
|
||||
expect(result).toEqual([{ worldId: 'wrld_1' }]);
|
||||
expect(mocks.getMyTopWorlds).toHaveBeenCalledWith(30, 5, 'time', 'wrld_home');
|
||||
});
|
||||
});
|
||||
@@ -296,10 +296,10 @@ export const useActivityStore = defineStore('Activity', () => {
|
||||
|
||||
async function loadTopWorlds(
|
||||
userId,
|
||||
{ rangeDays = 30, limit = 5, sortBy = 'time' }
|
||||
{ rangeDays = 30, limit = 5, sortBy = 'time', excludeWorldId = '' }
|
||||
) {
|
||||
void userId;
|
||||
return database.getMyTopWorlds(rangeDays, limit, sortBy);
|
||||
return database.getMyTopWorlds(rangeDays, limit, sortBy, excludeWorldId);
|
||||
}
|
||||
|
||||
async function refreshActivity(userId, options) {
|
||||
@@ -358,12 +358,14 @@ export const useActivityStore = defineStore('Activity', () => {
|
||||
userId,
|
||||
rangeDays = 30,
|
||||
limit = 5,
|
||||
sortBy = 'time'
|
||||
sortBy = 'time',
|
||||
excludeWorldId = ''
|
||||
}) {
|
||||
return loadTopWorlds(userId, {
|
||||
rangeDays,
|
||||
limit,
|
||||
sortBy,
|
||||
excludeWorldId,
|
||||
isSelf: true
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user