Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit aff1201

Browse files
committed
refactor(clients):move clients from app-start.js to user.js
indentation
1 parent 95953e1 commit aff1201

File tree

2 files changed

+22
-46
lines changed

2 files changed

+22
-46
lines changed

app/scripts/lib/app-start.js

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,14 @@ import Constants from './constants';
2727
import Environment from './environment';
2828
import ErrorUtils from './error-utils';
2929
import FormPrefill from '../models/form-prefill';
30-
import FxaClient from './fxa-client';
3130
import HeightObserver from './height-observer';
3231
import IframeChannel from './channels/iframe';
3332
import InterTabChannel from './channels/inter-tab';
34-
import MarketingEmailClient from './marketing-email-client';
3533
import Metrics from './metrics';
3634
import Notifier from './channels/notifier';
3735
import NullChannel from './channels/null';
38-
import OAuthClient from './oauth-client';
3936
import OAuthRelier from '../models/reliers/oauth';
4037
import p from './promise';
41-
import ProfileClient from './profile-client';
4238
import RefreshObserver from '../models/refresh-observer';
4339
import Relier from '../models/reliers/relier';
4440
import Router from './router';
@@ -95,8 +91,7 @@ Start.prototype = {
9591

9692
initializeExperimentGroupingRules () {
9793
this._experimentGroupingRules = new ExperimentGroupingRules({
98-
env: this._config.env,
99-
featureFlags: this._config.featureFlags
94+
env: this._config.env
10095
});
10196
},
10297

@@ -108,15 +103,11 @@ Start.prototype = {
108103
.then(() => this.initializeInterTabChannel())
109104
.then(() => this.initializeExperimentGroupingRules())
110105
.then(() => this.initializeErrorMetrics())
111-
.then(() => this.initializeOAuthClient())
112106
// both the metrics and router depend on the language
113107
// fetched from config.
114108
.then(() => this.initializeRelier())
115109
// iframe channel depends on the relier.
116110
.then(() => this.initializeIframeChannel())
117-
// fxaClient depends on the relier and
118-
// inter tab communication.
119-
.then(() => this.initializeFxaClient())
120111
// depends on nothing
121112
.then(() => this.initializeNotificationChannel())
122113
// depends on iframeChannel and interTabChannel, web channel
@@ -125,10 +116,6 @@ Start.prototype = {
125116
.then(() => this.initializeMetrics())
126117
// assertionLibrary depends on fxaClient
127118
.then(() => this.initializeAssertionLibrary())
128-
// profileClient depends on fxaClient and assertionLibrary
129-
.then(() => this.initializeProfileClient())
130-
// marketingEmailClient depends on config
131-
.then(() => this.initializeMarketingEmailClient())
132119
// broker relies on the relier, fxaClient,
133120
// assertionLibrary, and metrics
134121
.then(() => this.initializeAuthenticationBroker())
@@ -229,25 +216,6 @@ Start.prototype = {
229216
this._formPrefill = new FormPrefill();
230217
},
231218

232-
initializeOAuthClient () {
233-
this._oAuthClient = new OAuthClient({
234-
oAuthUrl: this._config.oAuthUrl
235-
});
236-
},
237-
238-
initializeProfileClient () {
239-
this._profileClient = new ProfileClient({
240-
profileUrl: this._config.profileUrl
241-
});
242-
},
243-
244-
initializeMarketingEmailClient () {
245-
this._marketingEmailClient = new MarketingEmailClient({
246-
baseUrl: this._config.marketingEmailServerUrl,
247-
preferencesUrl: this._config.marketingEmailPreferencesUrl
248-
});
249-
},
250-
251219
initializeRelier () {
252220
if (! this._relier) {
253221
let relier;
@@ -381,15 +349,6 @@ Start.prototype = {
381349
}
382350
},
383351

384-
initializeFxaClient () {
385-
if (! this._fxaClient) {
386-
this._fxaClient = new FxaClient({
387-
authServerUrl: this._config.authServerUrl,
388-
interTabChannel: this._interTabChannel
389-
});
390-
}
391-
},
392-
393352
initializeUser () {
394353
if (! this._user) {
395354
const user = this._user = new User({

app/scripts/models/user.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,31 @@ const ResumeTokenMixin = require('./mixins/resume-token');
2121
const UrlMixin = require('./mixins/url');
2222
const Storage = require('../lib/storage');
2323
const vat = require('../lib/vat');
24+
const ProfileClient = require('../lib/profile-client');
25+
const MarketingEmailClient = require('../lib/marketing-email-client');
26+
const OAuthClient = require('../lib/oauth-client');
27+
const InterTabChannel = require('../lib/channels/inter-tab');
28+
const FxaClient = require('../lib/fxa-client');
2429

2530
var User = Backbone.Model.extend({
2631
initialize (options = {}) {
32+
this._config = options.config;
33+
this._interTabChannel = new InterTabChannel();
2734
this._oAuthClientId = options.oAuthClientId;
28-
this._oAuthClient = options.oAuthClient;
29-
this._profileClient = options.profileClient;
30-
this._fxaClient = options.fxaClient;
31-
this._marketingEmailClient = options.marketingEmailClient;
35+
this._oAuthClient = new OAuthClient({
36+
oAuthUrl: this._config.oAuthUrl
37+
});
38+
this._profileClient = new ProfileClient({
39+
profileUrl: this._config.profileUrl
40+
});
41+
this._fxaClient = new FxaClient({
42+
authServerUrl: this._config.authServerUrl,
43+
interTabChannel: this._interTabChannel
44+
});
45+
this._marketingEmailClient = new MarketingEmailClient({
46+
baseUrl: this._config.marketingEmailServerUrl,
47+
preferencesUrl: this._config.marketingEmailPreferencesUrl
48+
});
3249
this._metrics = options.metrics;
3350
this._assertion = options.assertion;
3451
this._notifier = options.notifier;

0 commit comments

Comments
 (0)