aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/graphql/user/resolvers.ts21
-rw-r--r--src/graphql/user/schema.graphql18
-rw-r--r--src/routes/user/[user]/+page.svelte36
3 files changed, 52 insertions, 23 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,
+ ),
}
};
diff --git a/src/graphql/user/schema.graphql b/src/graphql/user/schema.graphql
index 7c910015..b615a995 100644
--- a/src/graphql/user/schema.graphql
+++ b/src/graphql/user/schema.graphql
@@ -1,5 +1,5 @@
type Query {
- User(id: Int!): User!
+ User(id: Int): User!
}
type Mutation {
@@ -19,18 +19,18 @@ type Mutation {
): [Badge]!
deleteBadge(id: Int!): [Badge]!
pruneUserBadges: [Badge]!
- toggleHideMissingBadges: Preferences
- toggleHideAWCBadges: Preferences
- setBadgeWallCSS(css: String!): Preferences
- togglePinnedBadgeWallCategory(category: String!): Preferences
- setPinnedBadgeWallCategories(categories: [String!]!): Preferences
- setBiography(biography: String!): Preferences
- togglePinnedHololiveStream(stream: String!): Preferences
+ toggleHideMissingBadges: User!
+ toggleHideAWCBadges: User!
+ setBadgeWallCSS(css: String!): User!
+ togglePinnedBadgeWallCategory(category: String!): User!
+ setPinnedBadgeWallCategories(categories: [String!]!): User!
+ setBiography(biography: String!): User!
+ togglePinnedHololiveStream(stream: String!): User!
}
type User {
id: Int!
- badges: [Badge]!
+ badges: [Badge!]!
preferences: Preferences
}
diff --git a/src/routes/user/[user]/+page.svelte b/src/routes/user/[user]/+page.svelte
index 08bfd978..03e13f11 100644
--- a/src/routes/user/[user]/+page.svelte
+++ b/src/routes/user/[user]/+page.svelte
@@ -30,7 +30,11 @@
const setCategoriesQuery = graphql(`
mutation SetCategories($categories: [String!]!) {
setPinnedBadgeWallCategories(categories: $categories) {
- pinned_badge_wall_categories
+ id
+
+ preferences {
+ pinned_badge_wall_categories
+ }
}
}
`);
@@ -38,7 +42,11 @@
const toggleCategoryQuery = graphql(`
mutation ToggleCategory($category: String!) {
togglePinnedBadgeWallCategory(category: $category) {
- pinned_badge_wall_categories
+ id
+
+ preferences {
+ pinned_badge_wall_categories
+ }
}
}
`);
@@ -46,7 +54,11 @@
const toggleHideMissingBadgesQuery = graphql(`
mutation ToggleHideMissingBadges {
toggleHideMissingBadges {
- hide_missing_badges
+ id
+
+ preferences {
+ hide_missing_badges
+ }
}
}
`);
@@ -54,7 +66,11 @@
const toggleHideAWCBadgesQuery = graphql(`
mutation ToggleHideAWCBadges {
toggleHideAWCBadges {
- hide_awc_badges
+ id
+
+ preferences {
+ hide_awc_badges
+ }
}
}
`);
@@ -62,7 +78,11 @@
const setBiographyQuery = graphql(`
mutation SetBiography($biography: String!) {
setBiography(biography: $biography) {
- biography
+ id
+
+ preferences {
+ biography
+ }
}
}
`);
@@ -70,7 +90,11 @@
const setBadgeWallCSSQuery = graphql(`
mutation SetBadgeWallCSS($css: String!) {
setBadgeWallCSS(css: $css) {
- badge_wall_css
+ id
+
+ preferences {
+ badge_wall_css
+ }
}
}
`);