Skip to content

Commit

Permalink
Add sensible default for date_to
Browse files Browse the repository at this point in the history
  • Loading branch information
easteregg committed Jun 27, 2019
1 parent 1cc1eb5 commit 2fb8d4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/javascript/app/Stores/Modules/Profit/profit-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const delay_on_scroll_time = 150;
export default class ProfitTableStore extends BaseStore {
@observable data = [];
@observable date_from = 0;
@observable date_to = 0;
@observable date_to = toMoment().startOf('day').add(1, 'd').subtract(1, 's').unix();
@observable error = '';
@observable has_loaded_all = false;
@observable is_loading = false;
Expand Down Expand Up @@ -48,7 +48,7 @@ export default class ProfitTableStore extends BaseStore {
shouldFetchNextBatch(should_load_partially) {
if (!should_load_partially && (this.has_loaded_all || this.is_loading)) return false;
const today = toMoment().startOf('day').add(1, 'd').subtract(1, 's').unix();
if (this.date_to && this.date_to < today) return !should_load_partially;
if (this.date_to < today) return should_load_partially;
return true;
}
Expand Down Expand Up @@ -159,7 +159,7 @@ export default class ProfitTableStore extends BaseStore {
@action.bound
clearDateFilter() {
this.date_from = 0;
this.date_to = 0;
this.date_to = toMoment().startOf('day').add(1, 'd').subtract(1, 's').unix();
this.partial_fetch_time = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class StatementStore extends BaseStore {
@observable is_loading = false;
@observable has_loaded_all = false;
@observable date_from = 0;
@observable date_to = 0;
@observable date_to = toMoment().startOf('day').add(1, 'd').subtract(1, 's').unix();
@observable error = '';
// `client_loginid` is only used to detect if this is in sync with the client-store, don't rely on
Expand Down Expand Up @@ -46,13 +46,13 @@ export default class StatementStore extends BaseStore {
@action.bound
clearDateFilter() {
this.date_from = 0;
this.date_to = 0;
this.date_to = toMoment().startOf('day').add(1, 'd').subtract(1, 's').unix();
}
shouldFetchNextBatch(should_load_partially) {
if (!should_load_partially && (this.has_loaded_all || this.is_loading)) return false;
const today = toMoment().startOf('day').add(1, 'd').subtract(1, 's').unix();
if (this.date_to && this.date_to < today) return !should_load_partially;
if (this.date_to < today) return should_load_partially;
return true;
}
Expand Down

0 comments on commit 2fb8d4c

Please sign in to comment.