Add back expandSpoilers
This commit is contained in:
parent
c99415a868
commit
b1a8f6f3ab
|
@ -0,0 +1,63 @@
|
||||||
|
{
|
||||||
|
"id": "107831528995252317",
|
||||||
|
"created_at": "2022-02-20T17:35:55.224Z",
|
||||||
|
"in_reply_to_id": null,
|
||||||
|
"in_reply_to_account_id": null,
|
||||||
|
"sensitive": true,
|
||||||
|
"spoiler_text": "testing",
|
||||||
|
"visibility": "public",
|
||||||
|
"language": "en",
|
||||||
|
"uri": "https://fedibird.com/users/alex/statuses/107831528995252317",
|
||||||
|
"url": "https://fedibird.com/@alex/107831528995252317",
|
||||||
|
"replies_count": 0,
|
||||||
|
"reblogs_count": 0,
|
||||||
|
"favourites_count": 0,
|
||||||
|
"emoji_reactions_count": 0,
|
||||||
|
"emoji_reactions": [],
|
||||||
|
"content": "<p>hello world</p>",
|
||||||
|
"reblog": null,
|
||||||
|
"application": {
|
||||||
|
"name": "Web",
|
||||||
|
"website": null
|
||||||
|
},
|
||||||
|
"account": {
|
||||||
|
"id": "66768",
|
||||||
|
"username": "alex",
|
||||||
|
"acct": "alex",
|
||||||
|
"display_name": "",
|
||||||
|
"locked": false,
|
||||||
|
"bot": false,
|
||||||
|
"cat": false,
|
||||||
|
"discoverable": null,
|
||||||
|
"group": false,
|
||||||
|
"created_at": "2020-01-27T00:00:00.000Z",
|
||||||
|
"note": "<p></p>",
|
||||||
|
"url": "https://fedibird.com/@alex",
|
||||||
|
"avatar": "https://fedibird.com/avatars/original/missing.png",
|
||||||
|
"avatar_static": "https://fedibird.com/avatars/original/missing.png",
|
||||||
|
"header": "https://fedibird.com/headers/original/missing.png",
|
||||||
|
"header_static": "https://fedibird.com/headers/original/missing.png",
|
||||||
|
"followers_count": 1,
|
||||||
|
"following_count": 1,
|
||||||
|
"subscribing_count": 0,
|
||||||
|
"statuses_count": 5,
|
||||||
|
"last_status_at": "2022-02-20",
|
||||||
|
"emojis": [],
|
||||||
|
"fields": [],
|
||||||
|
"other_settings": {
|
||||||
|
"noindex": false,
|
||||||
|
"hide_network": false,
|
||||||
|
"hide_statuses_count": false,
|
||||||
|
"hide_following_count": false,
|
||||||
|
"hide_followers_count": false,
|
||||||
|
"enable_reaction": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"media_attachments": [],
|
||||||
|
"mentions": [],
|
||||||
|
"tags": [],
|
||||||
|
"emojis": [],
|
||||||
|
"card": null,
|
||||||
|
"poll": null,
|
||||||
|
"quote": null
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { getSettings } from '../settings';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
normalizeAccount,
|
normalizeAccount,
|
||||||
normalizePoll,
|
normalizePoll,
|
||||||
|
@ -19,11 +21,17 @@ export function importAccounts(accounts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function importStatus(status, idempotencyKey) {
|
export function importStatus(status, idempotencyKey) {
|
||||||
return { type: STATUS_IMPORT, status, idempotencyKey };
|
return (dispatch, getState) => {
|
||||||
|
const expandSpoilers = getSettings(getState()).get('expandSpoilers');
|
||||||
|
return dispatch({ type: STATUS_IMPORT, status, idempotencyKey, expandSpoilers });
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function importStatuses(statuses) {
|
export function importStatuses(statuses) {
|
||||||
return { type: STATUSES_IMPORT, statuses };
|
return (dispatch, getState) => {
|
||||||
|
const expandSpoilers = getSettings(getState()).get('expandSpoilers');
|
||||||
|
return dispatch({ type: STATUSES_IMPORT, statuses, expandSpoilers });
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function importPolls(polls) {
|
export function importPolls(polls) {
|
||||||
|
|
|
@ -81,6 +81,23 @@ describe('statuses reducer', () => {
|
||||||
|
|
||||||
expect(state.getIn(['AGNkA21auFR5lnEAHw', 'media_attachments'])).toEqual(expected);
|
expect(state.getIn(['AGNkA21auFR5lnEAHw', 'media_attachments'])).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('hides CWs', () => {
|
||||||
|
const status = require('soapbox/__fixtures__/status-cw.json');
|
||||||
|
const action = { type: STATUS_IMPORT, status };
|
||||||
|
|
||||||
|
const hidden = reducer(undefined, action).getIn(['107831528995252317', 'hidden']);
|
||||||
|
expect(hidden).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('expands CWs when expandSpoilers is enabled', () => {
|
||||||
|
const status = require('soapbox/__fixtures__/status-cw.json');
|
||||||
|
const action = { type: STATUS_IMPORT, status, expandSpoilers: true };
|
||||||
|
|
||||||
|
const hidden = reducer(undefined, action).getIn(['107831528995252317', 'hidden']);
|
||||||
|
expect(hidden).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('STATUS_CREATE_REQUEST', () => {
|
describe('STATUS_CREATE_REQUEST', () => {
|
||||||
|
|
|
@ -48,7 +48,7 @@ const minifyStatus = status => {
|
||||||
|
|
||||||
// Only calculate these values when status first encountered
|
// Only calculate these values when status first encountered
|
||||||
// Otherwise keep the ones already in the reducer
|
// Otherwise keep the ones already in the reducer
|
||||||
const calculateStatus = (status, oldStatus) => {
|
const calculateStatus = (status, oldStatus, expandSpoilers = false) => {
|
||||||
if (oldStatus) {
|
if (oldStatus) {
|
||||||
return status.merge({
|
return status.merge({
|
||||||
search_index: oldStatus.get('search_index'),
|
search_index: oldStatus.get('search_index'),
|
||||||
|
@ -65,7 +65,7 @@ const calculateStatus = (status, oldStatus) => {
|
||||||
search_index: domParser.parseFromString(searchContent, 'text/html').documentElement.textContent,
|
search_index: domParser.parseFromString(searchContent, 'text/html').documentElement.textContent,
|
||||||
contentHtml: stripCompatibilityFeatures(emojify(status.get('content'), emojiMap)),
|
contentHtml: stripCompatibilityFeatures(emojify(status.get('content'), emojiMap)),
|
||||||
spoilerHtml: emojify(escapeTextContentForBrowser(spoilerText), emojiMap),
|
spoilerHtml: emojify(escapeTextContentForBrowser(spoilerText), emojiMap),
|
||||||
hidden: spoilerText.length > 0 || status.get('sensitive'),
|
hidden: expandSpoilers ? false : spoilerText.length > 0 || status.get('sensitive'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -85,21 +85,22 @@ const fixQuote = (status, oldStatus) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const fixStatus = (state, status) => {
|
const fixStatus = (state, status, expandSpoilers) => {
|
||||||
const oldStatus = state.get(status.get('id'));
|
const oldStatus = state.get(status.get('id'));
|
||||||
|
|
||||||
return status.withMutations(status => {
|
return status.withMutations(status => {
|
||||||
normalizeStatus(status);
|
normalizeStatus(status);
|
||||||
fixQuote(status, oldStatus);
|
fixQuote(status, oldStatus);
|
||||||
calculateStatus(status, oldStatus);
|
calculateStatus(status, oldStatus, expandSpoilers);
|
||||||
minifyStatus(status);
|
minifyStatus(status);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const importStatus = (state, status) => state.set(status.id, fixStatus(state, fromJS(status)));
|
const importStatus = (state, status, expandSpoilers) =>
|
||||||
|
state.set(status.id, fixStatus(state, fromJS(status), expandSpoilers));
|
||||||
|
|
||||||
const importStatuses = (state, statuses) =>
|
const importStatuses = (state, statuses, expandSpoilers) =>
|
||||||
state.withMutations(mutable => statuses.forEach(status => importStatus(mutable, status)));
|
state.withMutations(mutable => statuses.forEach(status => importStatus(mutable, status, expandSpoilers)));
|
||||||
|
|
||||||
const deleteStatus = (state, id, references) => {
|
const deleteStatus = (state, id, references) => {
|
||||||
references.forEach(ref => {
|
references.forEach(ref => {
|
||||||
|
@ -130,9 +131,9 @@ const initialState = ImmutableMap();
|
||||||
export default function statuses(state = initialState, action) {
|
export default function statuses(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case STATUS_IMPORT:
|
case STATUS_IMPORT:
|
||||||
return importStatus(state, action.status);
|
return importStatus(state, action.status, action.expandSpoilers);
|
||||||
case STATUSES_IMPORT:
|
case STATUSES_IMPORT:
|
||||||
return importStatuses(state, action.statuses);
|
return importStatuses(state, action.statuses, action.expandSpoilers);
|
||||||
case STATUS_CREATE_REQUEST:
|
case STATUS_CREATE_REQUEST:
|
||||||
return importPendingStatus(state, action.params);
|
return importPendingStatus(state, action.params);
|
||||||
case STATUS_CREATE_FAIL:
|
case STATUS_CREATE_FAIL:
|
||||||
|
|
Loading…
Reference in New Issue