Add thread sort settings (#1475)
* Add thread sorting preferences * UI tweaks * Tweak settings * Tune the copy
This commit is contained in:
parent
9c4374f66a
commit
da8499c881
9 changed files with 256 additions and 13 deletions
|
|
@ -25,6 +25,7 @@ const VISIBILITY_VALUES = ['ignore', 'warn', 'hide']
|
|||
const DEFAULT_LANG_CODES = (deviceLocales || [])
|
||||
.concat(['en', 'ja', 'pt', 'de'])
|
||||
.slice(0, 6)
|
||||
const THREAD_SORT_VALUES = ['oldest', 'newest', 'most-likes', 'random']
|
||||
|
||||
export class LabelPreferencesModel {
|
||||
nsfw: LabelPreference = 'hide'
|
||||
|
|
@ -55,6 +56,8 @@ export class PreferencesModel {
|
|||
homeFeedRepostsEnabled: boolean = true
|
||||
homeFeedQuotePostsEnabled: boolean = true
|
||||
homeFeedMergeFeedEnabled: boolean = false
|
||||
threadDefaultSort: string = 'oldest'
|
||||
threadFollowedUsersFirst: boolean = true
|
||||
requireAltTextEnabled: boolean = false
|
||||
|
||||
// used to linearize async modifications to state
|
||||
|
|
@ -86,6 +89,8 @@ export class PreferencesModel {
|
|||
homeFeedRepostsEnabled: this.homeFeedRepostsEnabled,
|
||||
homeFeedQuotePostsEnabled: this.homeFeedQuotePostsEnabled,
|
||||
homeFeedMergeFeedEnabled: this.homeFeedMergeFeedEnabled,
|
||||
threadDefaultSort: this.threadDefaultSort,
|
||||
threadFollowedUsersFirst: this.threadFollowedUsersFirst,
|
||||
requireAltTextEnabled: this.requireAltTextEnabled,
|
||||
}
|
||||
}
|
||||
|
|
@ -189,6 +194,21 @@ export class PreferencesModel {
|
|||
) {
|
||||
this.homeFeedMergeFeedEnabled = v.homeFeedMergeFeedEnabled
|
||||
}
|
||||
// check if thread sort order is set in preferences, then hydrate
|
||||
if (
|
||||
hasProp(v, 'threadDefaultSort') &&
|
||||
typeof v.threadDefaultSort === 'string' &&
|
||||
THREAD_SORT_VALUES.includes(v.threadDefaultSort)
|
||||
) {
|
||||
this.threadDefaultSort = v.threadDefaultSort
|
||||
}
|
||||
// check if tread followed-users-first is enabled in preferences, then hydrate
|
||||
if (
|
||||
hasProp(v, 'threadFollowedUsersFirst') &&
|
||||
typeof v.threadFollowedUsersFirst === 'boolean'
|
||||
) {
|
||||
this.threadFollowedUsersFirst = v.threadFollowedUsersFirst
|
||||
}
|
||||
// check if requiring alt text is enabled in preferences, then hydrate
|
||||
if (
|
||||
hasProp(v, 'requireAltTextEnabled') &&
|
||||
|
|
@ -494,6 +514,16 @@ export class PreferencesModel {
|
|||
this.homeFeedMergeFeedEnabled = !this.homeFeedMergeFeedEnabled
|
||||
}
|
||||
|
||||
setThreadDefaultSort(v: string) {
|
||||
if (THREAD_SORT_VALUES.includes(v)) {
|
||||
this.threadDefaultSort = v
|
||||
}
|
||||
}
|
||||
|
||||
toggleThreadFollowedUsersFirst() {
|
||||
this.threadFollowedUsersFirst = !this.threadFollowedUsersFirst
|
||||
}
|
||||
|
||||
toggleRequireAltTextEnabled() {
|
||||
this.requireAltTextEnabled = !this.requireAltTextEnabled
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue