diff --git a/js/src/graphql/actor.ts b/js/src/graphql/actor.ts index de899ef21..3a1ec38d9 100644 --- a/js/src/graphql/actor.ts +++ b/js/src/graphql/actor.ts @@ -205,31 +205,34 @@ export const LOGGED_USER_DRAFTS = gql` loggedUser { id drafts(page: $page, limit: $limit) { - id - uuid - title - draft - picture { + total + elements { id - url - alt - } - beginsOn - status - visibility - attributedTo { - ...ActorFragment - } - organizerActor { - ...ActorFragment - } - participantStats { - going - notApproved - } - options { - maximumAttendeeCapacity - remainingAttendeeCapacity + uuid + title + draft + picture { + id + url + alt + } + beginsOn + status + visibility + attributedTo { + ...ActorFragment + } + organizerActor { + ...ActorFragment + } + participantStats { + going + notApproved + } + options { + maximumAttendeeCapacity + remainingAttendeeCapacity + } } } } diff --git a/js/src/types/current-user.model.ts b/js/src/types/current-user.model.ts index f2dda9ad2..4c4e57cd9 100644 --- a/js/src/types/current-user.model.ts +++ b/js/src/types/current-user.model.ts @@ -54,7 +54,7 @@ export interface IUser extends ICurrentUser { disabled: boolean; participations: Paginate; mediaSize: number; - drafts: IEvent[]; + drafts: Paginate; settings: IUserSettings; activitySettings: IActivitySetting[]; followedGroupEvents: Paginate; diff --git a/js/src/views/Event/MyEventsView.vue b/js/src/views/Event/MyEventsView.vue index ef1ab3295..286e73090 100644 --- a/js/src/views/Event/MyEventsView.vue +++ b/js/src/views/Event/MyEventsView.vue @@ -19,9 +19,9 @@ > -
+
{{ @@ -73,15 +73,31 @@ />
-
+
- +

{{ t("Drafts") }}

+ + +
- {{ month[0] }} +

{{ month[0] }}

@@ -209,10 +225,15 @@ import { import { useQuery } from "@vue/apollo-composable"; import { computed, inject, ref, defineAsyncComponent } from "vue"; import { IUser } from "@/types/current-user.model"; -import { booleanTransformer, useRouteQuery } from "vue-use-route-query"; +import { + booleanTransformer, + integerTransformer, + useRouteQuery, +} from "vue-use-route-query"; import { Locale } from "date-fns"; import { useI18n } from "vue-i18n"; import { useRestrictions } from "@/composition/apollo/config"; +import { useHead } from "@vueuse/head"; const EventParticipationCard = defineAsyncComponent( () => import("@/components/Event/EventParticipationCard.vue") @@ -253,8 +274,6 @@ const dateFilter = useRouteQuery("dateFilter", new Date(), { const hasMoreFutureParticipations = ref(true); const hasMorePastParticipations = ref(true); -// config: CONFIG - const { result: loggedUserUpcomingEventsResult, fetchMore: fetchMoreUpcomingEvents, @@ -277,10 +296,17 @@ const groupEvents = computed( .elements ?? [] ); +const LOGGED_USER_DRAFTS_LIMIT = 10; +const draftsPage = useRouteQuery("draftsPage", 1, integerTransformer); + const { result: draftsResult } = useQuery<{ loggedUser: Pick; -}>(LOGGED_USER_DRAFTS, () => ({ page: 1, limit: 10 })); -const drafts = computed(() => draftsResult.value?.loggedUser.drafts ?? []); +}>( + LOGGED_USER_DRAFTS, + () => ({ page: draftsPage.value, limit: LOGGED_USER_DRAFTS_LIMIT }), + () => ({ fetchPolicy: "cache-and-network" }) +); +const drafts = computed(() => draftsResult.value?.loggedUser.drafts); const { result: participationsResult, fetchMore: fetchMoreParticipations } = useQuery<{ @@ -294,12 +320,6 @@ const pastParticipations = computed( } ); -// metaInfo() { -// return { -// title: this.t("My events") as string, -// }; -// }, - const monthlyEvents = ( elements: Eventable[], revertSort = false @@ -413,86 +433,8 @@ const dateFnsLocale = inject("dateFnsLocale"); const firstDayOfWeek = computed((): number => { return dateFnsLocale?.options?.weekStartsOn ?? 0; }); + +useHead({ + title: computed(() => t("My events")), +}); - - diff --git a/lib/graphql/schema/user.ex b/lib/graphql/schema/user.ex index 5a3aff7bd..ce139cf97 100644 --- a/lib/graphql/schema/user.ex +++ b/lib/graphql/schema/user.ex @@ -96,7 +96,9 @@ defmodule Mobilizon.GraphQL.Schema.UserType do resolve(&User.user_memberships/3) end - field(:drafts, list_of(:event), description: "The list of draft events this user has created") do + field(:drafts, :paginated_event_list, + description: "The list of draft events this user has created" + ) do arg(:page, :integer, default_value: 1, description: "The page in the paginated drafts events list" diff --git a/lib/mobilizon/events/events.ex b/lib/mobilizon/events/events.ex index 95234053b..aedc9d394 100644 --- a/lib/mobilizon/events/events.ex +++ b/lib/mobilizon/events/events.ex @@ -465,13 +465,13 @@ defmodule Mobilizon.Events do |> Page.build_page(page, limit) end - @spec list_drafts_for_user(integer, integer | nil, integer | nil) :: [Event.t()] + @spec list_drafts_for_user(integer, integer | nil, integer | nil) :: Page.t(Event.t()) def list_drafts_for_user(user_id, page \\ nil, limit \\ nil) do Event |> user_events_query(user_id) |> filter_draft(true) - |> Page.paginate(page, limit) - |> Repo.all() + |> order_by(desc: :updated_at) + |> Page.build_page(page, limit) end @spec is_user_moderator_for_event?(integer | String.t(), integer | String.t()) :: boolean diff --git a/lib/web/plugs/http_security_plug.ex b/lib/web/plugs/http_security_plug.ex index b18c85d14..082507a2d 100644 --- a/lib/web/plugs/http_security_plug.ex +++ b/lib/web/plugs/http_security_plug.ex @@ -85,7 +85,8 @@ defmodule Mobilizon.Web.Plugs.HTTPSecurityPlug do else [ @script_src, - "'sha256-4RS22DYeB7U14dra4KcQYxmwt5HkOInieXK1NUMBmQI=' " + "'sha256-4RS22DYeB7U14dra4KcQYxmwt5HkOInieXK1NUMBmQI=' ", + "'sha256-zJdRXhLWm9NGI6BFr+sNmHBBrjAdJdFr7MpUq0EwK58=' " ] end diff --git a/lib/web/templates/page/index.html.heex b/lib/web/templates/page/index.html.heex index d24ba8cf8..7047727cb 100644 --- a/lib/web/templates/page/index.html.heex +++ b/lib/web/templates/page/index.html.heex @@ -20,7 +20,6 @@ <% end %> <%= tags(assigns) || assigns.tags %> - <%= Vite.inlined_phx_manifest() %> <%= Vite.vite_client() %> <%= Vite.vite_snippet("src/main.ts") %> diff --git a/test/web/plugs/http_security_plug_test.exs b/test/web/plugs/http_security_plug_test.exs index 6abd6a6cb..43be1dec4 100644 --- a/test/web/plugs/http_security_plug_test.exs +++ b/test/web/plugs/http_security_plug_test.exs @@ -73,7 +73,7 @@ defmodule Mobilizon.Web.Plugs.HTTPSecurityPlugTest do [csp] = Conn.get_resp_header(conn, "content-security-policy") assert csp =~ - ~r/script-src 'self' 'unsafe-eval' 'sha256-[\w+\/=]*' example.com matomo.example.com ;/ + ~r/script-src 'self' 'unsafe-eval' 'sha256-[\w+\/=]*' 'sha256-[\w+\/=]*' example.com matomo.example.com ;/ end end