Skip to content

Commit

Permalink
Add second review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Jun 10, 2024
1 parent 20754eb commit bb9e568
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions lib/API.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {Deferred} from 'simply-deferred';
import {has} from 'lodash';
import ExpensifyAPIDeferred from './APIDeferred';
import {isWindowAvailable, isFunction} from './utils';
import * as Utils from './utils';

/**
* @param {Network} network
Expand Down Expand Up @@ -48,7 +48,7 @@ export default function API(network, args) {
network
.get('/revision.txt')
.done((codeRevision) => {
if (isWindowAvailable() && codeRevision.trim() === window.CODE_REVISION) {
if (Utils.isWindowAvailable() && codeRevision.trim() === window.CODE_REVISION) {
console.debug('Code revision is up to date');
promise.resolve();
} else {
Expand Down Expand Up @@ -105,7 +105,7 @@ export default function API(network, args) {
let newParameters = {...parameters, command};

// If there was an enhanceParameters() method supplied in our args, then we will call that here
if (args && isFunction(args.enhanceParameters)) {
if (args && Utils.isFunction(args.enhanceParameters)) {
newParameters = args.enhanceParameters(newParameters);
}

Expand Down Expand Up @@ -175,7 +175,7 @@ export default function API(network, args) {
* @param {Function} callback
*/
registerDefaultHandler(jsonCodes, callback) {
if (!isFunction(callback)) {
if (!Utils.isFunction(callback)) {
return;
}

Expand Down Expand Up @@ -232,7 +232,7 @@ export default function API(network, args) {

return (parameters, keepalive = false) => {
// Optional validate function for required logic before making the call. e.g. validating params in the front-end etc.
if (isFunction(data.validate)) {
if (Utils.isFunction(data.validate)) {
data.validate(parameters);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/BrowserDetect.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isNavigatorAvailable, isWindowAvailable} from './utils';
import * as Utils from './utils';

const BROWSERS = {
EDGE: 'Edge',
Expand All @@ -15,7 +15,7 @@ const MOBILE_PLATFORMS = {
};

function searchString() {
if (!isWindowAvailable() || !isNavigatorAvailable()) {
if (!Utils.isWindowAvailable() || !Utils.isNavigatorAvailable()) {
return '';
}

Expand Down Expand Up @@ -78,7 +78,7 @@ function searchString() {
}

function getMobileDevice() {
if (!isNavigatorAvailable() || !navigator.userAgent) {
if (!Utils.isNavigatorAvailable() || !navigator.userAgent) {
return '';
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Log.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import API from './API';
import Network from './Network';
import Logger from './Logger';
import {isWindowAvailable, isFunction} from './utils';
import * as Utils from './utils';

/**
* Network interface for logger.
Expand All @@ -23,17 +23,17 @@ function serverLoggingCallback(logger, params) {
* @param {String} message
*/
function clientLoggingCallback(message) {
if (isWindowAvailable() && typeof window.g_printableReport !== 'undefined' && window.g_printableReport === true) {
if (Utils.isWindowAvailable() && typeof window.g_printableReport !== 'undefined' && window.g_printableReport === true) {
return;
}

if (window.console && isFunction(console.log)) {
if (window.console && Utils.isFunction(console.log)) {
console.log(message);
}
}

export default new Logger({
serverLoggingCallback,
clientLoggingCallback,
isDebug: isWindowAvailable() ? window.DEBUG : false,
isDebug: Utils.isWindowAvailable() ? window.DEBUG : false,
});
6 changes: 3 additions & 3 deletions lib/Network.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import $ from 'jquery';
import {isWindowAvailable, isObject} from './utils';
import * as Utils from './utils';

/**
* Adds our API command to the URL so the API call is more easily identified in the
Expand Down Expand Up @@ -40,7 +40,7 @@ export default function Network(endpoint) {
}

// Attach a listener to the event indicating that we're leaving a page
if (isWindowAvailable()) {
if (Utils.isWindowAvailable()) {
window.onbeforeunload = () => {
isNavigatingAway = true;
};
Expand Down Expand Up @@ -138,7 +138,7 @@ export default function Network(endpoint) {
}
if (Array.isArray(value)) {
value.forEach((valueItem, i) => {
if (isObject(valueItem)) {
if (Utils.isObject(valueItem)) {
Object.entries(valueItem).forEach(([valueItemObjectKey, valueItemObjectValue]) => {
formData.append(`${key}[${i}][${valueItemObjectKey}]`, valueItemObjectValue);
});
Expand Down
8 changes: 4 additions & 4 deletions lib/PubSub.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import has from 'lodash/has';
import {once} from 'lodash';
import Log from './Log';
import {isWindowAvailable, isFunction, isObject} from './utils';
import * as Utils from './utils';

/**
* PubSub
Expand Down Expand Up @@ -94,8 +94,8 @@ const PubSubModule = {
throw new Error('Attempted to subscribe to undefined event');
}

const callback = isFunction(optionalCallback) ? optionalCallback : () => {};
const scope = isObject(optionalScope) ? optionalScope : window;
const callback = Utils.isFunction(optionalCallback) ? optionalCallback : () => {};
const scope = Utils.isObject(optionalScope) ? optionalScope : window;
const eventID = generateID(eventName);

if (eventMap[eventName] === undefined) {
Expand Down Expand Up @@ -126,4 +126,4 @@ const PubSubModule = {
},
};

export default isWindowAvailable() && window.PubSub ? window.PubSub : PubSubModule;
export default Utils.isWindowAvailable() && window.PubSub ? window.PubSub : PubSubModule;
2 changes: 1 addition & 1 deletion lib/ReportHistoryStore.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export default class ReportHistoryStore {
const cachedHistory = this.cache[reportID] || [];

// If comment is not in cache then fetch it
if (cachedHistory.length > 0) {
if (cachedHistory.length === 0) {
return this.getFlatHistory(reportID);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/mixins/PubSub.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PubSubModule from '../PubSub';
import {isWindowAvailable} from '../utils';
import * as Utils from '../utils';

const PubSub = (isWindowAvailable() && window.PubSub) || PubSubModule;
const PubSub = (Utils.isWindowAvailable() && window.PubSub) || PubSubModule;

/**
* This mixin sets up automatic PubSub bindings which will be removed when
Expand Down
4 changes: 2 additions & 2 deletions lib/mixins/extraClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
* }
*/

import {isWindowAvailable} from '../utils';
import * as Utils from '../utils';

export default {
propTypes: {
extraClasses: isWindowAvailable() && window.PropTypes.oneOfType([window.PropTypes.string, window.PropTypes.array, window.PropTypes.object]),
extraClasses: Utils.isWindowAvailable() && window.PropTypes.oneOfType([window.PropTypes.string, window.PropTypes.array, window.PropTypes.object]),
},

UNSAFE_componentWillReceiveProps(nextProps) {
Expand Down

0 comments on commit bb9e568

Please sign in to comment.