Skip to content
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

Force version history to update when restoring a version or sharing #9718

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented Oct 12, 2023

Fixes https://github.com/microsoft/pxt-minecraft/issues/2356

Three version history fixes:

  1. Filter the history file out of the file explorer and github diffs
  2. Explicitly save a history snapshot before restoring an old version of the project so that we definitely save the old version of the project
  3. Save history whenever we do a share so that we don't have to wait for the user to make a change before it shows up in the version history

@riknoll riknoll requested review from eanders-ms and a team October 12, 2023 21:50
Copy link
Contributor

@thsparks thsparks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question but otherwise LGTM!

@@ -375,6 +375,51 @@ namespace pxt.workspace {
toWrite[pxt.HISTORY_FILE] = JSON.stringify(history);
}

export function pushSnapshotOnHistory(text: ScriptText, currentTime: number) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in saveSnapshotAsync in workspace.ts

@@ -375,6 +375,51 @@ namespace pxt.workspace {
toWrite[pxt.HISTORY_FILE] = JSON.stringify(history);
}

export function pushSnapshotOnHistory(text: ScriptText, currentTime: number) {
let history: pxt.workspace.HistoryFile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super necessary, and there might also be something that I'm missing, but have you considered putting this let history .. if .. else.. chunk in a separate function to limit repeated code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's slightly different in each function, sadly

@riknoll riknoll merged commit ace3889 into master Oct 17, 2023
@riknoll riknoll deleted the dev/riknoll/tm-force branch October 17, 2023 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants