-
Notifications
You must be signed in to change notification settings - Fork 681
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
Keep track of preview visibility on the server so it persists at page reload #1366
Conversation
src/server.js
Outdated
@@ -280,6 +280,14 @@ function init(socket, client) { | |||
client.names(data); | |||
} | |||
); | |||
|
|||
socket.on("msg:preview:toggle", function(data) { | |||
const chan = client.find(data.target).chan; |
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.
Add undefined checks for all these find
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.
@xPaw, done, are you okay with how I did that?
So doing |
Right, mentioned that in the PR description when I opened it. |
src/server.js
Outdated
|
||
socket.on("msg:preview:toggle", function(data) { | ||
const networkAndChan = client.find(data.target); | ||
if (networkAndChan) { |
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.
You could just return
in each if instead of going deeper.
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.
Done. I honestly prefer the nested version, shorter and makes more sense to me, but whatever.
Adding do not merge
label so I remember to squash before merging.
Maybe for collapse command we can do an optimization trick where it sends |
Agreed we can probably benefit from optimization later, but I won't have the cycles to do that right now. I'll let someone else chime in in a further PR, though I don't believe this will be an issue anyway. |
Otherwise, I believe this PR is up for review :) |
68be238
to
1572892
Compare
…view-toggle Keep track of preview visibility on the server so it persists at page reload
Alright, this will be my last preview-related enhancement for this release.
This is going to be especially useful because of the support for multiple previews per message + the image viewer cycling. Before this PR, collapsing NSFW previews then refreshing then cycling on image previews would display them back, oops!
One issue to keep in mind with this implementation is that running
/collapse
//expand
will emit as many times as there are previews to collapse/expand. I don't think this is an issue that is going to have tremendous repercussions performance-wise, so I think any improvements over this can be done in a further PR (help welcome!).