Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
Restore isMobileActive, component url handling
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Jan 30, 2018
1 parent 85f5704 commit 65f4f7e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
17 changes: 11 additions & 6 deletions src/Styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class GlobalStyles {
return Storage.getItem("activeTheme").then(function(theme) {
let runDefaultTheme = () => {
var theme = this.systemTheme();
theme.active = true;
theme.setMobileActive(true);
this.activeTheme = theme;
var constants = this.defaultConstants();
this.setStyles(this.defaultRules(constants), constants, theme.getMobileRules().statusBar);
Expand Down Expand Up @@ -62,9 +62,12 @@ export default class GlobalStyles {

ModelManager.getInstance().addItemSyncObserver("themes", "SN|Theme", function(items){
if(this.activeTheme && this.activeTheme.isSwapIn) {
this.activeTheme.isSwapIn = false;
this.activeTheme = _.find(this.themes(), {uuid: this.activeTheme.uuid});
this.activeTheme.active = true;
var matchingTheme = _.find(this.themes(), {uuid: this.activeTheme.uuid});
if(matchingTheme) {
this.activeTheme = matchingTheme;
this.activeTheme.isSwapIn = false;
this.activeTheme.setMobileActive(true);
}
}
}.bind(this));
}
Expand Down Expand Up @@ -137,16 +140,18 @@ export default class GlobalStyles {

activateTheme(theme, writeToStorage = true) {
if(this.activeTheme) {
this.activeTheme.active = false;
this.activeTheme.setMobileActive(false);
}

console.log("Activating theme", JSON.stringify(theme));

var run = () => {
var constants = _.merge(this.defaultConstants(), theme.getMobileRules().constants);
var rules = _.merge(this.defaultRules(constants), theme.getMobileRules().rules);
this.setStyles(rules, constants, theme.getMobileRules().statusBar);

this.activeTheme = theme;
theme.active = true;
theme.setMobileActive(true);

if(theme.default) {
Storage.removeItem("activeTheme");
Expand Down
2 changes: 1 addition & 1 deletion src/containers/account/ThemesSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class ThemesSection extends Component {
text={theme.name}
key={theme.uuid}
first={i == 0}
selected={() => {return theme.active}}
selected={() => {return theme.isMobileActive()}}
dimmed={theme.getNotAvailOnMobile()}
last={i == this.props.themes.length - 1 && this.props.themes.length > 1}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/models/app/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default class Component extends Item {
mapContentToLocalProperties(content) {
super.mapContentToLocalProperties(content)
/* Legacy */
this.url = content.url;
this.url = content.url || content.hosted_url;
/* New */
this.local_url = content.local_url;
this.hosted_url = content.hosted_url;
this.hosted_url = content.hosted_url || content.url;
this.offlineOnly = content.offlineOnly;

if(content.valid_until) {
Expand Down
9 changes: 9 additions & 0 deletions src/models/app/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ export default class Theme extends Component {
getNotAvailOnMobile() {
return this.getAppDataItem("notAvailableOnMobile");
}

/* We must not use .active because if you set that to true, it will also activate that theme on desktop/web */
setMobileActive(active) {
this.setAppDataItem("mobileActive", active);
}

isMobileActive() {
return this.getAppDataItem("mobileActive");
}
}
4 changes: 3 additions & 1 deletion src/screens/Notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ export default class Notes extends Abstract {
Sync.getInstance().removeSyncObserver(this.syncObserver);
Sync.getInstance().removeSyncStatusObserver(this.syncStatusObserver);
Auth.getInstance().removeEventObserver(this.signoutObserver);
this.options.removeChangeObserver(this.optionsObserver);
if(this.options) {
this.options.removeChangeObserver(this.optionsObserver);
}
clearInterval(this.syncTimer);
}

Expand Down
2 changes: 1 addition & 1 deletion vendor/react-native-navigation

0 comments on commit 65f4f7e

Please sign in to comment.