mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-22 07:52:43 +00:00
Issue #1511: Remove useUserSettings() and always add user settings in useLoggedUser()
The user time zone setting is now available in the event display page
This commit is contained in:
parent
0c56267795
commit
3a3d77b698
6 changed files with 31 additions and 24 deletions
|
@ -41,12 +41,12 @@
|
|||
</template>
|
||||
<script lang="ts" setup>
|
||||
// import { SnackbarProgrammatic as Snackbar } from "buefy";
|
||||
import { doUpdateSetting, useUserSettings } from "@/composition/apollo/user";
|
||||
import { doUpdateSetting, useLoggedUser } from "@/composition/apollo/user";
|
||||
import { onMounted, ref } from "vue";
|
||||
|
||||
const notificationOnDay = ref(true);
|
||||
|
||||
const { loggedUser } = useUserSettings();
|
||||
const { loggedUser } = useLoggedUser();
|
||||
|
||||
const updateSetting = async (
|
||||
variables: Record<string, unknown>
|
||||
|
|
|
@ -55,7 +55,7 @@ import { useTimezones } from "@/composition/apollo/config";
|
|||
import {
|
||||
doUpdateSetting,
|
||||
updateLocale,
|
||||
useUserSettings,
|
||||
useLoggedUser,
|
||||
} from "@/composition/apollo/user";
|
||||
import { saveLocaleData } from "@/utils/auth";
|
||||
import { computed, onMounted, watch } from "vue";
|
||||
|
@ -68,7 +68,7 @@ const { t, locale } = useI18n({ useScope: "global" });
|
|||
|
||||
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
const { loggedUser } = useUserSettings();
|
||||
const { loggedUser } = useLoggedUser();
|
||||
|
||||
const { mutate: doUpdateLocale } = updateLocale();
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { IDENTITIES, REGISTER_PERSON } from "@/graphql/actor";
|
||||
import {
|
||||
CURRENT_USER_CLIENT,
|
||||
LOGGED_USER,
|
||||
LOGGED_USER_AND_SETTINGS,
|
||||
LOGGED_USER_LOCATION,
|
||||
SET_USER_SETTINGS,
|
||||
UPDATE_USER_LOCALE,
|
||||
USER_SETTINGS,
|
||||
} from "@/graphql/user";
|
||||
import { IPerson } from "@/types/actor";
|
||||
import { ICurrentUser, IUser } from "@/types/current-user.model";
|
||||
|
@ -31,25 +30,14 @@ export function useCurrentUserClient() {
|
|||
export function useLoggedUser() {
|
||||
const { currentUser } = useCurrentUserClient();
|
||||
|
||||
const { result, error, onError } = useQuery<{ loggedUser: IUser }>(
|
||||
LOGGED_USER,
|
||||
const { result, error, onError, loading } = useQuery<{ loggedUser: IUser }>(
|
||||
LOGGED_USER_AND_SETTINGS,
|
||||
{},
|
||||
() => ({ enabled: currentUser.value?.id != null })
|
||||
);
|
||||
|
||||
const loggedUser = computed(() => result.value?.loggedUser);
|
||||
return { loggedUser, error, onError };
|
||||
}
|
||||
|
||||
export function useUserSettings() {
|
||||
const {
|
||||
result: userSettingsResult,
|
||||
error,
|
||||
loading,
|
||||
} = useQuery<{ loggedUser: IUser }>(USER_SETTINGS);
|
||||
|
||||
const loggedUser = computed(() => userSettingsResult.value?.loggedUser);
|
||||
return { loggedUser, error, loading };
|
||||
return { loggedUser, error, onError, loading };
|
||||
}
|
||||
|
||||
export function useUserLocation() {
|
||||
|
|
|
@ -125,6 +125,25 @@ export const USER_SETTINGS_FRAGMENT = gql`
|
|||
}
|
||||
`;
|
||||
|
||||
export const LOGGED_USER_AND_SETTINGS = gql`
|
||||
query LoggedUserQuery {
|
||||
loggedUser {
|
||||
id
|
||||
email
|
||||
locale
|
||||
provider
|
||||
defaultActor {
|
||||
...ActorFragment
|
||||
}
|
||||
settings {
|
||||
...UserSettingFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
${ACTOR_FRAGMENT}
|
||||
${USER_SETTINGS_FRAGMENT}
|
||||
`;
|
||||
|
||||
export const USER_SETTINGS = gql`
|
||||
query UserSetting {
|
||||
loggedUser {
|
||||
|
|
|
@ -632,7 +632,7 @@ import {
|
|||
useCurrentUserIdentities,
|
||||
usePersonStatusGroup,
|
||||
} from "@/composition/apollo/actor";
|
||||
import { useUserSettings } from "@/composition/apollo/user";
|
||||
import { useLoggedUser } from "@/composition/apollo/user";
|
||||
import {
|
||||
computed,
|
||||
inject,
|
||||
|
@ -664,7 +664,7 @@ const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10;
|
|||
const { eventCategories } = useEventCategories();
|
||||
const { anonymousParticipationConfig } = useAnonymousParticipationConfig();
|
||||
const { currentActor } = useCurrentActorClient();
|
||||
const { loggedUser } = useUserSettings();
|
||||
const { loggedUser } = useLoggedUser();
|
||||
const { identities } = useCurrentUserIdentities();
|
||||
|
||||
const { features } = useFeatures();
|
||||
|
|
|
@ -147,7 +147,7 @@ import RouteName from "../../router/name";
|
|||
import { AddressSearchType } from "@/types/enums";
|
||||
import { Address, IAddress } from "@/types/address.model";
|
||||
import { useTimezones } from "@/composition/apollo/config";
|
||||
import { useUserSettings, updateLocale } from "@/composition/apollo/user";
|
||||
import { useLoggedUser, updateLocale } from "@/composition/apollo/user";
|
||||
import { useHead } from "@/utils/head";
|
||||
import { computed, defineAsyncComponent, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
@ -159,7 +159,7 @@ const FullAddressAutoComplete = defineAsyncComponent(
|
|||
|
||||
const { timezones: serverTimezones, loading: loadingTimezones } =
|
||||
useTimezones();
|
||||
const { loggedUser, loading: loadingUserSettings } = useUserSettings();
|
||||
const { loggedUser, loading: loadingUserSettings } = useLoggedUser();
|
||||
|
||||
const { t } = useI18n({ useScope: "global" });
|
||||
|
||||
|
|
Loading…
Reference in a new issue