Jean-Tinland / simple-bar

A yabai status bar widget for Übersicht
https://www.jeantinland.com/toolbox/simple-bar
MIT License
1.21k stars 129 forks source link

Weather Widget: Fix Location Lookup #399

Closed nickthegroot closed 6 months ago

nickthegroot commented 6 months ago

Description

I work in a city that shares a name with a larger one. As such, the weather widget's call to wttr.in was incorrectly giving the weather for the larger city instead of my own.

This PR fixes the issue by instead fetching the weather based on a user's coordinates.

(Possibly) Related: #328

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  1. Observe weather widget with incorrect temp
  2. Click on weather widget, observe incorrect city location
  3. Merge changes
  4. Observe weather widget with correct temp
  5. Click on weather widget, observe correct city location

Test Configuration:

Checklist:

Changes to make to the documentation

N/A

Jean-Tinland commented 6 months ago

That's nice, I hadn't thought about handling it this way!

Thanks :)

Jean-Tinland commented 6 months ago

I had to revert this change as it was not working with my coordinates for unknown reasons...

The code is now working this way:

const { city, zip } = position?.address || {};
location.current = zip || city;

The zip code should be enough to avoid city name collisions. Please let me know if this is working for you.