Skip to content

Commit

Permalink
docs(example): Add comments to app-crashes example
Browse files Browse the repository at this point in the history
  • Loading branch information
hrafnkellb-advania committed Sep 21, 2021
1 parent 6dd669f commit 4a13e0a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions example/src/components/app-crashes/app-crashes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class AppCrashes {
}
}

async presentErrorReportItemModal(items: ErrorReportItem[]) {
async presentErrorReportItemsModal(items: ErrorReportItem[]) {
const modal = await modalController.create({
component: 'error-report-items-modal',
componentProps: { items },
Expand Down Expand Up @@ -103,20 +103,23 @@ export class AppCrashes {
{ this.crashReport ? Object.keys(this.crashReport).map(key => {
const value = this.crashReport[key];
let renderedValue;
let errorReportItems: ErrorReportItem[];

// Extract items we will display in the modal when the item is clicked
let errorReportModalItems: ErrorReportItem[];
// If the value is an object, we need to add all key/value items to the errorReportModalItems
const valueIsObject = value && typeof value === 'object' && value.length === undefined;
if (valueIsObject) {
const keys = Object.keys(value);
renderedValue = `${keys.length} properties`;
errorReportItems = keys.map(valueKey => ({ label: valueKey, value: value[valueKey] }));
errorReportModalItems = keys.map(valueKey => ({ label: valueKey, value: value[valueKey] }));
} else {
// If the value is not an object, add the value as is to the errorReportModalItems
renderedValue = value;
errorReportItems = [{ label: key, value }];
errorReportModalItems = [{ label: key, value }];
}

return (
<ion-item detail onClick={() => this.presentErrorReportItemModal(errorReportItems)}>
<ion-item detail onClick={() => this.presentErrorReportItemsModal(errorReportModalItems)}>
<ion-label>
<h3>{key}</h3>
<p>{renderedValue}</p>
Expand Down

0 comments on commit 4a13e0a

Please sign in to comment.