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 { &.inline {
margin-top: 5vh; margin-top: 5vh;
margin-bottom: 2vh;
} }
} }
</style> </style>

View File

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

View File

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

View File

@ -18,6 +18,7 @@ export enum GroupsRouteName {
POSTS = "POSTS", POSTS = "POSTS",
GROUP_EVENTS = "GROUP_EVENTS", GROUP_EVENTS = "GROUP_EVENTS",
GROUP_JOIN = "GROUP_JOIN", GROUP_JOIN = "GROUP_JOIN",
GROUP_FOLLOW = "GROUP_FOLLOW",
TIMELINE = "TIMELINE", TIMELINE = "TIMELINE",
} }
@ -149,6 +150,14 @@ export const groupsRoutes: RouteConfig[] = [
name: GroupsRouteName.GROUP_JOIN, name: GroupsRouteName.GROUP_JOIN,
meta: { requiredAuth: false, announcer: { skip: true } }, 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", path: "/@:preferredUsername/timeline",
name: GroupsRouteName.TIMELINE, name: GroupsRouteName.TIMELINE,

View File

@ -164,26 +164,17 @@
type="is-primary" type="is-primary"
>{{ $t("Join group") }}</b-button >{{ $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 <b-button
v-else-if=" v-if="
(!isCurrentActorFollowing || previewPublic) && currentActor.id ((!isCurrentActorFollowing && !isCurrentActorAGroupMember) ||
previewPublic) &&
!isCurrentActorPendingFollow &&
currentActor.id
" "
@click="followGroup" @click="followGroup"
type="is-primary" type="is-primary"
:disabled="previewPublic" :disabled="isCurrentActorPendingFollow"
>{{ $t("Follow 2") }}</b-button >{{ $t("Follow") }}</b-button
> >
<b-button <b-button
tag="router-link" tag="router-link"
@ -191,10 +182,21 @@
name: RouteName.GROUP_FOLLOW, name: RouteName.GROUP_FOLLOW,
params: { preferredUsername: usernameWithDomain(group) }, params: { preferredUsername: usernameWithDomain(group) },
}" }"
v-else-if="!isCurrentActorFollowing || previewPublic" v-else-if="
!isCurrentActorPendingFollow &&
!isCurrentActorFollowing &&
previewPublic
"
:disabled="previewPublic" :disabled="previewPublic"
type="is-primary" 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 ><b-button
v-if=" v-if="
isCurrentActorFollowing && !previewPublic && currentActor.id isCurrentActorFollowing && !previewPublic && currentActor.id
@ -473,7 +475,7 @@
}} }}
</event-metadata-block> </event-metadata-block>
<event-metadata-block <event-metadata-block
v-if="physicalAddress" v-if="physicalAddress.url"
:title="$t('Location')" :title="$t('Location')"
:icon=" :icon="
physicalAddress ? physicalAddress.poiInfos.poiIcon.icon : 'earth' physicalAddress ? physicalAddress.poiInfos.poiIcon.icon : 'earth'
@ -534,6 +536,18 @@
</div> </div>
<empty-content v-else-if="group" icon="calendar" :inline="true"> <empty-content v-else-if="group" icon="calendar" :inline="true">
{{ $t("No public upcoming events") }} {{ $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> </empty-content>
<b-skeleton animated v-else-if="$apollo.loading"></b-skeleton> <b-skeleton animated v-else-if="$apollo.loading"></b-skeleton>
<router-link <router-link
@ -1275,6 +1289,7 @@ div.container {
min-width: 20rem; min-width: 20rem;
flex: 2; flex: 2;
background: white; background: white;
padding: 0 5px;
@include desktop { @include desktop {
padding: 10px; padding: 10px;

View File

@ -402,7 +402,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Person do
Returns this person's group follows Returns this person's group follows
""" """
@spec person_follows(Actor.t(), map(), map()) :: {:ok, Page.t()} | {:error, String.t()} @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} context: %{current_user: %User{} = user}
}) do }) do
if user_can_access_person_details?(person, 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() |> update_user_default_actor_query()
|> Repo.update_all(set: [default_actor_id: actor_id]) |> Repo.update_all(set: [default_actor_id: actor_id])
Cachex.put(:default_actors, to_string(user_id), actor)
%User{user | default_actor: actor} %User{user | default_actor: actor}
end end

View File

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