[FIX] Init local settings on notification tap (#1438)
This commit is contained in:
parent
cd37a9b4ec
commit
0e87e1f6f4
|
@ -31,7 +31,7 @@ export const ROOMS = createRequestTypes('ROOMS', [
|
||||||
'CLOSE_SEARCH_HEADER'
|
'CLOSE_SEARCH_HEADER'
|
||||||
]);
|
]);
|
||||||
export const ROOM = createRequestTypes('ROOM', ['LEAVE', 'ERASE', 'USER_TYPING']);
|
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 MESSAGES = createRequestTypes('MESSAGES', ['REPLY_BROADCAST']);
|
||||||
export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes]);
|
export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes]);
|
||||||
export const SELECTED_USERS = createRequestTypes('SELECTED_USERS', ['ADD_USER', 'REMOVE_USER', 'RESET', 'SET_LOADING']);
|
export const SELECTED_USERS = createRequestTypes('SELECTED_USERS', ['ADD_USER', 'REMOVE_USER', 'RESET', 'SET_LOADING']);
|
||||||
|
|
|
@ -20,6 +20,12 @@ export function appInit() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function appInitLocalSettings() {
|
||||||
|
return {
|
||||||
|
type: APP.INIT_LOCAL_SETTINGS
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function setCurrentServer(server) {
|
export function setCurrentServer(server) {
|
||||||
return {
|
return {
|
||||||
type: types.SET_CURRENT_SERVER,
|
type: types.SET_CURRENT_SERVER,
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {
|
||||||
unsubscribeTheme
|
unsubscribeTheme
|
||||||
} from './utils/theme';
|
} from './utils/theme';
|
||||||
import EventEmitter from './utils/events';
|
import EventEmitter from './utils/events';
|
||||||
import { appInit } from './actions';
|
import { appInit, appInitLocalSettings } from './actions';
|
||||||
import { deepLinkingOpen } from './actions/deepLinking';
|
import { deepLinkingOpen } from './actions/deepLinking';
|
||||||
import Navigation from './lib/Navigation';
|
import Navigation from './lib/Navigation';
|
||||||
import Sidebar from './views/SidebarView';
|
import Sidebar from './views/SidebarView';
|
||||||
|
@ -550,6 +550,7 @@ export default class Root extends React.Component {
|
||||||
RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme);
|
RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme);
|
||||||
const [notification, deepLinking] = await Promise.all([initializePushNotifications(), Linking.getInitialURL()]);
|
const [notification, deepLinking] = await Promise.all([initializePushNotifications(), Linking.getInitialURL()]);
|
||||||
const parsedDeepLinkingURL = parseDeepLinking(deepLinking);
|
const parsedDeepLinkingURL = parseDeepLinking(deepLinking);
|
||||||
|
store.dispatch(appInitLocalSettings());
|
||||||
if (notification) {
|
if (notification) {
|
||||||
onNotification(notification);
|
onNotification(notification);
|
||||||
} else if (parsedDeepLinkingURL) {
|
} else if (parsedDeepLinkingURL) {
|
||||||
|
|
|
@ -20,6 +20,17 @@ import { isIOS } from '../utils/deviceInfo';
|
||||||
import database from '../lib/database';
|
import database from '../lib/database';
|
||||||
import protectedFunction from '../lib/methods/helpers/protectedFunction';
|
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() {
|
const restore = function* restore() {
|
||||||
try {
|
try {
|
||||||
let hasMigration;
|
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) {
|
if (!token || !server) {
|
||||||
yield all([
|
yield all([
|
||||||
RNUserDefaults.clear(RocketChat.TOKEN_KEY),
|
RNUserDefaults.clear(RocketChat.TOKEN_KEY),
|
||||||
|
@ -126,5 +128,6 @@ const start = function* start({ root }) {
|
||||||
const root = function* root() {
|
const root = function* root() {
|
||||||
yield takeLatest(APP.INIT, restore);
|
yield takeLatest(APP.INIT, restore);
|
||||||
yield takeLatest(APP.START, start);
|
yield takeLatest(APP.START, start);
|
||||||
|
yield takeLatest(APP.INIT_LOCAL_SETTINGS, initLocalSettings);
|
||||||
};
|
};
|
||||||
export default root;
|
export default root;
|
||||||
|
|
Loading…
Reference in New Issue