Skip to content

Commit

Permalink
Remove message Appearing when reloading after changing user settings
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 committed Sep 2, 2020
1 parent c5d4f74 commit f452173
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 32 deletions.
10 changes: 2 additions & 8 deletions src/controllers/user/display/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ import autoFocuser from 'autoFocuser';
const UserSettings = userSettings.UserSettings;

export default function (view, params) {
function onBeforeUnload(e) {
if (hasChanges) {
e.returnValue = 'You currently have unsaved changes. Are you sure you wish to leave?';
}
}

let settingsInstance;
let hasChanges;

const userId = params.userId || ApiClient.getCurrentUserId();
const currentSettings = userId === ApiClient.getCurrentUserId() ? userSettings : new UserSettings();
view.addEventListener('viewshow', function () {
window.addEventListener('beforeunload', onBeforeUnload);

view.addEventListener('viewshow', function () {
if (settingsInstance) {
settingsInstance.loadData();
} else {
Expand Down
10 changes: 2 additions & 8 deletions src/controllers/user/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,13 @@ import 'listViewStyle';
const UserSettings = userSettings.UserSettings;

export default function (view, params) {
function onBeforeUnload(e) {
if (hasChanges) {
e.returnValue = 'You currently have unsaved changes. Are you sure you wish to leave?';
}
}

let homescreenSettingsInstance;
let hasChanges;

const userId = params.userId || ApiClient.getCurrentUserId();
const currentSettings = userId === ApiClient.getCurrentUserId() ? userSettings : new UserSettings();
view.addEventListener('viewshow', function () {
window.addEventListener('beforeunload', onBeforeUnload);

view.addEventListener('viewshow', function () {
if (homescreenSettingsInstance) {
homescreenSettingsInstance.loadData();
} else {
Expand Down
10 changes: 2 additions & 8 deletions src/controllers/user/playback/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,13 @@ import 'listViewStyle';
const UserSettings = userSettings.UserSettings;

export default function (view, params) {
function onBeforeUnload(e) {
if (hasChanges) {
e.returnValue = 'You currently have unsaved changes. Are you sure you wish to leave?';
}
}

let settingsInstance;
let hasChanges;

const userId = params.userId || ApiClient.getCurrentUserId();
const currentSettings = userId === ApiClient.getCurrentUserId() ? userSettings : new UserSettings();
view.addEventListener('viewshow', function () {
window.addEventListener('beforeunload', onBeforeUnload);

view.addEventListener('viewshow', function () {
if (settingsInstance) {
settingsInstance.loadData();
} else {
Expand Down
10 changes: 2 additions & 8 deletions src/controllers/user/subtitles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ import autoFocuser from 'autoFocuser';
const UserSettings = userSettings.UserSettings;

export default function (view, params) {
function onBeforeUnload(e) {
if (hasChanges) {
e.returnValue = 'You currently have unsaved changes. Are you sure you wish to leave?';
}
}

let subtitleSettingsInstance;
let hasChanges;

const userId = params.userId || ApiClient.getCurrentUserId();
const currentSettings = userId === ApiClient.getCurrentUserId() ? userSettings : new UserSettings();
view.addEventListener('viewshow', function () {
window.addEventListener('beforeunload', onBeforeUnload);

view.addEventListener('viewshow', function () {
if (subtitleSettingsInstance) {
subtitleSettingsInstance.loadData();
} else {
Expand Down

0 comments on commit f452173

Please sign in to comment.