ident
All repositories: gitoria
1.8 KB
// lib/usedin.hl — "USED IN" (ident#26): the apps an identity is connected to, for its page (components/identity.hl,// `/identity/<id>`). CONCEPT.md "Per-app page": each row is a connection (identity + app) — `created` is when the identity// registered in the app (the first login), `lastLogin` the last time the app exchanged a one-time code for it (lib/apps.hl// exchange, one write per login). Each row links to the per-app page `/inbox/<connection id>` (notification switches).// Read only; no table of its own.import { now } from 'hl:time'import { countOf, str } from './util.hl'import { identityRecord, identityRows } from './identities.hl'import { appsTable, connectionsTable } from './apps.hl'import { appName } from './notify.hl'import { newestFirst } from './notify-helpers.hl'import { usedLine } from './usedin-helpers.hl'// { identity: { id, label, shortId, avatar, hasAvatar }, rows: [{ id, href, app, line }] , hasRows, noRows } for the// account's identity `identityId`, or null when it is not the account's. Rows: most recently registered first.static usedIn = (accountId, identityId) => {r = identityRecord(identityId)if (r == null || r.account != accountId) { return null }let me = nullfor (row of identityRows(accountId)) { if ('' + row.id == '' + identityId) { me = row } }if (me == null) { return null }t = now()let rows = []all = connectionsTable.find(null, null)mine = []if (countOf(all) > 0) { for (c of all) { if (c.identity == identityId) { mine.push(c) } } }if (mine.length > 0) {for (c of newestFirst(mine)) {if (appsTable.fetch(c.app) == null) { continue }rows.push({ id = c.id href = '/inbox/' + c.id app = appName(c.app) line = usedLine(c.created, c.lastLogin, t) })}}return { identity = me rows = rows hasRows = rows.length > 0 noRows = rows.length == 0 }}
Branches
Latest commits
- 0f6d1592Merge branch 'f18b-shell-session' into mainIdent
- 19868218|||PR ident#39 shell reads its session member instead of a cross-file emitmre
- 5d1b3fedMerge branch 'v61-day61' into mainIdent
- 83faeb15|||PR ident: vendor Hybriel day61mre
- b2572b34Merge branch 'v59-day59' into mainIdent
- 67cf016d|||PR ident: vendor Hybriel day59mre
- 600c043dMerge branch 'v58-day58' into mainIdent
- 365f8c80|||PR ident: vendor Hybriel day58mre
- 585126e5Merge branch 'f16-setf' into mainIdent
- 953bf03a|||PR ident setF mirror dropped (hybriel#370)mre
- a1419d9cMerge branch 'f15-navigate' into mainIdent
- 3b3e451f|||PR ident#36 navigate to the app instead of location.assignmre
- e36f4516Merge branch 'f14-online' into mainIdent
- 2c5eac91|||PR ident#38 online state without probe timermre
- bf1980f2Merge branch 'v56-day56' into mainIdent
- 62ae0adf|||PR ident: vendor Hybriel day56mre
- 0d18abc4Merge branch 'f13-avatar' into mainIdent
- 2a99730a|||PR ident#37 avatar in hlmre
- fa4ed25bMerge branch 'f11-upsert' into mainIdent
- 8f3d9bc9|||PR ident#42 keyed upsert and removemre