git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit d15b96a003ad7cda460400ff89c7f363316dd3b5

fix profile ranking, add follow button on profiles sheet

Matt McKegg committed on 2/13/2018, 3:52:29 AM
Parent: ad6ad7c587fb440270e66c1679db0abc3908635a

Files changed

modules/page/html/render/profile.jschanged
modules/sheet/profiles.jschanged
styles/dark/profile-list.mcsschanged
styles/light/profile-list.mcsschanged
modules/page/html/render/profile.jsView
@@ -20,9 +20,8 @@
2020 'feed.pull.profile': 'first',
2121 'sbot.async.publish': 'first',
2222 'keys.sync.id': 'first',
2323 'sheet.display': 'first',
24- 'profile.obs.rank': 'first',
2524 'profile.sheet.edit': 'first',
2625 'app.navigate': 'first',
2726 'profile.obs.contact': 'first',
2827 'profile.obs.recentlyUpdated': 'first',
@@ -233,13 +232,13 @@
233232
234233 // scoped
235234
236235 function onlyFollowing (ids, max) {
237- return computed([ids, contact.yourFollowing, recent], (a, b, c) => {
236+ return computed([recent, ids, contact.yourFollowing], (a, b, c) => {
238237 var result = a.filter(x => b.includes(x) && c.includes(x))
239238 if (result.length === 0 && a.length) {
240239 // fallback to just recent
241- result = a.filter(x => c.includes(x))
240+ result = a.filter(x => b.includes(x))
242241 }
243242 if (max) {
244243 return result.slice(0, max)
245244 } else {
@@ -248,9 +247,9 @@
248247 })
249248 }
250249
251250 function onlyRecent (ids, max) {
252- return computed([ids, recent], (a, b) => {
251+ return computed([recent, ids], (a, b) => {
253252 var result = a.filter(x => b.includes(x))
254253 if (max) {
255254 return result.slice(0, max)
256255 } else {
modules/sheet/profiles.jsView
@@ -5,8 +5,9 @@
55 exports.needs = nest({
66 'sheet.display': 'first',
77 'keys.sync.id': 'first',
88 'contact.obs.following': 'first',
9+ 'contact.html.followToggle': 'first',
910 'profile.obs.rank': 'first',
1011 'about.html.image': 'first',
1112 'about.obs.name': 'first',
1213 'app.navigate': 'first',
@@ -78,25 +79,24 @@
7879 })
7980
8081 function renderContactBlock (profiles) {
8182 var yourId = api.keys.sync.id()
82- var yourFollows = api.contact.obs.following(yourId)
8383 profiles = api.profile.obs.rank(profiles)
8484 return [
8585 h('div', {
8686 classList: 'ProfileList'
8787 }, [
8888 map(profiles, (id) => {
89- var following = computed(yourFollows, f => f.includes(id))
9089 return h('a.profile', {
9190 href: id,
92- classList: [
93- when(following, '-following')
94- ]
91+ title: id
9592 }, [
9693 h('div.avatar', [api.about.html.image(id)]),
9794 h('div.main', [
9895 h('div.name', [ api.about.obs.name(id) ])
96+ ]),
97+ h('div.buttons', [
98+ api.contact.html.followToggle(id, {block: false})
9999 ])
100100 ])
101101 }, { idle: true, maxTime: 2 })
102102 ])
styles/dark/profile-list.mcssView
@@ -102,8 +102,14 @@
102102 }
103103 }
104104 }
105105
106+ div.buttons {
107+ display: flex;
108+ align-items: center;
109+ padding-right: 10px;
110+ }
111+
106112 :hover {
107113 background-color: #434141;
108114 div.controls {
109115 opacity: 1
styles/light/profile-list.mcssView
@@ -103,8 +103,14 @@
103103 }
104104 }
105105 }
106106
107+ div.buttons {
108+ display: flex;
109+ align-items: center;
110+ padding-right: 10px;
111+ }
112+
107113 :hover {
108114 background-color: rgba(255, 255, 255, 0.4);
109115 div.controls {
110116 opacity: 1

Built with git-ssb-web