Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
import createThunk from '@filerobot/utils/lib/createThunk';
export var fetchFileComments = createThunk(async function (fileUuid, thunkApi) {
  var _await$thunkApi$extra = await thunkApi.extra.apiClient.get("file/".concat(fileUuid, "/comments?comments_info=1"), {
      id: 'getComments',
      abortSignal: thunkApi.signal
    }),
    comments = _await$thunkApi$extra.comments;
  var transformedComments = comments.map(function (comment) {
    var commentProps = JSON.parse(comment.text || null) || {};
    return _objectSpread(_objectSpread({}, comment), {}, {
      createdAt: comment.added_at,
      parentId: commentProps.parentId || commentProps.parent || null,
      body: commentProps.text || commentProps.body,
      shapes: commentProps.shapes,
      user: _objectSpread(_objectSpread({}, comment.user), {}, {
        id: comment.user.uuid,
        name: comment.user.name || comment.user.email
      }),
      meta: {
        likers: comment.meta.likes,
        subscribers: comment.meta.subscribes,
        displayTimeStamp: commentProps.displayTimeStamp,
        resolved: commentProps.resolved,
        canvasDimensions: commentProps.canvasDimensions
      }
    });
  });
  return transformedComments;
});
export var addNewComment = createThunk(async function (_ref, thunkApi) {
  var _submittedComment$use, _submittedComment$use2, _submittedComment$use3, _submittedComment$use4;
  var newText = _ref.newText,
    fileUuid = _ref.fileUuid,
    currentUserInfo = _ref.currentUserInfo;
  // https://scaleflexhq.atlassian.net/browse/FRA-1687 -- BE task to get user info with response
  var _await$thunkApi$extra2 = await thunkApi.extra.apiClient.post("file/".concat(fileUuid, "/comments?comments_info=1"), {
      data: {
        comment: {
          text: JSON.stringify(newText)
        }
      },
      id: 'addNewComment',
      abortSignal: thunkApi.signal
    }),
    comments = _await$thunkApi$extra2.comments;
  var submittedComment = comments[0];
  var newComment = {
    id: submittedComment === null || submittedComment === void 0 ? void 0 : submittedComment.id,
    body: newText.body,
    text: JSON.stringify(newText),
    user: _objectSpread(_objectSpread(_objectSpread({}, currentUserInfo), submittedComment.user), {}, {
      id: submittedComment === null || submittedComment === void 0 ? void 0 : (_submittedComment$use = submittedComment.user) === null || _submittedComment$use === void 0 ? void 0 : _submittedComment$use.uuid,
      name: (submittedComment === null || submittedComment === void 0 ? void 0 : (_submittedComment$use2 = submittedComment.user) === null || _submittedComment$use2 === void 0 ? void 0 : _submittedComment$use2.name) || (submittedComment === null || submittedComment === void 0 ? void 0 : (_submittedComment$use3 = submittedComment.user) === null || _submittedComment$use3 === void 0 ? void 0 : _submittedComment$use3.email),
      email: submittedComment === null || submittedComment === void 0 ? void 0 : (_submittedComment$use4 = submittedComment.user) === null || _submittedComment$use4 === void 0 ? void 0 : _submittedComment$use4.email
    }),
    parentId: newText.parentId || null,
    shapes: newText.shapes,
    createdAt: submittedComment === null || submittedComment === void 0 ? void 0 : submittedComment.added_at,
    meta: {
      likers: [],
      subscribers: [],
      resolved: false,
      canvasDimensions: newText.canvasDimensions,
      displayTimeStamp: newText.displayTimeStamp
    }
  };
  return newComment;
});
export var updateCommentText = createThunk(async function (_ref2, thunkApi) {
  var fileUuid = _ref2.fileUuid,
    commentId = _ref2.commentId,
    newText = _ref2.newText;
  var response = await thunkApi.extra.apiClient.put("file/".concat(fileUuid, "/comments?comments_info=1"), {
    data: _objectSpread({
      comment_id: commentId
    }, newText),
    enabledAbort: false,
    abortSignal: thunkApi.signal
  });
  return response;
});
export var submitCommentAction = createThunk(async function (_ref3, thunkApi) {
  var fileUuid = _ref3.fileUuid,
    commentId = _ref3.commentId,
    action = _ref3.action;
  var response = await thunkApi.extra.apiClient.put("file/".concat(fileUuid, "/comments?comments_info=1"), {
    data: {
      comment_id: commentId,
      action: action
    },
    abortSignal: thunkApi.signal
  });
  return response;
});
export var deleteComment = createThunk(async function (_ref4, thunkApi) {
  var fileUuid = _ref4.fileUuid,
    commentsUuids = _ref4.commentsUuids;
  await thunkApi.extra.apiClient["delete"]("file/".concat(fileUuid, "/comments?comments_info=1"), {
    data: {
      comment_ids: commentsUuids
    },
    abortSignal: thunkApi.signal
  });
  var newCommentsPromise = thunkApi.dispatch(fetchFileComments(fileUuid));
  thunkApi.signal.addEventListener('abort', function () {
    return newCommentsPromise.abort();
  }, {
    once: true
  });
  var newComments = await newCommentsPromise;
  return newComments;
});