fixes days calculation

This commit is contained in:
@wwwjim 2020-09-24 17:37:09 -07:00
parent 353a333a3e
commit e936391d66
3 changed files with 16 additions and 10 deletions

View File

@ -42,6 +42,11 @@ export const getCIDGatewayURL = (cid) => {
return `${Constants.gateways.ipfs}/${cid}`;
};
// NOTE(jsign): Each epoch is 30s, then divide by 60 for getting mins, by 60 to get hours, then by 24 to get days
export const getDaysFromEpoch = (epoch) => {
return `${(epoch * 30) / DAY} days`;
};
export const getCIDGatewayURLWithExtension = (cid, name) => {
const url = getCIDGatewayURL(cid);
const extension = getFileExtension(name);

View File

@ -323,12 +323,9 @@ export default class SceneMakeFilecoinDeal extends React.Component {
descriptionStyle={{ maxWidth: 688 }}
readOnly
label="Default Filecoin deal duration (read only)"
description={`Your deal is set for ${this.state
.settings_cold_default_duration /
30 /
2 /
60 /
24} days.`}
description={`Your deal is set for ${Strings.getDaysFromEpoch(
this.state.settings_cold_default_duration
)}.`}
name="settings_cold_default_duration"
type="number"
unit="epochs"

View File

@ -1,6 +1,7 @@
import * as React from "react";
import * as Actions from "~/common/actions";
import * as System from "~/components/system";
import * as Strings from "~/common/strings";
import { css } from "@emotion/react";
import { LoaderSpinner } from "~/components/system/components/Loaders";
@ -200,6 +201,9 @@ export default class SceneSettings extends React.Component {
<System.Input
containerStyle={{ marginTop: 24 }}
label="Default Filecoin deal duration"
description={`${Strings.getDaysFromEpoch(
this.state.settings_cold_default_duration
)}`}
name="settings_cold_default_duration"
type="number"
value={this.state.settings_cold_default_duration}
@ -226,14 +230,14 @@ export default class SceneSettings extends React.Component {
onChange={this._handleChange}
/>
<System.CheckBox
{/* <System.CheckBox
style={{ marginTop: 48 }}
name="settings_cold_default_auto_renew"
value={this.state.settings_cold_default_auto_renew}
onChange={this._handleChange}
>
Enable auto renew for Filecoin Network deals.
</System.CheckBox>
</System.CheckBox> */}
<System.Input
containerStyle={{ marginTop: 24 }}
@ -272,14 +276,14 @@ export default class SceneSettings extends React.Component {
{this.state.settings_hot_enabled ? (
<div css={STYLES_SUBGROUP}>
<System.CheckBox
{/* <System.CheckBox
style={{ marginTop: 48 }}
name="settings_hot_allow_unfreeze"
value={this.state.settings_hot_allow_unfreeze}
onChange={this._handleChange}
>
IPFS allow unfreeze setting description.
</System.CheckBox>
</System.CheckBox> */}
<System.Input
containerStyle={{ marginTop: 24 }}