1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Add static emoji option

This commit is contained in:
Zhiyuan Zheng
2022-05-13 00:04:15 +02:00
parent 9c3e8f58b0
commit dde33ad1ad
9 changed files with 131 additions and 59 deletions

View File

@ -1,5 +1,6 @@
import { SettingsV0 } from './v0'
import { SettingsV1 } from './v1'
import { SettingsV2 } from './v2'
const settingsMigration = {
1: (state: SettingsV0): SettingsV1 => {
@ -7,6 +8,13 @@ const settingsMigration = {
...state,
darkTheme: 'lighter'
}
},
2: (state: SettingsV1): SettingsV2 => {
return {
...state,
darkTheme: 'lighter',
staticEmoji: false
}
}
}

View File

@ -0,0 +1,9 @@
export type SettingsV2 = {
fontsize: -1 | 0 | 1 | 2 | 3
language: string
theme: 'light' | 'dark' | 'auto'
darkTheme: 'lighter' | 'darker'
browser: 'internal' | 'external'
staticEmoji: boolean
analytics: boolean
}

View File

@ -1,6 +1,7 @@
import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit'
import { LOCALES } from '@root/i18n/locales'
import { RootState } from '@root/store'
import { SettingsV2 } from '@utils/migrations/settings/v2'
import * as Analytics from 'expo-firebase-analytics'
import * as Localization from 'expo-localization'
import { pickBy } from 'lodash'
@ -13,14 +14,7 @@ export const changeAnalytics = createAsyncThunk(
}
)
export type SettingsState = {
fontsize: -1 | 0 | 1 | 2 | 3
language: string
theme: 'light' | 'dark' | 'auto'
darkTheme: 'lighter' | 'darker'
browser: 'internal' | 'external'
analytics: boolean
}
export type SettingsState = SettingsV2
export const settingsInitialState = {
fontsize: 0,
@ -37,6 +31,7 @@ export const settingsInitialState = {
theme: 'auto',
darkTheme: 'lighter',
browser: 'internal',
staticEmoji: false,
analytics: true
}
@ -73,6 +68,12 @@ const settingsSlice = createSlice({
action: PayloadAction<NonNullable<SettingsState['browser']>>
) => {
state.browser = action.payload
},
changeStaticEmoji: (
state,
action: PayloadAction<NonNullable<SettingsState['staticEmoji']>>
) => {
state.staticEmoji = action.payload
}
},
extraReducers: builder => {
@ -89,6 +90,8 @@ export const getSettingsTheme = (state: RootState) => state.settings.theme
export const getSettingsDarkTheme = (state: RootState) =>
state.settings.darkTheme
export const getSettingsBrowser = (state: RootState) => state.settings.browser
export const getSettingsStaticEmoji = (state: RootState) =>
state.settings.staticEmoji
export const getSettingsAnalytics = (state: RootState) =>
state.settings.analytics
@ -97,6 +100,7 @@ export const {
changeLanguage,
changeTheme,
changeDarkTheme,
changeBrowser
changeBrowser,
changeStaticEmoji
} = settingsSlice.actions
export default settingsSlice.reducer