Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Sort log info to display the latest trade at the top #3588

Merged
merged 3 commits into from
May 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Sort log info to display the latest trade at the top
  • Loading branch information
Farabi authored and Farabi committed Apr 25, 2022
commit ebac8c8eca2ff2f87fb03d4e41733ccd21d74455
4 changes: 2 additions & 2 deletions src/botPage/view/LogTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import ReactDataGrid from 'react-data-grid';
import { observer as globalObserver } from '../../common/utils/observer';
import { translate } from '../../common/i18n';
import { appendRow, saveAs } from './shared';
import { appendRowTop, saveAs } from './shared';

const minHeight = 550;

Expand Down Expand Up @@ -53,7 +53,7 @@ export default class LogTable extends Component {
if (!Object.keys(log).length) {
return;
}
this.setState(appendRow(log, this.state));
this.setState(appendRowTop(log, this.state));
}
});
}
Expand Down
11 changes: 11 additions & 0 deletions src/botPage/view/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ export const appendRow = (trade, state) => ({
],
});

export const appendRowTop = (trade, state) => ({
Copy link
Contributor

@sara-fs sara-fs Apr 25, 2022

Choose a reason for hiding this comment

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

Since we are repeating codes in this method and the codes above, is there a better way to mix them?

Copy link
Author

Choose a reason for hiding this comment

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

We can maybe mix them with conditional rendering using ternary operators.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good job, I think we can only decide on ...state.rows, ...
Whatever you think is better

id : state.id + 1,
rows: [
{
...trade,
id: state.id + 1,
},
...state.rows,
],
});

export const updateRow = (prevRowIndex, trade, state) => ({
id : state.id,
rows: [
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy