Rework device list tracking logic (#425)
Yet another attempt at fixing
https://github.com/vector-im/riot-web/issues/2305.
This now implements the algorithm described at
http://matrix.org/speculator/spec/HEAD/client_server/unstable.html#tracking-the-device-list-for-a-user:
* We now keep a flag to tell us which users' device lists we are tracking. That
makes it much easier to figure out whether we should care about device-update
notifications from /sync (thereby fixing
https://github.com/vector-im/riot-web/issues/3588).
* We use the same flag to indicate whether the device list for a particular
user is out of date. Previously we did this implicitly by only updating the
stored sync token when the list had been updated, but that was somewhat
complicated, and in any case didn't help in cases where we initiated the key
download due to a user joining an encrypted room.
Also fixes https://github.com/vector-im/riot-web/issues/3310.