fix(auth): refresh home listings after login and auto-focus login input
This commit is contained in:
@@ -32,6 +32,12 @@ class AuthModal extends HTMLElement {
|
|||||||
this.hidden = false
|
this.hidden = false
|
||||||
this.render()
|
this.render()
|
||||||
document.body.style.overflow = 'hidden'
|
document.body.style.overflow = 'hidden'
|
||||||
|
|
||||||
|
// Focus on input after render
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
const input = this.querySelector('#uuid')
|
||||||
|
if (input) input.focus()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
hide() {
|
hide() {
|
||||||
|
|||||||
@@ -299,14 +299,14 @@ style.textContent = /* css */`
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: var(--space-sm);
|
top: var(--space-sm);
|
||||||
left: var(--space-sm);
|
left: var(--space-sm);
|
||||||
width: 28px;
|
width: 36px;
|
||||||
height: 28px;
|
height: 36px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
background: var(--color-bg);
|
background: var(--color-bg);
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: var(--radius-sm);
|
border-radius: var(--radius-full);
|
||||||
box-shadow: var(--shadow-sm);
|
box-shadow: var(--shadow-sm);
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
color: var(--color-text-muted);
|
color: var(--color-text-muted);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { t, i18n } from '../../i18n.js'
|
|||||||
import { listingsService } from '../../services/listings.js'
|
import { listingsService } from '../../services/listings.js'
|
||||||
import { directus } from '../../services/directus.js'
|
import { directus } from '../../services/directus.js'
|
||||||
import { locationsService } from '../../services/locations.js'
|
import { locationsService } from '../../services/locations.js'
|
||||||
|
import { auth } from '../../services/auth.js'
|
||||||
import '../listing-card.js'
|
import '../listing-card.js'
|
||||||
import '../skeleton-card.js'
|
import '../skeleton-card.js'
|
||||||
import '../search-box.js'
|
import '../search-box.js'
|
||||||
@@ -38,6 +39,14 @@ class PageHome extends HTMLElement {
|
|||||||
this.render()
|
this.render()
|
||||||
this.setupEventListeners()
|
this.setupEventListeners()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Re-render listings on auth change to show owner badges
|
||||||
|
this.authUnsubscribe = auth.subscribe(() => {
|
||||||
|
const container = this.querySelector('#listings-container')
|
||||||
|
if (container) {
|
||||||
|
container.innerHTML = this.renderListings()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Listen for URL changes (back/forward navigation)
|
// Listen for URL changes (back/forward navigation)
|
||||||
window.addEventListener('hashchange', this.handleHashChange.bind(this))
|
window.addEventListener('hashchange', this.handleHashChange.bind(this))
|
||||||
@@ -45,6 +54,7 @@ class PageHome extends HTMLElement {
|
|||||||
|
|
||||||
disconnectedCallback() {
|
disconnectedCallback() {
|
||||||
if (this.unsubscribe) this.unsubscribe()
|
if (this.unsubscribe) this.unsubscribe()
|
||||||
|
if (this.authUnsubscribe) this.authUnsubscribe()
|
||||||
window.removeEventListener('hashchange', this.handleHashChange.bind(this))
|
window.removeEventListener('hashchange', this.handleHashChange.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user