Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale_OLD
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jovuit
funkwhale_OLD
Commits
2384f761
Verified
Commit
2384f761
authored
7 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Now fetch activity from API on first timeline display (#141)
parent
18d8baae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
front/src/App.vue
+0
-26
0 additions, 26 deletions
front/src/App.vue
front/src/store/instance.js
+3
-0
3 additions, 0 deletions
front/src/store/instance.js
front/src/views/instance/Timeline.vue
+42
-1
42 additions, 1 deletion
front/src/views/instance/Timeline.vue
with
45 additions
and
27 deletions
front/src/App.vue
+
0
−
26
View file @
2384f761
...
...
@@ -36,9 +36,6 @@
</
template
>
<
script
>
import
{
WebSocketBridge
}
from
'
django-channels
'
import
logger
from
'
@/logging
'
import
Sidebar
from
'
@/components/Sidebar
'
import
Raven
from
'
@/components/Raven
'
...
...
@@ -53,34 +50,11 @@ export default {
},
created
()
{
this
.
$store
.
dispatch
(
'
instance/fetchSettings
'
)
this
.
openWebsocket
()
let
self
=
this
setInterval
(()
=>
{
// used to redraw ago dates every minute
self
.
$store
.
commit
(
'
ui/computeLastDate
'
)
},
1000
*
60
)
},
methods
:
{
openWebsocket
()
{
if
(
!
this
.
$store
.
state
.
auth
.
authenticated
)
{
return
}
let
self
=
this
let
token
=
this
.
$store
.
state
.
auth
.
token
// let token = 'test'
const
bridge
=
new
WebSocketBridge
()
bridge
.
connect
(
`/api/v1/instance/activity?token=
${
token
}
`
,
null
,
{
reconnectInterval
:
5000
})
bridge
.
listen
(
function
(
event
)
{
logger
.
default
.
info
(
'
Received timeline update
'
,
event
)
self
.
$store
.
commit
(
'
instance/event
'
,
event
)
})
bridge
.
socket
.
addEventListener
(
'
open
'
,
function
()
{
console
.
log
(
'
Connected to WebSocket
'
)
})
}
}
}
</
script
>
...
...
This diff is collapsed.
Click to expand it.
front/src/store/instance.js
+
3
−
0
View file @
2384f761
...
...
@@ -43,6 +43,9 @@ export default {
if
(
state
.
events
.
length
>
state
.
maxEvents
)
{
state
.
events
=
state
.
events
.
slice
(
0
,
state
.
maxEvents
)
}
},
events
:
(
state
,
value
)
=>
{
state
.
events
=
value
}
},
actions
:
{
...
...
This diff is collapsed.
Click to expand it.
front/src/views/instance/Timeline.vue
+
42
−
1
View file @
2384f761
<
template
>
<div
class=
"main pusher"
>
<div
class=
"ui vertical center aligned stripe segment"
>
<div
class=
"ui text container"
>
<div
v-if=
"isLoading"
:class=
"['ui',
{'active': isLoading}, 'inverted', 'dimmer']">
<div
class=
"ui text loader"
>
Loading timeline...
</div>
</div>
<div
v-else
class=
"ui text container"
>
<h1
class=
"ui header"
>
Recent activity on this instance
</h1>
<div
class=
"ui feed"
>
<component
...
...
@@ -26,6 +29,9 @@
<
script
>
import
{
mapState
}
from
'
vuex
'
import
{
WebSocketBridge
}
from
'
django-channels
'
import
axios
from
'
axios
'
import
logger
from
'
@/logging
'
import
Like
from
'
@/components/activity/Like
'
import
Listen
from
'
@/components/activity/Listen
'
...
...
@@ -33,16 +39,51 @@ import Listen from '@/components/activity/Listen'
export
default
{
data
()
{
return
{
isLoading
:
false
,
components
:
{
'
Like
'
:
Like
,
'
Listen
'
:
Listen
}
}
},
created
()
{
this
.
openWebsocket
()
this
.
fetchEvents
()
},
computed
:
{
...
mapState
({
events
:
state
=>
state
.
instance
.
events
})
},
methods
:
{
fetchEvents
()
{
this
.
isLoading
=
true
let
self
=
this
axios
.
get
(
'
/activity/
'
).
then
((
response
)
=>
{
self
.
isLoading
=
false
self
.
$store
.
commit
(
'
instance/events
'
,
response
.
data
.
results
)
})
},
openWebsocket
()
{
if
(
!
this
.
$store
.
state
.
auth
.
authenticated
)
{
return
}
let
self
=
this
let
token
=
this
.
$store
.
state
.
auth
.
token
// let token = 'test'
const
bridge
=
new
WebSocketBridge
()
bridge
.
connect
(
`/api/v1/instance/activity?token=
${
token
}
`
,
null
,
{
reconnectInterval
:
5000
})
bridge
.
listen
(
function
(
event
)
{
logger
.
default
.
info
(
'
Received timeline update
'
,
event
)
self
.
$store
.
commit
(
'
instance/event
'
,
event
)
})
bridge
.
socket
.
addEventListener
(
'
open
'
,
function
()
{
console
.
log
(
'
Connected to WebSocket
'
)
})
}
}
}
</
script
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment