Add user ratings

Summary:
Adds a star rating to flipper internal.

Based on the nuclide behaviour:
We get an event emitted when a user changes their rating.
And we also get the rating with every ping event, which is fired every minute, if flipper is the primary window.

The only thing I don't like that much is that this doesn't actually say anywhere what the stars are for.

Reviewed By: passy

Differential Revision: D16420281

fbshipit-source-id: 69a52f64058955d7cd068215478e95c554cb9ed4
This commit is contained in:
John Knox
2019-07-24 00:11:26 -07:00
committed by Facebook Github Bot
parent a646c4e2ff
commit f7875002dd
6 changed files with 123 additions and 1 deletions

View File

@@ -46,6 +46,7 @@ export type State = {
serverPorts: ServerPorts,
downloadingImportData: boolean,
launcherMsg: LauncherMsg,
flipperRating: ?number,
};
type BooleanActionType =
@@ -81,6 +82,12 @@ export type Action =
severity: 'warning' | 'error',
message: string,
},
}
| {
type: 'SET_FLIPPER_RATING',
payload: {
rating: number,
},
};
const initialState: () => State = () => ({
@@ -100,6 +107,7 @@ const initialState: () => State = () => ({
severity: 'warning',
message: '',
},
flipperRating: null,
});
export default function reducer(state: State, action: Action): State {
@@ -146,6 +154,11 @@ export default function reducer(state: State, action: Action): State {
...state,
launcherMsg: action.payload,
};
} else if (action.type === 'SET_FLIPPER_RATING') {
return {
...state,
flipperRating: action.payload.rating,
};
} else {
return state;
}
@@ -183,3 +196,10 @@ export const toggleRightSidebarAvailable = (payload?: boolean): Action => ({
type: 'rightSidebarAvailable',
payload,
});
export const setFlipperRating = (rating: number): Action => ({
type: 'SET_FLIPPER_RATING',
payload: {
rating,
},
});

View File

@@ -64,7 +64,14 @@ export type Store = ReduxStore<State, Actions>;
export type MiddlewareAPI = ReduxMiddlewareAPI<State, Actions>;
export default combineReducers<_, Actions>({
application,
application: persistReducer(
{
key: 'application',
storage,
whitelist: ['flipperRating'],
},
application,
),
connections: persistReducer(
{
key: 'connections',