Skip to content

Commit d5a84fc

Browse files
committed
Add colors for trust levels
Green for highest trust Orange for middle trust Red for lowest trust
1 parent f23b763 commit d5a84fc

4 files changed

Lines changed: 32 additions & 9 deletions

File tree

android/tinySSB/app/src/main/assets/web/prod/contacts.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,20 @@ function show_contact_details(id) {
153153
}
154154
var c = tremola.contacts[id];
155155
console.log(id);
156-
backend("contacts:getTrust " + decodeScuttlebuttId(id));
156+
backend("contacts:getTrust " + decodeScuttlebuttId(id));
157157

158158
new_contact_id = id;
159159
document.getElementById('old_contact_alias').value = c.alias ? c['alias'] : "";
160160
var details = '';
161-
var details = '';
162161
details += '<br><div>IAM-Alias: &nbsp;' + (c.iam != "" ? c.iam : "&mdash;") + '</div>\n';
163162
details += '<br><div>Shortname: &nbsp;' + id2b32(id) + '</div>\n';
164163
details += '<br><div style="word-break: break-all;">SSB identity: &nbsp;<tt>' + id + '</tt></div>\n';
165164
details += '<br><div class=settings style="padding: 0px;"><div class=settingsText>Forget this contact</div><div style="float: right;"><label class="switch"><input id="hide_contact" type="checkbox" onchange="toggle_forget_contact(this);"><span class="slider round"></span></label></div></div>'
166165

167-
// Add slider, values below it, and the set button next to the slider
166+
// Add slider with colored gradient
168167
details += '<br><div>Trust Level:</div>\n';
169168
details += '<div style="display: flex; align-items: center;">';
170-
details += '<input type="range" id="slider" min="0" max="2" step="1" value="' + c['trusted'] + '" style="flex: 1; margin-right: 10px;">\n';
169+
details += '<input type="range" id="slider" min="0" max="2" step="1" value="' + c['trusted'] + '" style="flex: 1; margin-right: 10px; appearance: none; -webkit-appearance: none; background: linear-gradient(to right, red 0%, orange 50%, green 100%); height: 8px; border-radius: 5px;">';
171170
details += '<button id="setButton" style="flex: 0;">Set</button>\n';
172171
details += '</div>';
173172

@@ -200,7 +199,6 @@ function show_contact_details(id) {
200199
errorMessage.textContent = ''; // Clear any previous errors
201200
handleSetValue(sliderValue); // Call the function with slider value
202201
closeOverlay();
203-
204202
}
205203
}
206204

@@ -217,6 +215,7 @@ function show_contact_details(id) {
217215
overlayIsActive = true;
218216
}
219217

218+
220219
function changeTrustLevel(contactID, value) {
221220
console.log("Supposed to set contact " + contactID + "'s Trust Level to " + value);
222221
let ch = tremola.chats[recps2nm([myId])];

android/tinySSB/app/src/main/assets/web/tremola.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,5 +589,26 @@ input:checked + .slider:before {
589589
filter: invert(62%) sepia(8%) saturate(116%) hue-rotate(145deg) brightness(89%) contrast(89%);
590590
}
591591

592+
.circle {
593+
display: inline-block;
594+
width: 10px;
595+
height: 10px;
596+
border-radius: 50%;
597+
margin-right: 5px;
598+
}
599+
600+
.green {
601+
background-color: green;
602+
}
603+
604+
.orange {
605+
background-color: orange;
606+
}
607+
608+
.red {
609+
background-color: red;
610+
}
611+
612+
592613

593614
/* eof */

android/tinySSB/app/src/main/assets/web/tremola.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@
8686
<div id='lst:games' class='w100 coreScroll' style='display: none;'></div>
8787
<div id='lst:contacts' class='w100 coreScroll' style="display: none;">
8888
<div id='lst:contacts-trustLevelTwo-overview'>
89-
<h3>Verified Contacts</h3>
89+
<h3><span class="circle green"></span> Verified Contacts</h3>
9090
<div id='lst:contacts-trustLevelTwo' class='w100 contactScroll'></div>
9191
</div>
9292
<div id='lst:contacts-trustLevelOne-overview'>
93-
<h3>Trusted Contacts</h3>
93+
<h3><span class="circle orange"></span> Trusted Contacts</h3>
9494
<div id='lst:contacts-trustLevelOne' class='w100 contactScroll'></div>
9595
</div>
9696

9797
<div id='lst:contacts-trustLevelZero-overview'>
98-
<h3>Other Contacts</h3>
98+
<h3><span class="circle red"></span> Other Contacts</h3>
9999
<div id='lst:contacts-trustLevelZero' class='w100 contactScroll'></div>
100100
</div>
101101
</div>

android/tinySSB/app/src/main/assets/web/tremola_ui.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,10 @@ function qr_scan_success(s) {
443443
if (tremola.contacts[new_contact_id].trusted < 2) {
444444
//do this in the backend as well
445445
let ch = tremola.chats[recps2nm([myId])];
446-
let tips = JSON.stringify(ch.timeline.get_tips())
446+
let tips = JSON.stringify([])
447+
if (typeof ch.timeline.get_tips === 'function') {
448+
tips = JSON.stringify(ch.timeline.get_tips())
449+
}
447450
backend("contacts:setTrust " + decodeScuttlebuttId(new_contact_id) + " 2" + " " + tips);
448451
} else {
449452
launch_snackbar("This contact already exists");

0 commit comments

Comments
 (0)