-
Notifications
You must be signed in to change notification settings - Fork 55
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
update history when opening and closing viewer #488
Conversation
* Add the `openfile` param to the url when opening a file * update the document title from the Mime mixin * push the new url to the browser history * Also update the title and push the url when moving inside a collection * push original url to browser history state when closing the viewer fixes server#12470 Alternatives ------------ We could pop state back to where we started when closing the viewer. That way history would not contain urls for visited files. In particular when navigating through collections I think having a full history may be useful Warning ------- Adds the following warning: ``` /home/next/code/nextcloud/server/apps/viewer/src/mixins/Mime.js 111:20 warning The property or function OC.encodePath was deprecated in Nextcloud 18.0.0 ``` I tried to work around it by using encodePath from https://www.npmjs.com/package/@nextcloud/paths But no external imports are allowed in mixins. Next Steps ---------- * Handle popstate events so we can actually go back in history Signed-off-by: Azul <azul@riseup.net>
1a50389
to
45a9036
Compare
Hi @azul ! I'm not sure this is the road to take for this to be honest. |
@skjnldsv my main focus was on getting an actionable url when opening the viewer. In terms of what others do:
|
I would only therefore add a click listener and close the viewer on it. |
|
I didn't took those example because both of them have different behavior. The urls changes because you can access the ressources directly. But we don't, so the navigation will make no sense as reloading will lead to a different view. Nextcloud doesn't offer to access the viewer directly. If there was, sure, this feature would make sense :) |
@skjnldsv There is a way to access files opened in the viewer directly now. The urls i am adding also work on reload / copied to another browser window. |
Aaah, I was not aware this got in! Nice! |
One thing that is still not working with this commit though is navigating back in history to a given image. This will require an update to the servers |
I have not tried this. I will give it a try. I think we could make it work in talk as well. But that would require changes to talk then. |
So my current thinking is this:
Moving in history is handled by
Optionally Apps that want to react to The simplified |
Thanks for the insight @azul :) Here's my proposal. Then on files, you can register the full behavior you wanted with the history.
|
@skjnldsv Your proposal sounds good and clean to me. It's a similar situation where it's difficult for the viewer app to guess the correct title to display. Title handling and history operations are closely related as the current history entry will be shown with the title it had when the next entry is added. So what one usually wants to do is first push the new history entry and then update the title. Oh... one more thing comes to my mind... We might also need a close callback that gets called when the viewer is closed again - or is there already a way to detect this? |
Another thought.... do we need to differenciate between So how about a |
I wouldn't mix everything. |
@skjnldsv I just noticed that i can use Vue.js to watch Is there a reason for keeping the file that was opened first in |
It should be updated indeed 🤔 |
What i was doing is a reactivity binding from the files app just to see if it works: export default {
name: 'History',
components: {},
data() {
return {
Viewer: OCA.Viewer.state,
}
},
computed: {
file() {
return this.Viewer.file
},
},
watch: {
file: function(val, oldVal) {
alert(val + ' <- ' + oldVal)
},
},
} But I don't know if this kind of reactivity binding between apps is a good idea or not. On the one hand i think the state is somewhat internal to the viewer. On the other hand it would allow for watching such things really easily and the 'normal' vue.js way. |
I don't understand what you're doing, this is against what I told in #488 (comment) ? |
Okay... sorry. I see how this can be confusing. I'll try to clarify. I got back about what you told me above in #488 (comment) and #488 (comment) . Main point being that in order to get the History handling working we'd also need a way to trigger code when the initial file was opened and when the viewer was closed. (As these also should result in updates to the history). My suggestion would be something like I continued looking at the code for further understanding and noticed that the exposed My last comment was trying to explain the approach i took there to clarify if this is an expected use of I'm happy to use and implement either approach. Just trying to make sure I don't add a callback based API when using the exposed |
That's what I was afraid. So you need to add the proper onNext and onPrev callbacks, that is all we need :) Line 34 in b313993
No need to watch anything, you trigger them on the the already existing previous and next functionsLines 609 to 628 in 0158091
And regarding having to trigger on open, well, since the app trigerred the Viewer open, it will know when it's triggerred 😉 |
I understand a bit more. |
Ok, I'll add |
openfile
param to the url when opening a filefixes nextcloud/server#12470
Alternatives
We could pop state back to where we started when closing the viewer.
That way history would not contain urls for visited files.
In particular when navigating through collections
I think having a full history may be useful
Warning
Adds the following warning:
I tried to work around it
by using encodePath from https://www.npmjs.com/package/@nextcloud/paths
But no external imports are allowed in mixins.
Next Steps