Skip to content
This repository was archived by the owner on Nov 23, 2026. It is now read-only.

mediaviewer: add state to urls - #3294

Merged
kulmann merged 1 commit into
owncloud:masterfrom
dschmidt:gallery
Apr 8, 2020
Merged

kulmann merged 1 commit into
owncloud:masterfrom
dschmidt:gallery

Conversation

@dschmidt

@dschmidt dschmidt commented Apr 3, 2020 •

Copy link
Copy Markdown
Member

Hey everyone,

I'm sorry this PR addresses a bunch of separate issues/topics at once.
I wanted to figure out what can be done and what is possible in which scope. I would like to discuss the overall approach here, if desired I can send more fine grained PRs for individual aspects.

Commits can obviously still be cleaned up a bit :)
Loader is also obviously a stupid name for the mixin, any better ideas?
I specifically tried to encapsulate all folder loading logic there so it can be reused in other apps, what do you think about that? Where could we put that?

This includes the commit from #3288.

Description

This PR adds state to app routes (i.e. the context from which they were opened and the file they open). They are accessible as contextRouteName and filePath.

Moreover it adds a local history to the mediaviewer app, so forward and back buttons work and we can smootly animate between different pictures without transitioning between routes (and to keep the changes somewhat limited in this regard).

Related Issue

  • Fixes <issue_link>

Motivation and Context

Apps opened from the files view did not contain state in the url, so F5 is broken. We should either not route to apps or make the urls useful (which I think is a pretty good idea for webapps anyway).

How Has This Been Tested?

I tested local files, favorites and public links.
Navigating to a folder, opening pictures, clicking prev and next, using the forward and back buttons in the browser works as expected, I could not break it or find any behavior that I did not expect...

shares don't allow me to open apps, so not tested.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • Loading the mediaviewer directly for a public link didn't work, even without a password needed ... I don't know why, I couldn't make loadFolder work.

@dschmidt dschmidt added the Status:Needs-Review Needs review from a maintainer label Apr 3, 2020
@dschmidt
dschmidt requested a review from DeepDiver1975 as a code owner April 3, 2020 23:53
@dschmidt dschmidt self-assigned this Apr 3, 2020
@dschmidt
dschmidt requested review from LukasHirt and lordelix April 3, 2020 23:54
@dschmidt

dschmidt commented Apr 4, 2020

Copy link
Copy Markdown
Member Author

it would also be nice to scroll to the last opened file when closing, this comment hints their might be code to achieve that already: #3184 (comment)

Can anyone point me to it?

@kulmann kulmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We already talked about the general direction in private: first of all it's awesome that you brought the app back to life. Second I personally think (like you) that it's very important to map certain aspects of the current state to the URL, and that's definitely the case for the active file in the mediaviewer. Users want to be able to refresh the page on that. So, big 👍 for all of this. I personally would like to have more context data available in core directly, but this in nothing to be addressed in this PR. I left some comments for improvement and also solved scrolling to the active file when closing to the app and going back to the files app (provided in a comment). We're using the path npm package in core, so you can use it to make some more file and folder related lines of this PR easier / more readable.
Thanks for the good work so far!

Comment thread apps/files/src/components/FilesApp.vue Resolved
Comment thread apps/media-viewer/src/Mediaviewer.vue Resolved
Comment thread apps/media-viewer/src/app.js Resolved
Comment thread apps/media-viewer/src/Mediaviewer.vue Resolved
@LukasHirt

Copy link
Copy Markdown
Collaborator

I specifically tried to encapsulate all folder loading logic there so it can be reused in other apps, what do you think about that? Where could we put that?

Since we can't reach mixins from different apps, one option could be to bring this to store. That is however not such a nice solution. If you feel like this would be something really used often we could move it into the owncloud-sdk or as a core plugin.

Comment thread apps/media-viewer/src/Mediaviewer.vue Resolved
Comment thread apps/media-viewer/src/Mediaviewer.vue Resolved
@LukasHirt LukasHirt mentioned this pull request Apr 6, 2020
2 of 9 tasks
@dschmidt

dschmidt commented Apr 6, 2020

Copy link
Copy Markdown
Member Author

I specifically tried to encapsulate all folder loading logic there so it can be reused in other apps, what do you think about that? Where could we put that?

Since we can't reach mixins from different apps, one option could be to bring this to store. That is however not such a nice solution. If you feel like this would be something really used often we could move it into the owncloud-sdk or as a core plugin.

I'm not so familiar with how you are doing things in phoenix, but yes, I think this is something that can and probably will be reused over and over again.

Basically anything that deals with actual files and folders will need at least parts of it. MediaViewer, PDF Viewer or just look at AllFilesList.vue. davUrl, $_ocFilesFolder_getFolder. It could use my mixin instead by passing in this.$route.name as contextRouteName.
I think the code should be shared between regular folder views and apps. No idea if this kind of mixin is the best way, if it should live in core or the sdk or if the sdk should otherwise be fixed to be usable more easily, but this PR paves the way for refactoring it further by at least separating data loading from display logic.

@dschmidt
dschmidt force-pushed the gallery branch 2 times, most recently from 9ac1720 to 43774f1 Compare April 6, 2020 18:31
@dschmidt

dschmidt commented Apr 6, 2020 •

Copy link
Copy Markdown
Member Author

Hope I addressed all of the raised concerns :)

@dschmidt
dschmidt force-pushed the gallery branch 3 times, most recently from da6e016 to ff3ee4c Compare April 6, 2020 19:14
Comment thread apps/media-viewer/src/Mediaviewer.vue Resolved
@LukasHirt

Copy link
Copy Markdown
Collaborator

I'm not so familiar with how you are doing things in phoenix, but yes, I think this is something that can and probably will be reused over and over again.

The problem I'm seeing here is that bringing this to core would seem to me like making core dependent on files app. So bringing this as a core plugin doesn't feel right to me. And since we can't reach mixins from other apps this approach is automatically dismissed as well. So I guess the only solutions we are left with are the sdk or store.

Let's raise a ticket for this where we can discuss the best approach and put in the code a TODO with the link to it so we don't block this PR.

@LukasHirt

Copy link
Copy Markdown
Collaborator

LGTM. If @kulmann is also happy with changes I'd say let's merge it 😉

@kulmann kulmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please fix console outputs. After that it's good for merge 👍

Comment thread apps/media-viewer/src/mixins/loader.js Resolved
Comment thread apps/media-viewer/src/mixins/loader.js Resolved
Comment thread apps/media-viewer/src/mixins/loader.js Resolved
Comment thread apps/media-viewer/src/mixins/loader.js Resolved

@kulmann kulmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Happy to get this merged now. Thanks for your work!

@kulmann

kulmann commented Apr 8, 2020 •

Copy link
Copy Markdown
Contributor

@dschmidt Are you fine with squashing this PR into one commit before the merge?

@dschmidt

dschmidt commented Apr 8, 2020

Copy link
Copy Markdown
Member Author

If that's what you do in this project 🤷

... usually I like having a proper history, but as there's quite a bit of back and forth here, I can squash, sure.

@kulmann

kulmann commented Apr 8, 2020

Copy link
Copy Markdown
Contributor

If that's what you do in this project 🤷

... usually I like having a proper history, but as there's quite a bit of back and forth here, I can squash, sure.

Yes, I'm all for a clean history as well, but I don't think that it's worth the effort to do this for your 26 commits. ;-) And having 1 is nicer than having the 26. 😁

@dschmidt

dschmidt commented Apr 8, 2020

Copy link
Copy Markdown
Member Author

Yeah, well ... squashed :)

This commit adds context to apps in general and state to the mediaviewer app. It should be considered a first step towards further refactoring for more reuse of code and less boilerplate in apps.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Status:Needs-Review Needs review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants