diff --git a/app/templates/base.html b/app/templates/base.html
index 935cccf..8f69421 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -601,6 +601,40 @@
// ── Favorites tracking ──
favoriteIds: new Set([{% for p in favorite_pages %}'{{ p.id }}'{% if not loop.last %},{% endif %}{% endfor %}]),
+
+ refreshFavorites() {
+ const self = this;
+ fetch('/api/library/favorites', {credentials:'same-origin'})
+ .then(r => r.json())
+ .then(data => {
+ const items = data.items || [];
+ self.favoriteIds = new Set(items.map(i => i.id));
+ const favList = document.querySelector('.sidebar-items[data-section="favorites"]');
+ if (!favList) return;
+ if (items.length === 0) {
+ favList.innerHTML = '
';
+ } else {
+ favList.innerHTML = items.map(function(item) {
+ const icon = item.icon || '📄';
+ const name = (item.title || 'Untitled');
+ const safeName = name.replace(/'/g, "\\'").replace(/"/g, '"');
+ const url = item.url || ('/pages/' + item.id);
+ return '';
+ }).join('');
+ }
+ });
+ },
// ── Sections collapsible ──
sectionsOpen: (function() {
@@ -727,8 +761,7 @@
if (isFav) self.favoriteIds.delete(pageId);
else self.favoriteIds.add(pageId);
self.contextMenu.visible = false;
- // Reload to update sidebar
- location.reload();
+ self.refreshFavorites();
})
.catch(e => this.toast('Favorite action failed', 'error'));
break;
diff --git a/app/templates/page_editor.html b/app/templates/page_editor.html
index 7dc8ded..2abcb65 100644
--- a/app/templates/page_editor.html
+++ b/app/templates/page_editor.html
@@ -2,7 +2,7 @@
page_title %}{{ page.title }}{% endblock %} {% block topbar %}
{% set page_icon = "📄" if page.content_format != 'file' else "📎" %}
{% set page_title = page.title %}
-{% set right_actions = 'Edited ▾' %}
+{% set right_actions = 'Edited ▾' %}
{% include '_header.html' %}
{% endblock %} {% block content %}
@@ -686,7 +686,9 @@ page_title %}{{ page.title }}{% endblock %} {% block topbar %}
const csrf=document.cookie.match(/csrf_token=([^;]+)/);
const m=this.favorited?'DELETE':'POST';
fetch(`/board/api/favorites/${this.pid}`,{method:m,headers:{'X-CSRF-Token':csrf?csrf[1]:''}})
- .then(r=>r.json()).then(()=>{this.favorited=!this.favorited;this.showToast(this.favorited?'Added to favorites':'Removed from favorites');}).catch(()=>{this.showToast('Failed to toggle favorite');});
+ .then(r=>r.json()).then(()=>{this.favorited=!this.favorited;this.showToast(this.favorited?'Added to favorites':'Removed from favorites');
+ if(window.appState&&window.appState.refreshFavorites)window.appState.refreshFavorites();
+ }).catch(()=>{this.showToast('Failed to toggle favorite');});
},
toggleActivityOpen(){
if(!this.activityOpen){this.activityOpen=true;this._justOpened=true;setTimeout(()=>this._justOpened=false,200);}