choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
123 lines (96 loc) • 2.91 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.AttachmentStore = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _promiseMerger = _interopRequireDefault(require("../promise-merger"));
var _utils = require("./utils");
var publicKeys = new WeakMap();
var privateKeys = new WeakMap();
var AttachmentStore = /*#__PURE__*/function () {
function AttachmentStore() {
(0, _classCallCheck2["default"])(this, AttachmentStore);
this.batchCallback = function (uuids, args, items) {
return args[0](uuids, {
isPublic: args[1],
items: items
});
};
this.merger = new _promiseMerger["default"](this.batchCallback, {
maxAge: 60000,
max: 100
});
}
(0, _createClass2["default"])(AttachmentStore, [{
key: "fetchCountInBatch",
value: function fetchCountInBatch(options, field) {
var _getGlobalConfig = (0, _utils.getGlobalConfig)('attachment', field),
batchFetchCount = _getGlobalConfig.batchFetchCount;
if (batchFetchCount) {
var isPublic = options.isPublic,
attachmentUUID = options.attachmentUUID;
return this.merger.add(attachmentUUID, function () {
if (isPublic) {
var publicKey = publicKeys.get(batchFetchCount);
if (!publicKey) {
publicKey = Symbol('PUBLIC_KEY');
publicKeys.set(batchFetchCount, publicKey);
}
return publicKey;
}
var privateKey = privateKeys.get(batchFetchCount);
if (!privateKey) {
privateKey = Symbol('PRIVATE_KEY');
privateKeys.set(batchFetchCount, privateKey);
}
return privateKey;
}, [batchFetchCount, isPublic], options);
}
return Promise.resolve(undefined);
}
/**
* @deprecated
*/
}, {
key: "get",
value: function get(_uuid) {
return undefined;
}
/**
* @deprecated
*/
}, {
key: "set",
value: function set(_uuid, _cache) {}
/**
* @deprecated
*/
}, {
key: "getCount",
value: function getCount(_uuid) {
return undefined;
}
/**
* @deprecated
*/
}, {
key: "getAttachments",
value: function getAttachments(_uuid) {
return undefined;
}
/**
* @deprecated
*/
}, {
key: "clearCache",
value: function clearCache(_codes) {}
}]);
return AttachmentStore;
}();
exports.AttachmentStore = AttachmentStore;
var _default = new AttachmentStore();
exports["default"] = _default;
//# sourceMappingURL=AttachmentStore.js.map
;