summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/foundation/wrappers/client-ordering.js
blob: 683d81c22364cea31540fd733b6f84a22687dc60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
 * Created by dersu on 6/23/17.
 */
import { makeMetatype } from "@jet/environment/util/metatype";
import { Wrapper } from "./wrapper";
export class ClientOrderingWrapper extends Wrapper {
    async orderedVisibleIAPs(appBundleId, defaultOrdering, defaultVisibleIdentifiers, spotlightIdentifier) {
        return await new Promise((resolve, reject) => {
            // Collections that are parameters over the bridge cannot have `nil` constituents on the other side, so we
            // should make sure we don't give such inputs or else we'll crash the app.
            const cleanedDefaultOrdering = defaultOrdering.filter((item) => {
                return item !== null && item !== undefined;
            });
            const cleanedDefaultVisibleIdentifiers = defaultVisibleIdentifiers.filter((item) => {
                return item !== null && item !== undefined;
            });
            this.implementation.orderedVisibleIAPs(appBundleId, cleanedDefaultOrdering, cleanedDefaultVisibleIdentifiers, spotlightIdentifier, (ordering, error) => {
                if (error) {
                    reject(error);
                }
                else {
                    resolve(ordering);
                }
            });
        });
    }
    async visibilityForIAPs(productMap) {
        return await new Promise((resolve, reject) => {
            this.implementation.visibilityForIAPs(productMap, (visibilities, error) => {
                if (error) {
                    // Do not reject; we should gracefully fail, since this ordering
                    // data isn't strictly necessary to render search results.
                    resolve({});
                }
                else {
                    resolve(visibilities);
                }
            });
        });
    }
}
ClientOrderingWrapper.type = makeMetatype("app-store:client-ordering-wrapper");
//# sourceMappingURL=client-ordering.js.map