Move registration from redux selectors to util
This commit is contained in:
parent
ab909f1f42
commit
6b56dd4ce0
5 changed files with 7 additions and 27 deletions
|
@ -73,7 +73,6 @@ const updatesDuck = require('../../ts/state/ducks/updates');
|
|||
const userDuck = require('../../ts/state/ducks/user');
|
||||
|
||||
const conversationsSelectors = require('../../ts/state/selectors/conversations');
|
||||
const registrationSelectors = require('../../ts/state/selectors/registration');
|
||||
const searchSelectors = require('../../ts/state/selectors/search');
|
||||
|
||||
// Migrations
|
||||
|
@ -311,7 +310,6 @@ exports.setup = (options = {}) => {
|
|||
|
||||
const Selectors = {
|
||||
conversations: conversationsSelectors,
|
||||
registration: registrationSelectors,
|
||||
search: searchSelectors,
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { createSelector } from 'reselect';
|
|||
|
||||
import { StateType } from '../reducer';
|
||||
import { NetworkStateType } from '../ducks/network';
|
||||
import { isDone } from './registration';
|
||||
import { isDone } from '../../util/registration';
|
||||
|
||||
const getNetwork = (state: StateType): NetworkStateType => state.network;
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
import { createSelector } from 'reselect';
|
||||
|
||||
import { StateType } from '../reducer';
|
||||
import { ItemsStateType } from '../ducks/items';
|
||||
|
||||
const getItems = (state: StateType): ItemsStateType => state.items;
|
||||
|
||||
export const isDone = createSelector(
|
||||
getItems,
|
||||
(state: ItemsStateType): boolean => state.chromiumRegistrationDone === ''
|
||||
);
|
||||
|
||||
export const everDone = createSelector(
|
||||
getItems,
|
||||
(state: ItemsStateType): boolean =>
|
||||
state.chromiumRegistrationDoneEver === '' ||
|
||||
state.chromiumRegistrationDone === ''
|
||||
);
|
|
@ -4,14 +4,14 @@ import { NetworkStatus } from '../../components/NetworkStatus';
|
|||
import { StateType } from '../reducer';
|
||||
import { getIntl } from '../selectors/user';
|
||||
import { hasNetworkDialog } from '../selectors/network';
|
||||
import { isDone } from '../selectors/registration';
|
||||
import { isDone } from '../../util/registration';
|
||||
|
||||
const mapStateToProps = (state: StateType) => {
|
||||
return {
|
||||
...state.network,
|
||||
hasNetworkDialog: hasNetworkDialog(state),
|
||||
i18n: getIntl(state),
|
||||
isRegistrationDone: isDone(state),
|
||||
isRegistrationDone: isDone(),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import * as RegistrationSelectors from '../state/selectors/registration';
|
||||
|
||||
export function markEverDone() {
|
||||
// @ts-ignore
|
||||
window.storage.put('chromiumRegistrationDoneEver', '');
|
||||
|
@ -18,10 +16,12 @@ export function remove() {
|
|||
|
||||
export function isDone() {
|
||||
// @ts-ignore
|
||||
return RegistrationSelectors.isDone(window.reduxStore.getState());
|
||||
// tslint:disable-next-line no-backbone-get-set-outside-model
|
||||
return window.storage.get('chromiumRegistrationDone') === '';
|
||||
}
|
||||
|
||||
export function everDone() {
|
||||
// @ts-ignore
|
||||
return RegistrationSelectors.everDone(window.reduxStore.getState());
|
||||
// tslint:disable-next-line no-backbone-get-set-outside-model
|
||||
return window.storage.get('chromiumRegistrationDoneEver') === '' || isDone();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue