diff --git a/app/actions/actionsTypes.js b/app/actions/actionsTypes.js index 543070623..ced5b25ef 100644 --- a/app/actions/actionsTypes.js +++ b/app/actions/actionsTypes.js @@ -31,7 +31,7 @@ export const ROOMS = createRequestTypes('ROOMS', [ 'CLOSE_SEARCH_HEADER' ]); export const ROOM = createRequestTypes('ROOM', ['LEAVE', 'ERASE', 'USER_TYPING']); -export const APP = createRequestTypes('APP', ['START', 'READY', 'INIT']); +export const APP = createRequestTypes('APP', ['START', 'READY', 'INIT', 'INIT_LOCAL_SETTINGS']); export const MESSAGES = createRequestTypes('MESSAGES', ['REPLY_BROADCAST']); export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes]); export const SELECTED_USERS = createRequestTypes('SELECTED_USERS', ['ADD_USER', 'REMOVE_USER', 'RESET', 'SET_LOADING']); diff --git a/app/actions/index.js b/app/actions/index.js index ca322276a..494cb1c93 100644 --- a/app/actions/index.js +++ b/app/actions/index.js @@ -20,6 +20,12 @@ export function appInit() { }; } +export function appInitLocalSettings() { + return { + type: APP.INIT_LOCAL_SETTINGS + }; +} + export function setCurrentServer(server) { return { type: types.SET_CURRENT_SERVER, diff --git a/app/index.js b/app/index.js index f50910a62..2ad65f8aa 100644 --- a/app/index.js +++ b/app/index.js @@ -17,7 +17,7 @@ import { unsubscribeTheme } from './utils/theme'; import EventEmitter from './utils/events'; -import { appInit } from './actions'; +import { appInit, appInitLocalSettings } from './actions'; import { deepLinkingOpen } from './actions/deepLinking'; import Navigation from './lib/Navigation'; import Sidebar from './views/SidebarView'; @@ -550,6 +550,7 @@ export default class Root extends React.Component { RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme); const [notification, deepLinking] = await Promise.all([initializePushNotifications(), Linking.getInitialURL()]); const parsedDeepLinkingURL = parseDeepLinking(deepLinking); + store.dispatch(appInitLocalSettings()); if (notification) { onNotification(notification); } else if (parsedDeepLinkingURL) { diff --git a/app/sagas/init.js b/app/sagas/init.js index bba8f3028..f75df753a 100644 --- a/app/sagas/init.js +++ b/app/sagas/init.js @@ -20,6 +20,17 @@ import { isIOS } from '../utils/deviceInfo'; import database from '../lib/database'; import protectedFunction from '../lib/methods/helpers/protectedFunction'; +export const initLocalSettings = function* initLocalSettings() { + const sortPreferences = yield RocketChat.getSortPreferences(); + yield put(setAllPreferences(sortPreferences)); + + const useMarkdown = yield RocketChat.getUseMarkdown(); + yield put(toggleMarkdown(useMarkdown)); + + const allowCrashReport = yield RocketChat.getAllowCrashReport(); + yield put(toggleCrashReport(allowCrashReport)); +}; + const restore = function* restore() { try { let hasMigration; @@ -83,15 +94,6 @@ const restore = function* restore() { } } - const sortPreferences = yield RocketChat.getSortPreferences(); - yield put(setAllPreferences(sortPreferences)); - - const useMarkdown = yield RocketChat.getUseMarkdown(); - yield put(toggleMarkdown(useMarkdown)); - - const allowCrashReport = yield RocketChat.getAllowCrashReport(); - yield put(toggleCrashReport(allowCrashReport)); - if (!token || !server) { yield all([ RNUserDefaults.clear(RocketChat.TOKEN_KEY), @@ -126,5 +128,6 @@ const start = function* start({ root }) { const root = function* root() { yield takeLatest(APP.INIT, restore); yield takeLatest(APP.START, start); + yield takeLatest(APP.INIT_LOCAL_SETTINGS, initLocalSettings); }; export default root;