Uh oh!
There was an error while loading. Please reload this page.
Allow registering aliases without components - #49
Conversation
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
ariselseng
commented
Mar 21, 2019
@skjnldsv I get |
Don't register a mime, only the alias :) |
ariselseng
commented
Mar 21, 2019
@skjnldsv |
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
skjnldsv
commented
Mar 21, 2019
I pushed a fix, you should be able to register without a group (not needed for you since you want the media group I assume) and without a mimes array :) |
ariselseng
commented
Mar 21, 2019
@skjnldsv Thanks. It works fine now with only id and mimeAliases. I still get |
skjnldsv
commented
Mar 21, 2019
With that? I don't have the issue. Did you build the viewer app ? OCA.Viewer.registerHandler({id: 'camerarawpreviews',mimesAliases: {'image/x-dcraw': 'image/jpeg'}}) |
ariselseng
commented
Mar 21, 2019
@skjnldsv Only doing it in the app. My code is only ran once. This branch is built. If I try directly in the console there is no issue, but when doing it with DOMContentLoaded there is. document.addEventListener("DOMContentLoaded",function(){if(OCA.Viewer){console.log("TEST")OCA.Viewer.registerHandler({id: 'camerarawpreviews',mimesAliases: {'image/x-dcraw': 'image/jpeg'}})}});I only see "TEST" once in the console. |
skjnldsv
commented
Mar 21, 2019
Works here 🤷♀️ |
ariselseng
commented
Mar 21, 2019
@skjnldsv It's a race condition between watch.handlers and beforeMount. |
ariselseng
commented
Mar 21, 2019
@skjnldsv document.addEventListener("DOMContentLoaded",function(){if(OCA.Viewer){setTimeout(function(){OCA.Viewer.registerHandler({id: 'camerarawpreviews',mimesAliases: {'image/x-dcraw': 'image/jpeg'}})},0);}}); |
@skjnldsv if(this.registeredHandlers.indexOf(handler.id)===-1){this.registerHandler(handler)} |
| } | ||
| this.updatePreviousNext() | ||
| } else { | ||
| console.error(`The following file could not be displayed because to view matches its mime type`, fileName, fileInfo) |
There was a problem hiding this comment.
I feel this could be easier written?
There was a problem hiding this comment.
This is meant to be a dev debug. Since no regular user would open the console I guess 🤔
But I've always been terrible at writing error messages, so feel free to suggest a simpler one 😁
There was a problem hiding this comment.
@skjnldsv Hey no worries. I thought it was just unclear what it said. I am actually struggling understanding: "because to view matches". What about this: "The following file could not be displayed due to it's mime type"?
ariselseng
commented
Mar 21, 2019
@skjnldsv diff --git a/src/views/Viewer.vue b/src/views/Viewer.vue
index 722d284..863c2d6 100644
--- a/src/views/Viewer.vue+++ b/src/views/Viewer.vue@@ -158,8 +158,11 @@ export default {
watch: {
// make sure any late external app can register handlers
- handlers: function() {- this.registerHandler(this.handlers[this.handlers.length - 1])+ handlers: {+ handler: function() {+ this.registerHandler(this.handlers[this.handlers.length - 1])+ },+ immediate: false
}
}, |
skjnldsv
commented
Mar 21, 2019
What is the error on your side then? |
ariselseng
commented
Mar 21, 2019
ariselseng
commented
Mar 22, 2019
@skjnldsv Sorry my fix in the watch.handlers did not do anything I am afraid. |
ariselseng
commented
Mar 22, 2019
@skjnldsv Confirmed good fix: diff --git a/src/views/Viewer.vue b/src/views/Viewer.vue
index 722d284..474336e 100644
--- a/src/views/Viewer.vue+++ b/src/views/Viewer.vue@@ -106,6 +106,7 @@ export default {
},
data: () => ({
+ loaded: false,
handlers: OCA.Viewer.availableHandlers,
components: {},
@@ -159,7 +160,9 @@ export default {
watch: {
// make sure any late external app can register handlers
handlers: function() {
- this.registerHandler(this.handlers[this.handlers.length - 1])+ if (this.loaded) {+ this.registerHandler(this.handlers[this.handlers.length - 1])+ }
}
},
@@ -169,6 +172,7 @@ export default {
this.handlers.forEach(handler => {
this.registerHandler(handler)
})
+ this.loaded = true
})
window.addEventListener('resize', this.onResize) |
No this is not the fix we're looking for I think. 🙈 The question is why does the watch gets trigered after the handler is already registered (though this is not really an issue, since it's just a warning that state that the viewer won't register the camerapreview again since it already exists) I'd say, we should merge this and open an issue to properly investigate why the watcher gets fired despite being handled after the domReadyContent. What do you say? The current state of this pr is working for you, right? Aside from the console message? |
ariselseng
commented
Mar 22, 2019
Yes we can merge it. I am not sure what you mean with the fix. With the fix it works both asynchronously and with DOMContentLoaded. Just not asynchronously before DOMContentLoaded. |
DOMContentLoaded is mandatory anyway :) |
skjnldsv
commented
Apr 17, 2019
@cowai I ended up using your fix in #73 :) And sorry if I sounded harsh on my previous comments. I came back to this issue and while reading them, I was not happy with the way I wrote them. I'm very happy of all the help and suggestions you gave me! |
ariselseng
commented
Apr 17, 2019
@skjnldsv No worries. I did not think that at all ;) |
skjnldsv
commented
Apr 17, 2019
@cowai glad to hear!! Thanks 😉 |
Allow registering aliases without components
Allow registering aliases without components
Allow registering aliases without components
Allow registering aliases without components
Allow registering aliases without components
Signed-off-by: John Molakvoæ (skjnldsv) skjnldsv@protonmail.com