fix: purge stale 1-tap mobile pins, make remove pin button bold and prominent, and bust service worker cache

This commit is contained in:
2026-09-12 09:18:33 -07:00
parent 872be94476
commit 2bd6ebe302
4 changed files with 69 additions and 25 deletions
+15 -6
View File
@@ -28,7 +28,7 @@
<meta name="apple-mobile-web-app-title" content="FlockRadar"> <meta name="apple-mobile-web-app-title" content="FlockRadar">
<!-- Main Stylesheet --> <!-- Main Stylesheet -->
<link rel="stylesheet" href="css/styles.css"> <link rel="stylesheet" href="css/styles.css?v=7">
</head> </head>
<body> <body>
@@ -942,10 +942,19 @@
<!-- Leaflet Map JS --> <!-- Leaflet Map JS -->
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script> <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<!-- Data & Application Logic --> <!-- Data & Application Logic with Cache Busting -->
<script src="data/portals.js"></script> <script src="data/portals.js?v=7"></script>
<script src="js/auth.js"></script> <script src="js/auth.js?v=7"></script>
<script src="js/radar.js"></script> <script src="js/radar.js?v=7"></script>
<script src="js/app.js"></script> <script src="js/app.js?v=7"></script>
<!-- Service Worker Instant Cache Invalidation -->
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(registrations => {
registrations.forEach(r => r.update());
});
}
</script>
</body> </body>
</html> </html>
+14 -2
View File
@@ -124,7 +124,13 @@
communityReports = JSON.parse(stored); communityReports = JSON.parse(stored);
// Automatically prune any unverified test marks or pins without photo proof // Automatically prune any unverified test marks or pins without photo proof
const beforeCount = communityReports.length; const beforeCount = communityReports.length;
communityReports = communityReports.filter(r => r && r.photoUrl && !r.id.startsWith('usr-pin-')); communityReports = communityReports.filter(r =>
r &&
r.photoUrl &&
!r.id.startsWith('usr-pin-') &&
r.notes !== '1-Tap Mobile Driver Pin' &&
r.type !== 'Fixed ALPR Camera'
);
if (communityReports.length !== beforeCount) { if (communityReports.length !== beforeCount) {
localStorage.setItem(STORAGE_KEY_REPORTS, JSON.stringify(communityReports)); localStorage.setItem(STORAGE_KEY_REPORTS, JSON.stringify(communityReports));
} }
@@ -138,7 +144,13 @@
function clearUnverifiedReports() { function clearUnverifiedReports() {
try { try {
communityReports = communityReports.filter(r => r && r.photoUrl && !r.id.startsWith('usr-pin-')); communityReports = communityReports.filter(r =>
r &&
r.photoUrl &&
!r.id.startsWith('usr-pin-') &&
r.notes !== '1-Tap Mobile Driver Pin' &&
r.type !== 'Fixed ALPR Camera'
);
localStorage.setItem(STORAGE_KEY_REPORTS, JSON.stringify(communityReports)); localStorage.setItem(STORAGE_KEY_REPORTS, JSON.stringify(communityReports));
Object.keys(cameraMetadata).forEach(id => { Object.keys(cameraMetadata).forEach(id => {
if (id.startsWith('usr-pin-') || !cameraMetadata[id].photoUrl) { if (id.startsWith('usr-pin-') || !cameraMetadata[id].photoUrl) {
+10 -5
View File
@@ -301,8 +301,12 @@
window.FlockAuth.clearUnverifiedReports(); window.FlockAuth.clearUnverifiedReports();
} }
// Filter out any unverified user pins // Filter out any unverified user pins or accidental test marks
allCameras = [...DEFAULT_CAMERAS].filter(c => !c.id.startsWith('usr-pin-')); allCameras = [...DEFAULT_CAMERAS].filter(c =>
!c.id.startsWith('usr-pin-') &&
c.notes !== '1-Tap Mobile Driver Pin' &&
c.name !== 'Community Report: Fixed ALPR Camera'
);
// Load crowdsourced reports from auth store (ONLY if photo verified!) // Load crowdsourced reports from auth store (ONLY if photo verified!)
if (window.FlockAuth) { if (window.FlockAuth) {
@@ -418,9 +422,10 @@
Inspect Agency Records & Sharing ↗ Inspect Agency Records & Sharing ↗
</button> </button>
` : ''} ` : ''}
${(cam.isCommunity || cam.id.startsWith('rpt-') || cam.id.startsWith('usr-pin-') || cam.id.startsWith('test-') || cam.id.startsWith('cam-test-')) ? ` ${(!cam.id.startsWith('portal-') && (cam.isCommunity || cam.id.startsWith('rpt-') || cam.id.startsWith('usr-pin-') || cam.id.startsWith('test-') || cam.id.startsWith('cam-test-') || cam.notes === '1-Tap Mobile Driver Pin' || cam.agency === 'Crowdsourced Report' || cam.name.includes('Community Report'))) ? `
<button class="popup-inspect-btn" style="background: rgba(239, 68, 68, 0.18); border: 1px solid #ef4444; color: #f87171;" onclick="window.adminDeleteCamera('${escapeHtml(cam.id)}')"> <button class="popup-inspect-btn popup-delete-btn" style="background: #dc2626 !important; color: #ffffff !important; font-weight: 800 !important; font-size: 0.88rem !important; padding: 10px 14px !important; border-radius: 6px !important; margin-top: 6px !important; display: flex !important; align-items: center !important; justify-content: center !important; gap: 8px !important; border: none !important; cursor: pointer !important; box-shadow: 0 3px 10px rgba(220, 38, 38, 0.45) !important;" onclick="window.adminDeleteCamera('${escapeHtml(cam.id)}')">
🗑️ Admin: Delete Placed Pin <span style="font-size: 1rem;">🗑️</span>
<span>REMOVE THIS PIN (ADMIN)</span>
</button> </button>
` : ''} ` : ''}
</div> </div>
+30 -12
View File
@@ -1,35 +1,53 @@
// Service Worker for FlockRadar Offline Driving & Caching // Service Worker for FlockRadar Offline Driving & Live Updates
const CACHE_NAME = 'flockradar-v2'; const CACHE_NAME = 'flockradar-v6';
const ASSETS_TO_CACHE = [ const ASSETS_TO_CACHE = [
'./', './',
'./index.html', './index.html',
'./css/styles.css', './css/styles.css?v=6',
'./js/app.js', './js/app.js?v=6',
'./js/auth.js', './js/auth.js?v=6',
'./js/radar.js', './js/radar.js?v=6',
'./data/portals.js', './data/portals.js?v=6',
'./manifest.json' './manifest.json'
]; ];
self.addEventListener('install', event => { self.addEventListener('install', event => {
self.skipWaiting();
event.waitUntil( event.waitUntil(
caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS_TO_CACHE)) caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS_TO_CACHE))
); );
self.skipWaiting();
}); });
self.addEventListener('activate', event => { self.addEventListener('activate', event => {
event.waitUntil( event.waitUntil(
caches.keys().then(keys => Promise.all( caches.keys().then(keys => Promise.all(
keys.filter(key => key !== CACHE_NAME).map(key => caches.delete(key)) keys.filter(key => key !== CACHE_NAME).map(key => caches.delete(key))
)) )).then(() => self.clients.claim())
); );
self.clients.claim();
}); });
self.addEventListener('fetch', event => { self.addEventListener('fetch', event => {
// Network first, fallback to cache // Always network-first for HTML, JS and CSS to ensure instant updates
const url = new URL(event.request.url);
if (url.origin === self.location.origin) {
event.respondWith(
fetch(event.request, { cache: 'no-cache' })
.then(response => {
if (response && response.status === 200) {
const clone = response.clone();
caches.open(CACHE_NAME).then(cache => cache.put(event.request, clone));
}
return response;
})
.catch(() => caches.match(event.request))
);
return;
}
// Fallback for CDN resources (Leaflet tiles etc)
event.respondWith( event.respondWith(
fetch(event.request).catch(() => caches.match(event.request)) caches.match(event.request).then(cached => {
return cached || fetch(event.request);
})
); );
}); });