Skip to content

Commit

Permalink
Merge pull request #2405 from hippware/2327
Browse files Browse the repository at this point in the history
New requirement for welcome header from #2327
  • Loading branch information
Eric Kirkham authored May 29, 2018
2 parents c2fc411 + d4292d3 commit a84ed22
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 129 deletions.
1 change: 1 addition & 0 deletions __tests__/__snapshots__/BotCompose.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,7 @@ exports[`BotCompose renders with owned bot 1`] = `
"followedSize": 0,
"followersSize": 0,
"handle": null,
"hasUsedGeofence": false,
"id": "user",
"isBlocked": false,
"isFollowed": false,
Expand Down
111 changes: 0 additions & 111 deletions __tests__/__snapshots__/Home.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -309,117 +309,6 @@ Visitors
</View>
</View>
</BlurView>
<View
style={
Object {
"alignItems": "center",
"backgroundColor": "rgb(255,255,255)",
"bottom": 0,
"flexDirection": "row",
"left": 0,
"padding": 40,
"paddingHorizontal": 60,
"position": "absolute",
"right": 0,
"top": 0,
}
}
>
<Image
resizeMode="cover"
source={
Object {
"testUri": "../../../images/bannerBg.png",
}
}
style={
Object {
"bottom": 0,
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
}
}
/>
<Image
resizeMode="contain"
source={
Object {
"testUri": "../../../images/footOpaquePink.png",
}
}
style={
Object {
"height": 89,
"marginRight": 40,
"width": 69,
}
}
/>
<View
style={
Object {
"flex": 1,
"justifyContent": "center",
}
}
>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Array [
Object {
"color": "rgb(253,95,108)",
"fontFamily": "Roboto-Bold",
"fontSize": 15,
},
undefined,
]
}
>
Find out when your friends
visit your favorite places!
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Array [
Object {
"color": "rgb(155,155,155)",
"fontFamily": "Roboto-Regular",
"fontSize": 13,
},
Object {
"marginTop": 10,
},
]
}
>
Start by tapping
<Image
resizeMode="contain"
source={
Object {
"testUri": "../../../images/footOpaquePink.png",
}
}
style={
Object {
"height": 18,
"width": 15,
}
}
/>
on your
favorite bots!
</Text>
</View>
</View>
</View>
</View>
</View>
Expand Down
33 changes: 18 additions & 15 deletions src/components/Home/FirstLoadOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@ const bg = require('../../../images/bannerBg.png')

const FirstLoadOverlay = inject('wocky')(
observer(({wocky}: Props) => {
return wocky!.sessionCount <= 2 ? (
<View style={styles.container}>
<Image source={bg} style={styles.bgImage} resizeMode="cover" />
<Image source={foot} style={styles.image} resizeMode="contain" />
<View style={{flex: 1, justifyContent: 'center'}}>
<RText color={colors.PINK} size={15} weight="Bold">
{'Find out when your friends\r\nvisit your favorite places!'}
</RText>
<RText size={13} color={colors.DARK_GREY} style={{marginTop: 5 * k}}>
{'Start by tapping '}
<Image source={foot} style={styles.icon} resizeMode="contain" />
{' on your\r\nfavorite bots!'}
</RText>
return (
wocky!.profile &&
!wocky!.profile!.hasUsedGeofence && (
<View style={styles.container}>
<Image source={bg} style={styles.bgImage} resizeMode="cover" />
<Image source={foot} style={styles.image} resizeMode="contain" />
<View style={{flex: 1, justifyContent: 'center'}}>
<RText color={colors.PINK} size={15} weight="Bold">
{'Find out when your friends\r\nvisit your favorite places!'}
</RText>
<RText size={13} color={colors.DARK_GREY} style={{marginTop: 5 * k}}>
{'Start by tapping '}
<Image source={foot} style={styles.icon} resizeMode="contain" />
{' on your\r\nfavorite bots!'}
</RText>
</View>
</View>
</View>
) : null
)
)
})
)

Expand Down
2 changes: 1 addition & 1 deletion third-party/wocky-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export {EventBotShare, IEventBotShare} from './model/EventBotShare'
export {File, IFile, FileRef} from './model/File'
export {Location, ILocationSnapshot} from './model/Location'
export {Message, IMessage} from './model/Message'
export {OwnProfile} from './model/OwnProfile'
export {OwnProfile, IOwnProfile} from './model/OwnProfile'
export {XmppTransport} from './transport/XmppTransport'
export {GraphQLTransport} from './transport/GraphQLTransport'
export {IWockyTransport, IPagingList} from './transport/IWockyTransport'
Expand Down
9 changes: 9 additions & 0 deletions third-party/wocky-client/src/model/OwnProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ export const OwnProfile = types
types.model('OwnProfile', {
email: types.maybe(types.string),
phoneNumber: types.maybe(types.string),
hasUsedGeofence: false,
})
)
.actions(self => ({
setHasUsedGeofence: value => {
self.hasUsedGeofence = value
},
}))
.named('OwnProfile')

export type IOwnProfileType = typeof OwnProfile.Type
export interface IOwnProfile extends IOwnProfileType {}
5 changes: 5 additions & 0 deletions third-party/wocky-client/src/store/Wocky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const Wocky = types
self.load(self.profile, data)
}
if (self.profile.handle) self.sessionCount = 3
return self.profile
}
return self.profiles.get(id, data)
}),
Expand Down Expand Up @@ -397,6 +398,9 @@ export const Wocky = types
_updateBot: flow(function*(d: any) {
yield waitFor(() => self.connected)
yield self.transport.updateBot(d)
if (d.geofence) {
self.profile!.setHasUsedGeofence(true)
}
// subscribe owner to his bot
const bot = self.bots.storage.get(d.id)
self.profile!.ownBots.addToTop(bot)
Expand Down Expand Up @@ -425,6 +429,7 @@ export const Wocky = types
}),
_subscribeGeofenceBot: flow(function*(id: string) {
yield waitFor(() => self.connected)
self.profile!.setHasUsedGeofence(true)
return yield self.transport.subscribeBot(id, true)
}),
_subscribeBot: flow(function*(id: string) {
Expand Down
6 changes: 5 additions & 1 deletion third-party/wocky-client/src/transport/GraphQLTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ export class GraphQLTransport implements IWockyTransport {
query LoadProfile {
user(id: "${user}") {
${PROFILE_PROPS}
${user === this.username ? '... on CurrentUser { email phoneNumber }' : ''}
${
user === this.username
? '... on CurrentUser { email phoneNumber hasUsedGeofence }'
: ''
}
}
}
`,
Expand Down
23 changes: 22 additions & 1 deletion third-party/wocky-client/test/geofence.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {expect} from 'chai'
import {createXmpp, waitFor} from './support/testuser'
import {IWocky} from '../src/store/Wocky'
import {IWocky, IProfile, IOwnProfile} from '../src'
import {IBot} from '../src/model/Bot'

let user1: IWocky, user2: IWocky
Expand Down Expand Up @@ -46,15 +46,27 @@ describe('Geofence', () => {
}
})

it('load own profile, check hasUsedGeofence', async done => {
try {
const profile1: IOwnProfile = await user1.loadProfile(user1.username!)
expect(profile1.hasUsedGeofence).to.be.false
done()
} catch (e) {
done(e)
}
})

it('creates a geofence bot', async done => {
try {
expect(user1.profile.hasUsedGeofence).to.be.false
bot = await user1.createBot()
await bot.update({
location: {latitude: 1.1, longitude: 2.1},
title: 'Test bot',
geofence: true,
addressData: {city: 'Koper', country: 'Slovenia'},
})
expect(user1.profile.hasUsedGeofence).to.be.true
// console.log('bot updated', bot.toJSON())
expect(bot.geofence).to.be.true
expect(bot.visitorsSize).to.equal(0)
Expand All @@ -64,6 +76,15 @@ describe('Geofence', () => {
done(e)
}
})
it('load own profile, check hasUsedGeofence', async done => {
try {
const profile1: IOwnProfile = await user1.loadProfile(user1.username!)
expect(profile1.hasUsedGeofence).to.be.true
done()
} catch (e) {
done(e)
}
})
it('creates a geofence bot2', async done => {
try {
bot2 = await user1.createBot()
Expand Down

0 comments on commit a84ed22

Please sign in to comment.