v0.12.25 FCM bug fixes
This commit is contained in:
@@ -211,7 +211,8 @@ function PushDebugTab() {
|
||||
const [testing, setTesting] = useState(false);
|
||||
|
||||
const permission = (typeof Notification !== 'undefined') ? Notification.permission : 'unsupported';
|
||||
const cachedToken = localStorage.getItem('rc_fcm_token');
|
||||
const [cachedToken, setCachedToken] = useState(localStorage.getItem('rc_fcm_token'));
|
||||
const [lastError, setLastError] = useState(localStorage.getItem('rc_fcm_error'));
|
||||
|
||||
const load = async () => {
|
||||
setLoading(true);
|
||||
@@ -245,9 +246,21 @@ function PushDebugTab() {
|
||||
|
||||
const clearToken = () => {
|
||||
localStorage.removeItem('rc_fcm_token');
|
||||
localStorage.removeItem('rc_fcm_error');
|
||||
setCachedToken(null);
|
||||
setLastError(null);
|
||||
toast('Cached token cleared — reload to re-register with server', 'info');
|
||||
};
|
||||
|
||||
const reregister = () => {
|
||||
localStorage.removeItem('rc_fcm_token');
|
||||
localStorage.removeItem('rc_fcm_error');
|
||||
setCachedToken(null);
|
||||
setLastError(null);
|
||||
window.dispatchEvent(new CustomEvent('rosterchirp:push-init'));
|
||||
toast('Re-registering push subscription…', 'info');
|
||||
};
|
||||
|
||||
const box = { background: 'var(--surface-variant)', border: '1px solid var(--border)', borderRadius: 'var(--radius)', padding: '12px 14px', marginBottom: 14 };
|
||||
const sectionLabel = { fontSize: 11, fontWeight: 600, color: 'var(--text-tertiary)', textTransform: 'uppercase', letterSpacing: '0.5px', marginBottom: 8 };
|
||||
|
||||
@@ -263,8 +276,12 @@ function PushDebugTab() {
|
||||
<DebugRow label="Cached FCM token" value={cachedToken ? cachedToken.slice(0, 36) + '…' : 'None'} ok={!!cachedToken} bad={!cachedToken} />
|
||||
{debugData && <DebugRow label="FCM env vars" value={debugData.fcmConfigured ? 'Present' : 'Missing'} ok={debugData.fcmConfigured} bad={!debugData.fcmConfigured} />}
|
||||
{debugData && <DebugRow label="Firebase Admin" value={debugData.firebaseAdminReady ? 'Ready' : 'Not ready'} ok={debugData.firebaseAdminReady} bad={!debugData.firebaseAdminReady} />}
|
||||
{lastError && <DebugRow label="Last reg. error" value={lastError} bad={true} />}
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
|
||||
<button className="btn btn-sm btn-primary" onClick={reregister}>Re-register</button>
|
||||
<button className="btn btn-sm btn-secondary" onClick={clearToken}>Clear cached token</button>
|
||||
</div>
|
||||
<button className="btn btn-sm btn-secondary" onClick={clearToken}>Clear cached token</button>
|
||||
</div>
|
||||
|
||||
{/* Test push */}
|
||||
|
||||
Reference in New Issue
Block a user