Merge branch 'develop' into travis/feature/wellknown2

This commit is contained in:
Travis Ralston 2019-05-16 12:59:50 -06:00
commit 0c7aa39273
48 changed files with 1737 additions and 44 deletions

View file

@ -15,6 +15,7 @@ limitations under the License.
*/
import { EventStatus } from 'matrix-js-sdk';
import MatrixClientPeg from '../MatrixClientPeg';
/**
* Returns whether an event should allow actions like reply, reactions, edit, etc.
@ -43,3 +44,8 @@ export function isContentActionable(mxEvent) {
return false;
}
export function canEditContent(mxEvent) {
return isContentActionable(mxEvent) &&
mxEvent.getSender() === MatrixClientPeg.get().getUserId();
}

View file

@ -50,11 +50,15 @@ export async function checkConsistency() {
let dataInLocalStorage = false;
let dataInCryptoStore = false;
let cryptoInited = false;
let healthy = true;
if (localStorage) {
dataInLocalStorage = localStorage.length > 0;
log(`Local storage contains data? ${dataInLocalStorage}`);
cryptoInited = localStorage.getItem("mx_crypto_initialised");
log(`Crypto initialised? ${cryptoInited}`);
} else {
healthy = false;
error("Local storage cannot be used on this browser");
@ -84,10 +88,11 @@ export async function checkConsistency() {
track("Crypto store disabled");
}
if (dataInLocalStorage && !dataInCryptoStore) {
if (dataInLocalStorage && cryptoInited && !dataInCryptoStore) {
healthy = false;
error(
"Data exists in local storage but not in crypto store. " +
"Data exists in local storage and crypto is marked as initialised " +
" but no data found in crypto store. " +
"IndexedDB storage has likely been evicted by the browser!",
);
track("Crypto store evicted");
@ -104,6 +109,7 @@ export async function checkConsistency() {
return {
dataInLocalStorage,
dataInCryptoStore,
cryptoInited,
healthy,
};
}
@ -155,3 +161,17 @@ export function trackStores(client) {
});
}
}
/**
* Sets whether crypto has ever been successfully
* initialised on this client.
* StorageManager uses this to determine whether indexeddb
* has been wiped by the browser: this flag is saved to localStorage
* and if it is true and not crypto data is found, an error is
* presented to the user.
*
* @param {bool} cryptoInited True if crypto has been set up
*/
export function setCryptoInitialised(cryptoInited) {
localStorage.setItem("mx_crypto_initialised", cryptoInited);
}