Add birth date gating to moderation settings (#1435)
* Add birth date preference, modal to set, link in settings, and age gate in moderation * Styling fixes for android * Fix types
This commit is contained in:
parent
0090371011
commit
9e8b14f710
9 changed files with 297 additions and 62 deletions
|
@ -118,6 +118,7 @@ export class CreateAccountModel {
|
|||
password: this.password,
|
||||
inviteCode: this.inviteCode,
|
||||
})
|
||||
/* dont await */ this.rootStore.preferences.setBirthDate(this.birthDate)
|
||||
track('Create Account')
|
||||
} catch (e: any) {
|
||||
this.rootStore.onboarding.skip() // undo starting the onboard
|
||||
|
|
|
@ -7,6 +7,7 @@ import {RootStoreModel} from '../root-store'
|
|||
import {ModerationOpts} from '@atproto/api'
|
||||
import {DEFAULT_FEEDS} from 'lib/constants'
|
||||
import {deviceLocales} from 'platform/detection'
|
||||
import {getAge} from 'lib/strings/time'
|
||||
import {LANGUAGES} from '../../../locale/languages'
|
||||
|
||||
// TEMP we need to permanently convert 'show' to 'ignore', for now we manually convert -prf
|
||||
|
@ -47,6 +48,7 @@ export class PreferencesModel {
|
|||
contentLabels = new LabelPreferencesModel()
|
||||
savedFeeds: string[] = []
|
||||
pinnedFeeds: string[] = []
|
||||
birthDate: Date | undefined = undefined
|
||||
homeFeedRepliesEnabled: boolean = true
|
||||
homeFeedRepliesThreshold: number = 2
|
||||
homeFeedRepostsEnabled: boolean = true
|
||||
|
@ -60,6 +62,13 @@ export class PreferencesModel {
|
|||
makeAutoObservable(this, {lock: false}, {autoBind: true})
|
||||
}
|
||||
|
||||
get userAge(): number | undefined {
|
||||
if (!this.birthDate) {
|
||||
return undefined
|
||||
}
|
||||
return getAge(this.birthDate)
|
||||
}
|
||||
|
||||
serialize() {
|
||||
return {
|
||||
contentLanguages: this.contentLanguages,
|
||||
|
@ -199,6 +208,7 @@ export class PreferencesModel {
|
|||
) {
|
||||
this.pinnedFeeds = prefs.feeds.pinned
|
||||
}
|
||||
this.birthDate = prefs.birthDate
|
||||
})
|
||||
|
||||
// set defaults on missing items
|
||||
|
@ -430,6 +440,11 @@ export class PreferencesModel {
|
|||
)
|
||||
}
|
||||
|
||||
async setBirthDate(birthDate: Date) {
|
||||
this.birthDate = birthDate
|
||||
await this.rootStore.agent.setPersonalDetails({birthDate})
|
||||
}
|
||||
|
||||
toggleHomeFeedRepliesEnabled() {
|
||||
this.homeFeedRepliesEnabled = !this.homeFeedRepliesEnabled
|
||||
}
|
||||
|
|
|
@ -136,6 +136,10 @@ export interface PostLanguagesSettingsModal {
|
|||
name: 'post-languages-settings'
|
||||
}
|
||||
|
||||
export interface BirthDateSettingsModal {
|
||||
name: 'birth-date-settings'
|
||||
}
|
||||
|
||||
export type Modal =
|
||||
// Account
|
||||
| AddAppPasswordModal
|
||||
|
@ -143,6 +147,7 @@ export type Modal =
|
|||
| DeleteAccountModal
|
||||
| EditProfileModal
|
||||
| ProfilePreviewModal
|
||||
| BirthDateSettingsModal
|
||||
|
||||
// Curation
|
||||
| ContentFilteringSettingsModal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue