Fix: friends.js Auth-Guards für nicht eingeloggte User
This commit is contained in:
parent
44fcb9bc16
commit
21e50c6c7b
4 changed files with 22 additions and 8 deletions
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
||||||
<link rel="stylesheet" href="/css/design-system.css">
|
<link rel="stylesheet" href="/css/design-system.css">
|
||||||
<link rel="stylesheet" href="/css/layout.css?v=80">
|
<link rel="stylesheet" href="/css/layout.css?v=81">
|
||||||
<link rel="stylesheet" href="/css/components.css?v=80">
|
<link rel="stylesheet" href="/css/components.css?v=81">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
@ -269,9 +269,9 @@
|
||||||
<div id="modal-container"></div>
|
<div id="modal-container"></div>
|
||||||
|
|
||||||
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
|
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
|
||||||
<script src="/js/api.js?v=80"></script>
|
<script src="/js/api.js?v=81"></script>
|
||||||
<script src="/js/ui.js?v=80"></script>
|
<script src="/js/ui.js?v=81"></script>
|
||||||
<script src="/js/app.js?v=80"></script>
|
<script src="/js/app.js?v=81"></script>
|
||||||
|
|
||||||
<!-- Feature-Seiten werden lazy geladen -->
|
<!-- Feature-Seiten werden lazy geladen -->
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Router, State-Management, Navigation, Initialisierung.
|
Router, State-Management, Navigation, Initialisierung.
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const APP_VER = '80'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
const APP_VER = '81'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||||
|
|
||||||
const App = (() => {
|
const App = (() => {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,16 @@ window.Page_friends = (() => {
|
||||||
// HAUPT-RENDER
|
// HAUPT-RENDER
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
function _render(prefill = null) {
|
function _render(prefill = null) {
|
||||||
|
if (!_appState.user) {
|
||||||
|
_container.innerHTML = UI.emptyState({
|
||||||
|
icon: UI.icon('users'),
|
||||||
|
title: 'Anmelden erforderlich',
|
||||||
|
text: 'Melde dich an, um Freunde zu finden und Anfragen zu verwalten.',
|
||||||
|
action: `<button class="btn btn-primary" onclick="App.navigate('settings')">Anmelden</button>`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const myName = _appState?.user?.name || '';
|
const myName = _appState?.user?.name || '';
|
||||||
const myLink = `${location.origin}/#friends?suche=${encodeURIComponent(myName)}`;
|
const myLink = `${location.origin}/#friends?suche=${encodeURIComponent(myName)}`;
|
||||||
|
|
||||||
|
|
@ -147,13 +157,14 @@ window.Page_friends = (() => {
|
||||||
// DATEN LADEN
|
// DATEN LADEN
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
async function _loadFriends() {
|
async function _loadFriends() {
|
||||||
|
if (!_appState.user) return;
|
||||||
try {
|
try {
|
||||||
const data = await API.friends.list();
|
const data = await API.friends.list();
|
||||||
_renderIncoming(data.incoming || []);
|
_renderIncoming(data.incoming || []);
|
||||||
_renderOutgoing(data.outgoing || []);
|
_renderOutgoing(data.outgoing || []);
|
||||||
_renderFriends(data.friends || []);
|
_renderFriends(data.friends || []);
|
||||||
_updateBadge((data.incoming || []).length);
|
_updateBadge((data.incoming || []).length);
|
||||||
} catch { /* 401 wird vom Auth-Guard abgefangen */ }
|
} catch { /* silent — 401 bei abgemeldeter Session */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
function _updateBadge(count) {
|
function _updateBadge(count) {
|
||||||
|
|
@ -413,6 +424,7 @@ window.Page_friends = (() => {
|
||||||
// SUCHE
|
// SUCHE
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
async function _doSearch(q) {
|
async function _doSearch(q) {
|
||||||
|
if (!_appState.user) return;
|
||||||
const el = _container.querySelector('#fr-search-results');
|
const el = _container.querySelector('#fr-search-results');
|
||||||
try {
|
try {
|
||||||
const results = await API.friends.search(q);
|
const results = await API.friends.search(q);
|
||||||
|
|
@ -462,6 +474,7 @@ window.Page_friends = (() => {
|
||||||
// AKTIONEN
|
// AKTIONEN
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
async function _sendRequest(userId, btn) {
|
async function _sendRequest(userId, btn) {
|
||||||
|
if (!_appState.user) { App.navigate('settings'); return; }
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
btn.innerHTML = `<svg class="ph-icon"><use href="/icons/phosphor.svg#spinner"></use></svg>`;
|
btn.innerHTML = `<svg class="ph-icon"><use href="/icons/phosphor.svg#spinner"></use></svg>`;
|
||||||
try {
|
try {
|
||||||
|
|
@ -514,6 +527,7 @@ window.Page_friends = (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function _openChat(userId) {
|
async function _openChat(userId) {
|
||||||
|
if (!_appState.user) { App.navigate('settings'); return; }
|
||||||
try {
|
try {
|
||||||
const { conversation_id } = await API.chat.start(userId);
|
const { conversation_id } = await API.chat.start(userId);
|
||||||
App.navigate('chat', true, { conversation_id });
|
App.navigate('chat', true, { conversation_id });
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Offline-Cache + Push Notifications + Tile-Cache
|
Offline-Cache + Push Notifications + Tile-Cache
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const CACHE_VERSION = 'by-v104';
|
const CACHE_VERSION = 'by-v105';
|
||||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue