Commit 1dbcec96 authored by jboyson's avatar jboyson

Respect cookie settings

parent 3ba8ae4e
...@@ -4,7 +4,8 @@ import { parseBoolean } from '~/lib/utils/common_utils'; ...@@ -4,7 +4,8 @@ import { parseBoolean } from '~/lib/utils/common_utils';
import FindFile from '~/vue_shared/components/file_finder/index.vue'; import FindFile from '~/vue_shared/components/file_finder/index.vue';
import eventHub from '../notes/event_hub'; import eventHub from '../notes/event_hub';
import diffsApp from './components/app.vue'; import diffsApp from './components/app.vue';
import { TREE_LIST_STORAGE_KEY } from './constants'; import { TREE_LIST_STORAGE_KEY, DIFF_WHITESPACE_COOKIE_NAME } from './constants';
import Cookies from 'js-cookie';
export default function initDiffsApp(store) { export default function initDiffsApp(store) {
const fileFinderEl = document.getElementById('js-diff-file-finder'); const fileFinderEl = document.getElementById('js-diff-file-finder');
...@@ -90,9 +91,11 @@ export default function initDiffsApp(store) { ...@@ -90,9 +91,11 @@ export default function initDiffsApp(store) {
this.setRenderTreeList(renderTreeList); this.setRenderTreeList(renderTreeList);
// Set whitespace default as per user preferences // Set whitespace default as per user preferences unless cookie is already set
const hideWhitespace = this.showWhitespaceDefault ? '0' : '1'; if (!Cookies.get(DIFF_WHITESPACE_COOKIE_NAME)) {
this.setShowWhitespace({ showWhitespace: hideWhitespace !== '1' }); const hideWhitespace = this.showWhitespaceDefault ? '0' : '1';
this.setShowWhitespace({ showWhitespace: hideWhitespace !== '1' });
}
}, },
methods: { methods: {
...mapActions('diffs', ['setRenderTreeList', 'setShowWhitespace']), ...mapActions('diffs', ['setRenderTreeList', 'setShowWhitespace']),
......
...@@ -27,7 +27,7 @@ RSpec.describe 'Merge request > User toggles whitespace changes', :js do ...@@ -27,7 +27,7 @@ RSpec.describe 'Merge request > User toggles whitespace changes', :js do
find('.js-show-diff-settings').click find('.js-show-diff-settings').click
expect(find('#show-whitespace')).to be_checked expect(find('#show-whitespace')).not_to be_checked
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment