From fe1790f217b1b7f1472f7ae24b23fabfa7f0f977 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 18 Jun 2026 20:53:21 +0300 Subject: [PATCH] fixes --- src/api/public.js | 4 +- src/api/user.js | 2 +- src/components/conversation/conversation.js | 4 +- src/modules/statuses.js | 6 +- src/stores/sync_config.js | 1 - test/unit/specs/stores/lists.spec.js | 120 ++++++++++---------- 6 files changed, 67 insertions(+), 70 deletions(-) diff --git a/src/api/public.js b/src/api/public.js index 570e84dff..1e91676f0 100644 --- a/src/api/public.js +++ b/src/api/public.js @@ -339,14 +339,14 @@ export const fetchFavoritedByUsers = ({ id, credentials }) => url: MASTODON_STATUS_FAVORITEDBY_URL(id), method: 'GET', credentials, - }).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) })) + }).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) })) export const fetchRebloggedByUsers = ({ id, credentials }) => promisedRequest({ url: MASTODON_STATUS_REBLOGGEDBY_URL(id), method: 'GET', credentials, - }).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) })) + }).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) })) export const fetchEmojiReactions = ({ id, credentials }) => promisedRequest({ diff --git a/src/api/user.js b/src/api/user.js index f7228d84f..127debdea 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -44,7 +44,7 @@ const MASTODON_DENY_USER_URL = (id) => `/api/v1/follow_requests/${id}/reject` const MASTODON_USER_RELATIONSHIPS_URL = ({ id, withSuspended }) => `/api/v1/accounts/relationships/${paramsString({ id, withSuspended })}` const MASTODON_USER_IN_LISTS = (id) => `/api/v1/accounts/${id}/lists` -export const MASTODON_LIST_URL = (id) => `/api/v1/lists/${id}` +export const MASTODON_LIST_URL = (id = '') => `/api/v1/lists/${id}` export const MASTODON_LIST_ACCOUNTS_URL = (id) => `/api/v1/lists/${id}/accounts` const MASTODON_USER_BLOCKS_URL = ({ maxId, diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 27584d945..281f2b573 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -445,7 +445,7 @@ const conversation = { fetchConversation({ id: this.statusId, credentials: useOAuthStore().token, - }).then(({ ancestors, descendants }) => { + }).then(({ data: { ancestors, descendants } }) => { this.$store.dispatch('addNewStatuses', { statuses: ancestors }) this.$store.dispatch('addNewStatuses', { statuses: descendants }) this.setHighlight(this.originalStatusId) @@ -456,7 +456,7 @@ const conversation = { id: this.statusId, credentials: useOAuthStore().token, }) - .then((status) => { + .then(({ data: status }) => { this.$store.dispatch('addNewStatuses', { statuses: [status] }) this.fetchConversation() }) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 66bcda13d..378759a82 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -788,12 +788,12 @@ const statuses = { fetchFavoritedByUsers({ id, credentials: useOAuthStore().token, - }), + }).then(({ data }) => data), fetchRebloggedByUsers({ id, credentials: useOAuthStore().token, - }), - ]).then(([{ data: favoritedByUsers }, { data: rebloggedByUsers }]) => { + }).then(({ data }) => data),, + ]).then(([favoritedByUsers, rebloggedByUsers]) => { commit('addFavs', { id, favoritedByUsers, diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index f42d068d7..ccc4bbd4d 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -244,7 +244,6 @@ export const _mergeJournal = (...journals) => { } }) .map((x) => x.data) - console.log(journal) if (path.startsWith('collections')) { const lastRemoveIndex = findLastIndex( diff --git a/test/unit/specs/stores/lists.spec.js b/test/unit/specs/stores/lists.spec.js index 9c0092522..c71cce555 100644 --- a/test/unit/specs/stores/lists.spec.js +++ b/test/unit/specs/stores/lists.spec.js @@ -2,7 +2,7 @@ import { createTestingPinia } from '@pinia/testing' import { HttpResponse, http } from 'msw' import { setActivePinia } from 'pinia' -import { test as mockedIt } from '/test/fixtures/mock_api.js' +import { test as it } from '/test/fixtures/mock_api.js' import { useListsStore } from 'src/stores/lists.js' @@ -17,7 +17,7 @@ describe('The lists store', () => { }) describe('actions', () => { - mockedIt('updates array of all lists', () => { + it('updates array of all lists', () => { const list = { id: '1', title: 'testList' } store.setLists([list]) @@ -25,74 +25,72 @@ describe('The lists store', () => { expect(store.allLists).to.eql([list]) }) - mockedIt( - 'adds a new list with a title, updating the title for existing lists', - async ({ worker }) => { - const list = { id: '1', title: 'testList' } - const modList = { id: '1', title: 'anotherTestTitle' } + it('adds a new list with a title, updating the title for existing lists', async ({ + worker, + }) => { + const list = { id: '1', title: 'testList' } + const modList = { id: '1', title: 'anotherTestTitle' } - worker.use( - http.put(MASTODON_LIST_URL(':id'), () => - HttpResponse.json({ ok: true }), - ), - ) - console.log('1 =========', worker.listHandlers()) + worker.use( + http.put(MASTODON_LIST_URL(':id'), () => + HttpResponse.json({ ok: true }), + ), + ) + console.log('1 =========', worker.listHandlers()) - await store.setList({ listId: list.id, title: list.title }) - expect(store.allListsObject[list.id]).to.eql({ - title: list.title, - accountIds: [], - }) - expect(store.allLists).to.have.length(1) - expect(store.allLists[0]).to.eql(list) + await store.setList({ listId: list.id, title: list.title }) + expect(store.allListsObject[list.id]).to.eql({ + title: list.title, + accountIds: [], + }) + expect(store.allLists).to.have.length(1) + expect(store.allLists[0]).to.eql(list) - console.log('2 =========', worker.listHandlers()) + console.log('2 =========', worker.listHandlers()) - await store.setList({ listId: modList.id, title: modList.title }) - expect(store.allListsObject[modList.id]).to.eql({ - title: modList.title, - accountIds: [], - }) - expect(store.allLists).to.have.length(1) - expect(store.allLists[0]).to.eql(modList) + await store.setList({ listId: modList.id, title: modList.title }) + expect(store.allListsObject[modList.id]).to.eql({ + title: modList.title, + accountIds: [], + }) + expect(store.allLists).to.have.length(1) + expect(store.allLists[0]).to.eql(modList) - console.log('3 =========', worker.listHandlers()) - }, - ) + console.log('3 =========', worker.listHandlers()) + }) - mockedIt( - 'adds a new list with an array of IDs, updating the IDs for existing lists', - async ({ worker }) => { - const list = { id: '1', accountIds: ['1', '2', '3'] } - const modList = { id: '1', accountIds: ['3', '4', '5'] } + it('adds a new list with an array of IDs, updating the IDs for existing lists', async ({ + worker, + }) => { + const list = { id: '1', accountIds: ['1', '2', '3'] } + const modList = { id: '1', accountIds: ['3', '4', '5'] } - worker.use( - http.post(MASTODON_LIST_ACCOUNTS_URL(':id'), () => - HttpResponse.json({ ok: true }), - ), - http.delete(MASTODON_LIST_ACCOUNTS_URL(':id'), () => - HttpResponse.json({ ok: true }), - ), - ) + worker.use( + http.post(MASTODON_LIST_ACCOUNTS_URL(':id'), () => + HttpResponse.json({ ok: true }), + ), + http.delete(MASTODON_LIST_ACCOUNTS_URL(':id'), () => + HttpResponse.json({ ok: true }), + ), + ) - await store.setListAccounts({ - listId: list.id, - accountIds: list.accountIds, - }) - expect(store.allListsObject[list.id].accountIds).to.eql(list.accountIds) + await store.setListAccounts({ + listId: list.id, + accountIds: list.accountIds, + }) + expect(store.allListsObject[list.id].accountIds).to.eql(list.accountIds) - await store.setListAccounts({ - listId: modList.id, - accountIds: modList.accountIds, - }) + await store.setListAccounts({ + listId: modList.id, + accountIds: modList.accountIds, + }) - expect(store.allListsObject[modList.id].accountIds).to.eql( - modList.accountIds, - ) - }, - ) + expect(store.allListsObject[modList.id].accountIds).to.eql( + modList.accountIds, + ) + }) - mockedIt('deletes a list', async ({ worker }) => { + it('deletes a list', async ({ worker }) => { store.$patch({ allLists: [{ id: '1', title: 'testList' }], allListsObject: { @@ -114,7 +112,7 @@ describe('The lists store', () => { }) describe('getters', () => { - mockedIt('returns list title', () => { + it('returns list title', () => { store.$patch({ allLists: [{ id: '1', title: 'testList' }], allListsObject: { @@ -126,7 +124,7 @@ describe('The lists store', () => { expect(store.findListTitle(id)).to.eql('testList') }) - mockedIt('returns list accounts', () => { + it('returns list accounts', () => { store.$patch({ allLists: [{ id: '1', title: 'testList' }], allListsObject: {