Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEL-281] Telehealth waiting area/ practitioner tool (ios) #18

Merged
merged 12 commits into from
May 8, 2021
Binary file modified images/jane_logo_72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/watermark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 20 additions & 3 deletions react/features/analytics/AnalyticsEvents.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from "lodash";
import _ from 'lodash';

/**
* The constant for the event type 'track'.
* TODO: keep these constants in a single place. Can we import them from
Expand Down Expand Up @@ -801,9 +802,25 @@ export function createConnectionQualityChangedEvent(strength, stats) {
* Remove the track id from the ConnectionQualityChangedEvent property.
* If we don't want to send the trackId along with the property to amplitude.
*
* @param {Object} event - event object.
* @returns {Object|number|string|undefined} property.
* @param {Object} event - Event object.
* @returns {Object|number|string|undefined} Property.
*/
function removeTrackIdFromEventPropertyObject(event) {
return event && _.isObject(event) && Object.values(event)[0];
}

/**
* Creates an event for an action on the waiting area page.
*
* @param {string} action - The action that the event represents.
* @param {boolean} attributes - Additional attributes to attach to the event.
* @returns {Object} The event in a format suitable for sending via
* sendAnalytics.
*/
export function createWaitingAreaPageEvent(action, attributes = {}) {
return {
action,
attributes,
source: 'waiting.area'
};
}
8 changes: 6 additions & 2 deletions react/features/app/actions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @flow

import type { Dispatch } from 'redux';

import { setRoom } from '../base/conference';
import { enableJaneWaitingArea, isJaneWaitingAreaEnabled } from '../jane-waiting-area-native';
import {
configWillLoad,
createFakeConfig,
Expand Down Expand Up @@ -131,7 +131,11 @@ export function appNavigate(uri: ?string) {
// FIXME: unify with web, currently the connection and track creation happens in conference.js.
if (room && navigator.product === 'ReactNative') {
dispatch(createDesiredLocalTracks());
dispatch(connect());
if (isJaneWaitingAreaEnabled(getState())) {
dispatch(enableJaneWaitingArea(true));
} else {
dispatch(connect());
}
}
};
}
Expand Down
16 changes: 2 additions & 14 deletions react/features/base/conference/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { getLocalTracks, trackAdded, trackRemoved } from '../tracks';
import {
getBackendSafeRoomName,
getJitsiMeetGlobalNS
getJitsiMeetGlobalNS, sendBeaconToJaneRN
} from '../util';

import {
Expand Down Expand Up @@ -417,7 +417,7 @@ export function conferenceWillLeave(conference: Object) {
if (url && surveyUrl) {

Linking.openURL(surveyUrl).then(() => {
sendBeaconRn(url, data).then(r => {
sendBeaconToJaneRN(url, data).then(r => {
console.log(r, 'response');
})
.catch(e => {
Expand All @@ -434,18 +434,6 @@ export function conferenceWillLeave(conference: Object) {
};
}


// eslint-disable-next-line require-jsdoc,no-unused-vars,no-empty-function
function sendBeaconRn(url, data) {
return fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'text/plain; charset=UTF-8'
},
body: data
});
}

/**
* Initializes a new conference.
*
Expand Down
21 changes: 21 additions & 0 deletions react/features/base/conference/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import _ from 'lodash';

import jwtDecode from 'jwt-decode';
import { JitsiTrackErrors } from '../lib-jitsi-meet';
import {
getLocalParticipant,
Expand Down Expand Up @@ -351,3 +352,23 @@ export function sendLocalParticipant(

conference.setDisplayName(name);
}

/**
* Check if the call is the test call.
*
*
* @param {Function|Object} state - The redux store, state, or
* {@code getState} function.
* @returns {boolean}
*/
export function isJaneTestCall(state) {
const { jwt } = state['features/base/jwt'];
const jwtPayload = jwt && jwtDecode(jwt) ?? null;
const context = jwtPayload && jwtPayload.context ?? null;
const user = context && context.user ?? null;
const participantId = user && user.participant_id;
const videoChatSessionId = context && context.video_chat_session_id;
const participantEmail = user && user.email;

return participantId === 0 && videoChatSessionId === 0 && participantEmail === '[email protected]';
}
5 changes: 5 additions & 0 deletions react/features/base/environment/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

import Platform from '../react/Platform';
import { Dimensions } from 'react-native';

/**
* Returns whether or not the current environment is a mobile device.
Expand Down Expand Up @@ -36,3 +37,7 @@ export function checkChromeExtensionsInstalled(config: Object = {}) {
(config.chromeExtensionsInfo || []).map(info => extensionInstalledFunction(info))
);
}

export function iphoneHasNotch () {
return Platform.OS === 'ios' && Dimensions.get('window').height > 811 && !Platform.isPad || false;
}
11 changes: 11 additions & 0 deletions react/features/base/i18n/dateUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,14 @@ function _getSupportedLocale() {

return supportedLocale || 'en';
}

/**
* Returns a unix timestamp in milliseconds({@code number}).
*
* @param {Date | string} date - The date from jwt token.
* @returns {number}
*/
export function getTimeStamp(date) {
return moment(date, 'YYYY-MM-DD HH:mm:ss')
.valueOf();
}
30 changes: 30 additions & 0 deletions react/features/base/react/components/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// @flow

import {
checkLocalParticipantCanJoin,
isJaneWaitingAreaEnabled
} from '../../../jane-waiting-area-native/functions';
import { getLocalParticipantType } from '../../participants/functions';

/**
* Returns the field value in a platform generic way.
*
* @param {Object | string} fieldParameter - The parameter passed through the change event function.
* @returns {string}
*/
export function getFieldValue(fieldParameter: Object | string) {
return typeof fieldParameter === 'string' ? fieldParameter : fieldParameter?.target?.value;
}

// eslint-disable-next-line require-jsdoc
export function shouldShowPreCallMessage(state: Object) {
const participantType = getLocalParticipantType(state);
const { remoteParticipantsStatuses } = state['features/jane-waiting-area-native'];

if (isJaneWaitingAreaEnabled(state)) {
return participantType !== 'StaffMember'
&& !checkLocalParticipantCanJoin(remoteParticipantsStatuses, participantType);
}

return true;
}
Loading