Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 4849
Browse files Browse the repository at this point in the history
  • Loading branch information
aksonov committed Mar 5, 2020
2 parents 0923bb1 + 8afadd3 commit bc82129
Show file tree
Hide file tree
Showing 17 changed files with 246 additions and 179 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Also: [Deployment history](https://github.com/hippware/tr-wiki/wiki/Client-deplo

Ticket numbers refer to the ticket tracker for this project if not specified.

* Update: phoenix (PR #4855), tslib (PR #4856)
* react-test-renderer (PR #4857), @babel/core (PR #4858)
* typescript (PR #4859), react-dom (PR #4861)
* Make the hamburger/main menu a different colour for Staging (#4830)
* Speculative fix for: TypeError in Transport.ts:1411 (#4288)
* src/components/SignIn.tsx:102: undefined is not an object (#4820)
* Change notification to "... is sharing their location with you" (#4867)

# 4.40.1 - 2020 Feb 27

* Update: @storybook/react-native (PR #4833), tslib (PR #4834)
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"moment": "^2.24.0",
"mst-middlewares": "3.10.2",
"patch-package": "^6.0.5",
"phoenix": "^1.4.12",
"phoenix": "^1.4.14",
"postinstall-postinstall": "^2.0.0",
"prop-types": "^15.7.2",
"react": "16.9.0",
Expand Down Expand Up @@ -100,7 +100,7 @@
"validate.js": "github:hippware/validate.js#969b4fb274b0bb5234b8fe4199cc07dc1acb536e"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/core": "^7.8.6",
"@babel/node": "^7.8.4",
"@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
Expand All @@ -126,12 +126,12 @@
"metro-react-native-babel-preset": "^0.58.0",
"prettier": "^1.19.1",
"pretty-quick": "^2.0.1",
"react-dom": "^16.12.0",
"react-test-renderer": "16.12.0",
"react-dom": "^16.13.0",
"react-test-renderer": "16.13.0",
"ts-jest": "^25.2.1",
"ts-node": "^8.6.2",
"tsconfig-paths": "^3.6.0",
"tslib": "^1.11.0",
"tslib": "^1.11.1",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.15.0",
"tslint-react": "^4.2.0",
Expand Down
14 changes: 14 additions & 0 deletions patches/@absinthe+socket+0.2.1.patch
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,17 @@ index 9e5f12d..2c38c75 100644

const onTimeout = (absintheSocket, notifier) =>
notifierNotifyActive(
diff --git a/node_modules/@absinthe/socket/src/subscription.js b/node_modules/@absinthe/socket/src/subscription.js
index de44085..3cf71bd 100644
--- a/node_modules/@absinthe/socket/src/subscription.js
+++ b/node_modules/@absinthe/socket/src/subscription.js
@@ -143,6 +143,9 @@ const onDataMessage = (
if (notifier) {
notifierNotifyResultEvent(notifier, payload.result);
}
+ else {
+ console.bugsnagNotify(new Error('Subscription not found'), 'absinthe_socket_subscription_error', payload)
+ }
};

const dataMessageEventName = "subscription:data";
4 changes: 2 additions & 2 deletions src/components/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {observer} from 'mobx-react'
import {useFirebaseStore} from 'src/utils/injectors'

const countryMap = {}
getAllCountries(FlagType.FLAT).then((countries) => {
getAllCountries(FlagType.FLAT).then(countries => {
countries.forEach(country => (countryMap[country.cca2] = country))
})

Expand All @@ -26,7 +26,7 @@ let defaultCountryCode: CountryCode = 'US'

if (CarrierInfo) {
CarrierInfo.isoCountryCode(result => {
if (result && result !== 'nil') {
if (result && result !== 'nil' && countryMap[result.toUpperCase()]) {
defaultCountryCode = result.toUpperCase()
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/store/NotificationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class NotificationStore {
() => {
if (getType(self.wocky.notification!).name === EventLocationShare.name) {
const profile = (self.wocky.notification as IEventLocationShare)!.sharedWith
self.flash(`${profile.handle} and you are sharing location.`, {
self.flash(`${profile.handle} is sharing their location with you`, {
autoCloseTimeout: 3000,
profile,
})
Expand Down
12 changes: 7 additions & 5 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import firebase, {RNFirebase, Firebase} from 'react-native-firebase'
import DeviceInfo from 'react-native-device-info'
import {actionLogger, Transport, Wocky} from 'wocky-client'
import analytics from '../utils/analytics'
import {bugsnagIdentify, bugsnagNotify} from '../utils/bugsnagConfig'
import {bugsnagIdentify} from '../utils/bugsnagConfig'
import FirebaseStore from './FirebaseStore'
import AuthStore from './AuthStore'
import fileService from './fileService'
Expand All @@ -29,7 +29,7 @@ import GeocodingStore from './GeocodingStore'
import {AppInfo} from './AppInfo'
import ContactStore from './ContactStore'
import reportStore from './ReportStore'
import {log} from 'src/utils/logger'
import {log, modifyConsoleAndGetLogger} from 'src/utils/logger'
import {autorun} from 'mobx'
import {settings} from '../globals'
import AsyncStorage from '@react-native-community/async-storage'
Expand All @@ -40,13 +40,15 @@ const auth = firebase.auth()

const STORE_NAME = 'MainStore'

const logger = modifyConsoleAndGetLogger()

export type IEnv = {
transport: Transport
auth: RNFirebase.auth.Auth
firebase: Firebase
fileService: any
deviceInfo: TRDeviceInfo
bugsnagNotify: (e: Error, name?: string, extra?: {[name: string]: any}) => void
logger: any
}

const cleanState = {
Expand Down Expand Up @@ -136,14 +138,14 @@ function tryMigrate(parsed): object {
export async function createStore() {
let mstStore, storeData
const deviceInfo = await deviceInfoFetch()
const transport = new Transport(await DeviceInfo.getUniqueId())
const transport = new Transport(await DeviceInfo.getUniqueId(), logger)
const env: IEnv = {
transport,
auth,
firebase,
fileService,
deviceInfo,
bugsnagNotify,
logger,
}
const appInfo = {jsVersion, nativeVersion: deviceInfo.binaryVersion}
try {
Expand Down
39 changes: 39 additions & 0 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {bugsnagNotify} from './bugsnagConfig'
import BackgroundGeolocation from 'react-native-background-geolocation-android'

// tslint:disable:no-console
export function log(...args) {
if (!__DEV__) return
Expand All @@ -15,3 +18,39 @@ export function assert(...args) {
if (!__DEV__) return
;(console as any).assert(...args)
}

export function modifyConsoleAndGetLogger() {
if (!(console as any)._modified) {
if (!__DEV__) {
const no_op = () => {
// Prevent 'block is empty' lint warning
}

console.assert = no_op
console.log = no_op
console.info = no_op
console.warn = no_op
console.error = no_op
}

;(console as any).persistLog = (s: string): void => {
BackgroundGeolocation.logger.info(s)
if (__DEV__) {
console.log(s)
}
}
;(console as any).bugsnagNotify = (
e: Error,
name?: string,
extra?: {[name: string]: any}
): void => {
bugsnagNotify(e, name, extra)
if (__DEV__) {
console.log(`${name}`, e, extra)
}
}
;(console as any)._modified = true
}

return console
}
2 changes: 1 addition & 1 deletion storybook/stories/HomeBannerStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const wocky = FakeWockyStore.create(
activeBots: [],
},
{
transport: new Transport('mock'),
transport: new Transport('mock', console),
}
)

Expand Down
17 changes: 0 additions & 17 deletions third-party/wocky-client/src/logger.ts

This file was deleted.

4 changes: 4 additions & 0 deletions third-party/wocky-client/src/model/Location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export const createLocation = ({
createdAt,
activity,
activityConfidence,
id,
}: {
lat: number
lon: number
accuracy: number
createdAt: Date
activity: UserActivityType | 'unknown' | '' | null
activityConfidence: number | null
id?: string
}) => {
return Location.create({
latitude: lat,
Expand All @@ -23,6 +25,7 @@ export const createLocation = ({
createdAt,
activity: activity && activity.length && activity !== 'unknown' ? activity : undefined,
activityConfidence: activityConfidence || undefined,
id: id || undefined,
})
}

Expand All @@ -36,6 +39,7 @@ export const Location = types
types.enumeration(['still', 'on_foot', 'walking', 'in_vehicle', 'on_bicycle', 'running'])
),
activityConfidence: types.maybe(types.number),
id: types.maybe(types.string),
})
.volatile(() => ({
isCurrent: false,
Expand Down
19 changes: 5 additions & 14 deletions third-party/wocky-client/src/store/Wocky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {EventList, createEvent, EventEntity, IEventEntity} from '../model/EventL
import _ from 'lodash'
import {RequestType} from '../model/PaginableList'
import {ILocation, ILocationSnapshot, createLocation} from '../model/Location'
import {log} from '../logger'

export const Wocky = types
.compose(
Expand Down Expand Up @@ -41,12 +40,6 @@ export const Wocky = types
})
.named(SERVICE_NAME)
.actions(self => ({
bugsnagNotify: (e: Error, name?: string, extra?: {[name: string]: any}): void => {
const env = getEnv(self)
if (env.bugsnagNotify) {
env.bugsnagNotify(e, name, extra)
}
},
loadProfile: flow(function*(id: string) {
yield waitFor(() => self.connected)
const isOwn = id === self.username
Expand All @@ -69,8 +62,12 @@ export const Wocky = types
}) as (id: string) => Promise<IProfile>,
}))
.extend(self => {
const logger = getEnv(self).logger
return {
views: {
get logger() {
return logger
},
get connecting() {
return self.transport.connecting
},
Expand Down Expand Up @@ -348,7 +345,7 @@ export const Wocky = types
}
return item
} catch (e) {
log('ONNOTIFICATION ERROR: ' + e.message)
self.logger.log('ONNOTIFICATION ERROR: ' + e.message)
}
// }
},
Expand Down Expand Up @@ -492,12 +489,6 @@ export const Wocky = types
profile.setLocation(
createLocation({...location, createdAt: iso8601toDate(location.capturedAt)})
)
} else {
self.bugsnagNotify(
new Error('Unable to setLocation due to profile not found'),
'wocky_sharedLocation_profile_not_found',
{id, location}
)
}
}
),
Expand Down
Loading

0 comments on commit bc82129

Please sign in to comment.