encointer / explorer

explore the encointer network, browse local communitities an monitor populations
GNU General Public License v3.0
1 stars 1 forks source link

put the nextMeetupTime function in MapSidebar #111

Closed Quackaholic-Quacktivity closed 1 year ago

Quackaholic-Quacktivity commented 1 year ago

closes #88

Quackaholic-Quacktivity commented 1 year ago

currently having some problems with yarn, thus I'm not able to check it , but I hope I can solve it.

brenzi commented 1 year ago

I'd expect this more concise snippet to work, but there seems to be a missing sign somewhere:

    async function getNextMeetupDate () {
      const meetupLocations = await api.rpc.encointer.getLocations(cid);
      const tempLocation = locationFromJson(api, meetupLocations[0]);
      const tempTime = await getNextMeetupTime(api, tempLocation);

      const localtime = timespace.getFuzzyLocalTimeFromPoint(tempTime.toNumber(), [meetupLocations[0].lon, meetupLocations[0].lat]);
      debug && console.log('the date is: ' + localtime + meetupLocations[0]);
      setNextMeetupTime(localtime.toString());
    }
brenzi commented 1 year ago

@clangenb If you see the root cause right away, it would be nice to get over it. If not, it can wait

clangenb commented 1 year ago

Yeah, the same locationFromJson was the root cause in the app too - the negative sign is gone. I think stringToLocation is the culprit. I would have a potential quick fix, but I don't have time today.

clangenb commented 1 year ago

Changing it to this function fixes it, I tested it locally, the meetup time is now: 19.03.2023, 18:17:03

export function locationFromJson (api, location) {
  return api.createType('Location', {
    lat: stringToDegree(location.lat),
    lon: stringToDegree(location.lon)
  });
}