Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Init local settings on notification tap #1438

Merged
merged 3 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/actions/actionsTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
6 changes: 6 additions & 0 deletions app/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
21 changes: 12 additions & 9 deletions app/sagas/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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;