UNPKG

@sendbird/uikit-react-native

Version:

Sendbird UIKit for React Native: A feature-rich and customizable chat UI kit with messaging, channel management, and user authentication.

88 lines 3.21 kB
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } import { ASYNC_NOOP } from '@sendbird/uikit-utils'; export default class InternalLocalCacheStorage { constructor(storage) { _defineProperty(this, "_mmkv", void 0); _defineProperty(this, "_async", void 0); _defineProperty(this, "clear", ASYNC_NOOP); _defineProperty(this, "flushGetRequests", ASYNC_NOOP); if ('getString' in storage) { this._mmkv = storage; } else { this._async = storage; } } async getAllKeys() { if (this._mmkv) { return this._mmkv.getAllKeys(); } else if (this._async) { return this._async.getAllKeys(); } else { return []; } } async getItem(key) { if (this._mmkv) { return this._mmkv.getString(key) ?? null; } else if (this._async) { return this._async.getItem(key); } else { return null; } } async removeItem(key) { if (this._mmkv) { this._mmkv.delete(key); } else if (this._async) { return this._async.removeItem(key); } } async setItem(key, value) { if (this._mmkv) { this._mmkv.set(key, value); } else if (this._async) { return this._async.setItem(key, value); } } async multiGet(keys) { if (this._mmkv) { return Promise.all(keys.map(async key => [key, await this.getItem(key)])); } else if (this._async) { var _this$_async; if ((_this$_async = this._async) !== null && _this$_async !== void 0 && _this$_async.multiGet) { return this._async.multiGet(keys); } else { return Promise.all(keys.map(async key => [key, await this.getItem(key)])); } } else { return []; } } async multiRemove(keys) { if (this._mmkv) { await Promise.all(keys.map(async key => this.removeItem(key))); } else if (this._async) { var _this$_async2; if ((_this$_async2 = this._async) !== null && _this$_async2 !== void 0 && _this$_async2.multiRemove) { await this._async.multiRemove(keys); } else { await Promise.all(keys.map(async key => this.removeItem(key))); } } } async multiSet(keyValuePairs) { if (this._mmkv) { await Promise.all(keyValuePairs.map(([key, value]) => this.setItem(key, value))); } else if (this._async) { var _this$_async3; if ((_this$_async3 = this._async) !== null && _this$_async3 !== void 0 && _this$_async3.multiSet) { await this._async.multiSet(keyValuePairs); } else { await Promise.all(keyValuePairs.map(([key, value]) => this.setItem(key, value))); } } } } //# sourceMappingURL=InternalLocalCacheStorage.js.map