provider.jsx 1.11 KB
Newer Older
1
2
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
3
4
5
6
7

export default class Provider {
    constructor() {
        this.latestPrefix = '';
        this.latestComplete = true;
8
        this.disableDispatches = false;
9
        this.requestStarted = false;
10
11
    }

12
    handlePretextChanged(pretext) { // eslint-disable-line no-unused-vars
13
14
15
        // NO-OP for inherited classes to override
    }

16
17
18
19
    resetRequest() {
        this.requestStarted = false;
    }

20
    startNewRequest(prefix) {
21
22
        this.latestPrefix = prefix;
        this.latestComplete = false;
23
        this.requestStarted = true;
24
25
26
    }

    shouldCancelDispatch(prefix) {
27
28
29
30
        if (this.disableDispatches) {
            return true;
        }

31
32
33
34
        if (!this.requestStarted) {
            return true;
        }

35
36
37
38
39
40
41
42
        if (prefix === this.latestPrefix) {
            this.latestComplete = true;
        } else if (this.latestComplete) {
            return true;
        }

        return false;
    }
43
44
45
46
47
48
49
50

    allowDividers() {
        return true;
    }

    presentationType() {
        return 'text';
    }
51
}