Persist data over multiple restarts
Categories
(Chat Core :: Matrix, defect)
Tracking
(Not tracked)
People
(Reporter: clokep, Assigned: khushil324)
References
Details
Attachments
(1 file, 7 obsolete files)
6.25 KB,
patch
|
clokep
:
review+
|
Details | Diff | Splinter Review |
Currently the MatrixClient
object that gets created stores data in memory instead of storing it to disk, etc. etc. When repeatedly connection you end up with multiple "devices" connected to your Matrix account, additionally I believe this is what causes the full history to be downloaded each connection.
The createClient
docs show how an options object can be passed in to configure the store
. I think we want to use the IndexDBStore
instead, which uses IndexedDB
under the hood.
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
await opts.store.startup();
The code is not moving ahead from this part.
My concern is if we are importing the right IndexedDB.
Reporter | ||
Comment 2•5 years ago
|
||
Hey Khushil, I might have steered you wrong. It seems that IndexedDB.jsm "provides Promise-based wrappers around ordinarily IDBRequest-based IndexedDB methods and classes."
I think we want to use the following instead: Cu.importGlobalProperties(["indexedDB"]);
(see https://searchfox.org/comm-central/rev/0c6472bec30280a0648e5101ffacaf72907e4cc2/mozilla/toolkit/modules/IndexedDB.jsm#15-18).
Reporter | ||
Updated•5 years ago
|
Assignee | ||
Comment 3•5 years ago
|
||
There is still an issue: if you click on previous conversation(Today, Yesterday, Last week), you will see the same messages multiple times. It's UI related issue only. I will solve that in follow-up bug.
Assignee | ||
Comment 4•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 5•5 years ago
|
||
Apply after patches from Bug 1347533 and Bug 1348038.
Assignee | ||
Comment 6•5 years ago
|
||
Reporter | ||
Comment 7•5 years ago
|
||
Assignee | ||
Comment 8•5 years ago
|
||
Assignee | ||
Comment 9•5 years ago
|
||
(In reply to Patrick Cloke [:clokep] from comment #7)
Protocol code shouldn't reach out to anything to do with UI, it should be
considered backend only.
indexedDB from Cu.importGlobalProperties(["indexedDB"]);
is working so changed the logic from window.indexedDB to indexedDB.
Assignee | ||
Comment 10•5 years ago
|
||
Assignee | ||
Comment 11•5 years ago
|
||
Apply topic patch first from bug 1348038.
Reporter | ||
Comment 12•5 years ago
|
||
Assignee | ||
Comment 13•5 years ago
•
|
||
(In reply to Patrick Cloke [:clokep] from comment #12)
I think we also want to clear out
this._roomList
to reset the state. See
https://searchfox.org/comm-central/rev/
2131bede09ff0e7273bc77f669150491cd0d7685/chat/protocols/irc/irc.jsm#2258-2262
Right.
The core code guarantees the account gets disconnected:
https://searchfox.org/comm-central/source/chat/components/src/imAccounts.
jsm#760-762
Ohh, got it. This multiple calls of reportDisconnected were causing some error so needed the check of if (this.disconnected)
further in the code.
I don't think we can just make this async -- the caller doesn't know it is
async so won't properly await.
The caller doesn't need to wait since the "connect" function is not returning anything. We just need to call this.reportConnected()
whenever we are prepared. We are doing it here. Without await, the store will not startup on time and createClient
function will throw an error. We just need synchronous behavior in the "connect" function itself, we don't need to worry about the caller function.
I'm not convinced this is the best thing to use here... I think we should
use something based on the account ID instead. This means that even if
someone deletes the account and recreates it we are guaranteed to be using a
different storage.Maybe something like:
dbName = "chat:matrix:" + this.imAccount.id;
? I
think that will do something like "chat:matrix:1". Looking at how we
generate entries for the password manager might be useful.
Okay cool.
What does this change do?
[opts.useAuthorizationHeader = false] Set to true to use Authorization header instead of query param to send the access token to the server.
Do you know if this comment is still valid?
Yes, we don't need it now.
Is this just for debugging or do we still need it?
It will generate a message and we want to show it to the user. That's why. This all will changes once we update this writeConv function and show the right message according to the respective event.
Reporter | ||
Comment 14•5 years ago
|
||
(In reply to Khushil Mistry [:khushil324] from comment #13)
(In reply to Patrick Cloke [:clokep] from comment #12)
I don't think we can just make this async -- the caller doesn't know it is
async so won't properly await.The caller doesn't need to wait since the "connect" function is not returning anything. We just need to call
this.reportConnected()
whenever we are prepared. We are doing it here. Without await, the store will not startup on time andcreateClient
function will throw an error. We just need synchronous behavior in the "connect" function itself, we don't need to worry about the caller function.
What happens if we need to cancel the connection before it is complete or something of that nature?
What does this change do?
[opts.useAuthorizationHeader = false] Set to true to use Authorization header instead of query param to send the access token to the server.
OK, but why do we need to make this change?
Is this just for debugging or do we still need it?
It will generate a message and we want to show it to the user. That's why. This all will changes once we update this writeConv function and show the right message according to the respective event.
So this should have been part of bug 1348038?
Assignee | ||
Comment 15•5 years ago
|
||
Assignee | ||
Comment 16•5 years ago
|
||
OK, but why do we need to make this change?
The documentation recommends it. Plus we may need it with SSO.
So this should have been part of bug 1348038?
Maybe, this is getting changed in the next patch so it will not matter much here.
Reporter | ||
Comment 17•5 years ago
|
||
Assignee | ||
Comment 18•5 years ago
|
||
(In reply to Patrick Cloke [:clokep] from comment #17)
This is incorrect, it should be
delete this._roomList
(although you might
actually need to instantiate it as anew Map()
).
I am changing how we use _roomList in the upcoming patch. Here, we are using _roomList[id] instead of has(), get() and set() which is the wrong usage of Map. So I will just put delete this._roomList
here.
Assignee | ||
Comment 19•5 years ago
|
||
Reporter | ||
Comment 20•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Comment 21•5 years ago
|
||
Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/9585630b0575
Persist data over multiple restarts. r=clokep
Updated•5 years ago
|
Description
•