From 22f967d642017afa4ab797216fe68e494ed07101 Mon Sep 17 00:00:00 2001 From: Matteo Cominetti Date: Mon, 8 Mar 2021 12:52:29 +0000 Subject: [PATCH] feat(frontend): recent commits > recent activity --- packages/frontend/src/graphql/streams.gql | 10 ++- packages/frontend/src/graphql/user.gql | 10 --- packages/frontend/src/views/Streams.vue | 96 +++++++++++++++++------ 3 files changed, 79 insertions(+), 37 deletions(-) diff --git a/packages/frontend/src/graphql/streams.gql b/packages/frontend/src/graphql/streams.gql index be7df7f3f..285a54b79 100644 --- a/packages/frontend/src/graphql/streams.gql +++ b/packages/frontend/src/graphql/streams.gql @@ -17,8 +17,16 @@ query Streams($cursor: String) { avatar role } - commits { + commits(limit: 1) { totalCount + items { + id + createdAt + message + authorId + authorName + authorAvatar + } } branches { totalCount diff --git a/packages/frontend/src/graphql/user.gql b/packages/frontend/src/graphql/user.gql index 209346af6..815adaa70 100644 --- a/packages/frontend/src/graphql/user.gql +++ b/packages/frontend/src/graphql/user.gql @@ -15,16 +15,6 @@ query { } commits { totalCount - items { - id - streamId - streamName - authorId - authorName - authorAvatar - message - branchName - } } } } diff --git a/packages/frontend/src/views/Streams.vue b/packages/frontend/src/views/Streams.vue index 1a762adf0..853038c9c 100644 --- a/packages/frontend/src/views/Streams.vue +++ b/packages/frontend/src/views/Streams.vue @@ -20,37 +20,55 @@ - Recent Commits + Recent Activity - - - - - - - - {{ commit.message }} - - - - in - - {{ commit.streamName }} - - - - +
+ + + + + + + + {{ a.message }} + + + + + Sent to + + {{ a.streamName }} + + + + + + + + + + + {{ a.name }} + + + + A new stream was created + + + + +
@@ -119,7 +137,24 @@ export default { streams: [], newStreamDialog: false }), - computed: {}, + computed: { + recentActivity() { + let activity = [] + + if (this.streams && this.streams.items) { + this.streams.items.forEach((x) => + x.commits.items.forEach((y) => { + y.streamName = x.name + activity.push(y) + }) + ) + activity.push(...this.streams.items) + } + + activity.sort(this.compareUpdates) + return activity + } + }, watch: {}, methods: { infiniteHandler($state) { @@ -177,6 +212,15 @@ export default { console.error(error) }) }) + }, + compareUpdates(a, b) { + if (a.createdAt < b.createdAt) { + return 1 + } + if (a.createdAt > b.createdAt) { + return -1 + } + return 0 } } }