From 5caf5fa00d5fb9f2031cd51f469b422e393e8c52 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 11 Feb 2020 16:47:00 +0100 Subject: [PATCH 1/5] link fe: display unread counts for public channels Was previously only displaying for the private channel. --- pkg/interface/link/src/js/components/lib/channel-sidebar.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/interface/link/src/js/components/lib/channel-sidebar.js b/pkg/interface/link/src/js/components/lib/channel-sidebar.js index a845abd90..b7a75d104 100644 --- a/pkg/interface/link/src/js/components/lib/channel-sidebar.js +++ b/pkg/interface/link/src/js/components/lib/channel-sidebar.js @@ -45,6 +45,9 @@ export class ChannelsSidebar extends Component { let selected = (props.selected === path); let linkCount = !!props.links[path] ? props.links[path].totalItems : 0; + const unseenCount = !!props.links[path] + ? props.links[path].unseenCount + : linkCount return ( ) }); From 94feb5bf2e97be6c65727fc01cd3c987c616ef88 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 11 Feb 2020 16:50:42 +0100 Subject: [PATCH 2/5] link fe: ensure item and page counts Getting updates for things we hadn't gotten initial data on would leave us without any counters. This defaults them to zero, if we don't have any yet. --- pkg/interface/link/src/js/reducers/link-update.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/interface/link/src/js/reducers/link-update.js b/pkg/interface/link/src/js/reducers/link-update.js index d183e8457..3c90cc31c 100644 --- a/pkg/interface/link/src/js/reducers/link-update.js +++ b/pkg/interface/link/src/js/reducers/link-update.js @@ -76,7 +76,7 @@ export class LinkUpdateReducer { data.pages, state.links[path] ); state.links[path].unseenCount = - state.links[path].unseenCount + data.pages.length; + (state.links[path].unseenCount || 0) + data.pages.length; } } @@ -160,7 +160,14 @@ export class LinkUpdateReducer { // - _addNewItems(items, pages = {local: {}}, page = 0) { + _addNewItems(items, pages, page = 0) { + if (!pages) { + pages = { + local: {}, + totalPages: 0, + totalItems: 0 + }; + } const i = page; if (!pages[i]) { pages[i] = []; From e801316368ac5dd13f2e7ab0f3eaab56863fce7e Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 11 Feb 2020 17:16:07 +0100 Subject: [PATCH 3/5] link fe: display correct member counts We were passing in a contacts object, which may not always contain all group members. We now pass in a groups object (set of ships) instead, and derive contributor count from that. --- .../link/src/js/components/lib/channel-sidebar.js | 8 ++++---- pkg/interface/link/src/js/components/lib/channels-item.js | 6 ++++-- pkg/interface/link/src/js/components/root.js | 7 ++++--- pkg/interface/link/src/js/components/skeleton.js | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pkg/interface/link/src/js/components/lib/channel-sidebar.js b/pkg/interface/link/src/js/components/lib/channel-sidebar.js index b7a75d104..aa1d72515 100644 --- a/pkg/interface/link/src/js/components/lib/channel-sidebar.js +++ b/pkg/interface/link/src/js/components/lib/channel-sidebar.js @@ -10,7 +10,7 @@ export class ChannelsSidebar extends Component { const { props, state } = this; let privateChannel = - Object.keys(props.paths) + Object.keys(props.groups) .filter((path) => { return (path === "/~/default") }) @@ -25,7 +25,7 @@ export class ChannelsSidebar extends Component { { return (!path.startsWith("/~/")) }) @@ -53,7 +53,7 @@ export class ChannelsSidebar extends Component { 0 ? {" " + props.unseenCount + " unread"} : null; diff --git a/pkg/interface/link/src/js/components/root.js b/pkg/interface/link/src/js/components/root.js index a1b424eb5..893621866 100644 --- a/pkg/interface/link/src/js/components/root.js +++ b/pkg/interface/link/src/js/components/root.js @@ -31,6 +31,7 @@ export class Root extends Component { const { props, state } = this; let paths = !!state.contacts ? state.contacts : {}; + const groups = !!state.groups ? state.groups : {}; let links = !!state.links ? state.links : {}; let comments = !!state.comments ? state.comments : {}; @@ -43,7 +44,7 @@ export class Root extends Component { return ( @@ -84,7 +85,7 @@ export class Root extends Component { return ( Date: Tue, 11 Feb 2020 17:39:03 +0100 Subject: [PATCH 4/5] link fe: rename members -> contacts and refactor Renames the somewhat ambiguous "members" property into "contacts", to more clearly indicate the source/nature of the data within. (Avoid confusion with "members of a group", which is contained in groups instead.) Also refactors the retrieving of appropriately-defaulted contact values into a utility function. --- .../link/src/js/components/lib/comments.js | 16 +++++--------- pkg/interface/link/src/js/components/link.js | 5 +++-- .../link/src/js/components/links-list.js | 21 ++----------------- pkg/interface/link/src/js/components/root.js | 10 ++++----- pkg/interface/link/src/js/lib/util.js | 13 ++++++++++++ 5 files changed, 28 insertions(+), 37 deletions(-) diff --git a/pkg/interface/link/src/js/components/lib/comments.js b/pkg/interface/link/src/js/components/lib/comments.js index bd80497e8..c76a706b3 100644 --- a/pkg/interface/link/src/js/components/lib/comments.js +++ b/pkg/interface/link/src/js/components/lib/comments.js @@ -2,7 +2,7 @@ import React, { Component } from 'react' import { CommentItem } from './comment-item'; import { CommentsPagination } from './comments-pagination'; -import { uxToHex } from '../../lib/util'; +import { getContactDetails } from '../../lib/util'; import { api } from '../../api'; export class Comments extends Component { @@ -48,20 +48,14 @@ export class Comments extends Component { let commentObj = commentsPage[entry] let { ship, time, udon } = commentObj; - let members = !!props.members - ? props.members - : {}; + let contacts = !!props.contacts + ? props.contacts + : {}; - let nickname = !!members[ship] - ? members[ship].nickname - : ""; + const {nickname, color} = getContactDetails(contacts[ship]); let nameClass = nickname ? "inter" : "mono"; - let color = !!members[ship] - ? uxToHex(members[ship].color) - : "000000"; - return( Date: Tue, 11 Feb 2020 17:41:32 +0100 Subject: [PATCH 5/5] link fe: prefix ship names in comments with sig --- pkg/interface/link/src/js/components/lib/comment-item.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/link/src/js/components/lib/comment-item.js b/pkg/interface/link/src/js/components/lib/comment-item.js index d2d8fa61c..65c5b4ee3 100644 --- a/pkg/interface/link/src/js/components/lib/comment-item.js +++ b/pkg/interface/link/src/js/components/lib/comment-item.js @@ -41,7 +41,7 @@ export class CommentItem extends Component { />

- {((props.nickname) ? props.nickname : props.ship)} + {props.nickname ? props.nickname : '~'+props.ship} {this.state.timeSinceComment}