1
0

Require Sia 1.2.0 and fix UI available/free storage display

This commit is contained in:
Scott E. Graves
2017-04-14 11:27:10 -05:00
parent f2e11ac9d2
commit f74b4c7aad
3 changed files with 11 additions and 19 deletions

View File

@@ -68,21 +68,21 @@
</td>
</tr>
<tr>
<td style="text-align: right">Total GB:</td>
<td style="text-align: right">Total:</td>
<td id="ID_Renter_EstimatedSpace"></td>
<td colspan="50%"></td>
<td style="text-align: right">Price (per GB):</td>
<td id="ID_Renter_EstimatedCost"></td>
</tr>
<tr>
<td style="text-align: right">Available GB:</td>
<td style="text-align: right">Available:</td>
<td id="ID_Renter_AvailablSpace"></td>
<td colspan="50%"></td>
<td style="text-align: right">Download (per GB):</td>
<td id="ID_Renter_EstimatedDownloadCost"></td>
</tr>
<tr>
<td style="text-align: right">Used GB:</td>
<td style="text-align: right">Used:</td>
<td id="ID_Renter_UsedSpace"></td>
<td colspan="50%"></td>
<td style="text-align: right">Upload (per GB):</td>

View File

@@ -3,7 +3,7 @@
#include <cstdint>
#define SIDRIVE_VERSION_STRING "0.0.1"
#define COMPAT_SIAD_VERSION "1.1.2"
#define COMPAT_SIAD_VERSION "1.2.0"
#ifdef _WIN32
// Disable DLL-interface warnings
@@ -194,15 +194,6 @@ inline static Hastings SiaCurrencyToHastings(const SiaCurrency& currency)
return parser.stack[0].value.ToString(conv);
}
inline static SString SiaCurrencyToGB(const SiaCurrency& value)
{
ttmath::Conv conv;
conv.base = 10;
conv.round = 3;
return value.ToWString(conv);
}
SString SIADRIVE_EXPORTABLE BytesToFriendlyDisplay(const SiaCurrency& bytes);
BOOL SIADRIVE_EXPORTABLE RetryAction(std::function<BOOL()> func, std::uint16_t retryCount, const DWORD& retryDelay);

View File

@@ -438,12 +438,13 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
global->GetValue("uiState")->SetValue("allocatedRenterFunds", CefV8Value::CreateString(SiaCurrencyToString(allocatedFunds).str()), V8_PROPERTY_ATTRIBUTE_NONE);
// Space
SiaCurrency totalUsedGb = _siaApi->GetRenter()->GetTotalUsedBytes() ? _siaApi->GetRenter()->GetTotalUsedBytes() / (1024.0 * 1024.0 * 1024.0) : 0.0;
auto totalAvailable = (totalUsedGb / (allocatedFunds - unspentFunds)) * allocatedFunds;
auto totalRemainGb = totalAvailable - totalUsedGb;
ExecuteSetter(context, renterActions, "setEstimatedSpace", SiaCurrencyToGB(totalAvailable));
ExecuteSetter(context, renterActions, "setAvailableSpace", SiaCurrencyToGB(totalRemainGb));
ExecuteSetter(context, renterActions, "setUsedSpace", SiaCurrencyToGB(totalUsedGb));
SiaCurrency totalUsed = _siaApi->GetRenter()->GetTotalUsedBytes() ? _siaApi->GetRenter()->GetTotalUsedBytes() : 0.0;
SiaCurrency totalAvailable;
_siaApi->GetRenter()->CalculateEstimatedStorage(allocatedFunds, totalAvailable);
auto totalRemain = totalAvailable > 0 ? totalAvailable - totalUsed : 0;
ExecuteSetter(context, renterActions, "setEstimatedSpace", BytesToFriendlyDisplay(totalAvailable));
ExecuteSetter(context, renterActions, "setAvailableSpace", BytesToFriendlyDisplay(totalRemain));
ExecuteSetter(context, renterActions, "setUsedSpace", BytesToFriendlyDisplay(totalUsed));
// Upload Progress
/*