diff options
| author | Eva <evauwu@riseup.net> | 2023-05-26 09:48:27 +0200 |
|---|---|---|
| committer | Eva <evauwu@riseup.net> | 2024-03-21 21:53:11 +0100 |
| commit | a16bb198ab937ae0a0661c85c0bc2997d6407d5d (patch) | |
| tree | 0210fcd5e6a9bbc33e92de0cda10d93d1f271c0a /client | |
| parent | 3f182a66add4cae057083de00c3ba504674043a7 (diff) | |
client/views: more thorough link fallbacks
Prevents a bunch of errors that can happen when a resource is deleted.
Diffstat (limited to 'client')
| -rw-r--r-- | client/js/util/views.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/client/js/util/views.js b/client/js/util/views.js index 38c98a1..bb52409 100644 --- a/client/js/util/views.js +++ b/client/js/util/views.js @@ -209,13 +209,13 @@ function makePostLink(id, includeHash) { } function makeTagLink(name, includeHash, includeCount, tag) { - const category = tag ? tag.category : "unknown"; + const category = tag && tag.category ? tag.category : "unknown"; let text = misc.getPrettyName(name); if (includeHash === true) { text = "#" + text; } if (includeCount === true) { - text += " (" + (tag ? tag.postCount : 0) + ")"; + text += " (" + (tag && tag.postCount ? tag.postCount : 0) + ")"; } return api.hasPrivilege("tags:view") ? makeElement( @@ -234,15 +234,15 @@ function makeTagLink(name, includeHash, includeCount, tag) { } function makePoolLink(id, includeHash, includeCount, pool, name) { - const category = pool ? pool.category : "unknown"; + const category = pool && pool.category ? pool.category : "unknown"; let text = misc.getPrettyName( - name ? name : pool ? pool.names[0] : "unknown" + name ? name : pool && pool.names ? pool.names[0] : "unknown" ); if (includeHash === true) { text = "#" + text; } if (includeCount === true) { - text += " (" + (pool ? pool.postCount : 0) + ")"; + text += " (" + (pool && pool.postCount ? pool.postCount : 0) + ")"; } return api.hasPrivilege("pools:view") ? makeElement( @@ -264,7 +264,7 @@ function makeUserLink(user) { let text = makeThumbnail(user ? user.avatarUrl : null); text += user && user.name ? misc.escapeHtml(user.name) : "Anonymous"; const link = - user && api.hasPrivilege("users:view") + user && user.name && api.hasPrivilege("users:view") ? makeElement( "a", { href: uri.formatClientLink("user", user.name) }, |