question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add something like `is_leaf` Boolean field to serialized ContentNodes to replace common "leaf or branch" checks in JS code

See original GitHub issue

In the ContentNodeViewSet (and other related viewsets), it would be nice to have a field like is_leaf that returns true whenever the node is a resource/leaf and false if it is a topic or a channel.

There are dozens of places in the JS code where we have to check if this is the case based on the kind field that could be simplified if we had this field.

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
rtibblescommented, Mar 15, 2021

Noting that on the backend TOPIC should be the kind on every node that isn’t a leaf node (even the channel root node), wherever the special CHANNEL kind is being set it is only on the frontend.

So, the annotated field on the ContentNodeViewset would just be a simple boolean check of kind == 'TOPIC'.

1reaction
jonboisercommented, Mar 15, 2021

So, after adding the is_leaf field on the ContentNodeViewset, checks on the frontend like kind === ContentNodeKinds.TOPIC || kind === ContentNodeKinds.CHANNEL can be replace by a simple !is_leaf. Am I correct?

Yes, that’s right. I think we can even safely replace the kind === ContentNodeKinds.TOPIC check (without the check for CHANNEL) in most places as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

prosemirror-demo/0.15.0.html at master - GitHub
default) nodes get dropped when their entire content is replaced,. whereas defining nodes persist and wrap the inserted content. Likewise, the the <em> ......
Read more >
https://fit.ijf.org/assets/b/javascript.e85c570d.j...
modules are defined as an array // [ module function, map of requires ] // // map of requires is short require name...
Read more >
Collaborative JavaScript Debugging - JS Bin
A live pastebin for HTML, CSS & JavaScript and a range of processors, including SCSS, CoffeeScript, Jade and more...
Read more >
Fast and easy JSON output: using the new JSON serializer
Using the serializer is as simple as adding a serialization declaration to the top of an XQuery: declare option exist:serialize "method=json ...
Read more >
Rev 2807 and /web/ Rev 2808 - WebSVN – ALCASAR
events, perform animations, and add Ajax interactions to your web pages. USED : used for the entire userinterface. jquery.dataTables.js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found