git ssb

1+

Daan Patchwork / manyverse



Commit d7816dd2aeba4ca8d2f6ed7ebcfd215098f9b7d7

dx: tiny refactor in ListOfPeers

Andre Staltz committed on 4/23/2020, 1:32:42 PM
Parent: e49a289c25079d2d6f3c6fbaf04d15ffaab42753

Files changed

src/frontend/screens/central/connections-tab/view/Body/ListOfPeers.tschanged
src/frontend/screens/central/connections-tab/view/Body/ListOfPeers.tsView
@@ -152,19 +152,40 @@
152152 if (nextProps.stagedPeers !== prevProps.stagedPeers) return true;
153153 return false;
154154 }
155155
156+ private getItemHeight = (entry: MixedPeerKV) => {
157+ return isRoomKV(entry) ? SHORT_ITEM_HEIGHT : ITEM_HEIGHT;
158+ };
159+
160+ /**
161+ * Sort peers lexicographically by the extracted key:
162+ * - First, the room server
163+ * - Second, room peers in connection
164+ * - Third, staged room peers
165+ */
166+ private roomsKeyExtractor = (entry: MixedPeerKV) => {
167+ const [addr] = entry;
168+ if (isRoomKV(entry)) {
169+ return `A-${addr}`;
170+ } else if (isInConnection(entry)) {
171+ return `B-${addr}`;
172+ } else {
173+ return `C-${addr}`;
174+ }
175+ };
176+
177+ private renderPeer = (peer: PeerKV) => {
178+ return h(ConnectionItem, {peer, onPressPeer: this.props.onPressPeer});
179+ };
180+
156181 private renderStagedPeer = (peer: StagedKV) => {
157182 return h(StagedItem, {
158183 peer,
159184 onPressStaged: this.props.onPressStaged,
160185 } as StagedItemProps);
161186 };
162187
163- private renderPeer = (peer: PeerKV) => {
164- return h(ConnectionItem, {peer, onPressPeer: this.props.onPressPeer});
165- };
166-
167188 private renderRoom = (room: RoomKV) => {
168189 return h(RoomItem, {
169190 room,
170191 onPressRoom: this.props.onPressRoom,
@@ -180,29 +201,8 @@
180201 return this.renderStagedPeer(entry);
181202 }
182203 };
183204
184- private getItemHeight = (entry: MixedPeerKV) => {
185- return isRoomKV(entry) ? SHORT_ITEM_HEIGHT : ITEM_HEIGHT;
186- };
187-
188- /**
189- * Sort peers lexicographically by the extracted key:
190- * - First, the room server
191- * - Second, room peers in connection
192- * - Third, staged room peers
193- */
194- private roomsKeyExtractor = (entry: MixedPeerKV) => {
195- const [addr] = entry;
196- if (isRoomKV(entry)) {
197- return `A-${addr}`;
198- } else if (isInConnection(entry)) {
199- return `B-${addr}`;
200- } else {
201- return `C-${addr}`;
202- }
203- };
204-
205205 public render() {
206206 return h(View, {style: this.props.style}, [
207207 // Hub peers first
208208 h<PopListProps<PeerKV>>(PopList, {

Built with git-ssb-web