This is part of https://github.com/publiclab/plots2/issues/8513
Refer to https://github.com/publiclab/plots2/pull/8935#issuecomment-754906297
That will remove empty topics from the dashboard.
Hi @jywarren 馃憢馃従
I spent some part of the day racking my brain on how to approach this issue, I'll appreciate any input you have on this... So how the topics are displayed currently, is that;
current_user.subscriptions(:tag).includes(:tag).where.not(tid: exclude_tids) which returns an array of tag selections...[#<TagSelection:0x00007fcd5eed62b8
user_id: 3,
tid: 73,
following: true,
created_at: Thu, 24 Dec 2020 13:34:28 UTC +00:00,
updated_at: Thu, 07 Jan 2021 13:20:36 UTC +00:00>,
#<TagSelection:0x00007fcd5eed60b0
user_id: 3,
tid: 76,
following: true,
created_at: Thu, 24 Dec 2020 13:34:28 UTC +00:00,
updated_at: Wed, 06 Jan 2021 12:35:43 UTC +00:00>,
.
.
]
I have thought about maybe adding a display: none on a topic card that has 0 notes but this seems like a hack which I have to also think about pagination that already included the topic card on a particular page... so this is not ideal...
Next, I thought, of either at the controller/model level.. most likely at the model... obtaining the tags of each tag selection, then, figuring out if each tag has notes/wikis available, removing tags that don't... then using the tids to get back the tag selections to render back to the Topic Card... this approach feels like maybe there should be an easy way.. like perhaps a way to order the tags in such a way that empty tags are at the last pages or there could be an inner join(which I'm not very good at creating) that could be used for this...
Let me know what you think 馃槄
Also just realized that even if I remove empty tags before sending them to the view, there is a possibility that a topic might end up empty because of the shown_nids... we prevent the double display of nodes within the topic cards so what if a topic has nids that have already been displayed? They end up empty... so the display:none option is looking pretty viable now 馃槄
Hi @RuthNjeri i'm sorry i ran out of time today... i will be sure to go through this tomorrow afternoon. Thanks for your patience!
I actually really like the idea of adding a display: none on a topic card that has 0 notes
however, one way we could improve on this perhaps is to use a class like https://getbootstrap.com/docs/4.4/utilities/display/#hiding-elements -- and maybe an extra class like has-no-posts, solely as an indication of /why/ we're hiding it. So, if the two classes are used next to one another, our custom class kind of provides explanation for why the bootstrap class is being used to hide the element. Kind of an odd way to do it but it makes sense in terms of communicating with other developers! what do you think?
and, do you think pagination will be a big problem? I mean, only if you get a whole page of hidden topics, perhaps? or some confusion if there's a page where most are hidden and you see a "next page" link even though you're only seeing like 3 topics? This seems like a pretty unlikely scenario... but just to be thorough, we could consider showing a simple bar like Water quality | no recent posts or something instead of just hiding it. I don't like this solution quite as much but if the likelihood of confusion from pagination is higher than I'm imagining, i can see it as a possible way out.
Thanks, Ruth!!
Thanks for the feedback, I like your suggestion of using two classes... I could also add a comment just in case...
I can test out the pagination issue by manipulating some data locally and see what happens...
Also, I think because this is just version 2, we can begin with the hidden class...I could also add a link of this issue in the comment just in case an alternative is needed and we could implement Water quality | no recent posts in version 3...
Most helpful comment
I actually really like the idea of
adding a display: none on a topic card that has 0 noteshowever, one way we could improve on this perhaps is to use a class like https://getbootstrap.com/docs/4.4/utilities/display/#hiding-elements -- and maybe an extra class like
has-no-posts, solely as an indication of /why/ we're hiding it. So, if the two classes are used next to one another, our custom class kind of provides explanation for why the bootstrap class is being used to hide the element. Kind of an odd way to do it but it makes sense in terms of communicating with other developers! what do you think?