fix: purge stale 1-tap mobile pins, make remove pin button bold and prominent, and bust service worker cache
This commit is contained in:
+15
-6
@@ -28,7 +28,7 @@
|
||||
<meta name="apple-mobile-web-app-title" content="FlockRadar">
|
||||
|
||||
<!-- Main Stylesheet -->
|
||||
<link rel="stylesheet" href="css/styles.css">
|
||||
<link rel="stylesheet" href="css/styles.css?v=7">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -942,10 +942,19 @@
|
||||
<!-- Leaflet Map JS -->
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
|
||||
|
||||
<!-- Data & Application Logic -->
|
||||
<script src="data/portals.js"></script>
|
||||
<script src="js/auth.js"></script>
|
||||
<script src="js/radar.js"></script>
|
||||
<script src="js/app.js"></script>
|
||||
<!-- Data & Application Logic with Cache Busting -->
|
||||
<script src="data/portals.js?v=7"></script>
|
||||
<script src="js/auth.js?v=7"></script>
|
||||
<script src="js/radar.js?v=7"></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>
|
||||
</html>
|
||||
|
||||
+14
-2
@@ -124,7 +124,13 @@
|
||||
communityReports = JSON.parse(stored);
|
||||
// Automatically prune any unverified test marks or pins without photo proof
|
||||
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) {
|
||||
localStorage.setItem(STORAGE_KEY_REPORTS, JSON.stringify(communityReports));
|
||||
}
|
||||
@@ -138,7 +144,13 @@
|
||||
|
||||
function clearUnverifiedReports() {
|
||||
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));
|
||||
Object.keys(cameraMetadata).forEach(id => {
|
||||
if (id.startsWith('usr-pin-') || !cameraMetadata[id].photoUrl) {
|
||||
|
||||
+10
-5
@@ -301,8 +301,12 @@
|
||||
window.FlockAuth.clearUnverifiedReports();
|
||||
}
|
||||
|
||||
// Filter out any unverified user pins
|
||||
allCameras = [...DEFAULT_CAMERAS].filter(c => !c.id.startsWith('usr-pin-'));
|
||||
// Filter out any unverified user pins or accidental test marks
|
||||
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!)
|
||||
if (window.FlockAuth) {
|
||||
@@ -418,9 +422,10 @@
|
||||
Inspect Agency Records & Sharing ↗
|
||||
</button>
|
||||
` : ''}
|
||||
${(cam.isCommunity || cam.id.startsWith('rpt-') || cam.id.startsWith('usr-pin-') || cam.id.startsWith('test-') || cam.id.startsWith('cam-test-')) ? `
|
||||
<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)}')">
|
||||
🗑️ Admin: Delete Placed Pin
|
||||
${(!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 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)}')">
|
||||
<span style="font-size: 1rem;">🗑️</span>
|
||||
<span>REMOVE THIS PIN (ADMIN)</span>
|
||||
</button>
|
||||
` : ''}
|
||||
</div>
|
||||
|
||||
@@ -1,35 +1,53 @@
|
||||
// Service Worker for FlockRadar Offline Driving & Caching
|
||||
const CACHE_NAME = 'flockradar-v2';
|
||||
// Service Worker for FlockRadar Offline Driving & Live Updates
|
||||
const CACHE_NAME = 'flockradar-v6';
|
||||
const ASSETS_TO_CACHE = [
|
||||
'./',
|
||||
'./index.html',
|
||||
'./css/styles.css',
|
||||
'./js/app.js',
|
||||
'./js/auth.js',
|
||||
'./js/radar.js',
|
||||
'./data/portals.js',
|
||||
'./css/styles.css?v=6',
|
||||
'./js/app.js?v=6',
|
||||
'./js/auth.js?v=6',
|
||||
'./js/radar.js?v=6',
|
||||
'./data/portals.js?v=6',
|
||||
'./manifest.json'
|
||||
];
|
||||
|
||||
self.addEventListener('install', event => {
|
||||
self.skipWaiting();
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS_TO_CACHE))
|
||||
);
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', event => {
|
||||
event.waitUntil(
|
||||
caches.keys().then(keys => Promise.all(
|
||||
keys.filter(key => key !== CACHE_NAME).map(key => caches.delete(key))
|
||||
))
|
||||
)).then(() => self.clients.claim())
|
||||
);
|
||||
self.clients.claim();
|
||||
});
|
||||
|
||||
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(
|
||||
fetch(event.request).catch(() => caches.match(event.request))
|
||||
caches.match(event.request).then(cached => {
|
||||
return cached || fetch(event.request);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user