mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-12-18 08:09:04 +01:00
dc350be6f5
* Use Mastodon server-side settings for automatically expanding toots with CWs * Add modal warning about settings changes * Use Mastodon server-side settings for disabling swiping
26 lines
535 B
JavaScript
26 lines
535 B
JavaScript
import { expandSpoilers } from 'flavours/glitch/util/initial_state';
|
|
|
|
export function autoUnfoldCW (settings, status) {
|
|
if (!expandSpoilers) {
|
|
return false;
|
|
}
|
|
|
|
const rawRegex = settings.getIn(['content_warnings', 'filter']);
|
|
|
|
if (!rawRegex) {
|
|
return true;
|
|
}
|
|
|
|
let regex = null;
|
|
|
|
try {
|
|
regex = rawRegex && new RegExp(rawRegex.trim(), 'i');
|
|
} catch (e) {
|
|
// Bad regex, don't affect filters
|
|
}
|
|
|
|
if (!(status && regex)) {
|
|
return undefined;
|
|
}
|
|
return !regex.test(status.get('spoiler_text'));
|
|
}
|