Verified Commit 954b9c5f authored by Chocobozzz's avatar Chocobozzz
Browse files

Add new client hooks

parent 5336129c
......@@ -3,6 +3,75 @@ function register ({ registerHook, peertubeHelpers }) {
target: 'action:application.init',
handler: () => onApplicationInit(peertubeHelpers)
})
// Videos list
registerHook({
target: 'filter:api.videos.list.trending.params',
handler: params => Object.assign({}, params, { sort: '-views' })
})
registerHook({
target: 'filter:api.videos.list.trending.result',
handler: result => addSymbolToVideoNameResult(result, '<3')
})
registerHook({
target: 'filter:api.videos.list.local.params',
handler: params => Object.assign({}, params, { sort: '-views' })
})
registerHook({
target: 'filter:api.videos.list.local.result',
handler: result => addSymbolToVideoNameResult(result, ':)')
})
registerHook({
target: 'filter:api.videos.list.recently-added.params',
handler: params => Object.assign({}, params, { filter: 'all-local' })
})
registerHook({
target: 'filter:api.videos.list.recently-added.result',
handler: result => addSymbolToVideoNameResult(result, 'o/')
})
registerHook({
target: 'filter:api.videos.list.user-subscriptions.params',
handler: params => Object.assign({}, params, { sort: '-views' })
})
registerHook({
target: 'filter:api.videos.list.user-subscriptions.result',
handler: result => addSymbolToVideoNameResult(result, ':D')
})
// Search list
registerHook({
target: 'filter:api.search.videos.list.result',
handler: result => {
result.data.forEach(v => v.name += ' SEARCH')
return {
total: result.total,
data: result.data
}
}
})
registerHook({
target: 'filter:api.search.video-channels.list.result',
handler: result => {
result.data.forEach(v => v.displayName += ' :p')
return {
total: result.total,
data: result.data
}
}
})
}
export {
......@@ -19,3 +88,12 @@ function onApplicationInit (peertubeHelpers) {
topLeftBlock.style.backgroundImage = 'url(' + imageUrl + ')'
}
function addSymbolToVideoNameResult (result, symbol) {
result.data.forEach(v => v.name += ' ' + symbol)
return {
data: result.data,
total: result.total
}
}
......@@ -3,6 +3,38 @@ function register ({ registerHook, peertubeHelpers }) {
target: 'action:video-watch.init',
handler: () => console.log('Hello video watch world')
})
registerHook({
target: 'action:video-watch.video.loaded',
handler: () => 'video loaded'
})
registerHook({
target: 'filter:api.video-watch.video.get.result',
handler: video => {
video.name += ' \o/'
return video
}
})
registerHook({
target: 'filter:api.video-watch.video-threads.list.result',
handler: result => {
result.comments.forEach(c => c.text += ' THREAD')
return result
}
})
registerHook({
target: 'filter:api.video-watch.video-thread-replies.list.result',
handler: result => {
result.children.forEach(c => c.comment.text += ' REPLY DEEP 1')
return result
}
})
}
export {
......
{
"name": "peertube-plugin-hello-world",
"version": "0.0.9",
"version": "0.0.10",
"description": "Hello world PeerTube plugin example",
"engine": {
"peertube": ">=1.3.0"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment