Skip to content

Commit 5696c3a

Browse files
committed
authn.findProfileImage -> widgets.findImage
As discussed with Tim - https://github.com/solid/solid-ui/pull/119#discussion_r325081926
1 parent 13ba814 commit 5696c3a

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

src/signin.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ module.exports = {
3737
filterAvailablePanes, // Async
3838
findAppInstances,
3939
findOriginOwner,
40-
findProfileImage, // Sync
4140
getUserRoles, // Async
4241
loadTypeIndexes,
4342
logIn,
@@ -1304,19 +1303,6 @@ async function getUserRoles () {
13041303
return UI.store.each(profile, ns.rdf('type'), null, preferencesFile.doc())
13051304
}
13061305

1307-
function findProfileImage (profile) {
1308-
const iconDir = UI.icons.iconBase
1309-
if (profile.sameTerm(ns.foaf('Agent')) || profile.sameTerm(ns.rdf('Resource'))) {
1310-
return iconDir + 'noun_98053.svg' // Globe
1311-
}
1312-
const image = kb.any(profile, ns.sioc('avatar')) ||
1313-
kb.any(profile, ns.foaf('img')) ||
1314-
kb.any(profile, ns.vcard('logo')) ||
1315-
kb.any(profile, ns.vcard('hasPhoto')) ||
1316-
kb.any(profile, ns.vcard('photo')) ||
1317-
kb.any(profile, ns.foaf('depiction'))
1318-
return image ? image.uri : null
1319-
}
13201306
async function filterAvailablePanes (panes) {
13211307
const userRoles = await getUserRoles()
13221308
return Object.values(panes).filter(pane => isMatchingAudience(pane, userRoles))

src/widgets/buttons.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
*/
33
/* global alert */
44

5-
const { findProfileImage } = require('../signin')
6-
75
module.exports = {}
86

97
var buttons = {}
@@ -25,6 +23,9 @@ const dragAndDrop = require('./dragAndDrop')
2523
const cancelIconURI = UI.icons.iconBase + 'noun_1180156.svg' // black X
2624
const checkIconURI = UI.icons.iconBase + 'noun_1180158.svg' // green checkmark; Continue
2725

26+
const ns = UI.ns
27+
const kb = UI.store
28+
2829
function getStatusArea (context) {
2930
var box = context.statusArea || context.div || null
3031
if (box) return box
@@ -221,15 +222,29 @@ buttons.findImageByClass = function findImageByClass (x) {
221222
return iconDir + 'noun_10636_grey.svg' // Grey Circle - some thing
222223
}
223224

225+
buttons.findImage = (thing) => {
226+
const iconDir = UI.icons.iconBase
227+
if (thing.sameTerm(ns.foaf('Agent')) || thing.sameTerm(ns.rdf('Resource'))) {
228+
return iconDir + 'noun_98053.svg' // Globe
229+
}
230+
const image = kb.any(thing, ns.sioc('avatar')) ||
231+
kb.any(thing, ns.foaf('img')) ||
232+
kb.any(thing, ns.vcard('logo')) ||
233+
kb.any(thing, ns.vcard('hasPhoto')) ||
234+
kb.any(thing, ns.vcard('photo')) ||
235+
kb.any(thing, ns.foaf('depiction'))
236+
return image ? image.uri : null
237+
}
238+
224239
// @@ Also add icons for *properties* like home, work, email, range, domain, comment,
225240

226241
buttons.setImage = function (element, profile) {
227242
const kb = UI.store
228-
const uri = findProfileImage(profile)
243+
const uri = buttons.findImage(profile)
229244
element.setAttribute('src', uri || buttons.findImageByClass(profile))
230245
if (!uri && profile.uri) {
231246
kb.fetcher.nowOrWhenFetched(profile.doc(), undefined, () => {
232-
element.setAttribute('src', findProfileImage(profile) || buttons.findImageByClass(profile))
247+
element.setAttribute('src', buttons.findImage(profile) || buttons.findImageByClass(profile))
233248
})
234249
}
235250
}

0 commit comments

Comments
 (0)