[APP-639] Improve nsfw handling & force hidden on iOS (#605)

* Identify adult content labels and handle them more specifically

* Change adult content defaults to more conservative settings

* Add an adultcontentenabled override that prohibits access on iOS

* Improve usability of the content hider

* Fix lint
This commit is contained in:
Paul Frazee 2023-05-09 00:43:20 -05:00 committed by GitHub
parent 7a176b3fdf
commit b756a27958
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 223 additions and 62 deletions

View file

@ -10,15 +10,16 @@ import {
ALWAYS_FILTER_LABEL_GROUP,
ALWAYS_WARN_LABEL_GROUP,
} from 'lib/labeling/const'
import {isIOS} from 'platform/detection'
const deviceLocales = getLocales()
export type LabelPreference = 'show' | 'warn' | 'hide'
export class LabelPreferencesModel {
nsfw: LabelPreference = 'warn'
nudity: LabelPreference = 'show'
suggestive: LabelPreference = 'show'
nsfw: LabelPreference = 'hide'
nudity: LabelPreference = 'warn'
suggestive: LabelPreference = 'warn'
gore: LabelPreference = 'warn'
hate: LabelPreference = 'hide'
spam: LabelPreference = 'hide'
@ -30,6 +31,7 @@ export class LabelPreferencesModel {
}
export class PreferencesModel {
adultContentEnabled = !isIOS
contentLanguages: string[] =
deviceLocales?.map?.(locale => locale.languageCode) || []
contentLabels = new LabelPreferencesModel()
@ -102,7 +104,9 @@ export class PreferencesModel {
} else if (group.id === 'always-filter') {
return {pref: 'hide', desc: ALWAYS_FILTER_LABEL_GROUP}
} else if (group.id === 'always-warn') {
return {pref: 'warn', desc: ALWAYS_WARN_LABEL_GROUP}
res.pref = 'warn'
res.desc = ALWAYS_WARN_LABEL_GROUP
continue
} else if (group.id === 'unknown') {
continue
}
@ -115,6 +119,9 @@ export class PreferencesModel {
res.desc = group
}
}
if (res.desc.isAdultImagery && !this.adultContentEnabled) {
res.pref = 'hide'
}
return res
}
}