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

Markdown: merge uploaded files callback #5980

Merged
merged 13 commits into from
Feb 25, 2025

Conversation

tesar-tech
Copy link
Collaborator

@tesar-tech tesar-tech commented Feb 21, 2025

Description

Closes #5977

  • When user uploads multiple files at once they got all in one batch to the ImageUploadChanged. This is done by waiting for the imageUploadFunction in js for 100ms.
  • Also fixes issues with deleted reference in js, while keeping the reference in c#. This was also an issue with FileEdit. Implementation leverages the finalizer of FileEntry object. (the sub-issue 2)
  • Also fixes the sub-issue (1)
  • This also add s the Debug.WriteLine to safe js calling as otherwise it often silences an important exceptions.

… (by creating new empty dictionary) in js. Introduces "bug" where file entries in js keeps growing. To be fixed in the next commit.
…eleting of the file entry is bound to the lifetime of the c# FileEntry instance. When garbage collecting the instance, the entry is deleted from js. This ensures synchronization of existing (reachable) objects between c# and js. This commit extends the IFileEntryOwner.cs to keep the fileEntry deleting logic out of the interface implementations (FileEdit and Markdown)
@tesar-tech tesar-tech requested a review from stsrki February 21, 2025 08:27
@stsrki
Copy link
Collaborator

stsrki commented Feb 24, 2025

@tesar-tech, the name of your branch indicates 1.7, but you're targeting master. Mistake or intentional?

file.FileUploadEndedCallback.SetResult();
}

foreach ( var file in fileEntries )
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to be working fine on my side. Not sure if there will be any sideefects now with your solution so please check.

Also, the finalizer was never reached for me in debug mode. Maybe we don't need it anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is working, until user code hits the #5977 sub-issue 2. If we can live with that than the finalizer isn't needed...

Copy link
Collaborator

Choose a reason for hiding this comment

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

We never meant to support that anyway. The file should be handled asap during the changed event.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that's why I suggested the rename and the api change to TryWriteToStreamAsync, so users don't shoot their own leg with our "shoulds".

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nah :)

OK, please remove finalizers from final versions. And add release notes before I merge it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok.

You mean release notes here #5857 or creating a release note 175 .razor?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, sorry, I didn't notice you have changed branch. Skip release notes, then. I will do that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is working, until user code hits the #5977 sub-issue 2. If we can live with that than the finalizer isn't needed...

I should have done more tests. It seems we have now broken FilePicker. And FIlePicker works by saving references for later upload. So, I think we will need to go back to the finalizer or find an alternative for

foreach ( var file in files )
{
    await file.Owner.RemoveFileEntry( file.Id );
}

@tesar-tech tesar-tech changed the base branch from master to rel-1.7 February 24, 2025 21:01
@stsrki stsrki merged commit ae0cd5d into rel-1.7 Feb 25, 2025
2 checks passed
@stsrki stsrki deleted the sup/rel-1.7/Markdown-merge-uploaded-files-callback branch February 25, 2025 10:24
@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown: merge uploaded files callback
2 participants