kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
More isLoggedIn refactoring
rodzic
9cd06a15d5
commit
1e531f472e
|
@ -1,6 +1,7 @@
|
||||||
import api from '../api';
|
import api from '../api';
|
||||||
import { importFetchedAccounts, importFetchedStatus } from './importer';
|
import { importFetchedAccounts, importFetchedStatus } from './importer';
|
||||||
import { favourite, unfavourite } from './interactions';
|
import { favourite, unfavourite } from './interactions';
|
||||||
|
import { isLoggedIn } from 'soapbox/utils/accounts';
|
||||||
|
|
||||||
export const EMOJI_REACT_REQUEST = 'EMOJI_REACT_REQUEST';
|
export const EMOJI_REACT_REQUEST = 'EMOJI_REACT_REQUEST';
|
||||||
export const EMOJI_REACT_SUCCESS = 'EMOJI_REACT_SUCCESS';
|
export const EMOJI_REACT_SUCCESS = 'EMOJI_REACT_SUCCESS';
|
||||||
|
@ -44,7 +45,7 @@ export const simpleEmojiReact = (status, emoji) => {
|
||||||
|
|
||||||
export function fetchEmojiReacts(id, emoji) {
|
export function fetchEmojiReacts(id, emoji) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
if (!getState().get('me')) return dispatch(noOp());
|
if (!isLoggedIn(getState)) return dispatch(noOp());
|
||||||
|
|
||||||
dispatch(fetchEmojiReactsRequest(id, emoji));
|
dispatch(fetchEmojiReactsRequest(id, emoji));
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ export function fetchEmojiReacts(id, emoji) {
|
||||||
|
|
||||||
export function emojiReact(status, emoji) {
|
export function emojiReact(status, emoji) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
if (!getState().get('me')) return dispatch(noOp());
|
if (!isLoggedIn(getState)) return dispatch(noOp());
|
||||||
|
|
||||||
dispatch(emojiReactRequest(status, emoji));
|
dispatch(emojiReactRequest(status, emoji));
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ export function emojiReact(status, emoji) {
|
||||||
|
|
||||||
export function unEmojiReact(status, emoji) {
|
export function unEmojiReact(status, emoji) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
if (!getState().get('me')) return dispatch(noOp());
|
if (!isLoggedIn(getState)) return dispatch(noOp());
|
||||||
|
|
||||||
dispatch(unEmojiReactRequest(status, emoji));
|
dispatch(unEmojiReactRequest(status, emoji));
|
||||||
|
|
||||||
|
|
|
@ -257,9 +257,9 @@ export function setFilter(filterType) {
|
||||||
|
|
||||||
export function markReadNotifications() {
|
export function markReadNotifications() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
if (!isLoggedIn(getState)) return;
|
||||||
if (!state.get('me')) return;
|
|
||||||
|
|
||||||
|
const state = getState();
|
||||||
const topNotification = state.getIn(['notifications', 'items'], ImmutableOrderedMap()).first(ImmutableMap()).get('id');
|
const topNotification = state.getIn(['notifications', 'items'], ImmutableOrderedMap()).first(ImmutableMap()).get('id');
|
||||||
const lastRead = state.getIn(['notifications', 'lastRead']);
|
const lastRead = state.getIn(['notifications', 'lastRead']);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { debounce } from 'lodash';
|
||||||
import { showAlertForError } from './alerts';
|
import { showAlertForError } from './alerts';
|
||||||
import { patchMe } from 'soapbox/actions/me';
|
import { patchMe } from 'soapbox/actions/me';
|
||||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
import { isLoggedIn } from 'soapbox/utils/accounts';
|
||||||
import uuid from '../uuid';
|
import uuid from '../uuid';
|
||||||
|
|
||||||
export const SETTING_CHANGE = 'SETTING_CHANGE';
|
export const SETTING_CHANGE = 'SETTING_CHANGE';
|
||||||
|
@ -147,8 +148,9 @@ export function changeSetting(path, value) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const debouncedSave = debounce((dispatch, getState) => {
|
const debouncedSave = debounce((dispatch, getState) => {
|
||||||
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
const state = getState();
|
const state = getState();
|
||||||
if (!state.get('me')) return;
|
|
||||||
if (getSettings(state).getIn(['saved'])) return;
|
if (getSettings(state).getIn(['saved'])) return;
|
||||||
|
|
||||||
const data = state.get('settings').delete('saved').toJS();
|
const data = state.get('settings').delete('saved').toJS();
|
||||||
|
|
Ładowanie…
Reference in New Issue