From 3dc646fceff3f69670efdb5466da6c3eca356738 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 20 Feb 2024 22:58:43 +0100 Subject: [PATCH] wrapQuery: drop deprecated useResult --- front/src/ctfnote/me.ts | 2 +- front/src/ctfnote/utils.ts | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/front/src/ctfnote/me.ts b/front/src/ctfnote/me.ts index a792fc2fb..ba201447e 100644 --- a/front/src/ctfnote/me.ts +++ b/front/src/ctfnote/me.ts @@ -70,7 +70,7 @@ const MeSymbol: InjectionKey> = Symbol('me'); export function provideMe(refresh = false) { const { result: me } = getMe(refresh); - provide(MeSymbol, me); + provide(MeSymbol, me as Ref); return me; } diff --git a/front/src/ctfnote/utils.ts b/front/src/ctfnote/utils.ts index 6a33e852a..48a9d2700 100644 --- a/front/src/ctfnote/utils.ts +++ b/front/src/ctfnote/utils.ts @@ -1,15 +1,20 @@ import { OperationVariables } from '@apollo/client'; -import { UseQueryReturn, useResult } from '@vue/apollo-composable'; +import { UseQueryReturn } from '@vue/apollo-composable'; import ColorHash from 'color-hash'; import { DeepNonNullable, DeepRequired } from 'ts-essentials'; -import { inject, InjectionKey, Ref } from 'vue'; +import { computed, inject, InjectionKey } from 'vue'; export function wrapQuery( query: UseQueryReturn, def: D, wrapper: (data: DeepRequired>) => D ) { - const result = useResult(query.result as Ref, def, wrapper); + const result = computed(() => { + if (query.result) { + return wrapper(query.result as DeepRequired>); + } + return def; + }); const onResult = function (cb: (arg: D) => void) { query.onResult((data) => {