Skip to content

Commit e9ceb07

Browse files
committed
style: standard
1 parent e797c22 commit e9ceb07

File tree

2 files changed

+53
-53
lines changed

2 files changed

+53
-53
lines changed

lib/init.js

+43-43
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,30 @@ function init (hoodie) {
2727

2828
return hoodie.store.reset()
2929

30-
.then(function () {
31-
function migrate (doc) {
32-
doc.createdBy = account.id
33-
delete doc._rev
34-
return doc
35-
}
36-
return hoodie.store.add(options.beforeSignin.docs.map(migrate))
37-
})
38-
39-
.then(function () {
40-
return hoodie.store.connect()
41-
})
30+
.then(function () {
31+
function migrate (doc) {
32+
doc.createdBy = account.id
33+
delete doc._rev
34+
return doc
35+
}
36+
return hoodie.store.add(options.beforeSignin.docs.map(migrate))
37+
})
38+
39+
.then(function () {
40+
return hoodie.store.connect()
41+
})
4242
})
4343

4444
hoodie.account.hook.before('signout', function () {
4545
return hoodie.store.push()
46-
.catch(function (error) {
47-
if (error.status !== 401) {
48-
throw error
49-
}
46+
.catch(function (error) {
47+
if (error.status !== 401) {
48+
throw error
49+
}
5050

51-
error.message = 'Local changes could not be synced, sign in first'
52-
throw error
53-
})
51+
error.message = 'Local changes could not be synced, sign in first'
52+
throw error
53+
})
5454
})
5555
hoodie.account.hook.after('signout', function (options) {
5656
return hoodie.store.reset()
@@ -63,40 +63,40 @@ function init (hoodie) {
6363
hoodie.connectionStatus.on('disconnect', function () {
6464
hoodie.account.get('session')
6565

66-
.then(function (session) {
67-
if (session) {
68-
hoodie.store.disconnect()
69-
}
70-
})
66+
.then(function (session) {
67+
if (session) {
68+
hoodie.store.disconnect()
69+
}
70+
})
7171
})
7272
hoodie.connectionStatus.on('reconnect', function () {
7373
hoodie.account.get('session')
7474

75-
.then(function (session) {
76-
if (session) {
77-
hoodie.store.connect()
78-
}
79-
})
75+
.then(function (session) {
76+
if (session) {
77+
hoodie.store.connect()
78+
}
79+
})
8080
})
8181

8282
hoodie.account.get('session')
8383

84-
.then(function (session) {
84+
.then(function (session) {
8585
// signed out
86-
if (!session) {
87-
return
88-
}
86+
if (!session) {
87+
return
88+
}
8989

90-
// signed in, but session was invalid
91-
if (session.invalid) {
92-
return
93-
}
90+
// signed in, but session was invalid
91+
if (session.invalid) {
92+
return
93+
}
9494

95-
// hoodie.connectionStatus.ok is false if there is a connection issue
96-
if (hoodie.connectionStatus.ok === false) {
97-
return
98-
}
95+
// hoodie.connectionStatus.ok is false if there is a connection issue
96+
if (hoodie.connectionStatus.ok === false) {
97+
return
98+
}
9999

100-
hoodie.store.connect()
101-
})
100+
hoodie.store.connect()
101+
})
102102
}

tests/specs/init.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ test('"reset" triggered on "signin"', function (t) {
5656
var options = {}
5757
beforeSignInCall.args[1](options)
5858

59-
.then(function () {
60-
options.beforeSignin.accountId = 'accountid2'
61-
return afterSignInCall.args[1]({}, options)
62-
})
63-
.then(function () {
64-
t.deepEqual(signInTestOrder, ['reset', 'connect'], 'store.connect was called after store.reset')
65-
})
59+
.then(function () {
60+
options.beforeSignin.accountId = 'accountid2'
61+
return afterSignInCall.args[1]({}, options)
62+
})
63+
.then(function () {
64+
t.deepEqual(signInTestOrder, ['reset', 'connect'], 'store.connect was called after store.reset')
65+
})
6666
})
6767

6868
test('"reset" triggered after signout', function (t) {
@@ -515,9 +515,9 @@ test('hoodie.store.connect() is called', function (t) {
515515
var options = {}
516516
beforeSignInCall.args[1](options)
517517

518-
.then(function () {
519-
return afterSignInCall.args[1](hoodie.account, options)
520-
})
518+
.then(function () {
519+
return afterSignInCall.args[1](hoodie.account, options)
520+
})
521521
})
522522
test('hoodie.account.hook.before returns an error', function (t) {
523523
t.plan(2)

0 commit comments

Comments
 (0)