diff --git a/src/assets/images/backgrounds/login_bg.jpg b/src/assets/images/backgrounds/login_bg.jpg deleted file mode 100644 index 7117bea42f8..00000000000 Binary files a/src/assets/images/backgrounds/login_bg.jpg and /dev/null differ diff --git a/src/components/scenes/LoginScene.tsx b/src/components/scenes/LoginScene.tsx index 1abae7e0afb..209d2d8aa0d 100644 --- a/src/components/scenes/LoginScene.tsx +++ b/src/components/scenes/LoginScene.tsx @@ -14,22 +14,18 @@ import { cacheStyles, Theme, useTheme } from '../../components/services/ThemeCon import { ENV } from '../../env' import { ExperimentConfig, getExperimentConfig } from '../../experimentConfig' import { useAsyncEffect } from '../../hooks/useAsyncEffect' -import { useAsyncValue } from '../../hooks/useAsyncValue' import { useHandler } from '../../hooks/useHandler' import { useWatch } from '../../hooks/useWatch' import { lstrings } from '../../locales/strings' import { config } from '../../theme/appConfig' import { useDispatch, useSelector } from '../../types/reactRedux' import { EdgeSceneProps } from '../../types/routerTypes' -import { ImageProp } from '../../types/Theme' import { GuiTouchIdInfo } from '../../types/types' import { logEvent, trackError } from '../../util/tracking' -import { pickRandom } from '../../util/utils' import { withServices } from '../hoc/withServices' import { showHelpModal } from '../modals/HelpModal' import { UpdateModal } from '../modals/UpdateModal' import { Airship, showError } from '../services/AirshipInstance' -import { getBackgroundImage } from './../../util/ThemeCache' import { LoadingScene } from './LoadingScene' // Sneak the BlurView over to the login UI: @@ -75,11 +71,6 @@ export function LoginSceneComponent(props: Props) { // Effects // --------------------------------------------------------------------- - const [backgroundImage = theme.backgroundImage] = useAsyncValue(async () => { - const url = pickRandom(theme.backgroundImageServerUrls) - return await getBackgroundImage(disklet, url, theme.backgroundImage) - }, [disklet, theme]) - React.useEffect(() => { const { YOLO_USERNAME, YOLO_PASSWORD, YOLO_PIN } = ENV if (YOLO_USERNAME != null && (Boolean(YOLO_PASSWORD) || Boolean(YOLO_PIN)) && firstRun) { @@ -198,7 +189,6 @@ export function LoginSceneComponent(props: Props) { appConfig={config} appId={config.appId} appName={config.appNameShort} - backgroundImage={backgroundImage} context={context} fontDescription={fontDescription} initialLoginId={nextLoginId ?? undefined} @@ -231,8 +221,7 @@ const dummyTouchIdInfo: GuiTouchIdInfo = { const getStyles = cacheStyles((theme: Theme) => ({ container: { flex: 1, - paddingTop: StatusBar.currentHeight, - backgroundColor: theme.backgroundGradientColors[0] + paddingTop: StatusBar.currentHeight } })) diff --git a/src/theme/variables/edgeDark.ts b/src/theme/variables/edgeDark.ts index 93b8d6b245f..d1dbeb84e01 100644 --- a/src/theme/variables/edgeDark.ts +++ b/src/theme/variables/edgeDark.ts @@ -131,8 +131,6 @@ export const edgeDark: Theme = { backgroundGradientColors: [palette.darkestNavy, palette.darkAqua], backgroundGradientStart: { x: 0, y: 0 }, backgroundGradientEnd: { x: 1, y: 0 }, - backgroundImageServerUrls: ['https://content.edge.app'], - backgroundImage: undefined, // Camera Overlay cameraOverlayColor: palette.black, diff --git a/src/theme/variables/edgeLight.ts b/src/theme/variables/edgeLight.ts index 1dd45f85ac7..1483d44c949 100644 --- a/src/theme/variables/edgeLight.ts +++ b/src/theme/variables/edgeLight.ts @@ -125,8 +125,6 @@ export const edgeLight: Theme = { backgroundGradientColors: [palette.lightestGray, palette.lightestGray], backgroundGradientStart: { x: 0, y: 0 }, backgroundGradientEnd: { x: 0, y: 1 }, - backgroundImageServerUrls: ['https://content.edge.app'], - backgroundImage: undefined, // Camera Overlay cameraOverlayColor: palette.gray, diff --git a/src/theme/variables/testDark.ts b/src/theme/variables/testDark.ts index 1cc5e094da7..9806bdb4d12 100644 --- a/src/theme/variables/testDark.ts +++ b/src/theme/variables/testDark.ts @@ -131,8 +131,6 @@ export const testDark: Theme = { backgroundGradientColors: [palette.darkestNavy, palette.darkAqua], backgroundGradientStart: { x: 0, y: 0 }, backgroundGradientEnd: { x: 1, y: 0 }, - backgroundImageServerUrls: ['https://content.edge.app'], - backgroundImage: undefined, // Camera Overlay cameraOverlayColor: palette.black, diff --git a/src/theme/variables/testLight.ts b/src/theme/variables/testLight.ts index 2ecab10f246..acce394bff9 100644 --- a/src/theme/variables/testLight.ts +++ b/src/theme/variables/testLight.ts @@ -125,8 +125,6 @@ export const testLight: Theme = { backgroundGradientColors: [palette.lightestGray, palette.lightestGray], backgroundGradientStart: { x: 0, y: 0 }, backgroundGradientEnd: { x: 0, y: 1 }, - backgroundImageServerUrls: ['https://content.edge.app'], - backgroundImage: undefined, // Camera Overlay cameraOverlayColor: palette.gray, diff --git a/src/types/Theme.ts b/src/types/Theme.ts index 65afb5881b4..1fb844dfc2f 100644 --- a/src/types/Theme.ts +++ b/src/types/Theme.ts @@ -89,9 +89,6 @@ export interface Theme { backgroundGradientStart: { x: number; y: number } backgroundGradientEnd: { x: number; y: number } - backgroundImageServerUrls: string[] - backgroundImage?: ImageProp - // Camera Overlay cameraOverlayColor: string cameraOverlayOpStart: number diff --git a/src/util/ThemeCache.ts b/src/util/ThemeCache.ts deleted file mode 100644 index 8f0bb88da36..00000000000 --- a/src/util/ThemeCache.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { asDate, asObject, uncleaner } from 'cleaners' -import { Disklet } from 'disklet' -import RNFS from 'react-native-fs' - -import { BACKGROUND_IMAGE_FILE_NAME, BACKGROUND_IMAGE_LOCAL_URI } from '../constants/CdnConstants' -import { ImageProp } from '../types/Theme' - -const THEME_CACHE_FILE_NAME = 'themeCache.json' - -const asThemeCache = asObject({ - assets: asObject( - asObject({ - start: asDate, - expiration: asDate - }) - ) -}) -const wasThemeCache = uncleaner(asThemeCache) -type ThemeCache = ReturnType - -interface ItemTimestamps { - start: Date - expiration: Date -} - -async function getThemeCache(disklet: Disklet): Promise { - const data = await disklet.getText(THEME_CACHE_FILE_NAME) - return asThemeCache(JSON.parse(data)) -} - -async function setThemeCache(disklet: Disklet, data: ThemeCache): Promise { - const text = JSON.stringify(wasThemeCache(data)) - await disklet.setText(THEME_CACHE_FILE_NAME, text) -} - -const getThemeItemTimestamps = async (url: string): Promise => { - const response = await fetch(url, { method: 'HEAD' }) - const start = response.headers.get('x-amz-meta-start-date') // '2021-08-26T01:37:50Z' - const expiration = response.headers.get('x-amz-meta-expiration-date') // '2021-08-29T01:37:50Z' - if (start == null || expiration == null) throw new Error('Failed to find file on CDN') - return { start: new Date(start), expiration: new Date(expiration) } -} - -const downloadFile = async (disklet: Disklet, fromUrl: string, toFile: string): Promise => { - // See if the server even has an image for us in the first place: - const cache: ThemeCache = await getThemeCache(disklet).catch(() => ({ assets: {} })) - const { start, expiration } = await getThemeItemTimestamps(fromUrl) - if (expiration.valueOf() < Date.now()) { - delete cache.assets[fromUrl] - await setThemeCache(disklet, cache) - return - } - const cacheTimes = cache.assets[fromUrl] - if (cacheTimes != null && cacheTimes.start.valueOf() === start.valueOf() && cacheTimes.expiration.valueOf() === expiration.valueOf()) return - - // Download file whenever local file timestamps do not equal remote file timestamps - const download = RNFS.downloadFile({ fromUrl, toFile }) - const status = await download.promise - if (status.statusCode !== 200) throw new Error('Failed to download') - cache.assets[fromUrl] = { start, expiration } - await setThemeCache(disklet, cache) -} - -export async function getBackgroundImage(disklet: Disklet, imageServer?: string | null, fallback?: ImageProp): Promise { - if (imageServer == null) return fallback - const backgroundImageUrl = `${imageServer}/${BACKGROUND_IMAGE_FILE_NAME}` - const now = Date.now() - - let image = fallback - - const cache: ThemeCache = await getThemeCache(disklet).catch(() => ({ assets: {} })) - const cacheTimes = cache.assets[backgroundImageUrl] - if (cacheTimes != null && cacheTimes.start.valueOf() < now && cacheTimes.expiration.valueOf() > now && (await RNFS.exists(BACKGROUND_IMAGE_LOCAL_URI))) { - image = { uri: BACKGROUND_IMAGE_LOCAL_URI } - } - // Always return existing local file but query and download new remote file in the background - downloadFile(disklet, backgroundImageUrl, BACKGROUND_IMAGE_LOCAL_URI).catch(() => { - console.warn(`Error downloading from background image server ${backgroundImageUrl} to ${BACKGROUND_IMAGE_LOCAL_URI}`) - }) - return image -} diff --git a/src/util/utils.ts b/src/util/utils.ts index b565f1a9289..714a0b93cbf 100644 --- a/src/util/utils.ts +++ b/src/util/utils.ts @@ -519,11 +519,6 @@ export const shuffleArray = (array: T[]): T[] => { return array } -export const pickRandom = (array?: T[]): T | null => { - if (array == null || array.length === 0) return null - return array[Math.floor(Math.random() * array.length)] -} - /** * Waits for a collection of promises. * Returns all the promises that manage to resolve within the timeout.