-
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
save changes #900
save changes #900
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is more cleanup but this is a good enough start. should deal w/ the save as issue
@@ -31,6 +31,7 @@ | |||
</head> | |||
|
|||
<body> | |||
<img id="screenshot-img" src="ui_assets/3DStreet-Viewer-Start-Editor.svg" alt="Invisible Image" style="display:none;"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created an invisible image so that the screentock functions can be synchronous
@@ -21,7 +21,7 @@ AFRAME.registerComponent('screentock', { | |||
type: { type: 'string', default: 'jpg' }, // png, jpg, img | |||
imgElementSelector: { type: 'selector' } | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed all the async code from here
@@ -189,6 +191,102 @@ const checkIfImagePathIsEmpty = async (sceneId) => { | |||
} | |||
}; | |||
|
|||
const saveScreenshot = async (value) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved screenshot functionality to the scene api file so that the toolbar component didn't call functions from the screenshotmodalcomponent
|
||
const uploadThumbnailImage = async () => { | ||
try { | ||
// saveScreenshot('img'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note, i commented this out, since in every call makeScreenshot
is called prior
@@ -30,7 +30,6 @@ export default class Toolbar extends Component { | |||
this.state = { | |||
// isPlaying: false, | |||
isSaveActionActive: false, | |||
isCapturingScreen: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed all state related functionality for this
// AFRAME.INSPECTOR.close(); | ||
// } | ||
makeScreenshot = () => { | ||
const imgHTML = '<img id="screentock-destination">'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the invisible imgHTML
@@ -343,8 +323,8 @@ export default class Toolbar extends Component { | |||
}; | |||
|
|||
toggleSaveActionState = () => { | |||
this.makeScreenshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicitly call makescreenshot rather than state management
...prevState, | ||
isCapturingScreen: true | ||
})); | ||
this.makeScreenshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call makescreenshot instead of using state
@@ -44,24 +62,16 @@ const deleteScene = async (sceneId) => { | |||
} | |||
}; | |||
|
|||
const updateScene = async (sceneId, userUID, sceneData, title, version) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to pass user id in updating a scene
@@ -34,6 +36,22 @@ const generateSceneId = async (authorId) => { | |||
return newSceneId; | |||
}; | |||
|
|||
const createScene = async (authorId, sceneData, title, version) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a createScene
@@ -88,28 +96,6 @@ const updateSceneIdAndTitle = async (sceneId, title) => { | |||
} | |||
}; | |||
|
|||
const isSceneAuthor = async ({ sceneId, authorId }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no longer needed
AFRAME.scenes[0].setAttribute('metadata', 'sceneId', sceneId); | ||
AFRAME.scenes[0].setAttribute('metadata', 'sceneTitle', sceneTitle); | ||
|
||
AFRAME.scenes[0].setAttribute('metadata', 'authorId', sceneData.author); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when a new scene is loaded, set the authorId
// import { loginHandler } from '../SignInModal'; | ||
|
||
export const uploadThumbnailImage = async (uploadedFirstTime) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to a shared location so that Toolbar isn't calling this component
@@ -218,48 +183,42 @@ export default class Toolbar extends Component { | |||
console.log( | |||
'no urlSceneId or doSaveAs is true, therefore generate new one' | |||
); | |||
currentSceneId = await generateSceneId(this.props.currentUser.uid); | |||
currentSceneId = await createScene( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of generating a scene id and then updating a scene, we are simply creating a scene w/ all the relevant info
console.log('newly generated currentSceneId', currentSceneId); | ||
window.location.hash = `#/scenes/${currentSceneId}.json`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are doing this later anyways, so this is duplicative
await uploadThumbnailImage(true); | ||
} | ||
AFRAME.scenes[0].setAttribute('metadata', 'sceneId' + currentSceneId); | ||
AFRAME.scenes[0].setAttribute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also updating the authorid now
// make sure to update sceneId with new one in metadata component! | ||
AFRAME.scenes[0].setAttribute('metadata', 'sceneId: ' + currentSceneId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note, i change sceneId:
to sceneId
}, [currentUser, currentSceneId]); | ||
|
||
return <Toolbar currentUser={currentUser} isAuthor={isAuthor} />; | ||
return <Toolbar currentUser={currentUser} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleaned this up. no longer passing stuff that doesnt make sense
meta comments:
testing results:I have a hard time testing the core issue of the "race conditions" of async preview generation not compatible Instead, I have tested the following to see what is the outcome for preview image generation and uploading:
|
all looks great! change noted as discussed: opening another user's scene, and moving an object, it no longer asks for save as |
one interesting thing here is that screenshots are only set on the first time a scene is saved. won't this cause drift with the screenshot and what the user has created?
EDIT: actually, this relates to "set scene thumbnail". I dont think we need to ask the user to do this and instead we should just do this for the users ourselves.