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

fix(feed): boundaries and zoom for map feed #1399

Merged
merged 10 commits into from
Dec 6, 2024
Merged

Conversation

sujal-into
Copy link
Collaborator

fix: #1371

Description:
Set the zoom level to 3, so the map gets fit into the container, however, it doesn't show the whole map

@sujal-into sujal-into self-assigned this Nov 19, 2024
Copy link

netlify bot commented Nov 19, 2024

Deploy Preview for teritori-dapp ready!

Name Link
🔨 Latest commit 49d4069
🔍 Latest deploy log https://app.netlify.com/sites/teritori-dapp/deploys/6751a5030a7bc60008369179
😎 Deploy Preview https://deploy-preview-1399--teritori-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 19, 2024

Deploy Preview for testitori ready!

Name Link
🔨 Latest commit 8835c32
🔍 Latest deploy log https://app.netlify.com/sites/testitori/deploys/67440f9d37e17c000876ba55
😎 Deploy Preview https://deploy-preview-1399--testitori.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sujal-into sujal-into added the Social Feed Everything related to the Social Feed label Nov 19, 2024
Copy link
Collaborator

@n0izn0iz n0izn0iz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely there must be a way to compute a zoom level that always fit the width of the map no?

it should probably be used in #1398 also

n0izn0iz
n0izn0iz previously approved these changes Nov 20, 2024
Copy link
Collaborator

@n0izn0iz n0izn0iz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested and reviewed

@WaDadidou WaDadidou changed the title fix: max bound set for whole map fix(feed): max bound set for whole map Nov 21, 2024
Copy link
Collaborator

@hthieu1110 hthieu1110 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you take a look at my comments pls :) thanks.

Comment on lines 121 to 127
const lat = 45;
const lng = 90;

const adjustedWorldMapBounds: LatLngBoundsLiteral = [
[-lat, -lng],
[lat, lng],
];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is independent of the Component so we should put it outside of the component and we can use UPPER_CASE to define the constants

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't follow this convention, please use normal variable naming as in js, there is no real constants

we can put it outside of the func though

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed here: b42b56d

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't follow this convention, please use normal variable naming as in js, there is no real constants

we can put it outside of the func though

IMHO, if it's a constant and declared outside of function scope, it should be a UPPER_CASE.
if it's just a keyword const and declared in function scope, it's ok to define it with normal case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const in js don't exist
Screenshot 2024-12-04 at 18 02 19

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes refacto harder if the variable stops being a constant according to your definition
also we don't have a way to enforce this rule so this means more review work

Copy link
Collaborator

@n0izn0iz n0izn0iz Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the rust language it make more sense because constant are real constant and thus when you see UPPER_CASE, you have some guarantees. Even then it doesn't have much value IMO but at least it can be verified by tooling.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can vote on this

[lat, lng],
];

const updateMinZoom = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not defined the function inside of useEffect which makes the code less readable.

I suggest sth like

useEffect(() => {
    !!map && updateMinZoom(map);
    .......
}, [[map, setMinZoom])

Copy link
Collaborator

@n0izn0iz n0izn0iz Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, we followed this in berty and it made the code very hard to maintain IMO

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can extract a hook though if you really want

const useUpdateMinZoom = (map) => {
    useEffect(...)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed here: 066f8cc

@clegirar
Copy link
Collaborator

clegirar commented Dec 2, 2024

I read comments from both PR's (#1398 #1399) and it refers to each other, can we just have one PR with split and specific commits for more clarity ?

For the code it's seems okay for me, i understand norman who said that it should be better to have a calcul that fit with any screen size, and it's not really what it's implemented here, can you explain @sujal-into where MAP_HALF_BOUND values came from ?

But i tested the behavior and i tried to resize in big and small screens and it works well 👍

@clegirar
Copy link
Collaborator

clegirar commented Dec 2, 2024

This PR will receive some changes from this PR #1398
I'll explain all changes that i'm going to bring 👍

@clegirar
Copy link
Collaborator

clegirar commented Dec 3, 2024

MAP_MAX_BOUND variable is the GPS coordinates (latitude, longitude) of the south-west corner and the north-east corner of a classic planisphere (so they don't come from nowhere).
zoomSnap is the value that forces the map's zoom level to always be a multiple of this, so we decreased it to have a better fit with our container.
And the last thing I want to mentioned is that the initial leaflet map is a square and our container is a rectangle, so this is the main reason we have so much difficulty to fit perfectly with our container, it's because we can't perfectly fit squares into rectangle without have some white strips on the sides.

We are obligate to pass zoom initial value to MapContainer so it must be arbitrary, we set it to 2.15 (default value that fit with the rectangle in many cases, without white strips on the sides).
I moved updateMinZoom directly in MapManager because it doesn't make a lot of sense to extract a hook that is usable in just one case, and can be write in 6 lines
.
This hook initially did more than 6 lines but the event listener didn't work, so I removed it and I don't understand why we have to handle a resize window behaviour ? I understand we have to handle some responsiveness but resizing windows is not included in that part imo.

One thing about the ternary condition in zoom props, but the consultedPostLocation seems to be not correctly works with MapContainer, but I found a props in setView for consulted and creation post condition, it's that setView take a zoom props that we can directly pass to it, found it more appropriate, and it works well.

Found it little bit confusing to have one value minZoom that is shared for zoom and minZoom value in MapContainer, but we don't need to follow the zoom value for the moment so I don't have opinions on that.

Copy link

netlify bot commented Dec 3, 2024

Deploy Preview for gno-dapp ready!

Name Link
🔨 Latest commit 49d4069
🔍 Latest deploy log https://app.netlify.com/sites/gno-dapp/deploys/6751a503ebea8d0008be1d52
😎 Deploy Preview https://deploy-preview-1399--gno-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@clegirar clegirar changed the title fix(feed): max bound set for whole map fix(feed): boundaries and zoom for map feed Dec 5, 2024
@n0izn0iz
Copy link
Collaborator

n0izn0iz commented Dec 5, 2024

aussi, en vertu de l'article 49 alinéa 3 de la constitution, j'engage la responsabilité de mon organisation décentralisée sur l'application de la requête de fusionnement numéro 1399

Copy link
Collaborator

@n0izn0iz n0izn0iz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would prefer that it's fully responsive but it's already pretty good

@clegirar
Copy link
Collaborator

clegirar commented Dec 5, 2024

Like even set the boundaries dynamically ?

@n0izn0iz
Copy link
Collaborator

n0izn0iz commented Dec 5, 2024

I mean add back the resize event handler, but it's okay to do it later

@n0izn0iz n0izn0iz merged commit fb82523 into main Dec 6, 2024
23 checks passed
@n0izn0iz
Copy link
Collaborator

n0izn0iz commented Dec 6, 2024

qu'ils viennent me chercher

@n0izn0iz n0izn0iz deleted the bugfix/zoom-out-bounds branch December 6, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Social Feed Everything related to the Social Feed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(feed/map): shouldn't be able to zoom out of bounds
5 participants