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