Commit 19f35e2c94a94cff5dd05b17e542ca140e76edd5
Only show viewers toggle on own profile
Anders Rune Jensen committed on 8/23/2018, 10:45:54 PMParent: 12159b81d351d1a871b5da6f49b9831a3ad151e2
Files changed
about/html/edit.js | changed |
about/html/edit.js | |||
---|---|---|---|
@@ -39,8 +39,10 @@ | |||
39 | 39 … | // TODO refactor this to use obs better | |
40 | 40 … | function edit (id) { | |
41 | 41 … | // TODO - get this to wait till the connection is present ! | |
42 | 42 … | ||
43 … | + var isMe = api.keys.sync.id() === id | ||
44 … | + | ||
43 | 45 … | var avatar = Struct({ | |
44 | 46 … | current: api.about.obs.imageUrl(id), | |
45 | 47 … | new: Dict() | |
46 | 48 … | }) | |
@@ -68,15 +70,15 @@ | |||
68 | 70 … | var names = dictToCollection(namesRecord) | |
69 | 71 … | ||
70 | 72 … | var publicWebHosting = Struct({ | |
71 | 73 … | current: api.about.obs.latestValue(id, 'publicWebHosting'), | |
72 | - new: Value() | ||
74 … | + new: Value(api.about.obs.latestValue(id, 'publicWebHosting')()) | ||
73 | 75 … | }) | |
74 | 76 … | ||
75 | 77 … | var lightbox = hyperlightbox() | |
76 | 78 … | ||
77 | 79 … | var isPossibleUpdate = computed([name.new, avatar.new, publicWebHosting.new], (name, avatar, publicWebHostingValue) => { | |
78 | - return name || avatar.link || publicWebHostingValue != publicWebHosting.current() | ||
80 … | + return name || avatar.link || (isMe && publicWebHostingValue !== publicWebHosting.current()) | ||
79 | 81 … | }) | |
80 | 82 … | ||
81 | 83 … | var avatarSrc = computed([avatar], avatar => { | |
82 | 84 … | if (avatar.new.link) return api.blob.sync.url(avatar.new.link) | |
@@ -139,19 +141,20 @@ | |||
139 | 141 … | 'ev-keyup': e => name.new.set(e.target.value) | |
140 | 142 … | }) | |
141 | 143 … | ]) | |
142 | 144 … | ]), | |
143 | - h('section.viewer', [ | ||
144 | - h('header', 'Public viewers'), | ||
145 | - h('section', [ | ||
146 | - h('span', 'Show my posts on public viewers'), | ||
147 | - h('input', { | ||
148 | - type: 'checkbox', | ||
149 | - checked: publicWebHosting.current, | ||
150 | - 'ev-change': e => publicWebHosting.new.set(e.target.checked) | ||
151 | - }) | ||
152 | - ]) | ||
153 | - ]), | ||
145 … | + isMe | ||
146 … | + ? h('section.viewer', [ | ||
147 … | + h('header', 'Public viewers'), | ||
148 … | + h('section', [ | ||
149 … | + h('span', 'Show my posts on public viewers'), | ||
150 … | + h('input', { | ||
151 … | + type: 'checkbox', | ||
152 … | + checked: publicWebHosting.current, | ||
153 … | + 'ev-change': e => publicWebHosting.new.set(e.target.checked) | ||
154 … | + }) | ||
155 … | + ]) | ||
156 … | + ]) : '', | ||
154 | 157 … | when(isPossibleUpdate, h('section.action', [ | |
155 | 158 … | h('button.cancel', { 'ev-click': clearNewSelections }, 'cancel'), | |
156 | 159 … | h('button.confirm', { 'ev-click': handleUpdateClick }, 'confirm changes') | |
157 | 160 … | ])) | |
@@ -231,9 +234,9 @@ | |||
231 | 234 … | } | |
232 | 235 … | ||
233 | 236 … | if (newName) msg.name = newName | |
234 | 237 … | if (newAvatar.link) msg.image = newAvatar | |
235 | - if (publicWebHosting.new() != publicWebHosting.current()) msg.publicWebHosting = publicWebHosting.new() | ||
238 … | + if (publicWebHosting.new() !== publicWebHosting.current()) msg.publicWebHosting = publicWebHosting.new() | ||
236 | 239 … | ||
237 | 240 … | api.message.html.confirm(msg, (err, data) => { | |
238 | 241 … | if (err) return console.error(err) | |
239 | 242 … |
Built with git-ssb-web