Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into login-common
Browse files Browse the repository at this point in the history
  • Loading branch information
jpevarnek committed Dec 18, 2015
2 parents 7093739 + 2ed87bf commit c1ffef6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/generic_core/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export var settings :uproxy_core_api.GlobalSettings = {
stunServers: DEFAULT_STUN_SERVERS.slice(0),
hasSeenSharingEnabledScreen: false,
hasSeenWelcome: false,
hasSeenMetrics: false,
allowNonUnicast: false,
mode: user_interface.Mode.GET,
version: STORAGE_VERSION,
Expand Down
38 changes: 16 additions & 22 deletions src/generic_core/uproxy_core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,28 @@ export class uProxyCore implements uproxy_core_api.CoreApi {
if (newSettings.stunServers.length === 0) {
newSettings.stunServers = globals.DEFAULT_STUN_SERVERS;
}
var oldDescription = globals.settings.description;
globals.storage.save('globalSettings', newSettings)
.catch((e) => {
log.error('Could not save globalSettings to storage', e.stack);
});

// Clear the existing servers and add in each new server.
// Trying globalSettings = newSettings does not correctly update
// pre-existing references to stunServers (e.g. from RemoteInstances).
globals.settings.stunServers
.splice(0, globals.settings.stunServers.length);
for (var i = 0; i < newSettings.stunServers.length; ++i) {
globals.settings.stunServers.push(newSettings.stunServers[i]);
}
_.merge(globals.settings, newSettings, (a :Object, b :Object) => {
// ensure we do not merge the arrays and that the reference remains intact
if (_.isArray(a) && _.isArray(b)) {
var arrayA = <Object[]>a;
arrayA.splice(0, arrayA.length);
for (var i in b) {
arrayA.push((<Object[]>b)[i]);
}
return a;
}

// this causes us to fall back to the default merge behaviour
return undefined;
});

if (newSettings.description != globals.settings.description) {
globals.settings.description = newSettings.description;
if (globals.settings.description !== oldDescription) {
// Resend instance info to update description for logged in networks.
for (var networkName in social_network.networks) {
for (var userId in social_network.networks[networkName]) {
Expand All @@ -221,21 +227,9 @@ export class uProxyCore implements uproxy_core_api.CoreApi {
}
}

globals.settings.hasSeenSharingEnabledScreen =
newSettings.hasSeenSharingEnabledScreen;
globals.settings.hasSeenWelcome = newSettings.hasSeenWelcome;
globals.settings.allowNonUnicast = newSettings.allowNonUnicast;
globals.settings.mode = newSettings.mode;
globals.settings.statsReportingEnabled = newSettings.statsReportingEnabled;
globals.settings.splashState = newSettings.splashState;
globals.settings.consoleFilter = newSettings.consoleFilter;
loggingController.setDefaultFilter(
loggingTypes.Destination.console,
globals.settings.consoleFilter);
globals.settings.language = newSettings.language;
globals.settings.force_message_version = newSettings.force_message_version;
globals.settings.quiverUserName = newSettings.quiverUserName;
globals.settings.showCloud = newSettings.showCloud;
}

public getFullState = () :Promise<uproxy_core_api.InitialState> => {
Expand Down
16 changes: 9 additions & 7 deletions src/generic_ui/polymer/splash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var splash = {
if (this.supportsQuiver && model.globalSettings.splashState
== this.SPLASH_STATES.METRICS_OPT_IN) {
ui.view = ui_constants.View.ROSTER;
} else if (model.globalSettings.hasSeenWelcome &&
} else if (model.globalSettings.hasSeenMetrics &&
model.globalSettings.splashState == this.SPLASH_STATES.INTRO) {
// Skip metrics opt-in if we've seen it before.
this.setState(this.SPLASH_STATES.NETWORKS);
Expand All @@ -51,7 +51,7 @@ var splash = {
}
},
prev: function() {
if (model.globalSettings.hasSeenWelcome &&
if (model.globalSettings.hasSeenMetrics &&
model.globalSettings.splashState == this.SPLASH_STATES.NETWORKS) {
// Skip metrics opt-in if we've seen it before.
this.setState(this.SPLASH_STATES.INTRO);
Expand All @@ -69,15 +69,17 @@ var splash = {
window.location.reload();
}
},
enableStats: function() {
model.globalSettings.statsReportingEnabled = true;
updateSeenMetrics: function(val :Boolean) {
model.globalSettings.hasSeenMetrics = true;
model.globalSettings.statsReportingEnabled = val;
core.updateGlobalSettings(model.globalSettings);
this.next();
},
enableStats: function() {
return this.updateSeenMetrics(true);
},
disableStats: function() {
model.globalSettings.statsReportingEnabled = false;
core.updateGlobalSettings(model.globalSettings);
this.next();
return this.updateSeenMetrics(false);
},
observe: {
'model.networkNames': 'updateNetworkButtonNames',
Expand Down
1 change: 1 addition & 0 deletions src/generic_ui/scripts/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class Model {
description: '',
stunServers: [],
hasSeenSharingEnabledScreen: false,
hasSeenMetrics: false,
hasSeenWelcome: false,
splashState : 0,
mode : ui_constants.Mode.GET,
Expand Down
1 change: 1 addition & 0 deletions src/integration/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ describe('uproxy core', function() {
stunServers: <any>[],
hasSeenSharingEnabledScreen: true,
hasSeenWelcome: false,
hasSeenMetrics: false,
allowNonUnicast: true,
statsReportingEnabled: false
};
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/uproxy_core_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface GlobalSettings {
stunServers :freedom.RTCPeerConnection.RTCIceServer[];
hasSeenSharingEnabledScreen :boolean;
hasSeenWelcome :boolean;
hasSeenMetrics :boolean;
allowNonUnicast :boolean;
mode :ui.Mode;
statsReportingEnabled :boolean;
Expand Down

0 comments on commit c1ffef6

Please sign in to comment.