Fix linting/formatting

This commit is contained in:
Râu Cao 2026-01-24 12:52:03 +07:00
parent 518685b7dc
commit 721fe5f01d
Signed by: raucao
GPG Key ID: 37036C356E56CC51
6 changed files with 82 additions and 55 deletions

View File

@ -61,7 +61,6 @@ export default class MapComponent extends Component {
zIndex: 10, // Ensure it sits above the map tiles
});
// Default view settings
let center = [99.05738, 7.55087];
let zoom = 13.0;
@ -95,7 +94,11 @@ export default class MapComponent extends Component {
target: element,
layers: [openfreemap, bookmarkLayer],
view: view,
controls: defaultControls({ zoom: false, rotate: true, attribution: true }),
controls: defaultControls({
zoom: false,
rotate: true,
attribution: true,
}),
});
apply(this.mapInstance, 'https://tiles.openfreemap.org/styles/liberty');
@ -210,7 +213,9 @@ export default class MapComponent extends Component {
geolocation.un('change:position', zoomToLocation);
locateListenerKey = null;
}
} catch (e) { /* ignore */ }
} catch (e) {
/* ignore */
}
// Hide pulse
if (this.locationOverlayElement) {
@ -261,7 +266,8 @@ export default class MapComponent extends Component {
else if (accuracy) {
const viewportWidthMeters = 6.325 * accuracy;
const minDimensionPixels = Math.min(size[0], size[1]);
const requiredResolutionMeters = viewportWidthMeters / minDimensionPixels;
const requiredResolutionMeters =
viewportWidthMeters / minDimensionPixels;
const metersPerMapUnit = getPointResolution(
view.getProjection(),
1,
@ -443,23 +449,23 @@ export default class MapComponent extends Component {
// If the pin is in the bottom half (y > splitPoint), it is obscured
if (pixel[1] > splitPoint) {
// Target position: Center of top half = height * 0.25
const targetY = height * 0.25;
const deltaY = pixel[1] - targetY;
// Target position: Center of top half = height * 0.25
const targetY = height * 0.25;
const deltaY = pixel[1] - targetY;
const view = this.mapInstance.getView();
const center = view.getCenter();
const resolution = view.getResolution();
const view = this.mapInstance.getView();
const center = view.getCenter();
const resolution = view.getResolution();
// Move the map center SOUTH (decrease Y) to move the pin UP (decrease pixel Y)
const deltaMapUnits = deltaY * resolution;
const newCenter = [center[0], center[1] - deltaMapUnits];
// Move the map center SOUTH (decrease Y) to move the pin UP (decrease pixel Y)
const deltaMapUnits = deltaY * resolution;
const newCenter = [center[0], center[1] - deltaMapUnits];
view.animate({
center: newCenter,
duration: 500,
easing: (t) => t * (2 - t) // Ease-out
});
view.animate({
center: newCenter,
duration: 500,
easing: (t) => t * (2 - t), // Ease-out
});
}
}
@ -525,7 +531,7 @@ export default class MapComponent extends Component {
const viewState = {
center: currentCenter,
zoom: currentZoom
zoom: currentZoom,
};
localStorage.setItem('marco:map-view', JSON.stringify(viewState));
@ -545,7 +551,9 @@ export default class MapComponent extends Component {
if (features && features.length > 0) {
console.debug(`Found ${features.length} features in map layer:`);
for (const f of features) { console.debug(f) }
for (const f of features) {
console.debug(f);
}
const bookmarkFeature = features.find((f) => f.get('isBookmark'));
if (bookmarkFeature) {
clickedBookmark = bookmarkFeature.get('originalPlace');

View File

@ -79,10 +79,10 @@ export default class PlaceDetails extends Component {
get cuisine() {
if (!this.tags.cuisine) return null;
return this.tags.cuisine
.split(';')
.map(c => capitalize.compute([c]))
.map(c => c.replace('_', ' '))
.join(', ');
.split(';')
.map((c) => capitalize.compute([c]))
.map((c) => c.replace('_', ' '))
.join(', ');
}
get wikipedia() {
@ -123,17 +123,24 @@ export default class PlaceDetails extends Component {
</p>
{{#if this.place.description}}
<p class="place-description">
{{this.place.description}}
{{this.place.description}}
</p>
{{/if}}
<div class="actions">
<button
type="button"
class={{if this.place.createdAt "btn btn-secondary" "btn btn-outline"}}
class={{if
this.place.createdAt
"btn btn-secondary"
"btn btn-outline"
}}
{{on "click" (fn @onToggleSave this.place)}}
>
<Icon @name="bookmark" @color={{if this.place.createdAt "currentColor" "#007bff"}} />
<Icon
@name="bookmark"
@color={{if this.place.createdAt "currentColor" "#007bff"}}
/>
{{if this.place.createdAt "Saved" "Save"}}
</button>
</div>
@ -164,14 +171,22 @@ export default class PlaceDetails extends Component {
{{#if this.website}}
<p class="content-with-icon">
<Icon @name="globe" @title="Website" />
<span><a href={{this.website}} target="_blank" rel="noopener noreferrer">{{this.websiteDomain}}</a></span>
<span><a
href={{this.website}}
target="_blank"
rel="noopener noreferrer"
>{{this.websiteDomain}}</a></span>
</p>
{{/if}}
{{#if this.wikipedia}}
<p>
<strong>Wikipedia:</strong>
<a href="https://wikipedia.org/wiki/{{this.wikipedia}}" target="_blank" rel="noopener noreferrer">Article</a>
<a
href="https://wikipedia.org/wiki/{{this.wikipedia}}"
target="_blank"
rel="noopener noreferrer"
>Article</a>
</p>
{{/if}}

View File

@ -50,23 +50,23 @@ export default class PlacesSidebar extends Component {
// Update selection to the new saved place object
// This updates the local UI state immediately without a route refresh
if (this.args.onUpdate) {
// When deleting, we revert to a "fresh" object or just close.
// Since we close the sidebar below, we might not strictly need to update local state,
// but it's good practice.
// Reconstruct the "original" place without ID/Geohash/CreatedAt
const freshPlace = {
...place,
id: undefined,
geohash: undefined,
createdAt: undefined
};
this.args.onUpdate(freshPlace);
// When deleting, we revert to a "fresh" object or just close.
// Since we close the sidebar below, we might not strictly need to update local state,
// but it's good practice.
// Reconstruct the "original" place without ID/Geohash/CreatedAt
const freshPlace = {
...place,
id: undefined,
geohash: undefined,
createdAt: undefined,
};
this.args.onUpdate(freshPlace);
}
// Also fire onSelect if it exists (for list view)
// Also fire onSelect if it exists (for list view)
if (this.args.onSelect) {
// Similar logic for select if needed, but we usually close.
this.args.onSelect(null);
// Similar logic for select if needed, but we usually close.
this.args.onSelect(null);
}
// Close sidebar after delete
@ -81,7 +81,8 @@ export default class PlacesSidebar extends Component {
} else {
// It's a fresh POI -> Save it
const placeData = {
title: place.osmTags.name || place.osmTags['name:en'] || 'Untitled Place',
title:
place.osmTags.name || place.osmTags['name:en'] || 'Untitled Place',
lat: place.lat,
lon: place.lon,
tags: [],
@ -128,11 +129,11 @@ export default class PlacesSidebar extends Component {
{{else}}
<h2>Nearby Places</h2>
{{/if}}
<button
type="button"
class="close-btn"
{{on "click" @onClose}}
><Icon @name="x" @size={{20}} @color="#333" /></button>
<button type="button" class="close-btn" {{on "click" @onClose}}><Icon
@name="x"
@size={{20}}
@color="#333"
/></button>
</div>
<div class="sidebar-content">

View File

@ -24,7 +24,7 @@ out center;
`.trim();
const url = `https://overpass.bke.ro/api/interpreter?data=${encodeURIComponent(
// const url = `https://overpass-api.de/api/interpreter?data=${encodeURIComponent(
// const url = `https://overpass-api.de/api/interpreter?data=${encodeURIComponent(
query
)}`;
@ -101,7 +101,7 @@ out center;
}
const url = `https://overpass.bke.ro/api/interpreter?data=${encodeURIComponent(
// const url = `https://overpass-api.de/api/interpreter?data=${encodeURIComponent(
// const url = `https://overpass-api.de/api/interpreter?data=${encodeURIComponent(
query
)}`;
const res = await this.fetchWithRetry(url);

View File

@ -129,7 +129,7 @@ body {
}
.btn-outline:hover {
border: 1px solid #898989;
border: 1px solid #898989;
}
.btn-secondary {

View File

@ -38,8 +38,11 @@ export default class PlaceTemplate extends Component {
// 3. If not saved, check our local "optimistic" state (from handleUpdate)
// This handles the "unsaved" state immediately after deletion before any other sync
if (this.localPlace && (this.localPlace.osmId === id || this.localPlace.id === id)) {
return this.localPlace;
if (
this.localPlace &&
(this.localPlace.osmId === id || this.localPlace.id === id)
) {
return this.localPlace;
}
// 4. Fallback to the route model (which might be the stale "saved" object from when the route loaded)
@ -50,7 +53,7 @@ export default class PlaceTemplate extends Component {
...model,
id: undefined,
createdAt: undefined,
geohash: undefined
geohash: undefined,
};
}