Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib/depject/message/html/timestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ exports.needs = nest({
exports.create = function (api) {
return nest('message.html.timestamp', timestamp)

function timestamp (msg) {
return h('a.Timestamp', {
href: api.message.sync.root(msg) || msg.key,
anchor: msg.key,
title: moment(api.message.sync.timestamp(msg)).format('LLLL zz')
}, moment(api.message.sync.timestamp(msg)).fromNow())
function timestamp (msg, link = true) {
if (link) {
return h('a.Timestamp', {
href: api.message.sync.root(msg) || msg.key,
anchor: msg.key,
title: moment(api.message.sync.timestamp(msg)).format('LLLL zz')
}, moment(api.message.sync.timestamp(msg)).fromNow())
} else {
return moment(api.message.sync.timestamp(msg)).fromNow()
}
}
}
20 changes: 18 additions & 2 deletions lib/depject/page/html/render/profile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const nest = require('depnest')
const ref = require('ssb-ref')
const { h, when, computed, map, send, dictToCollection, resolve, onceTrue } = require('mutant')
const { h, when, computed, map, send, dictToCollection, resolve, onceTrue, Value } = require('mutant')

exports.needs = nest({
'about.obs': {
Expand All @@ -14,12 +14,14 @@ exports.needs = nest({
'blob.html.input': 'first',
'message.async.publish': 'first',
'message.html.markdown': 'first',
'message.html.timestamp': 'first',
'message.sync.root': 'first',
'about.html.image': 'first',
'feed.html.rollup': 'first',
'sbot.pull.resumeStream': 'first',
'sbot.pull.stream': 'first',
'sbot.async.publish': 'first',
'sbot.async.getLatest': 'first',
'sbot.obs.connection': 'first',
'keys.sync.id': 'first',
'sheet.display': 'first',
Expand All @@ -45,6 +47,16 @@ exports.create = function (api) {
const contact = api.profile.obs.contact(id)
const recent = api.profile.obs.recentlyUpdated()
const isYou = id === yourId
const lastActivity = Value()
api.sbot.async.getLatest(id, (err, val) => {
if (err) {
console.dir(err)
} else {
if (val) {
lastActivity.set(val)
}
}
})

onceTrue(api.sbot.obs.connection, sbot => {
// request a once off replicate of this feed
Expand Down Expand Up @@ -142,7 +154,11 @@ exports.create = function (api) {
])

const prepend = h('header', { className: 'ProfileHeader' }, [
h('div.image', api.about.html.image(id)),
h('div.image', [
api.about.html.image(id),
h('div.lastActivity',
computed(lastActivity,
msg => `${i18n('Last activity')}: ${api.message.html.timestamp(msg, false)}`))]),
h('div.main', [
h('div.title', [
h('h1', [name]),
Expand Down
10 changes: 10 additions & 0 deletions lib/depject/sbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ exports.gives = {
},
async: {
get: true,
getLatest: true,
publish: true,
addBlob: true,
connConnect: true,
Expand Down Expand Up @@ -142,6 +143,15 @@ exports.create = function (api) {
})
}
}),
getLatest: rec.async(function (id, cb) {
if (typeof cb !== 'function') {
throw new Error('cb must be function')
}
sbot.getLatest(id, function (err, value) {
if (err) return cb(err)
cb(null, value)
})
}),
publish: rec.async((content, cb) => {
const indexes = api.progress.obs.indexes()
const progress = indexes()
Expand Down