Skip to content

Commit f95891b

Browse files
committed
-improved wallets list to now show colour names and not bug out if too long
1 parent c8fe44d commit f95891b

File tree

2 files changed

+102
-44
lines changed

2 files changed

+102
-44
lines changed

electron-ui/cc_wallet/cc_wallet_renderer.js

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ function set_callbacks(socket) {
114114
console.log("Received command: " + command);
115115

116116
if (command == "start_server") {
117-
get_wallets();
118117
get_colour(g_wallet_id)
119118
get_colour_name(g_wallet_id)
120119
get_transactions();
@@ -194,6 +193,44 @@ function get_wallet_summaries_response(data){
194193
// {id: {"type": type, "balance": balance, "name": name, "colour": colour}}
195194
// {id: {"type": type, "balance": balance}}
196195
wallets_details = data
196+
wallets_tab.innerHTML = ""
197+
var new_innerHTML = ""
198+
for (var i in data) {
199+
var wallet = data[i];
200+
var type = wallet["type"]
201+
var id = i
202+
var name = wallet["type"]
203+
if (type=="STANDARD_WALLET"){
204+
name = "Chia Wallet"
205+
type = "Chia"
206+
} else if (name=="COLOURED_COIN") {
207+
name = "CC Wallet"
208+
type = wallet["name"]
209+
if (type.length > 20) {
210+
type = type.substring(0,20);
211+
type = type.concat("...")
212+
}
213+
}
214+
get_wallet_balance(id)
215+
//href, wallet_name, wallet_description, wallet_amount
216+
var href = ""
217+
if (type == "STANDARD_WALLET") {
218+
href = "../wallet-dark.html"
219+
} else if (type == "RATE_LIMITED") {
220+
href = "../rl_wallet/rl_wallet.html"
221+
} else if (type == "COLOURED_COIN") {
222+
href = "../cc_wallet/cc_wallet.html"
223+
}
224+
225+
if (id == g_wallet_id) {
226+
new_innerHTML += create_side_wallet(id, href, name, type, 0, true)
227+
} else {
228+
new_innerHTML += create_side_wallet(id, href, name, type, 0, false)
229+
}
230+
231+
}
232+
new_innerHTML += create_wallet_button()
233+
wallets_tab.innerHTML = new_innerHTML
197234
}
198235

199236
async function get_wallet_balance(id) {
@@ -363,48 +400,6 @@ function handle_state_changed(data) {
363400
}
364401
}
365402

366-
function get_wallets() {
367-
/*
368-
Sends websocket request to get list of all wallets available
369-
*/
370-
data = {
371-
"command": "get_wallets",
372-
}
373-
json_data = JSON.stringify(data);
374-
ws.send(json_data);
375-
}
376-
377-
function get_wallets_response(data) {
378-
wallets_tab.innerHTML = ""
379-
new_innerHTML = ""
380-
const wallets = data["wallets"]
381-
for (var i = 0; i < wallets.length; i++) {
382-
var wallet = wallets[i];
383-
var type = wallet["type"]
384-
var id = wallet["id"]
385-
var name = wallet["name"]
386-
get_wallet_balance(id)
387-
//href, wallet_name, wallet_description, wallet_amount
388-
var href = ""
389-
if (type == "STANDARD_WALLET") {
390-
href = "../wallet-dark.html"
391-
} else if (type == "RATE_LIMITED") {
392-
href = "../rl_wallet/rl_wallet.html"
393-
} else if (type == "COLOURED_COIN") {
394-
href = "../cc_wallet/cc_wallet.html"
395-
}
396-
397-
if (id == g_wallet_id) {
398-
new_innerHTML += create_side_wallet(id, href, name, type, 0, true)
399-
} else {
400-
new_innerHTML += create_side_wallet(id, href, name, type, 0, false)
401-
}
402-
403-
}
404-
new_innerHTML += create_wallet_button()
405-
wallets_tab.innerHTML = new_innerHTML
406-
}
407-
408403
function get_colour(id) {
409404
/*
410405
Sends websocket request to get the colour

electron-ui/renderer.js

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ function set_callbacks(socket) {
106106
var data = message["data"];
107107

108108
if (command == "start_server") {
109-
get_wallets();
109+
//get_wallets();
110+
get_wallet_summaries();
110111
get_transactions();
111112
get_wallet_balance(g_wallet_id);
112113
get_height_info();
@@ -131,6 +132,8 @@ function set_callbacks(socket) {
131132
get_sync_status_response(data)
132133
} else if (command == "get_wallets") {
133134
get_wallets_response(data)
135+
} else if (command == "get_wallet_summaries") {
136+
get_wallet_summaries_response(data)
134137
}
135138
});
136139

@@ -585,6 +588,66 @@ function get_wallets_response(data) {
585588
wallets_tab.innerHTML = new_innerHTML
586589
}
587590

591+
function get_wallet_summaries() {
592+
/*
593+
Sends websocket request to get wallet summaries
594+
*/
595+
data = {
596+
"info": "123",
597+
}
598+
599+
request = {
600+
"command": "get_wallet_summaries",
601+
"data": data
602+
}
603+
604+
json_data = JSON.stringify(request);
605+
ws.send(json_data);
606+
}
607+
608+
function get_wallet_summaries_response(data){
609+
// {id: {"type": type, "balance": balance, "name": name, "colour": colour}}
610+
// {id: {"type": type, "balance": balance}}
611+
console.log("reveived get_wallet_summaries")
612+
var new_innerHTML = ""
613+
for (var i in data) {
614+
var wallet = data[i];
615+
var type = wallet["type"]
616+
var id = i
617+
var name = wallet["type"]
618+
if (type=="STANDARD_WALLET"){
619+
name = "Chia Wallet"
620+
type = "Chia"
621+
} else if (name=="COLOURED_COIN") {
622+
name = "CC Wallet"
623+
type = wallet["name"]
624+
if (type.length > 20) {
625+
type = type.substring(0,20);
626+
type = type.concat("...")
627+
}
628+
}
629+
get_wallet_balance(id)
630+
//href, wallet_name, wallet_description, wallet_amount
631+
var href = ""
632+
if (type == "STANDARD_WALLET") {
633+
href = "../wallet-dark.html"
634+
} else if (type == "RATE_LIMITED") {
635+
href = "../rl_wallet/rl_wallet.html"
636+
} else if (type == "COLOURED_COIN") {
637+
href = "../cc_wallet/cc_wallet.html"
638+
}
639+
640+
if (id == g_wallet_id) {
641+
new_innerHTML += create_side_wallet(id, href, name, type, 0, true)
642+
} else {
643+
new_innerHTML += create_side_wallet(id, href, name, type, 0, false)
644+
}
645+
646+
}
647+
new_innerHTML += create_wallet_button()
648+
wallets_tab.innerHTML = new_innerHTML
649+
}
650+
588651
function clean_table() {
589652
while (table.rows.length > 0) {
590653
table.deleteRow(0);

0 commit comments

Comments
 (0)