-
Notifications
You must be signed in to change notification settings - Fork 489
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
fix: allow json and text fiels to be in preview file component #1646
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.
nit: it is not possible to select text because it tries to drag&drop entire preview.
I think we should disable d&d for text previews, as its more usefulf for people to be able to select part of text and copy it.
Done! Also added |
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.
@rafaelramalho19 thanks!
last nit: you switched to concat
, which shows full file, but @jessicaschilling agreed we should be keeping first
to avoid loading unbound text files into browser. Mind changing it back to first
and if buf.length > 256000
show a footer at the end of preview informing user that preview was truncated?
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.
@rafaelramalho19 something is still fishy: (1) clicking on "Load more" loaded entire thing instead of just one more chunk, and still displayes the footer. When i click on "Load more" again the footer disapears (2) footer is displayed for small text file, where is nothing more to load
Are you able to reproduce? (I'm on Firefox)
Yes - in |
Yes @lidel , but the weird thing is that the buffer says that |
@rafaelramalho19 iterator docs suggest thats expected behavior?
Some ideas:
|
5982cd1
to
635cac3
Compare
This means right click → save as and "Download" buttons will result in file save dialog that defaults to the name used in MFS
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.
@rafaelramalho19 works as expected and UX when opening huge text files is pretty nice now, thank you! 👌
Feel free to merge this and prepare a patch release, so we can include it in ipfs/ipfs-desktop#1638 🚢
Please do the first and not the second. If you do the second, the iterator will not know that it's not going to be invoked any more so will not perform any resource cleanup, tear down underlying streams etc, and could leak resources. For example: async function * gen () {
yield 'hello'
console.info('i will do cleanup now')
}
async function main () {
console.info('using low-level API')
const iter = gen()
const val = await iter.next()
console.info('val', val)
console.info('not calling .next again..')
console.info('---')
console.info('using for...await of')
for await (const val of gen()) {
console.info('val', val)
}
console.info('all done')
}
main() Running this file results in:
Note how when using the low-level |
Thanks @achingbrain, I've filled #1652 with an idea how to avoid the cleanup problem. @rafaelramalho19 I don't believe this should block (we will address #1652 in a later release of webui) |
Closes #1642
Closes #1647
Important info: https://github.com/achingbrain/uint8arrays#tostringarray-encoding--utf8
Questions
ipfs.cat
start returning uint8arrays recently?