Skip to content

Commit

Permalink
rename values
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Jan 13, 2020
1 parent 0b2661b commit 70e1760
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/uptime/public/contexts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

export { UptimeRefreshContext, UptimeRefreshContextProvider } from './uptime_refresh_context';
export {
UMSettingsContextValues,
UptimeSettingsContextValues,
UptimeSettingsContext,
UptimeSettingsContextProvider,
} from './uptime_settings_context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
*/

import React, { createContext, useMemo, useState } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { store } from '../state';
import { triggerAppRefresh } from '../state/actions';

interface UMRefreshContext {
interface UptimeRefreshContext {
lastRefresh: number;
refreshApp: () => void;
}

const defaultContext: UMRefreshContext = {
const defaultContext: UptimeRefreshContext = {
lastRefresh: 0,
refreshApp: () => {
throw new Error('App refresh was not initialized, set it when you invoke the context');
Expand All @@ -24,9 +23,6 @@ const defaultContext: UMRefreshContext = {
export const UptimeRefreshContext = createContext(defaultContext);

export const UptimeRefreshContextProvider: React.FC = ({ children }) => {
const history = useHistory();
const location = useLocation();

const [lastRefresh, setLastRefresh] = useState<number>(Date.now());

const refreshApp = () => {
Expand All @@ -36,8 +32,8 @@ export const UptimeRefreshContextProvider: React.FC = ({ children }) => {
};

const value = useMemo(() => {
return { lastRefresh, history, location, refreshApp };
}, [history, location, lastRefresh]);
return { lastRefresh, refreshApp };
}, [lastRefresh]);

return <UptimeRefreshContext.Provider value={value} children={children} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { UptimeAppProps } from '../uptime_app';
import { CONTEXT_DEFAULTS } from '../../common/constants';
import { CommonlyUsedRange } from '../components/functional/uptime_date_picker';

export interface UMSettingsContextValues {
export interface UptimeSettingsContextValues {
basePath: string;
dateRangeStart: string;
dateRangeEnd: string;
Expand All @@ -26,7 +26,7 @@ const { BASE_PATH, DATE_RANGE_START, DATE_RANGE_END } = CONTEXT_DEFAULTS;
* These are default values for the context. These defaults are typically
* overwritten by the Uptime App upon its invocation.
*/
const defaultContext: UMSettingsContextValues = {
const defaultContext: UptimeSettingsContextValues = {
basePath: BASE_PATH,
dateRangeStart: DATE_RANGE_START,
dateRangeEnd: DATE_RANGE_END,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import React, { createContext, useMemo } from 'react';
import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json';
import { UptimeAppColors } from '../uptime_app';

export interface UMThemeContextValues {
export interface UptimeThemeContextValues {
colors: UptimeAppColors;
}

/**
* These are default values for the context. These defaults are typically
* overwritten by the Uptime App upon its invocation.
*/
const defaultContext: UMThemeContextValues = {
const defaultContext: UptimeThemeContextValues = {
colors: {
danger: euiLightVars.euiColorDanger,
mean: euiLightVars.euiColorPrimary,
Expand Down

0 comments on commit 70e1760

Please sign in to comment.