@atlaskit/global-search
Version:
A cross-product search component (batteries included)
103 lines (84 loc) • 4.3 kB
JavaScript
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _get from "@babel/runtime/helpers/get";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import ConfluenceClientImpl from './ConfluenceClient';
import { SimpleCache } from '../util/simple-cache';
var CachingConfluenceClient = /*#__PURE__*/function (_ConfluenceClientImpl) {
_inherits(CachingConfluenceClient, _ConfluenceClientImpl);
var _super = _createSuper(CachingConfluenceClient);
function CachingConfluenceClient(url, prefetchedResults) {
var _thisSuper, _thisSuper2, _this;
_classCallCheck(this, CachingConfluenceClient);
_this = _super.call(this, url);
_this.itemCache = new SimpleCache(prefetchedResults && prefetchedResults.then(function (result) {
return result.objects.items;
}), function () {
return _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(CachingConfluenceClient.prototype)), "getRecentItems", _thisSuper).call(_thisSuper);
});
_this.spaceCache = new SimpleCache(prefetchedResults && prefetchedResults.then(function (result) {
return result.spaces.items;
}), function () {
return _get((_thisSuper2 = _assertThisInitialized(_this), _getPrototypeOf(CachingConfluenceClient.prototype)), "getRecentSpaces", _thisSuper2).call(_thisSuper2);
});
return _this;
}
_createClass(CachingConfluenceClient, [{
key: "getRecentItems",
value: function () {
var _getRecentItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this.itemCache.get();
case 2:
return _context.abrupt("return", _context.sent);
case 3:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function getRecentItems() {
return _getRecentItems.apply(this, arguments);
}
return getRecentItems;
}()
}, {
key: "getRecentSpaces",
value: function () {
var _getRecentSpaces = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return this.spaceCache.get();
case 2:
return _context2.abrupt("return", _context2.sent);
case 3:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function getRecentSpaces() {
return _getRecentSpaces.apply(this, arguments);
}
return getRecentSpaces;
}()
}]);
return CachingConfluenceClient;
}(ConfluenceClientImpl);
export { CachingConfluenceClient as default };