builttoroam / device_calendar

A cross platform plugin for modifying calendars on the user's device
https://pub.dev/packages/device_calendar
BSD 3-Clause "New" or "Revised" License
267 stars 267 forks source link

Fixing event JSON mapping #382

Closed thomassth closed 2 years ago

thomassth commented 2 years ago

Part of #320

Of course #321 only fixes internal JSON translations.

This fixes JSON translations between app and respective device OS.

thomassth commented 2 years ago

It seems to be fine on Android

Not tested on iOS yet

thomassth commented 2 years ago

It wasn't entirely fixed actually

A lot of event arguments have changed names some time ago, probably during the setup for timezones, and wasn't updated across the board. Ie. Currently the event title and other fields created by toJSON can't be read by fromJson. Reading and writing to devices were fine though since probably only toJSONwas edited.

I only discovered that when I merge the PR for testing.

I just realized that any JSON maps previously created will be unusable. Either we make toJSON able to read both of them or we need a mitigation.

thomassth commented 2 years ago

This is where the trouble came from

https://github.com/builttoroam/device_calendar/commit/aea337990b410ed411d03bdb80712486195854fd#diff-9e474c05021706fff3750cb85b2d9a25f4d2d528b95c285bb1881cc5bfff03b9

Either we follow through or we need to revert.

thomassth commented 2 years ago

I tried it on iOS and it seems fine. You said that any maps created previously will be unreadable, you mean anything that was persisted? Within the scope of a single session the values should be consistent now?

Any Event JSONs created prior to 4.0 are unreadable after 4.0. If somebody store event JSONs and reuse them they are in big trouble.

4.0 and 4.0.1 will still create faulty JSONs because the conversion is incomplete. Said people are in moderate trouble.

In all cases, if you DON'T store these JSONs and only pass them between operations, 4.0 is faulty, 4.0.1 fixes the times of events, this PR should fix the rest.

We definitely need better testing procedures.