LocationsButton
Summary: _typescript_ Reviewed By: jknoxville Differential Revision: D17284485 fbshipit-source-id: 7de710e7302413bc4735f0b0e31770c045a84fe6
This commit is contained in:
committed by
Facebook Github Bot
parent
fe6813042c
commit
e1b0af0f4b
@@ -16,12 +16,14 @@ import {State as PluginState} from 'src/reducers/pluginStates';
|
|||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
bookmarks: Array<Bookmark>;
|
bookmarks: Array<Bookmark>;
|
||||||
|
hasRetrievedBookmarks: boolean;
|
||||||
|
retreivingBookmarks: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type OwnProps = {};
|
type OwnProps = {};
|
||||||
|
|
||||||
type StateFromProps = {
|
type StateFromProps = {
|
||||||
currentURI: string;
|
currentURI: string | undefined;
|
||||||
selectedDevice: BaseDevice | null | undefined;
|
selectedDevice: BaseDevice | null | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -51,7 +53,7 @@ const shortenText = (text: string, MAX_CHARACTERS = 30): string => {
|
|||||||
|
|
||||||
type Props = OwnProps & StateFromProps & DispatchFromProps;
|
type Props = OwnProps & StateFromProps & DispatchFromProps;
|
||||||
class LocationsButton extends Component<Props, State> {
|
class LocationsButton extends Component<Props, State> {
|
||||||
state = {
|
state: State = {
|
||||||
bookmarks: [],
|
bookmarks: [],
|
||||||
hasRetrievedBookmarks: false,
|
hasRetrievedBookmarks: false,
|
||||||
retreivingBookmarks: false,
|
retreivingBookmarks: false,
|
||||||
@@ -109,10 +111,16 @@ class LocationsButton extends Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mapStateFromPluginStatesToProps = (pluginStates: PluginState) => {
|
const mapStateFromPluginStatesToProps = (pluginStates: PluginState) => {
|
||||||
const navPluginState = pluginStates[
|
const pluginKey = Object.keys(pluginStates).find(key =>
|
||||||
Object.keys(pluginStates).find(key => /#Navigation$/.test(key))
|
/#Navigation$/.test(key),
|
||||||
] as (NavPluginState | null);
|
);
|
||||||
const currentURI = navPluginState && navPluginState.currentURI;
|
let currentURI: string | undefined;
|
||||||
|
if (pluginKey) {
|
||||||
|
const navPluginState = pluginStates[pluginKey] as
|
||||||
|
| NavPluginState
|
||||||
|
| undefined;
|
||||||
|
currentURI = navPluginState && navPluginState.currentURI;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
currentURI,
|
currentURI,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user