Commit 19bbbce5 authored by Nastassia Danilova's avatar Nastassia Danilova

emojify status context

parent 5c967651
Pipeline #30600 passed with stages
in 7 minutes and 47 seconds
......@@ -20,6 +20,20 @@ const addStatuses = (state, { statuses }) => {
const newStatuses = reduce(statuses, (result, status) => {
const oldStatus = state.statusesByIds[status.id] || {}
result[status.id] = { ...oldStatus, ...emojifyStatus(status, oldStatus) }
if (result[status.id].context) {
if (result[status.id].context.ancestors) {
result[status.id].context.ancestors = result[status.id].context.ancestors.map(item => ({
...item,
...emojifyStatus(item, {})
}))
}
if (result[status.id].context.descendants) {
result[status.id].context.descendants = result[status.id].context.descendants.map(item => ({
...item,
...emojifyStatus(item, {})
}))
}
}
return result
}, {})
......
......@@ -32,7 +32,10 @@ export const emojifyStatus = (status, oldStatus) => {
}
const emojis = status.reblog ? status.reblog.emojis : status.emojis
const oldEmojis = oldStatus.reblog ? oldStatus.reblog.emojis : oldStatus.emojis
status.content = emojify(status.content || oldStatus.content, emojis || oldEmojis)
status.spoiler_text = emojify(status.spoiler_text || oldStatus.spoiler_text, emojis || oldEmojis)
if (emojis || oldEmojis) {
status.content = emojify(status.content || oldStatus.content, emojis || oldEmojis)
status.spoiler_text = emojify(status.spoiler_text || oldStatus.spoiler_text, emojis || oldEmojis)
}
return status
}
......@@ -470,7 +470,10 @@ describe('Status thunks', () => {
id: '1',
content: 'Status content'
}
const context = { ancestors: [], descendants: [] }
const context = {
ancestors: [{ id: '2', content: '', spoiler_text: '' }],
descendants: [{ id: '3', content: '', spoiler_text: '' }]
}
fetch.mockReset()
fetch
......@@ -496,8 +499,8 @@ describe('Status thunks', () => {
content: 'Status content',
spoiler_text: undefined,
context: {
ancestors: [],
descendants: []
ancestors: [{ id: '2', content: '', spoiler_text: '' }],
descendants: [{ id: '3', content: '', spoiler_text: '' }]
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment