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

Add fromJson and toJson to MultaccItem, allowing storage of arbitrary data #17

Merged
merged 4 commits into from Mar 6, 2020

Conversation

@TortoiseWrath
Copy link
Member

TortoiseWrath commented Mar 5, 2020

Fixes #18 .

This is the result of a discussion in the Slack workspace in which it was determined that it will be better not to force each implementation of the MultaccItem interface to store its data in a single string (value).

This implementation is based on: https://flutter.dev/docs/development/data-and-backend/json#serializing-json-inside-model-classes

I am adding @mayank99 and @micah-white as reviewers because this was Mayank's idea and Micah will probably have to deal with the resulting JSON at some point in the backend.

The name contact_types was misleading since the classes in this package
are used to create different types of items, not contacts.
Previously, the only data stored besides the database key in a
MultaccItem was a `value` string. This commit modifies the MultaccItem
base class to replace this string with a `fromJson` constructor and
`toJson` method.

The TwitterItem class provides an example implementation. The user ID
and display name are stored in two instance variables in the TwitterItem
class. The JSON stored in the database will look like:
    {'at':'fckeveryword','id':'944864788336824321'}

This way, implementations of MultaccItem can store arbitrary data as
necessary for the given platform.
This commit removes extraneous @override annotations and adds some fat
arrows to make the code less Java-flavored and more Dart-flavored.
@todo

This comment has been minimized.

Copy link

todo bot commented Mar 6, 2020

Implement Twitter launching

// @todo Implement Twitter launching
}
bool isLaunchable() => true;
}


This comment was generated by todo based on a todo comment in 39f740f in #17. cc @multacc.
@TortoiseWrath TortoiseWrath changed the title Add JSON serialization/deserialization to MultaccItem, allowing storage of arbitrary data Add fromJson and toJson to MultaccItem, allowing storage of arbitrary data Mar 6, 2020
@TortoiseWrath TortoiseWrath mentioned this pull request Mar 6, 2020
@mayank99 mayank99 merged commit 1ebd1f2 into master Mar 6, 2020
@mayank99 mayank99 deleted the contact-model branch Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.