vector-im-hydrogen-web/matrix.mjs
Bruno Windels 0cf9e84bdd WIP
2018-12-21 14:35:24 +01:00

95 lines
2.3 KiB
JavaScript

/*
idb stores:
all in one database per stored session:
- session
- device id
- last sync token
- access token
- home server
- user id
- user name
- avatar
- filter(s)?
- room_summaries
- room_id
- heroes
- room_name
- room_avatar (just the url)
- tags (account_data?)
- is_direct
- unread_message_count ?
- unread_message_with_mention ?
- roomstate_{room_id}
how about every state event gets a revision number
for each state event, we store the min and max revision number where they form part of the room state
then we "just" do a where revision_range includes revision, and every state event event/gap in the timeline we store the revision number, and we have an index on it? so we can easily look for the nearest one
it's like every state event we know about has a range where it is relevant
we want the intersection of a revision with all ranges
1 2 3 * 4 5 6
| topic | oth*er topic |
| power levels * |
| member a'1 | membe*r a'2 |
*-------- get intersection for all or some type & state_keys for revision 3 (forward) or 4 (backwards)
tricky to do a > && < in indexeddb
we'll need to do either > or < for min or max revision and iterate through the cursor and apply the rest of the conditions in code ...
all current state for last event would have max revision of some special value to indicate it hasn't been replaced yet.
the idea is that we can easily load just the state for a given event in the timeline,
can be the last synced event, or a permalink event
- members_{room_id}
historical?
- timeline_{room_id}
- search?
where to store avatars?
we could cache the requested ones in a table ...
or service worker, but won't work on my phone
*/
class Credentials {
accessToken,
deviceId
}
class LoginFlow {
constructor(network) {
}
//differentiate between next stage and Credentials?
async next(stage) {}
static async attemptPasswordLogin(username, password) {
}
}
class LoginStage {
get type() {}
serialize() {} //called by LoginFlow::next
}
class PasswordStage extends LoginStage {
set password() {
}
set username() {
}
serialize() {
return {
identifier: {
type: "m.id.user",
user: this._username
},
password: this._password
};
}
}