Open davwheat opened 3 years ago
This is (to an extent) on purpose. We don't see the editedAt
attribute being passed when the post is loaded as a relation, because the BasicPostSerializer
is used, which does not include this attribute. In contrast, when the post is loaded as the primary target, PostSerializer
, which includes editedAt
and other attributes, it used. I suppose editedAt
could be moved to BasicPostSerializer
, but it doesn't seem like an absolutely essential detail to include (for instance, whether a post has been hidden/soft deleted isn't transmitted either with BasicPostSerializer
, and that could also be important to UX). We could also switch to using PostSerializer
for the mentions relationships, but that could mean excessive overhead and slight performance decreases.
I do think that switching to use PostSerializer
might not be the way to go, for the reasons you mentioned, especially as Flarum and forums which use Flarum grow.
How realistic would it be to generate a hash of a post's details (attributes and content) and transmit this as part of the relationship. This could be compared to a client-side generated (or given when the post is initially loaded) hash, and, if they don't match, the post could be reloaded. This would solve the issue of transmitting all the post details multiple times, at the expense of a longer delay in updating posts (but as the chance of the post being updated is so slim, it won't matter much).
How realistic would it be to generate a hash of a post's details (attributes and content) and transmit this as part of the relationship.
Well, to do that, we'd need to pull in the same data that would be needed if we were using PostSerializer, so no backend speed benefit there (just data transmission). Plus there'd have to be a mechanism watching for changed hashes and reloading posts if that's the case. It's possible, but the implementations that immediately come to mind would all be quite messy.
Yeah, that's a good point about loading all the data. What about simply including edited_at
? Or maybe a new column, like attributes_changed_at
which should be updated if anything about the post changes, which can also be tapped in to by other extensions?
If this differs between the relationship provided by the server and the client's local copy, then the post is reloaded?
That's possible, but we'd need to standardize it across all models somehow, or communicate to the frontend which models do/don't support it. Not inherently opposed as an eventual change though.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum. In any case, thanks for taking an interest in this software and contributing by opening the issue in the first place!
We are closing this issue as it seems to have grown stale. If you still encounter this problem with the latest version, feel free to re-open it.
Bug Report
Title could be made clearer by a core dev, most likely. Not sure how to word it.
Current Behavior If two people (A, B) view a discussion, then person A edits a post, and person B replies to the edited post, person B sees the updated content in A's post, but no 'Edited' label shows next to the post. (Confusing, but see video for example.)
The same also occurs with custom post attributes used by extensions (e.g.
fof/best-answer
: previous post doesn't show as best answer even if it has been set).Steps to Reproduce
Edited
label displaysExpected Behavior The updated post should display the
Edited
label next to it (like it does after a full refresh).Screenshots
https://user-images.githubusercontent.com/7406822/102798918-ab746c80-43a9-11eb-8c35-0088f619f4c1.mp4
Environment
php flarum info
Possible Solution
Additional Context The backend seems to not pass changed attributes, only
contentHtml
and some other info of the mentioned post. This means that the client gets the new content, but doesn't know that it was edited.Either: