Ok, so here are multiple issues:
1. In cypher, `NOT NULL` will return `NULL` not `FALSE`. If we want
`FALSE` to be set in the database import, we should use `COAELESCE`
to find the first not-null value.
See:
https://neo4j.com/docs/cypher-manual/current/syntax/working-with-null/https://markhneedham.com/blog/2017/02/22/neo4j-null-values-even-work/
2. I removed the `disabled` and `deleted` checks on the commented
counter. With `neo4j-graphql-js` it is not possible to filter on the
join models (at least not without a lot of complexity) for disabled or
deleted items. Let's live with the fact that the list of commented posts
will include those posts, where the user has deleted his comment or where
the user's comment was disabled. It's being displayed as "not available"
so I think this is OK for now.
3. De-couple the pagination counters from the "commented", "shouted"
etc. counters. It might be that the list of posts is different for
different users. E.g. if the user has blocked you, the "posts" list
will be empty. The "shouted" or "commented" list will not have the
posts of the author. If you are a moderator, the list will include
disabled posts. So the counters are not in sync with the actual list
coming from the backend. Therefore I implemented "fetch and check if
resultSet < pageSize" instead of a global counter.
The latest commit has some cypress tests failing when only a few posts
are visible on the index page. If this explicit default fixes the tests,
the documentation cannot be quite right in saying that it's the default.
FYI: @mattwr18
If we always choose `0` as the default value for `endVal` in case it is
not given (maybe apollo assigns null when the request is in flight) then
just make `0` the default.
Wow @Tirokk that was a good catch! I thought that the emitting side
knows the `index`, but no, it only emits `removePostFromList` and that's
it. In order to delete the right post, we have to pass in the `index`
ourselves. So, the caller of the function is the page component itself.
I didn't see the error myself, because in Javascript if you parse
`undefined` or `null` as Integer, you get 0 and it does not raise an
error.
Created a folder `utils` for PostHelpers.js.
Fixed a new incoming problem of the master with deleting Posts on the User Profile.
Co-Authored-By: mattwr18 <mattwr18@gmail.com>
One is how many comments you wrote, one is how many **posts** are there
with at least one comment of you.
E.g. you can comment twice on the same post. You will have a
`commentedCount` increase of 1 but a `commentsCount` of 2.
FYI @ogerly @Tirokk