mirror of
https://github.com/discourse/discourse.git
synced 2025-03-15 07:58:05 +08:00
BUGFIX: Don't depend on localStorage for Discourse to function
This commit is contained in:
parent
0ffa98904f
commit
00469e976d
@ -13,17 +13,26 @@ Discourse.Mobile = {
|
||||
this.isMobileDevice = $html.hasClass('mobile-device');
|
||||
this.mobileView = $html.hasClass('mobile-view');
|
||||
|
||||
if (localStorage && localStorage.mobileView) {
|
||||
var savedValue = (localStorage.mobileView === 'true');
|
||||
if (savedValue !== this.mobileView) {
|
||||
this.reloadPage(savedValue);
|
||||
try{
|
||||
if (localStorage && localStorage.mobileView) {
|
||||
var savedValue = (localStorage.mobileView === 'true');
|
||||
if (savedValue !== this.mobileView) {
|
||||
this.reloadPage(savedValue);
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
// localStorage may be disabled, just skip this
|
||||
// you get security errors if it is disabled
|
||||
}
|
||||
},
|
||||
|
||||
toggleMobileView: function() {
|
||||
if (localStorage) {
|
||||
localStorage.mobileView = !this.mobileView;
|
||||
try{
|
||||
if (localStorage) {
|
||||
localStorage.mobileView = !this.mobileView;
|
||||
}
|
||||
} catch(err) {
|
||||
// localStorage may be disabled, skip
|
||||
}
|
||||
this.reloadPage(!this.mobileView);
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user