ProtonMail / proton-mail

React web application to manage ProtonMail
https://beta.protonmail.com
GNU General Public License v3.0
178 stars 26 forks source link

Refacto conversation and message cache #49

Closed Swiip closed 4 years ago

Swiip commented 4 years ago

EDIT: final situation

Motivations: caches implementations for message and conversation was a bit messy. But more important, lots of event updates was missed.

Remains a question about cache duplication in useElements and useMessage/useConversation. It will be addressed in another PR (if addressed)

Swiip commented 4 years ago

It seems to work at this point. Two things I want to precise:

I replaced the MessageProvider and replaced by a use***Cache which create a sort of sub-cache inside the main one. It seems simpler to me instead of stacking contexts. Update management for the cache is located next to it.

The useMessageCache and the useConversationCache are containing the same data as the localCache of useElements. It should be possible to link data from useElements to other cache to remove duplication. But it could be complicated for a "not so important" memory gain.

Swiip commented 4 years ago

After different attempts, I fallback on cache inside independants contexts. It's the best solution I found to manage futur eventual unloading.

That and new event management and some new tests. I think it's ok to merge now.

The question of cache duplication can be handled later.