@ -370,6 +370,9 @@
// Toggle state is already updated by bind:checked
// Toggle state is already updated by bind:checked
console.log("Toggle changed, showOnlyMyEvents:", showOnlyMyEvents);
console.log("Toggle changed, showOnlyMyEvents:", showOnlyMyEvents);
// Reset the attempt flag to allow reloading with new filter
hasAttemptedEventLoad = false;
// Reload events with the new filter
// Reload events with the new filter
const authors =
const authors =
showOnlyMyEvents & & isLoggedIn & & userPubkey ? [userPubkey] : null;
showOnlyMyEvents & & isLoggedIn & & userPubkey ? [userPubkey] : null;
@ -2088,11 +2091,12 @@
async function loadAllEvents(reset = false, authors = null) {
async function loadAllEvents(reset = false, authors = null) {
if (
if (
!isLoggedIn ||
!isLoggedIn ||
(userRole !== "write" & &
(userRole !== "read" & &
userRole !== "write" & &
userRole !== "admin" & &
userRole !== "admin" & &
userRole !== "owner")
userRole !== "owner")
) {
) {
alert("W rite, admin, or owner permission required");
alert("Read, w rite, admin, or owner permission required");
return;
return;
}
}
@ -2117,11 +2121,15 @@
authors,
authors,
"including delete events",
"including delete events",
);
);
// For reset, use current timestamp to get the most recent events
const untilTimestamp = reset
? Math.floor(Date.now() / 1000)
: oldestEventTimestamp;
const events = await fetchAllEvents({
const events = await fetchAllEvents({
limit: reset ? 100 : 200,
limit: reset ? 100 : 200,
until: reset
until: untilTimestamp,
? Math.floor(Date.now() / 1000)
: oldestEventTimestamp,
authors: authors,
authors: authors,
});
});
console.log("Received events:", events.length, "events");
console.log("Received events:", events.length, "events");
@ -2210,6 +2218,9 @@
}
}
// Load events when events tab is selected (only if no events loaded yet)
// Load events when events tab is selected (only if no events loaded yet)
// Track if we've already attempted to load events to prevent infinite loops
let hasAttemptedEventLoad = false;
$: if (
$: if (
selectedTab === "events" & &
selectedTab === "events" & &
isLoggedIn & &
isLoggedIn & &
@ -2217,12 +2228,23 @@
userRole === "write" ||
userRole === "write" ||
userRole === "admin" ||
userRole === "admin" ||
userRole === "owner") & &
userRole === "owner") & &
allEvents.length === 0
allEvents.length === 0 & &
!hasAttemptedEventLoad & &
!isLoadingEvents
) {
) {
hasAttemptedEventLoad = true;
const authors = showOnlyMyEvents & & userPubkey ? [userPubkey] : null;
const authors = showOnlyMyEvents & & userPubkey ? [userPubkey] : null;
loadAllEvents(true, authors);
loadAllEvents(true, authors);
}
}
// Reset the attempt flag when switching tabs or when showOnlyMyEvents changes
$: if (
selectedTab !== "events" ||
(selectedTab === "events" & & allEvents.length > 0)
) {
hasAttemptedEventLoad = false;
}
// NIP-98 authentication helper
// NIP-98 authentication helper
async function createNIP98AuthHeader(url, method) {
async function createNIP98AuthHeader(url, method) {
if (!isLoggedIn || !userPubkey) {
if (!isLoggedIn || !userPubkey) {
@ -2985,6 +3007,11 @@
{ /if }
{ /if }
{ :else if isLoggedIn && userPubkey }
{ :else if isLoggedIn && userPubkey }
< div class = "profile-loading-section" >
< div class = "profile-loading-section" >
<!-- Logout button in top - right corner -->
< button
class="logout-btn floating"
on:click={ handleLogout } >Log out< /button
>
< h3 > Profile Loading< / h3 >
< h3 > Profile Loading< / h3 >
< p > Your profile metadata is being loaded...< / p >
< p > Your profile metadata is being loaded...< / p >
< button
< button
@ -3370,6 +3397,7 @@
.profile-loading-section {
.profile-loading-section {
padding: 1rem;
padding: 1rem;
text-align: center;
text-align: center;
position: relative; /* Allow absolute positioning of floating logout button */
}
}
.profile-loading-section h3 {
.profile-loading-section h3 {