Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INV-3685][INV-3732][INV-3678] Show Map Markers with Cached Recordsets, hide default recordsets from caching #3738

Merged
merged 33 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2e655db
Add new values to UserRecordSet interface
LocalNewsTV Dec 4, 2024
4e4bed8
Create util to convert Recordset filters into bounding box
LocalNewsTV Dec 4, 2024
f0916ac
add new RecordCacheService function, loadRecordsetSourceMetadata()
LocalNewsTV Dec 4, 2024
d817779
export getSelectColumbsByRecordSetType for reuse
LocalNewsTV Dec 4, 2024
91e4b7e
Add new values to Reducer cases
LocalNewsTV Dec 4, 2024
4c1bb34
Implement loadRecordSetSourceMetadata in locaforage-cache
LocalNewsTV Dec 4, 2024
6f65e90
Add connectivity to useEffect dependencies
LocalNewsTV Dec 5, 2024
ae80f20
Add cacheMetadata to InitState.getSuccess for layerstates
LocalNewsTV Dec 5, 2024
5895245
WIP recordset-layers implementation
LocalNewsTV Dec 5, 2024
8c009c4
Move cacheMetadata types to featurecollections
LocalNewsTV Dec 9, 2024
941ac18
Delete Layers when toggling network,
LocalNewsTV Dec 9, 2024
66908c1
Move VECTOR_MAP_FONT_FACE to constant
LocalNewsTV Dec 9, 2024
950aac9
Add Record Cache data to map layer when caching completes, clean some…
LocalNewsTV Dec 9, 2024
a3388b5
raise minzoom on default getLabelLayer value
LocalNewsTV Dec 9, 2024
b76e951
Add refresh button to crash page
LocalNewsTV Dec 10, 2024
1675850
Remove unused variables
LocalNewsTV Dec 10, 2024
ef982cd
Implement loadRecordsetSourceMetadata in sqlite-cache.ts
LocalNewsTV Dec 10, 2024
c96a56f
Add cacheMetadata to FILTERS_PREPPED_FOR_VECTOR_ENDPOINT
LocalNewsTV Dec 10, 2024
ab23041
Remove unused takes, correct typo
LocalNewsTV Dec 10, 2024
81be2f0
remove unused functions
LocalNewsTV Dec 10, 2024
bc7a8c1
Fire InitState request when becoming an offline user
LocalNewsTV Dec 10, 2024
a7feb3c
Remove unused vars
LocalNewsTV Dec 10, 2024
6a2f9bf
create recordset request flows for when offline
LocalNewsTV Dec 11, 2024
a1af112
Cleanup recordset-layer helpers
LocalNewsTV Dec 11, 2024
343a1af
Add and differenciate 'WorkingOffline' into loggedIn flag, hook into …
LocalNewsTV Dec 11, 2024
d2ad659
Remove cache buttons from default recordsets
LocalNewsTV Dec 11, 2024
06f1786
Force offline when offline user
LocalNewsTV Dec 11, 2024
4ef55fb
Cleanup code smell
LocalNewsTV Dec 11, 2024
4a837d3
code smells
LocalNewsTV Dec 11, 2024
e31269d
tidy up Db queries for null features
LocalNewsTV Dec 11, 2024
dc42436
Add short ID Column for loading, add label to sqlite shapes
LocalNewsTV Dec 11, 2024
0969b13
add loggedInOrWorkingOffline variable, make authenticated / workingOf…
LocalNewsTV Dec 12, 2024
1b07384
Merge branch 'dev' into 3685-offline-map-recordset-markers-2
LocalNewsTV Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/src/UI/ErrorHandler/ErrorHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export const ErrorHandler = ({ detail }) => {
>
{copied ? 'Copied!' : 'Copy Error Detail To Clipboard'}
</Button>
<Button variant="contained" color="primary" onClick={() => location.reload()}>
Refresh
</Button>
<Button
sx={{ margin: '0.5rem' }}
variant={'contained'}
Expand Down
29 changes: 17 additions & 12 deletions app/src/UI/Map2/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import {
rebuildLayersOnTableHashUpdate,
refreshColoursOnColourUpdate,
refreshVisibilityOnToggleUpdate,
removeDeletedRecordSetLayersOnRecordSetDelete
removeDeletedRecordSetLayersOnRecordSetDelete,
removeLayersOnNetworkConnectivityChange
} from 'UI/Map2/helpers/recordset-layers';
import { addWMSLayersIfNotExist, refreshWMSOnToggle } from 'UI/Map2/helpers/wms-layers';
import { addServerBoundariesIfNotExists, refreshServerBoundariesOnToggle } from 'UI/Map2/helpers/server-boundaries';
Expand All @@ -51,7 +52,6 @@ export const Map = ({ children }) => {

const [draw, setDraw] = useState(null);
const [mapReady, setMapReady] = useState(false);

const mapContainer: React.MutableRefObject<HTMLDivElement | null> = useRef<HTMLDivElement>(null);
const map: React.MutableRefObject<MapLibre | null> = useRef<MapLibre>(null);

Expand All @@ -61,7 +61,7 @@ export const Map = ({ children }) => {

// Avoid remounting map to avoid unnecesssary tile fetches or bad umounts:
const authInitiated = useSelector((state) => state.Auth.initialized);
const loggedIn = useSelector((state) => state.Auth.authenticated);
const { authenticated, loggedInOrWorkingOffline } = useSelector((state) => state.Auth);
const connectedToNetwork = useSelector((state) => state.Network.connected);

// RecordSet Layers
Expand Down Expand Up @@ -145,7 +145,7 @@ export const Map = ({ children }) => {
authHeaderRef.current = currentAuthHeader;

useEffect(() => {
if (!loggedIn) {
if (!authenticated) {
return;
}

Expand All @@ -164,7 +164,7 @@ export const Map = ({ children }) => {
return () => {
clearInterval(id);
};
}, [loggedIn]);
}, [authenticated]);

// Map Init
useEffect(() => {
Expand All @@ -188,16 +188,21 @@ export const Map = ({ children }) => {
});
}, [authInitiated, map_center]);

// RecordSet Layers:
useEffect(() => {
if (!mapReady) return;
if (!map.current) return;
removeLayersOnNetworkConnectivityChange(map.current);
}, [connectedToNetwork]);

rebuildLayersOnTableHashUpdate(storeLayers, map.current, MapMode, API_BASE);
// RecordSet Layers:
useEffect(() => {
if (!mapReady) return;
if (!map.current) return;
rebuildLayersOnTableHashUpdate(storeLayers, map.current, MapMode, API_BASE, connectedToNetwork);
refreshColoursOnColourUpdate(storeLayers, map.current);
refreshVisibilityOnToggleUpdate(storeLayers, map.current);
removeDeletedRecordSetLayersOnRecordSetDelete(storeLayers, map.current);
}, [storeLayers, map.current, mapReady]);
}, [storeLayers, map.current, mapReady, connectedToNetwork, loggedInOrWorkingOffline]);

// Layer picker:
useEffect(() => {
Expand All @@ -210,11 +215,11 @@ export const Map = ({ children }) => {

useEffect(() => {
if (!mapReady) return;
if (loggedIn) {
if (authenticated) {
addServerBoundariesIfNotExists(serverBoundaries, map.current);
refreshServerBoundariesOnToggle(serverBoundaries, map.current);
}
}, [serverBoundaries, loggedIn, map.current, mapReady]);
}, [serverBoundaries, authenticated, map.current, mapReady]);

useEffect(() => {
if (!mapReady) return;
Expand Down Expand Up @@ -423,13 +428,13 @@ export const Map = ({ children }) => {
// toggle public map pmtile layer
useEffect(() => {
if (!mapReady) return;
if (loggedIn) {
if (loggedInOrWorkingOffline) {
toggleLayerOnBool(map.current, 'invasivesbc-pmtile-vector', false);
toggleLayerOnBool(map.current, 'iapp-pmtile-vector', false);
toggleLayerOnBool(map.current, 'invasivesbc-pmtile-vector-label', false);
toggleLayerOnBool(map.current, 'iapp-pmtile-vector-label', false);
}
}, [loggedIn, map.current, mapReady]);
}, [loggedInOrWorkingOffline, map.current, mapReady]);

useEffect(() => {
refreshWhatsHereFeature(map.current, { whatsHereFeature });
Expand Down
8 changes: 1 addition & 7 deletions app/src/UI/Map2/helpers/layer-definitions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import VECTOR_MAP_FONT_FACE from 'constants/vectorMapFontFace';
import { LayerSpecification, SourceSpecification } from 'maplibre-gl';
import { MOBILE } from 'state/build-time-config';

Expand Down Expand Up @@ -86,13 +87,6 @@ export class MapDefinitionEligibilityPredicatesBuilder {
}
}

// available from CDN, but not in asset pack
let VECTOR_MAP_FONT_FACE = 'Open Sans Bold';
if (MOBILE) {
// available locally, but not from CDN
VECTOR_MAP_FONT_FACE = 'Noto Sans Bold';
}

// determines layer stacking and whether the layer is individually toggle-able (eg only one basemap can be active at once)
export enum MapSourceAndLayerDefinitionMode {
BASEMAP = 'BASEMAP',
Expand Down
Loading
Loading