-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
start_column cannot be null #14
Comments
@swissspidy can you upload an ESLint JSON file that has this issue? I will use it to make a unit test, then work on a fix. |
@ataylorme sure! this should be it: [{"filePath":"/path/to/src/edit-story/app/media/utils/useUploadVideoFrame.js","messages":[{"ruleId":"jsdoc/require-param-description","severity":1,"message":"Missing JSDoc @param \"url\" description.","line":104,"column":null,"nodeType":"Block","endLine":104,"endColumn":null},{"ruleId":"jsdoc/require-param-type","severity":1,"message":"Missing JSDoc @param \"url\" type.","line":104,"column":null,"nodeType":"Block","endLine":104,"endColumn":null},{"ruleId":"jsdoc/require-returns-description","severity":1,"message":"Missing JSDoc @return description.","line":105,"column":null,"nodeType":"Block","endLine":105,"endColumn":null}],"errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * External dependencies\n */\nimport { useCallback } from 'react';\n/**\n * Internal dependencies\n */\nimport { useAPI } from '../../api';\nimport { useStory } from '../../story';\nimport { useConfig } from '../../config';\nimport { useUploader } from '../../uploader';\nimport { preloadImage, getFirstFrameOfVideo } from './';\n\nfunction useUploadVideoFrame({ updateMediaElement }) {\n const {\n actions: { updateMedia },\n } = useAPI();\n const { uploadFile } = useUploader();\n const { storyId } = useConfig();\n const { updateElementsByResourceId } = useStory((state) => ({\n updateElementsByResourceId: state.actions.updateElementsByResourceId,\n }));\n const setProperties = useCallback(\n (id, properties) => {\n updateElementsByResourceId({ id, properties });\n },\n [updateElementsByResourceId]\n );\n\n const processData = async (id, src) => {\n try {\n const obj = await getFirstFrameOfVideo(src);\n obj.name = getFileName(src) + '-poster.jpeg';\n const {\n id: posterId,\n source_url: poster,\n media_details: { width: posterWidth, height: posterHeight },\n } = await uploadFile(obj);\n // Meta data cannot be sent as part of upload.\n await updateMedia(posterId, {\n meta: {\n web_stories_is_poster: true,\n },\n });\n await updateMedia(id, {\n featured_media: posterId,\n meta: {\n web_stories_poster_id: posterId,\n },\n post: storyId,\n });\n\n // Preload the full image in the browser to stop jumping around.\n await preloadImage(poster);\n\n // Overwrite the original video dimensions. The poster reupload has more\n // accurate dimensions of the video that includes orientation changes.\n const newSize =\n (posterWidth &&\n posterHeight && {\n width: posterWidth,\n height: posterHeight,\n }) ||\n null;\n const newState = ({ resource }) => ({\n resource: {\n ...resource,\n posterId,\n poster,\n ...newSize,\n },\n });\n setProperties(id, newState);\n updateMediaElement({\n id,\n posterId,\n poster,\n ...newSize,\n });\n } catch (err) {\n // TODO Display error message to user as video poster upload has as failed.\n }\n };\n\n /**\n * Helper function get the file name from url.\n *\n * @param url\n * @return {string}\n */\n const getFileName = (url) =>\n url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));\n\n /**\n * Uploads the video's first frame as an attachment.\n *\n */\n const uploadVideoFrame = useCallback(processData, [\n storyId,\n updateMediaElement,\n uploadFile,\n updateMedia,\n setProperties,\n ]);\n\n return {\n uploadVideoFrame,\n };\n}\n\nexport default useUploadVideoFrame;\n","usedDeprecatedRules":[{"ruleId":"jsx-a11y/accessible-emoji","replacedBy":[]}]}] |
@swissspidy can you test out the |
Running that locally seems to work fine 👍 |
* Bump the version to `1.1.3` * Add a `start_column` is not null check * Update GitHub Actions to use the latest version Closes #14
@swissspidy FYI this fix has been merged and version |
Related to #7. A fix similar to #8 but for
start_column
should resolve this.The text was updated successfully, but these errors were encountered: