New Tab Page: Don't define Preferences type twice
This commit is contained in:
@@ -8,7 +8,6 @@ import { action } from 'typesafe-actions'
|
||||
|
||||
// Constants
|
||||
import { types } from '../constants/new_tab_types'
|
||||
import { Preferences } from '../api/preferences'
|
||||
import { Stats } from '../api/stats'
|
||||
import { PrivateTabData } from '../api/privateTabData'
|
||||
import { TorTabData } from '../api/torTabData'
|
||||
@@ -32,7 +31,7 @@ export const dismissBrandedWallpaperNotification = (isUserAction: boolean) =>
|
||||
isUserAction
|
||||
})
|
||||
|
||||
export const preferencesUpdated = (preferences: Preferences) =>
|
||||
export const preferencesUpdated = (preferences: NewTab.Preferences) =>
|
||||
action(types.NEW_TAB_PREFERENCES_UPDATED, preferences)
|
||||
|
||||
export const clockWidgetUpdated = (showClockWidget: boolean,
|
||||
|
||||
@@ -10,7 +10,7 @@ import * as torTabDataAPI from './torTabData'
|
||||
import * as brandedWallpaper from './brandedWallpaper'
|
||||
|
||||
export type InitialData = {
|
||||
preferences: preferencesAPI.Preferences
|
||||
preferences: NewTab.Preferences
|
||||
stats: statsAPI.Stats
|
||||
privateTabData: privateTabDataAPI.PrivateTabData
|
||||
torTabData: torTabDataAPI.TorTabData
|
||||
|
||||
@@ -10,22 +10,10 @@
|
||||
// especially string keys.
|
||||
//
|
||||
|
||||
export type Preferences = {
|
||||
showBackgroundImage: boolean
|
||||
brandedWallpaperOptIn: boolean
|
||||
showStats: boolean
|
||||
showToday: boolean
|
||||
showClock: boolean
|
||||
clockFormat: string
|
||||
showTopSites: boolean
|
||||
showRewards: boolean
|
||||
isBrandedWallpaperNotificationDismissed: boolean
|
||||
}
|
||||
type PreferencesUpdatedHandler = (prefData: NewTab.Preferences) => void
|
||||
|
||||
type PreferencesUpdatedHandler = (prefData: Preferences) => void
|
||||
|
||||
export function getPreferences (): Promise<Preferences> {
|
||||
return window.cr.sendWithPromise<Preferences>('getNewTabPagePreferences')
|
||||
export function getPreferences (): Promise<NewTab.Preferences> {
|
||||
return window.cr.sendWithPromise<NewTab.Preferences>('getNewTabPagePreferences')
|
||||
}
|
||||
|
||||
function sendSavePref (key: string, value: any) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import * as privateTabDataAPI from './api/privateTabData'
|
||||
import * as torTabDataAPI from './api/torTabData'
|
||||
import { getInitialData, getRewardsInitialData, getRewardsPreInitialData } from './api/initialData'
|
||||
|
||||
async function updatePreferences (prefData: preferencesAPI.Preferences) {
|
||||
async function updatePreferences (prefData: NewTab.Preferences) {
|
||||
getActions().preferencesUpdated(prefData)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ async function updateTorTabData (data: torTabDataAPI.TorTabData) {
|
||||
getActions().torTabDataUpdated(data)
|
||||
}
|
||||
|
||||
function onRewardsToggled (prefData: preferencesAPI.Preferences): void {
|
||||
function onRewardsToggled (prefData: NewTab.Preferences): void {
|
||||
if (prefData.showRewards) {
|
||||
rewardsInitData()
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ export const newTabReducer: Reducer<NewTab.State | undefined> = (state: NewTab.S
|
||||
break
|
||||
|
||||
case types.NEW_TAB_PREFERENCES_UPDATED:
|
||||
const preferences = payload as preferencesAPI.Preferences
|
||||
const preferences = payload as NewTab.Preferences
|
||||
const newState = {
|
||||
...state,
|
||||
...preferences
|
||||
|
||||
Vendored
+13
-9
@@ -91,7 +91,19 @@ declare namespace NewTab {
|
||||
cryptoDotComState: CryptoDotComWidgetState
|
||||
}
|
||||
|
||||
export interface EphemeralState {
|
||||
export type Preferences = {
|
||||
showBackgroundImage: boolean
|
||||
brandedWallpaperOptIn: boolean
|
||||
showStats: boolean
|
||||
showToday: boolean
|
||||
showClock: boolean
|
||||
clockFormat: string
|
||||
showTopSites: boolean
|
||||
showRewards: boolean
|
||||
isBrandedWallpaperNotificationDismissed: boolean
|
||||
}
|
||||
|
||||
export type EphemeralState = Preferences & {
|
||||
initialDataLoaded: boolean
|
||||
textDirection: string
|
||||
featureFlagBraveNTPSponsoredImagesWallpaper: boolean
|
||||
@@ -105,20 +117,12 @@ declare namespace NewTab {
|
||||
gridLayoutSize?: 'small'
|
||||
showGridSiteRemovedNotification?: boolean
|
||||
showBackgroundImage: boolean
|
||||
showStats: boolean
|
||||
showToday: boolean
|
||||
showClock: boolean
|
||||
clockFormat: string
|
||||
showTopSites: boolean
|
||||
customLinksEnabled: boolean
|
||||
showRewards: boolean
|
||||
showTogether: boolean
|
||||
showBinance: boolean
|
||||
showGemini: boolean
|
||||
showBitcoinDotCom: boolean
|
||||
showCryptoDotCom: boolean,
|
||||
brandedWallpaperOptIn: boolean
|
||||
isBrandedWallpaperNotificationDismissed: boolean
|
||||
stats: Stats,
|
||||
brandedWallpaperData?: BrandedWallpaper
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user