[FIX] Init local settings on notification tap (#1438)

This commit is contained in:
Diego Mello 2019-12-04 13:50:22 -03:00 committed by GitHub
parent cd37a9b4ec
commit 0e87e1f6f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 11 deletions

View File

@ -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']);

View File

@ -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,

View File

@ -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) {

View File

@ -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;