@@ -215,12 +215,14 @@ export function useRegistrationConfig() {
|
||||
}>(REGISTRATIONS, undefined, { fetchPolicy: "cache-only" });
|
||||
|
||||
const registrationsOpen = computed(
|
||||
() => result.value?.config.registrationsOpen
|
||||
() => result.value?.config?.registrationsOpen
|
||||
);
|
||||
const registrationsAllowlist = computed(
|
||||
() => result.value?.config.registrationsAllowlist
|
||||
() => result.value?.config?.registrationsAllowlist
|
||||
);
|
||||
const databaseLogin = computed(
|
||||
() => result.value?.config?.auth?.databaseLogin
|
||||
);
|
||||
const databaseLogin = computed(() => result.value?.config.auth.databaseLogin);
|
||||
return {
|
||||
registrationsOpen,
|
||||
registrationsAllowlist,
|
||||
|
||||
44
js/src/composition/apollo/discussions.ts
Normal file
44
js/src/composition/apollo/discussions.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { useQuery } from "@vue/apollo-composable";
|
||||
import { computed, unref } from "vue";
|
||||
import { useCurrentUserClient } from "./user";
|
||||
import type { Ref } from "vue";
|
||||
import { IGroup } from "@/types/actor";
|
||||
import { GROUP_DISCUSSIONS_LIST } from "@/graphql/discussion";
|
||||
|
||||
export function useGroupDiscussionsList(
|
||||
name: string | undefined | Ref<string | undefined>,
|
||||
options?: {
|
||||
discussionsPage?: number;
|
||||
discussionsLimit?: number;
|
||||
}
|
||||
) {
|
||||
const { currentUser } = useCurrentUserClient();
|
||||
const { result, error, loading, onResult, onError, refetch } = useQuery<
|
||||
{
|
||||
group: Pick<
|
||||
IGroup,
|
||||
"id" | "preferredUsername" | "name" | "domain" | "discussions"
|
||||
>;
|
||||
},
|
||||
{
|
||||
name: string;
|
||||
discussionsPage?: number;
|
||||
discussionsLimit?: number;
|
||||
}
|
||||
>(
|
||||
GROUP_DISCUSSIONS_LIST,
|
||||
() => ({
|
||||
name: unref(name),
|
||||
...options,
|
||||
}),
|
||||
() => ({
|
||||
enabled:
|
||||
unref(name) !== undefined &&
|
||||
unref(name) !== "" &&
|
||||
currentUser.value?.isLoggedIn,
|
||||
fetchPolicy: "cache-and-network",
|
||||
})
|
||||
);
|
||||
const group = computed(() => result.value?.group);
|
||||
return { group, error, loading, onResult, onError, refetch };
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { PERSON_MEMBERSHIPS } from "@/graphql/actor";
|
||||
import {
|
||||
CREATE_GROUP,
|
||||
DELETE_GROUP,
|
||||
FETCH_GROUP,
|
||||
FETCH_GROUP_PUBLIC,
|
||||
LEAVE_GROUP,
|
||||
UPDATE_GROUP,
|
||||
} from "@/graphql/group";
|
||||
@@ -50,7 +50,7 @@ export function useGroup(
|
||||
discussionsLimit?: number;
|
||||
}
|
||||
>(
|
||||
FETCH_GROUP,
|
||||
FETCH_GROUP_PUBLIC,
|
||||
() => ({
|
||||
name: unref(name),
|
||||
...options,
|
||||
|
||||
44
js/src/composition/apollo/resources.ts
Normal file
44
js/src/composition/apollo/resources.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { useQuery } from "@vue/apollo-composable";
|
||||
import { computed, unref } from "vue";
|
||||
import { useCurrentUserClient } from "./user";
|
||||
import type { Ref } from "vue";
|
||||
import { IGroup } from "@/types/actor";
|
||||
import { GROUP_RESOURCES_LIST } from "@/graphql/resources";
|
||||
|
||||
export function useGroupResourcesList(
|
||||
name: string | undefined | Ref<string | undefined>,
|
||||
options?: {
|
||||
resourcesPage?: number;
|
||||
resourcesLimit?: number;
|
||||
}
|
||||
) {
|
||||
const { currentUser } = useCurrentUserClient();
|
||||
const { result, error, loading, onResult, onError, refetch } = useQuery<
|
||||
{
|
||||
group: Pick<
|
||||
IGroup,
|
||||
"id" | "preferredUsername" | "name" | "domain" | "resources"
|
||||
>;
|
||||
},
|
||||
{
|
||||
name: string;
|
||||
resourcesPage?: number;
|
||||
resourcesLimit?: number;
|
||||
}
|
||||
>(
|
||||
GROUP_RESOURCES_LIST,
|
||||
() => ({
|
||||
name: unref(name),
|
||||
...options,
|
||||
}),
|
||||
() => ({
|
||||
enabled:
|
||||
unref(name) !== undefined &&
|
||||
unref(name) !== "" &&
|
||||
currentUser.value?.isLoggedIn,
|
||||
fetchPolicy: "cache-and-network",
|
||||
})
|
||||
);
|
||||
const group = computed(() => result.value?.group);
|
||||
return { group, error, loading, onResult, onError, refetch };
|
||||
}
|
||||
@@ -18,12 +18,13 @@ export function useCurrentUserClient() {
|
||||
result: currentUserResult,
|
||||
error,
|
||||
loading,
|
||||
onResult,
|
||||
} = useQuery<{
|
||||
currentUser: ICurrentUser;
|
||||
}>(CURRENT_USER_CLIENT);
|
||||
|
||||
const currentUser = computed(() => currentUserResult.value?.currentUser);
|
||||
return { currentUser, error, loading };
|
||||
return { currentUser, error, loading, onResult };
|
||||
}
|
||||
|
||||
export function useLoggedUser() {
|
||||
|
||||
Reference in New Issue
Block a user