var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.upsertAppSettings = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _createUpsertQuery = require("../sqlite-utils/createUpsertQuery");
var _SqliteClient = require("../SqliteClient");
var upsertAppSettings = exports.upsertAppSettings = function () {
  var _ref2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(_ref) {
    var appSettings, currentUserId, _ref$execute, execute, storableAppSettings, queries;
    return _regenerator["default"].wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          appSettings = _ref.appSettings, currentUserId = _ref.currentUserId, _ref$execute = _ref.execute, execute = _ref$execute === void 0 ? true : _ref$execute;
          storableAppSettings = JSON.stringify(appSettings);
          queries = [(0, _createUpsertQuery.createUpsertQuery)('userSyncStatus', {
            appSettings: storableAppSettings,
            userId: currentUserId
          })];
          _SqliteClient.SqliteClient.logger == null || _SqliteClient.SqliteClient.logger('info', 'upsertAppSettings', {
            appSettings: storableAppSettings,
            execute: execute,
            userId: currentUserId
          });
          if (!execute) {
            _context.next = 7;
            break;
          }
          _context.next = 7;
          return _SqliteClient.SqliteClient.executeSqlBatch(queries);
        case 7:
          return _context.abrupt("return", queries);
        case 8:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
  return function upsertAppSettings(_x) {
    return _ref2.apply(this, arguments);
  };
}();
//# sourceMappingURL=upsertAppSettings.js.map