Receive navigation events and persist them
Summary: After setting up the navigation event emitter on the android side, we must now receive them on the client side and persist them in the Redux store. Reviewed By: passy Differential Revision: D16280944 fbshipit-source-id: 3dc4c5c6add41388469c801700974eb0ccd9a56b
This commit is contained in:
committed by
Facebook Github Bot
parent
ce93ecfcca
commit
a9e90aa9b2
@@ -13,8 +13,13 @@ type State = {||};
|
||||
|
||||
type Data = {||};
|
||||
|
||||
type NavigationEvent = {|
|
||||
date: Date,
|
||||
uri: ?String,
|
||||
|};
|
||||
|
||||
type PersistedState = {|
|
||||
data: Array<Data>,
|
||||
navigationEvents: [NavigationEvent],
|
||||
|};
|
||||
|
||||
export default class extends FlipperPlugin<State, {}, PersistedState> {
|
||||
@@ -24,18 +29,28 @@ export default class extends FlipperPlugin<State, {}, PersistedState> {
|
||||
static keyboardActions = ['clear'];
|
||||
|
||||
static defaultPersistedState: PersistedState = {
|
||||
data: [],
|
||||
navigationEvents: [],
|
||||
};
|
||||
|
||||
static persistedStateReducer = (
|
||||
persistedState: PersistedState,
|
||||
method: string,
|
||||
data: Data,
|
||||
payload: Object,
|
||||
): $Shape<PersistedState> => {
|
||||
return {
|
||||
...persistedState,
|
||||
data: persistedState.data.concat([data]),
|
||||
};
|
||||
switch (method) {
|
||||
case 'nav_event':
|
||||
return {
|
||||
...persistedState,
|
||||
navigationEvents: [
|
||||
...persistedState.navigationEvents,
|
||||
{uri: payload.uri, date: new Date()},
|
||||
],
|
||||
};
|
||||
default:
|
||||
return {
|
||||
...persistedState,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
onKeyboardAction = (action: string) => {
|
||||
|
||||
Reference in New Issue
Block a user