Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit e4cd843

Browse files
authored
Merge pull request #82 from JSKitty/master
v0.1.7 - Expanded Profiles & Audio Bugfixes
2 parents e15b8c2 + 8d753b5 commit e4cd843

File tree

8 files changed

+326
-39
lines changed

8 files changed

+326
-39
lines changed

src-tauri/src/profile.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ pub async fn load_profile(npub: String) -> bool {
333333
}
334334

335335
#[tauri::command]
336-
pub async fn update_profile(name: String, avatar: String) -> bool {
336+
pub async fn update_profile(name: String, avatar: String, banner: String) -> bool {
337337
let client = NOSTR_CLIENT.get().expect("Nostr client not initialized");
338338

339339
// Grab our pubkey
@@ -366,6 +366,18 @@ pub async fn update_profile(name: String, avatar: String) -> bool {
366366
);
367367
}
368368

369+
// Optional banner
370+
if !banner.is_empty() || !profile.banner.is_empty() {
371+
meta = meta.banner(
372+
Url::parse(if banner.is_empty() {
373+
profile.banner.as_str()
374+
} else {
375+
banner.as_str()
376+
})
377+
.unwrap(),
378+
);
379+
}
380+
369381
// Add display_name
370382
if !profile.display_name.is_empty() {
371383
meta = meta.display_name(&profile.display_name);

src-tauri/src/util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ pub fn get_file_type_description(extension: &str) -> String {
6262
// Audio
6363
map.insert("wav", "Voice Message");
6464
map.insert("mp3", "Audio Clip");
65+
map.insert("m4a", "Audio Clip");
66+
map.insert("aac", "Audio Clip");
67+
map.insert("flac", "Audio Clip");
68+
map.insert("ogg", "Audio Clip");
6569

6670
// Videos
6771
map.insert("mp4", "Video");

src/icons/user-circle.svg

Lines changed: 3 additions & 0 deletions
Loading

src/index.html

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ <h2 id="popupTitle"></h2>
3838
<div id="emoji-results"></div>
3939
</div>
4040

41+
<div id="profile" class="chats" style="display: none;">
42+
<div style="height: 60px; background-color: #161616;">
43+
<div id="profile-back-btn" class="btn nav-back-btn">
44+
<span class="icon icon-chevron-double-left nav-icon"></span>
45+
</div>
46+
<div>
47+
<h3 id="profile-name" class="chat-contact-with-status btn"></h3>
48+
<span id="profile-status" class="cutoff chat-contact-status btn" style="font-style: normal;"></span>
49+
</div>
50+
</div>
51+
<div>
52+
<img id="profile-banner" class="profile-banner">
53+
<img id="profile-avatar" class="profile-avatar btn">
54+
</div>
55+
<div>
56+
<h3 id="profile-secondary-name" class="chat-contact-with-status btn"></h3>
57+
<span id="profile-secondary-status" class="cutoff chat-contact-status btn" style="font-style: normal; width: 90%;"></span>
58+
<div id="profile-badge-list" style="height: 50px;"></div>
59+
<span id="profile-description" class="chat-contact-status" style="width: 90%; white-space: pre-line; overflow-y: auto; height: 225px;"></span>
60+
</div>
61+
</div>
62+
4163
<div id="chats" class="chats">
4264
<div id="chat-bookmarks-btn" class="btn chat-bookmarks-btn" style="display: none;">
4365
<span class="icon icon-bookmark nav-icon"></span>
@@ -56,7 +78,7 @@ <h2 id="popupTitle"></h2>
5678
<span class="icon icon-chevron-double-left nav-icon"></span>
5779
</div>
5880
<h3 id="chat-contact"></h3>
59-
<span class="cutoff" id="chat-contact-status"></span>
81+
<span class="cutoff chat-contact-status" id="chat-contact-status"></span>
6082
<div id="msg-top-fade" class="fadeout-top-msgs"></div>
6183
<div id="chat-messages" class="chat-messages">
6284

@@ -83,7 +105,7 @@ <h3 id="chat-contact"></h3>
83105

84106
<div id="chat-new" style="display: none;">
85107
<div class="chat-new-header">
86-
<div id="chat-new-back-btn" class="btn chat-new-back-btn">
108+
<div id="chat-new-back-text-btn" class="btn chat-new-back-text-btn">
87109
<span class="icon icon-chevron-double-left nav-icon"></span>
88110
<p class="chat-new-back-text">Back</p>
89111
</div>
@@ -168,6 +190,10 @@ <h2 class="danger-title">Dangerzone</h2>
168190
</div>
169191

170192
<div id="navbar" class="row navbar" style="display: none;">
193+
<div id="profile-btn" class="btn navbar-btn navbar-btn-inactive">
194+
<span class="icon icon-user-circle navbar-icon"></span>
195+
<p class="navbar-text">Profile</p>
196+
</div>
171197
<div id="chat-btn" class="btn navbar-btn">
172198
<span class="icon icon-chats navbar-icon"></span>
173199
<p class="navbar-text">Chat</p>

src/js/misc.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22
* Generate a consistent Gradient Avatar from an npub
33
* @param {string} npub - The npub to generate an avatar for
44
* @param {string} username - A username to display initials from
5+
* @param {number} limitSizeTo - An optional pixel width/height to lock the avatar to
56
*/
6-
function pubkeyToAvatar(npub, username) {
7+
function pubkeyToAvatar(npub, username, limitSizeTo = 0) {
78
// Otherwise, display their Gradient Avatar
89
const divAvatar = document.createElement('div');
910
divAvatar.classList.add('placeholder-avatar');
11+
if (limitSizeTo > 0) {
12+
divAvatar.style.minHeight = limitSizeTo + 'px';
13+
divAvatar.style.minWidth = limitSizeTo + 'px';
14+
divAvatar.style.maxHeight = limitSizeTo + 'px';
15+
divAvatar.style.maxWidth = limitSizeTo + 'px';
16+
}
1017

1118
// Convert the last three chars of their npub in to RGB HEX as a placeholder avatar
1219
const strLastChars = npub.slice(-3).padEnd(3, 'a');

src/js/settings.js

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class VoiceSettings {
2424
// Load our Settings from disk (or use a default value)
2525
const strModelID = await loadChosenWhisperModel() || this.selectedModel;
2626
this.autoTranslate = await loadWhisperAutoTranslate();
27+
this.autoTranscribe = await loadWhisperAutoTranscribe();
2728

2829
// Set initial toggle states (will be loaded from backend DB in future)
2930
document.getElementById('auto-translate-toggle').checked = this.autoTranslate;
@@ -407,10 +408,11 @@ async function askForUsername() {
407408
const cProfile = arrChats.find(a => a.mine);
408409
cProfile.name = strUsername;
409410
renderCurrentProfile(cProfile);
411+
if (domProfile.style.display === '') renderProfileTab(cProfile);
410412

411413
// Send out the metadata update
412414
try {
413-
await invoke("update_profile", { name: strUsername, avatar: "" });
415+
await invoke("update_profile", { name: strUsername, avatar: "", banner: "" });
414416
} catch (e) {
415417
await popupConfirm('Username Update Failed!', 'An error occurred while updating your Username, the change may not have committed to the network, you can re-try any time.', true);
416418
}
@@ -445,15 +447,55 @@ async function askForAvatar() {
445447
const cProfile = arrChats.find(a => a.mine);
446448
cProfile.avatar = strUploadURL;
447449
renderCurrentProfile(cProfile);
450+
if (domProfile.style.display === '') renderProfileTab(cProfile);
448451

449452
// Send out the metadata update
450453
try {
451-
await invoke("update_profile", { name: "", avatar: strUploadURL });
454+
await invoke("update_profile", { name: "", avatar: strUploadURL, banner: "" });
452455
} catch (e) {
453456
return await popupConfirm('Avatar Update Failed!', e, true);
454457
}
455458
}
456459

460+
/**
461+
* A GUI wrapper to ask the user for a banner URL, and apply it both
462+
* in-app and on the Nostr network.
463+
*/
464+
async function askForBanner() {
465+
// Prompt the user to select an image file
466+
const file = await open({
467+
title: 'Choose a Banner',
468+
multiple: false,
469+
directory: false,
470+
filters: [{
471+
name: 'Image',
472+
extensions: ['png', 'jpeg', 'jpg', 'gif', 'webp']
473+
}]
474+
});
475+
if (!file) return;
476+
477+
// Upload the banner to a NIP-96 server
478+
let strUploadURL = '';
479+
try {
480+
strUploadURL = await invoke("upload_avatar", { filepath: file });
481+
} catch (e) {
482+
return await popupConfirm('Banner Upload Failed!', e, true);
483+
}
484+
485+
// Display the change immediately
486+
const cProfile = arrChats.find(a => a.mine);
487+
cProfile.banner = strUploadURL;
488+
renderCurrentProfile(cProfile);
489+
if (domProfile.style.display === '') renderProfileTab(cProfile);
490+
491+
// Send out the metadata update
492+
try {
493+
await invoke("update_profile", { name: "", avatar: "", banner: strUploadURL });
494+
} catch (e) {
495+
return await popupConfirm('Banner Update Failed!', e, true);
496+
}
497+
}
498+
457499
/**
458500
* A GUI wrapper to ask the user for a status, and apply it both
459501
* in-app and on the Nostr network.
@@ -466,6 +508,7 @@ async function askForStatus() {
466508
const cProfile = arrChats.find(a => a.mine);
467509
cProfile.status.title = strStatus;
468510
renderCurrentProfile(cProfile);
511+
if (domProfile.style.display === '') renderProfileTab(cProfile);
469512

470513
// Send out the metadata update
471514
try {

0 commit comments

Comments
 (0)