Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85650903
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/stores/statuses.js b/src/stores/statuses.js
index 9df26465fb..890dd4002d 100644
--- a/src/stores/statuses.js
+++ b/src/stores/statuses.js
@@ -190,8 +190,11 @@ export const useStatusesStore = defineStore('statuses', {
return fetchEmojiReactions({
id,
credentials: useOAuthStore().token,
- }).then(({ data: emojiReactions }) => {
- this.addEmojiReactionsBy(id, emojiReactions)
+ }).then(({ data, timestamp }) => {
+ data.forEach((reaction) => {
+ const users = useUsersStore().addNewUsers({ timestamp, data: reaction.accounts })
+ })
+ this.addEmojiReactionsBy(id, data)
})
},
fetchFavs(id) {
diff --git a/test/unit/specs/stores/statuses.spec.js b/test/unit/specs/stores/statuses.spec.js
index 9be47145cc..31bf517d25 100644
--- a/test/unit/specs/stores/statuses.spec.js
+++ b/test/unit/specs/stores/statuses.spec.js
@@ -290,7 +290,7 @@ describe('Statuses store', () => {
'EmojiReactions',
[
{
- accounts: [mockMastoAPIUser()],
+ accounts: [mockMastoAPIUser({ id: 'u1' }), mockMastoAPIUser({ id: 'u2' })],
count: 1,
me: false,
name: 'cofe',
@@ -298,8 +298,8 @@ describe('Statuses store', () => {
},
],
],
- ['Favs', [mockMastoAPIUser()]],
- ['Repeats', [mockMastoAPIUser()]],
+ ['Favs', [mockMastoAPIUser({ id: 'u1' }), mockMastoAPIUser({ id: 'u2' })]],
+ ['Repeats', [mockMastoAPIUser({ id: 'u1' }), mockMastoAPIUser({ id: 'u2' })]],
])('fetch%s', async (group, mockedResponse) => {
const mockFetch = vi.fn()
mockFetch.mockResolvedValueOnce(
@@ -309,6 +309,7 @@ describe('Statuses store', () => {
)
vi.stubGlobal('fetch', mockFetch)
+ const addNewUsers = vi.spyOn(useUsersStore(), 'addNewUsers')
let urlKey
let prefix = 'MASTODON'
@@ -335,13 +336,29 @@ describe('Statuses store', () => {
const result = await store[`fetch${group}`]('id')
const updated = store.allStatuses.get('id')
+ // Fetch called
expect(mockFetch).to.have.been.calledWith(url, DEFAULT_OPTIONS())
+
+ // Users updated
+ if (group !== 'StatusSource') {
+ // first call is the one for the status
+ expect(addNewUsers).to.have.been.calledTwice
+ const secondCallData = addNewUsers.mock.calls[1][0].data
+ expect(secondCallData).to.have.length(2)
+ expect(secondCallData[0]).to.have.property('id', 'u1')
+ expect(secondCallData[1]).to.have.property('id', 'u2')
+ }
+
if (group === 'Favs') {
- expect(updated.favoritedBy).to.have.length(1)
- expect(updated.fave_num).to.eql(1)
+ expect(store.favs).to.have.length(1)
+ expect(store.favs.get('id')).to.have.length(2)
+ expect(store.favs.get('id')).to.eql(new Set(['u1', 'u2']))
+ expect(updated.fave_num).to.eql(2)
} else if (group === 'Repeats') {
- expect(updated.rebloggedBy).to.have.length(1)
- expect(updated.repeat_num).to.eql(1)
+ expect(store.repeats).to.have.length(1)
+ expect(store.repeats.get('id')).to.have.length(2)
+ expect(store.repeats.get('id')).to.eql(new Set(['u1', 'u2']))
+ expect(updated.repeat_num).to.eql(2)
} else if (group === 'EmojiReactions') {
expect(updated.emoji_reactions).to.have.length(mockedResponse.length)
expect(updated.emoji_reactions[0].name).to.eql(mockedResponse[0].name)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Aug 30, 6:16 AM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1737827
Default Alt Text
(3 KB)
Attached To
Mode
rPUFE pleroma-fe-upstream
Attached
Detach File
Event Timeline
Log In to Comment