Browse Source

remove theme button from bar

Nostr-Signature: fc758a0681c072108b196911bbeee6d49df1efe635d5d78427b7874be4d6e657 573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc 6c0e991e960a29c623c936ab2a31478a85907780eda692c035762deabc740ca0a76df113f5ce853a6d839b023e2b483ce2d7686c40b91c4cea5f32945799a31f
main
Silberengel 3 weeks ago
parent
commit
397e2bbc65
  1. 1
      nostr/commit-signatures.jsonl
  2. 2
      src/lib/components/NavBar.svelte
  3. 101
      src/lib/components/SettingsModal.svelte

1
nostr/commit-signatures.jsonl

@ -20,3 +20,4 @@
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771587832,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","implemented IndexedDB to organize the persistent event cache\nbackground deletion removal\ncorrected and expanded search and added cancel button\nshow maintainers on the search result cards\nremove code search\nremoved hard-coded theme classes"]],"content":"Signed commit: implemented IndexedDB to organize the persistent event cache\nbackground deletion removal\ncorrected and expanded search and added cancel button\nshow maintainers on the search result cards\nremove code search\nremoved hard-coded theme classes","id":"8080f3cad9abacfc9a5fe08bc26744ff8444d0228ea8a6e8a449c8c2704885d6","sig":"70120c99f5e8a1e9df6d74af756a51641c4998265b9233d5a7d187d9e21302dc6377ae274b07be4d6515af1dabfada43fa9af1a087a34e2879b028ac34e551ca"} {"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771587832,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","implemented IndexedDB to organize the persistent event cache\nbackground deletion removal\ncorrected and expanded search and added cancel button\nshow maintainers on the search result cards\nremove code search\nremoved hard-coded theme classes"]],"content":"Signed commit: implemented IndexedDB to organize the persistent event cache\nbackground deletion removal\ncorrected and expanded search and added cancel button\nshow maintainers on the search result cards\nremove code search\nremoved hard-coded theme classes","id":"8080f3cad9abacfc9a5fe08bc26744ff8444d0228ea8a6e8a449c8c2704885d6","sig":"70120c99f5e8a1e9df6d74af756a51641c4998265b9233d5a7d187d9e21302dc6377ae274b07be4d6515af1dabfada43fa9af1a087a34e2879b028ac34e551ca"}
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771604372,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","bug-fixes"]],"content":"Signed commit: bug-fixes","id":"9a1ba983e0b0db8cff3675a078a376df5c9ad351c3988ea893f3e8084a65a1e6","sig":"724a326cbd6a33f1ff6a2c37b242c7571e35149281609e9eb1c6a197422a13834d9ac2f5d0719026bc66126bd0022df49adf50aa08af93dd95076f407b0f0456"} {"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771604372,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","bug-fixes"]],"content":"Signed commit: bug-fixes","id":"9a1ba983e0b0db8cff3675a078a376df5c9ad351c3988ea893f3e8084a65a1e6","sig":"724a326cbd6a33f1ff6a2c37b242c7571e35149281609e9eb1c6a197422a13834d9ac2f5d0719026bc66126bd0022df49adf50aa08af93dd95076f407b0f0456"}
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771607520,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","bug-fixes"]],"content":"Signed commit: bug-fixes","id":"2040e0adbed520ee9a21c6a1c7df48fae27021c1d3474b584388cd5ddafc6a49","sig":"893b4881e3876c0f556e3be991e9c6e99c9f5933bc9755e4075c1d0bfea95750b2318f3d3409d689c7e9a862cf053db0e7d3083ee28cf48ffbe794583c3ad783"} {"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771607520,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","bug-fixes"]],"content":"Signed commit: bug-fixes","id":"2040e0adbed520ee9a21c6a1c7df48fae27021c1d3474b584388cd5ddafc6a49","sig":"893b4881e3876c0f556e3be991e9c6e99c9f5933bc9755e4075c1d0bfea95750b2318f3d3409d689c7e9a862cf053db0e7d3083ee28cf48ffbe794583c3ad783"}
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771612082,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","harmonize user.name and user.email\nadd settings menu\nautosave OFF 10 min"]],"content":"Signed commit: harmonize user.name and user.email\nadd settings menu\nautosave OFF 10 min","id":"80834df600e5ad22f44fc26880333d28054895b7b5fde984921fab008a27ce6d","sig":"41991d089d26e3f90094dcebd1dee7504c59cadd0ea2f4dfe8693106d9000a528157fb905aec9001e0b8f3ef9e8590557f3df6961106859775d9416b546a44c0"}

2
src/lib/components/NavBar.svelte

@ -3,7 +3,6 @@
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { getPublicKeyWithNIP07, isNIP07Available } from '../services/nostr/nip07-signer.js'; import { getPublicKeyWithNIP07, isNIP07Available } from '../services/nostr/nip07-signer.js';
import { nip19 } from 'nostr-tools'; import { nip19 } from 'nostr-tools';
import ThemeToggle from './ThemeToggle.svelte';
import SettingsButton from './SettingsButton.svelte'; import SettingsButton from './SettingsButton.svelte';
import UserBadge from './UserBadge.svelte'; import UserBadge from './UserBadge.svelte';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
@ -229,7 +228,6 @@
</nav> </nav>
<div class="auth-section"> <div class="auth-section">
<SettingsButton /> <SettingsButton />
<ThemeToggle />
{#if userPubkey} {#if userPubkey}
{@const userNpub = (() => { {@const userNpub = (() => {
try { try {

101
src/lib/components/SettingsModal.svelte

@ -1,6 +1,9 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { settingsStore } from '../services/settings-store.js'; import { settingsStore } from '../services/settings-store.js';
import { userStore } from '../stores/user-store.js';
import { fetchUserEmail, fetchUserName, fetchUserProfile, extractProfileData, getUserName, getUserEmail } from '../utils/user-profile.js';
import { DEFAULT_NOSTR_RELAYS } from '../config.js';
interface Props { interface Props {
isOpen: boolean; isOpen: boolean;
@ -15,14 +18,15 @@
let theme = $state<'gitrepublic-light' | 'gitrepublic-dark' | 'gitrepublic-black'>('gitrepublic-dark'); let theme = $state<'gitrepublic-light' | 'gitrepublic-dark' | 'gitrepublic-black'>('gitrepublic-dark');
let loading = $state(true); let loading = $state(true);
let saving = $state(false); let saving = $state(false);
let loadingPresets = $state(false);
// Get default git user name and email (from git config if available) // Preset values that will be used if user doesn't override
let defaultUserName = $state(''); let presetUserName = $state('');
let defaultUserEmail = $state(''); let presetUserEmail = $state('');
onMount(async () => { onMount(async () => {
await loadSettings(); await loadSettings();
await loadGitDefaults(); await loadPresets();
}); });
async function loadSettings() { async function loadSettings() {
@ -40,21 +44,53 @@
} }
} }
async function loadGitDefaults() { async function loadPresets() {
// Try to get git config defaults from the server // Get user's pubkey from store
// This would require a new API endpoint, but for now we'll just use empty strings const currentUser = $userStore;
// The user can manually enter their git config values if (!currentUser.userPubkeyHex) {
defaultUserName = ''; // User not logged in, no presets available
defaultUserEmail = ''; presetUserName = '';
presetUserEmail = '';
return;
}
loadingPresets = true;
try {
// Fetch profile from kind 0 event (cache or relays)
const profileEvent = await fetchUserProfile(currentUser.userPubkeyHex, DEFAULT_NOSTR_RELAYS);
const profile = extractProfileData(profileEvent);
// Get preset values using the same fallback logic as the commit functions
presetUserName = getUserName(profile, currentUser.userPubkeyHex, currentUser.userPubkey || undefined);
presetUserEmail = getUserEmail(profile, currentUser.userPubkeyHex, currentUser.userPubkey || undefined);
} catch (err) {
console.warn('Failed to load presets from profile:', err);
// Fallback to shortened npub values
if (currentUser.userPubkey) {
presetUserName = currentUser.userPubkey.substring(0, 20);
presetUserEmail = `${currentUser.userPubkey.substring(0, 20)}@gitrepublic.web`;
} else if (currentUser.userPubkeyHex) {
const { nip19 } = await import('nostr-tools');
const npub = nip19.npubEncode(currentUser.userPubkeyHex);
presetUserName = npub.substring(0, 20);
presetUserEmail = `${npub.substring(0, 20)}@gitrepublic.web`;
} else {
presetUserName = '';
presetUserEmail = '';
}
} finally {
loadingPresets = false;
}
} }
async function saveSettings() { async function saveSettings() {
saving = true; saving = true;
try { try {
// Save empty string if user wants to use presets, otherwise save the custom value
await settingsStore.updateSettings({ await settingsStore.updateSettings({
autoSave, autoSave,
userName: userName.trim(), userName: userName.trim() || '', // Empty string means use preset
userEmail: userEmail.trim(), userEmail: userEmail.trim() || '', // Empty string means use preset
theme theme
}); });
@ -96,12 +132,19 @@
$effect(() => { $effect(() => {
if (isOpen) { if (isOpen) {
loadSettings(); loadSettings();
loadPresets();
} }
}); });
</script> </script>
{#if isOpen} {#if isOpen}
<div class="modal-overlay" onclick={(e) => e.target === e.currentTarget && onClose()}> <div
class="modal-overlay"
role="button"
tabindex="0"
onclick={(e) => e.target === e.currentTarget && onClose()}
onkeydown={(e) => e.key === 'Escape' && onClose()}
>
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h2>Settings</h2> <h2>Settings</h2>
@ -144,14 +187,20 @@
type="text" type="text"
id="user-name" id="user-name"
bind:value={userName} bind:value={userName}
placeholder={defaultUserName || 'Enter your git user.name'} placeholder={presetUserName || 'Enter your git user.name'}
class="setting-input" class="setting-input"
/> />
{#if defaultUserName} {#if presetUserName}
<p class="setting-hint">Default: {defaultUserName}</p> <p class="setting-hint">
{#if userName.trim()}
Custom value saved. Default would be: {presetUserName}
{:else}
Will use: <strong>{presetUserName}</strong> (from your Nostr profile: display_name → name → shortened npub)
{/if}
</p>
{/if} {/if}
<p class="setting-description"> <p class="setting-description">
Your name as it will appear in git commits. Your name as it will appear in git commits. Leave empty to use the preset value from your Nostr profile.
</p> </p>
</div> </div>
@ -164,22 +213,28 @@
type="email" type="email"
id="user-email" id="user-email"
bind:value={userEmail} bind:value={userEmail}
placeholder={defaultUserEmail || 'Enter your git user.email'} placeholder={presetUserEmail || 'Enter your git user.email'}
class="setting-input" class="setting-input"
/> />
{#if defaultUserEmail} {#if presetUserEmail}
<p class="setting-hint">Default: {defaultUserEmail}</p> <p class="setting-hint">
{#if userEmail.trim()}
Custom value saved. Default would be: {presetUserEmail}
{:else}
Will use: <strong>{presetUserEmail}</strong> (from your Nostr profile: NIP-05 → shortenednpub@gitrepublic.web)
{/if}
</p>
{/if} {/if}
<p class="setting-description"> <p class="setting-description">
Your email as it will appear in git commits. Your email as it will appear in git commits. Leave empty to use the preset value from your Nostr profile.
</p> </p>
</div> </div>
<!-- Theme Selector --> <!-- Theme Selector -->
<div class="setting-group"> <div class="setting-group">
<label class="setting-label"> <div class="setting-label">
<span class="label-text">Theme</span> <span class="label-text">Theme</span>
</label> </div>
<div class="theme-options"> <div class="theme-options">
<button <button
class="theme-option" class="theme-option"

Loading…
Cancel
Save