Fluid UI response
This commit is contained in:
@@ -102,7 +102,8 @@
|
||||
setSelect('ID_MountDrives', drives);
|
||||
}
|
||||
},
|
||||
notifyDriveUnmounted: _notifyDriveUnmounted
|
||||
notifyDriveUnmounted: _notifyDriveUnmounted,
|
||||
reloadApplication: reloadApplication
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -181,6 +182,7 @@
|
||||
function _calculateEstimatedStorage(funds, cb) {
|
||||
window.appActions.calculateEstimatedStorage(funds, cb)
|
||||
}
|
||||
|
||||
return {
|
||||
createWallet: _createWallet,
|
||||
mountDrive: _mountDrive,
|
||||
@@ -377,8 +379,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
window.addEventListener('load', ()=> {
|
||||
console.log('Main window load');
|
||||
function reloadApplication() {
|
||||
AppActions.stopApp();
|
||||
document.getElementById('ID_SiaDrive').innerText = 'SiaDrive ' + UiState.clientVersion();
|
||||
document.getElementById('ID_ServerVersion').innerText = '...';
|
||||
@@ -395,6 +396,11 @@
|
||||
} else {
|
||||
setMainWindow('offline_window');
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('load', ()=> {
|
||||
console.log('Main window load');
|
||||
reloadApplication();
|
||||
});
|
||||
|
||||
window.onunload = ()=> {
|
||||
|
@@ -309,12 +309,12 @@ void CSiaDriveApp::OnContextCreated(
|
||||
CEF_REQUIRE_RENDERER_THREAD();
|
||||
|
||||
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||
|
||||
CefRefPtr<FunctionHandler> handler(new FunctionHandler(*_siaApi, _appStarted, _siaDriveConfig, _siaDrive, [this]() {this->ShutdownServices(); }, [this](CefRefPtr<CefV8Context> context) {this->SiaApiRefreshCallback(context, *_siaCurl, _siaDriveConfig.get()); }));
|
||||
|
||||
CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(nullptr, nullptr);
|
||||
obj->SetValue("isWalletLocked", CefV8Value::CreateBool(_siaApi->GetWallet()->GetLocked()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
obj->SetValue("isWalletConfigured", CefV8Value::CreateBool(_siaApi->GetWallet()->GetCreated()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
obj->SetValue("isOnline", CefV8Value::CreateBool(_siaApi->GetWallet()->GetConnected()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
obj->SetValue("clientVersion", CefV8Value::CreateString(SIDRIVE_VERSION_STRING), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
obj->SetValue("allocatedRenterFunds", CefV8Value::CreateString(_siaApi->GetRenter()->GetFunds().ToString()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
obj->SetValue("isOnline", CefV8Value::CreateBool(_siaApi->GetWallet()->GetConnected()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
CefRefPtr<CefV8Value> defaultFunds = CefV8Value::CreateObject(nullptr, nullptr);
|
||||
defaultFunds->SetValue("Funds", CefV8Value::CreateString(SIA_DEFAULT_MINIMUM_FUNDS.ToString()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
defaultFunds->SetValue("Hosts", CefV8Value::CreateString(SString::FromUInt32(SIA_DEFAULT_HOST_COUNT).str()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
@@ -323,7 +323,6 @@ void CSiaDriveApp::OnContextCreated(
|
||||
obj->SetValue("defaultRenterSettings", defaultFunds, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
global->SetValue("uiState", obj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
CefRefPtr<FunctionHandler> handler(new FunctionHandler(*_siaApi, _appStarted, _siaDriveConfig, _siaDrive, [this]() {this->ShutdownServices(); }, [this](CefRefPtr<CefV8Context> context) {this->SiaApiRefreshCallback(context, *_siaCurl, _siaDriveConfig.get()); }));
|
||||
obj = CefV8Value::CreateObject(nullptr, nullptr);
|
||||
obj->SetValue("unlockWallet", CefV8Value::CreateFunction("unlockWallet", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
obj->SetValue("createWallet", CefV8Value::CreateFunction("createWallet", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
@@ -398,21 +397,22 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
||||
{
|
||||
context->Enter();
|
||||
auto global = context->GetGlobal();
|
||||
bool wasOnline = global->GetValue("uiState")->GetValue("isOnline")->GetBoolValue();
|
||||
auto uiState = global->GetValue("uiState");
|
||||
bool wasOnline = uiState->GetValue("isOnline")->GetBoolValue();
|
||||
bool isOnline = _siaApi->GetWallet()->GetConnected();
|
||||
if (wasOnline != isOnline)
|
||||
{
|
||||
_appStarted = false;
|
||||
context->GetBrowser()->Reload();
|
||||
}
|
||||
else if (_appStarted)
|
||||
uiState->SetValue("isOnline", CefV8Value::CreateBool(isOnline), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
if (isOnline)
|
||||
{
|
||||
auto uiActions = global->GetValue("uiUpdate");
|
||||
auto renterActions = uiActions->GetValue("Renter");
|
||||
auto walletActions = uiActions->GetValue("Wallet");
|
||||
|
||||
// Update server version
|
||||
// Update UI state and server version
|
||||
ExecuteSetter(context, uiActions, "setServerVersion", _siaApi->GetServerVersion());
|
||||
uiState->SetValue("isWalletLocked", CefV8Value::CreateBool(_siaApi->GetWallet()->GetLocked()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
uiState->SetValue("isWalletConfigured", CefV8Value::CreateBool(_siaApi->GetWallet()->GetCreated()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
uiState->SetValue("allocatedRenterFunds", CefV8Value::CreateString(_siaApi->GetRenter()->GetFunds().ToString()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
// Display wallet data
|
||||
auto confirmedBalance = _siaApi->GetWallet()->GetConfirmedBalance();
|
||||
@@ -472,6 +472,14 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
||||
// Display block height
|
||||
ExecuteSetter(context, uiActions, "setBlockHeight", SString::FromUInt64(_siaApi->GetConsensus()->GetHeight()));
|
||||
}
|
||||
|
||||
if (isOnline != wasOnline)
|
||||
{
|
||||
CefRefPtr<CefV8Value> reloadApplication = global->GetValue("uiUpdate")->GetValue("reloadApplication");
|
||||
CefV8ValueList args;
|
||||
reloadApplication->ExecuteFunctionWithContext(context, nullptr, args);
|
||||
}
|
||||
|
||||
context->Exit();
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user