aboutsummaryrefslogtreecommitdiff
path: root/src/graphql/user/resolvers.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-06 05:04:30 -0700
committerFuwn <[email protected]>2024-10-06 05:04:30 -0700
commit2c7149546582e58fc7421ad68869b16a64b5f4ad (patch)
tree06e7b44115eca71b6bc54d640f48d0a17916f56e /src/graphql/user/resolvers.ts
parentfeat(user): use preferences graphl api (diff)
downloaddue.moe-2c7149546582e58fc7421ad68869b16a64b5f4ad.tar.xz
due.moe-2c7149546582e58fc7421ad68869b16a64b5f4ad.zip
feat(user): live update for mutations
Diffstat (limited to 'src/graphql/user/resolvers.ts')
-rw-r--r--src/graphql/user/resolvers.ts21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/graphql/user/resolvers.ts b/src/graphql/user/resolvers.ts
index 66e3f1a2..3521f1a2 100644
--- a/src/graphql/user/resolvers.ts
+++ b/src/graphql/user/resolvers.ts
@@ -56,7 +56,11 @@ const authenticatedPreferencesOperation = async (
const authorised = authorisedJson.includes(identity.id);
- return operation(identity, authorised) as Promise<UserPreferences>
+ return {
+ id: identity.id,
+ badges: [] as Badge[],
+ preferences: operation(identity, authorised) as Promise<UserPreferences>
+ }
};
export const resolvers: WithIndex<Resolvers> = {
@@ -136,36 +140,37 @@ export const resolvers: WithIndex<Resolvers> = {
await authenticatedPreferencesOperation(
context as Context,
async (identity) => await toggleHideMissingBadges(identity.id)
- ) as UserPreferences,
+ ),
toggleHideAWCBadges: async (_, _args, context) =>
await authenticatedPreferencesOperation(
context as Context,
async (identity) => await toggleHideAWCBadges(identity.id)
- ) as UserPreferences,
+ ),
setBadgeWallCSS: async (_, args, context) =>
await authenticatedPreferencesOperation(
context as Context,
async (identity) => await setCSS(identity.id, args.css)
- ) as UserPreferences,
+ ),
togglePinnedBadgeWallCategory: async (_, args, context) =>
await authenticatedPreferencesOperation(
context as Context,
async (identity) => await togglePinnedBadgeWallCategory(identity.id, args.category)
- ) as UserPreferences,
+ ),
setPinnedBadgeWallCategories: async (_, args, context) =>
await authenticatedPreferencesOperation(
context as Context,
async (identity) => await setPinnedBadgeWallCategories(identity.id, args.categories)
- ) as UserPreferences,
+ ),
setBiography: async (_, args, context) =>
await authenticatedPreferencesOperation(
context as Context,
async (identity) => await setBiography(identity.id, args.biography.slice(0, 3000))
- ) as UserPreferences,
+ )
+ ,
togglePinnedHololiveStream: async (_, args, context) =>
await authenticatedPreferencesOperation(
context as Context,
async (identity) => await toggleHololiveStreamPinning(identity.id, args.stream)
- ) as UserPreferences,
+ ),
}
};