Skip to content

Commit

Permalink
add default name option if only pubkey
Browse files Browse the repository at this point in the history
  • Loading branch information
bitkarrot committed Jul 10, 2024
1 parent a7469cd commit 81cd140
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion public/js/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ document.addEventListener('DOMContentLoaded', function () {
let checkInterval = null;
// checkInterval = setInterval(checkUserInfo, 1000);
let cycleCount = 0;
const maxCycles = 24; // 240 cycles, 120 seconds = 2 minutes to login with Nostr before redirecting to Home Page
const maxCycles = 360; // 240 cycles, 120 seconds = 2 minutes to login with Nostr before redirecting to Home Page


// helper methods
Expand Down Expand Up @@ -516,6 +516,13 @@ async function loadUser() {
window.localStorage.peer_name = user.name;
window.localStorage.peer_url = user.picture;
window.localStorage.peer_npub = peer_npub;

if (user.name === undefined) {
// offer to set a username as the first 7 chars of the pubkey
peer_name = truncateString(user.pubkey + "...", 10);
window.localStorage.peer_name = peer_name;
}

} else {
console.log("No user info available (empty array)");
}
Expand Down Expand Up @@ -594,6 +601,12 @@ function checkUserInfo() {
// we are assuming peer_name exists. if not, then we need to offer
// option to set a username after 60 sec period of checking and no username

if (user.name === undefined) {
// offer to set a username as the first 7 chars of the pubkey
peer_name = truncateString(user.pubkey + "...", 10);
window.localStorage.peer_name = peer_name;
}

if (peer_name && peer_pubkey) {
console.log("discovery complete: checkUserInfo: ", peer_name, peer_pubkey, peer_url);

Expand Down
2 changes: 1 addition & 1 deletion public/views/commit_hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7b12c2902e940c16e0af7b58ecdbdb887bec9998
a7469cd339dc7b3b3f733c1913916476423db5d7

0 comments on commit 81cd140

Please sign in to comment.