mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Implement working leave button on group profile
This commit is contained in:
parent
6fec36470c
commit
0cd3617f65
@ -15,7 +15,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { joinGroupMutation } from '~/graphql/groups'
|
import { joinGroupMutation, leaveGroupMutation } from '~/graphql/groups'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'JoinLeaveButton',
|
name: 'JoinLeaveButton',
|
||||||
@ -23,11 +23,11 @@ export default {
|
|||||||
groupId: { type: String, required: true },
|
groupId: { type: String, required: true },
|
||||||
userId: { type: String, required: true },
|
userId: { type: String, required: true },
|
||||||
isMember: { type: Boolean, required: true },
|
isMember: { type: Boolean, required: true },
|
||||||
|
disabled: { type: Boolean, default: false },
|
||||||
|
loading: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
disabled: false,
|
|
||||||
loading: false,
|
|
||||||
hovered: false,
|
hovered: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -61,7 +61,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async toggle() {
|
async toggle() {
|
||||||
const join = !this.isMember
|
const join = !this.isMember
|
||||||
const mutation = join ? joinGroupMutation : null // Wolle: implement "leaveGroupMutation"
|
const mutation = join ? joinGroupMutation : leaveGroupMutation
|
||||||
|
|
||||||
this.hovered = false
|
this.hovered = false
|
||||||
const optimisticResult = { joinedByCurrentUser: join }
|
const optimisticResult = { joinedByCurrentUser: join }
|
||||||
@ -72,7 +72,7 @@ export default {
|
|||||||
mutation,
|
mutation,
|
||||||
variables: { groupId: this.groupId, userId: this.userId },
|
variables: { groupId: this.groupId, userId: this.userId },
|
||||||
})
|
})
|
||||||
const joinedGroup = join ? data.JoinGroup : { myRoleInGroup: null } // Wolle: implement "leaveGroupMutation"
|
const joinedGroup = join ? data.JoinGroup : data.LeaveGroup
|
||||||
this.$emit('update', joinedGroup)
|
this.$emit('update', joinedGroup)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
optimisticResult.joinedByCurrentUser = !join
|
optimisticResult.joinedByCurrentUser = !join
|
||||||
|
|||||||
@ -94,6 +94,8 @@
|
|||||||
:groupId="group && group.id ? group.id : ''"
|
:groupId="group && group.id ? group.id : ''"
|
||||||
:userId="currentUser.id"
|
:userId="currentUser.id"
|
||||||
:isMember="isGroupMember"
|
:isMember="isGroupMember"
|
||||||
|
:disabled="isGroupOwner"
|
||||||
|
:loading="$apollo.loading"
|
||||||
@optimistic="optimisticJoinLeave"
|
@optimistic="optimisticJoinLeave"
|
||||||
@update="updateJoinLeave"
|
@update="updateJoinLeave"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user