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

Refactor message data & persistence model #1875

Closed
janherich opened this issue Sep 18, 2017 · 0 comments
Closed

Refactor message data & persistence model #1875

janherich opened this issue Sep 18, 2017 · 0 comments
Assignees

Comments

@janherich
Copy link
Contributor

User Story

As a developer, I want to have single place in app, where all data uniquely tied to particular message are held, I also want to have only one (clear) way how to save/update/retrieve message data in/from realm.

Description

Type: Problem

Summary: Currently, we have message data all over the place in app-db and realm. It's directly attached as an ordered sequence under [:chats chat-id :messages] key, then we have some data related to messages indexed by message id in [:message-data :preview], [:message-data :short-preview], [:message-data :status] and soon also in [:handler-data] and [:message-id->pending-messages].
It's even worse for the realm persistence API, where something is held in message objects, something not (handler-data, pending-messages).
Every-time when we need to have something message-related with random access by message-id, we invent a new place in app-db where we put it, then we have to keep track of it in subscriptions, when updating messages, write boilerplate code for realm persistence, etc.

Solution

Summary: We well move everything message related under [:message-by-id] (or [:id->message]) path in app-db. We will rework our realm schema, and persistence functions, eliminate boilerplate and use only handful of message related functions to do everything in regard of message persistence.
Under [:chats chat-id :messages] we will have (ordered) vector of message-references, such as:

[[:message-by-id "id1"]
 [:message-by-id "id2"]
 [:message-by-id "id3"]]

As mentioned, ordering of the messages will be maintained by ordering of message references (responsibility of db functions updating [:chats chat-id :messages] data) and it will be job of messages subscription(s) to use the references to look-up actual message objects and return it as sequence to view layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants