Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ const ONYXKEYS = {
*/
PERSONAL_DETAILS_METADATA: 'personalDetailsMetadata',

/** GPS points stored for the GPS distance expense before they're accepted by the user */
GPS_DRAFT_DETAILS: 'gpsDraftDetails',

/** Contains all the info for Tasks */
TASK: 'task',

Expand Down Expand Up @@ -1135,6 +1138,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.STASHED_CREDENTIALS]: OnyxTypes.Credentials;
[ONYXKEYS.MODAL]: OnyxTypes.Modal;
[ONYXKEYS.IS_OPEN_APP_FAILURE_MODAL_OPEN]: boolean;
[ONYXKEYS.GPS_DRAFT_DETAILS]: OnyxTypes.GpsDraftDetails;
[ONYXKEYS.FULLSCREEN_VISIBILITY]: boolean;
[ONYXKEYS.NETWORK]: OnyxTypes.Network;
[ONYXKEYS.NEW_GROUP_CHAT_DRAFT]: OnyxTypes.NewGroupChatDraft;
Expand Down
36 changes: 36 additions & 0 deletions src/types/onyx/GpsDraftDetails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Stores data from GPS trip (GPS distance request)
*/
type GpsDraftDetails = {
/** Captured GPS points */
gpsPoints: Array<{
/** Latitude */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** Latitude */
/** Longitude */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

lat: number;
/** Longitude */
long: number;
}>;

/** Sum of geodesic distances between all consecutive points from gpsPoints in meters */
distanceInMeters: number;

/** Start address derived from coordinates of the first point from gpsPoints */
startAddress: {
/** Start address string shown to the user */
value: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the type is coordinates, I think the value shouldn't be a string, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be, as in case of type: "coordinates" value will be a stringified {lat: number; long: number} object. We need to keep the type in case we try to get human readable address from coordinates while offline (which will not work), so that when user reconnects we know that we can try again.

/** Is start address value a human readable address or stringified coordinates */
type: 'coordinates' | 'address';
};

/** End address derived from coordinates of the last point from gpsPoints */
endAddress: {
/** End address string shown to the user */
value: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered above

/** Is end address value a human readable address or stringified coordinates */
type: 'coordinates' | 'address';
};

/** Is GPS trip in progress */
isTracking: boolean;
};

export default GpsDraftDetails;
2 changes: 2 additions & 0 deletions src/types/onyx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import type ExportTemplate from './ExportTemplate';
import type FrequentlyUsedEmoji from './FrequentlyUsedEmoji';
import type {FundList} from './Fund';
import type Fund from './Fund';
import type GpsDraftDetails from './GpsDraftDetails';
import type HybridApp from './HybridApp';
import type ImportedSpreadsheet from './ImportedSpreadsheet';
import type ImportedSpreadsheetMemberData from './ImportedSpreadsheetMemberData';
Expand Down Expand Up @@ -165,6 +166,7 @@ export type {
Fund,
FundID,
FundList,
GpsDraftDetails,
IntroSelected,
IssueNewCard,
AddNewCompanyCardFeed,
Expand Down
Loading