mirror of
				https://github.com/vector-im/element-web.git
				synced 2025-11-04 10:11:03 +01:00 
			
		
		
		
	Merge pull request #3624 from matrix-org/t3chguy/remove_bluebird_2
Attempt number two at ripping out Bluebird from rageshake.js
This commit is contained in:
		
						commit
						050761d339
					
				@ -136,6 +136,8 @@ class IndexedDBLogStore {
 | 
			
		||||
        this.id = "instance-" + Math.random() + Date.now();
 | 
			
		||||
        this.index = 0;
 | 
			
		||||
        this.db = null;
 | 
			
		||||
 | 
			
		||||
        // these promises are cleared as soon as fulfilled
 | 
			
		||||
        this.flushPromise = null;
 | 
			
		||||
        // set if flush() is called whilst one is ongoing
 | 
			
		||||
        this.flushAgainPromise = null;
 | 
			
		||||
@ -208,16 +210,16 @@ class IndexedDBLogStore {
 | 
			
		||||
     */
 | 
			
		||||
    flush() {
 | 
			
		||||
        // check if a flush() operation is ongoing
 | 
			
		||||
        if (this.flushPromise && this.flushPromise.isPending()) {
 | 
			
		||||
            if (this.flushAgainPromise && this.flushAgainPromise.isPending()) {
 | 
			
		||||
                // this is the 3rd+ time we've called flush() : return the same
 | 
			
		||||
                // promise.
 | 
			
		||||
        if (this.flushPromise) {
 | 
			
		||||
            if (this.flushAgainPromise) {
 | 
			
		||||
                // this is the 3rd+ time we've called flush() : return the same promise.
 | 
			
		||||
                return this.flushAgainPromise;
 | 
			
		||||
            }
 | 
			
		||||
            // queue up a flush to occur immediately after the pending one
 | 
			
		||||
            // completes.
 | 
			
		||||
            // queue up a flush to occur immediately after the pending one completes.
 | 
			
		||||
            this.flushAgainPromise = this.flushPromise.then(() => {
 | 
			
		||||
                return this.flush();
 | 
			
		||||
            }).then(() => {
 | 
			
		||||
                this.flushAgainPromise = null;
 | 
			
		||||
            });
 | 
			
		||||
            return this.flushAgainPromise;
 | 
			
		||||
        }
 | 
			
		||||
@ -225,8 +227,7 @@ class IndexedDBLogStore {
 | 
			
		||||
        // a brand new one, destroying the chain which may have been built up.
 | 
			
		||||
        this.flushPromise = new Promise((resolve, reject) => {
 | 
			
		||||
            if (!this.db) {
 | 
			
		||||
                // not connected yet or user rejected access for us to r/w to
 | 
			
		||||
                // the db.
 | 
			
		||||
                // not connected yet or user rejected access for us to r/w to the db.
 | 
			
		||||
                reject(new Error("No connected database"));
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
@ -251,6 +252,8 @@ class IndexedDBLogStore {
 | 
			
		||||
            objStore.add(this._generateLogEntry(lines));
 | 
			
		||||
            const lastModStore = txn.objectStore("logslastmod");
 | 
			
		||||
            lastModStore.put(this._generateLastModifiedTime());
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
            this.flushPromise = null;
 | 
			
		||||
        });
 | 
			
		||||
        return this.flushPromise;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user