Improvements to group following

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-10-25 16:53:46 +02:00
parent 3e74982ec4
commit d0b125064f
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
8 changed files with 57 additions and 23 deletions

View file

@ -32,6 +32,7 @@ export default class EmptyContent extends Vue {
}
&.inline {
margin-top: 5vh;
margin-bottom: 2vh;
}
}
</style>

View file

@ -466,6 +466,7 @@ export const PERSON_STATUS_GROUP = gql`
elements {
id
notify
approved
target_actor {
id
preferredUsername

View file

@ -107,11 +107,17 @@ export default class GroupMixin extends Vue {
}
get isCurrentActorFollowing(): boolean {
return this.currentActorFollow !== null;
return this.currentActorFollow?.approved === true;
}
get isCurrentActorPendingFollow(): boolean {
return this.currentActorFollow?.approved === false;
}
get isCurrentActorFollowingNotify(): boolean {
return this.currentActorFollow?.notify === true;
return (
this.isCurrentActorFollowing && this.currentActorFollow?.notify === true
);
}
get currentActorFollow(): IFollower | null {

View file

@ -18,6 +18,7 @@ export enum GroupsRouteName {
POSTS = "POSTS",
GROUP_EVENTS = "GROUP_EVENTS",
GROUP_JOIN = "GROUP_JOIN",
GROUP_FOLLOW = "GROUP_FOLLOW",
TIMELINE = "TIMELINE",
}
@ -149,6 +150,14 @@ export const groupsRoutes: RouteConfig[] = [
name: GroupsRouteName.GROUP_JOIN,
meta: { requiredAuth: false, announcer: { skip: true } },
},
{
path: "/@:preferredUsername/follow",
component: (): Promise<ImportedComponent> =>
import("@/components/Group/JoinGroupWithAccount.vue"),
props: true,
name: GroupsRouteName.GROUP_FOLLOW,
meta: { requiredAuth: false, announcer: { skip: true } },
},
{
path: "/@:preferredUsername/timeline",
name: GroupsRouteName.TIMELINE,

View file

@ -164,26 +164,17 @@
type="is-primary"
>{{ $t("Join group") }}</b-button
>
<b-tooltip
v-if="
(!isCurrentActorFollowing || previewPublic) &&
group.openness !== Openness.OPEN
"
:label="$t('This group is invite-only')"
position="is-bottom"
>
<b-button disabled type="is-primary">{{
$t("Follow 1")
}}</b-button></b-tooltip
>
<b-button
v-else-if="
(!isCurrentActorFollowing || previewPublic) && currentActor.id
v-if="
((!isCurrentActorFollowing && !isCurrentActorAGroupMember) ||
previewPublic) &&
!isCurrentActorPendingFollow &&
currentActor.id
"
@click="followGroup"
type="is-primary"
:disabled="previewPublic"
>{{ $t("Follow 2") }}</b-button
:disabled="isCurrentActorPendingFollow"
>{{ $t("Follow") }}</b-button
>
<b-button
tag="router-link"
@ -191,10 +182,21 @@
name: RouteName.GROUP_FOLLOW,
params: { preferredUsername: usernameWithDomain(group) },
}"
v-else-if="!isCurrentActorFollowing || previewPublic"
v-else-if="
!isCurrentActorPendingFollow &&
!isCurrentActorFollowing &&
previewPublic
"
:disabled="previewPublic"
type="is-primary"
>{{ $t("Follow 3") }}</b-button
>{{ $t("Follow") }}</b-button
>
<b-button
outlined
v-if="isCurrentActorPendingFollow && currentActor.id"
@click="unFollowGroup"
type="is-primary"
>{{ $t("Cancel follow request") }}</b-button
><b-button
v-if="
isCurrentActorFollowing && !previewPublic && currentActor.id
@ -473,7 +475,7 @@
}}
</event-metadata-block>
<event-metadata-block
v-if="physicalAddress"
v-if="physicalAddress.url"
:title="$t('Location')"
:icon="
physicalAddress ? physicalAddress.poiInfos.poiIcon.icon : 'earth'
@ -534,6 +536,18 @@
</div>
<empty-content v-else-if="group" icon="calendar" :inline="true">
{{ $t("No public upcoming events") }}
<template #desc v-if="isCurrentActorFollowing">
<i18n
class="has-text-grey-dark"
path="You will receive notifications about this group's public activity depending on %{notification_settings}."
>
<router-link
:to="{ name: RouteName.NOTIFICATIONS }"
slot="notification_settings"
>{{ $t("your notification settings") }}</router-link
>
</i18n>
</template>
</empty-content>
<b-skeleton animated v-else-if="$apollo.loading"></b-skeleton>
<router-link
@ -1275,6 +1289,7 @@ div.container {
min-width: 20rem;
flex: 2;
background: white;
padding: 0 5px;
@include desktop {
padding: 10px;

View file

@ -402,7 +402,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Person do
Returns this person's group follows
"""
@spec person_follows(Actor.t(), map(), map()) :: {:ok, Page.t()} | {:error, String.t()}
def person_follows(%Actor{id: actor_id} = person, %{group: group}, %{
def person_follows(%Actor{} = person, %{group: group}, %{
context: %{current_user: %User{} = user}
}) do
if user_can_access_person_details?(person, user) do

View file

@ -264,6 +264,8 @@ defmodule Mobilizon.Users do
|> update_user_default_actor_query()
|> Repo.update_all(set: [default_actor_id: actor_id])
Cachex.put(:default_actors, to_string(user_id), actor)
%User{user | default_actor: actor}
end

View file

@ -32,7 +32,7 @@ defmodule Mobilizon.Web.Auth.Guardian do
try do
case Integer.parse(uid_str) do
{uid, ""} ->
{:ok, Users.get_user!(uid)}
{:ok, Users.get_user_with_actors!(uid)}
_ ->
{:error, :invalid_id}