All files / app/features queryKeys.ts

83.68% Statements 118/141
50% Branches 7/14
73.33% Functions 22/30
92.18% Lines 59/64

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175      232x 223x 107x 107x 107x 328x 107x 107x 107x 107x 107x 107x 107x 107x   666x 666x                   644x 644x     574x   107x   107x           158x         107x     107x           107x 107x         107x               107x         107x       107x         107x 107x             107x             107x 201x         107x 120x           107x       227x     107x   107x 107x       107x       2x 107x 107x           107x 107x 107x       107x 107x 107x           107x           107x     107x 107x     107x     257x 217x        
import { ReferenceType } from "proto/references_pb";
 
// profiles/users
export const languagesKey = "languages";
export const regionsKey = "regions";
export const badgesKey = "badges";
export const blockedUsersKey = "blockedUsers";
export const friendIdsKey = "friendIds";
export const accountInfoQueryKey = "accountInfo";
export const doNotEmailQueryKey = "doNotEmail";
export const tosQueryKey = "tos";
export const communityGuidelinesQueryKey = "communityGuidelines";
export const notificationSettingsQueryKey = "notificationSettings";
export const listNotificationsQueryKey = "listNotifications";
export const pingQueryKey = "ping";
export const username2Id = "username2Id";
export const volunteerInfoQueryKey = "volunteerInfo";
 
export function userKey(userId?: number) {
  return userId === undefined ? ["user"] : ["user", userId];
}
 
export function modUserKey(user?: string) {
  return user === undefined ? "modUser" : ["modUser", user];
}
export function modUserDetailsKey(user?: string) {
  return user === undefined ? "modUserDetails" : ["modUserDetails", user];
}
 
export function liteUserKey(userId?: number) {
  return userId === undefined ? ["liteUser"] : ["liteUser", userId];
}
 
export const liteUsersKey = (ids: number[] | string[]) => ["liteUsers", ...ids];
 
export const referencesGivenKey = "referencesGiven";
 
export const referencesReceivedBaseKey = "referencesReceived";
export interface ReferencesReceivedKeyInputs {
  userId: number;
  type: ReferenceType | "all";
}
 
export const availableWriteReferencesKey = (userId: number) => [
  "availableWriteReferences",
  { userId },
];
 
export const hasGivenHostRequestReferenceKey = "hasGivenHostRequestReference";
 
export type FriendRequestType = "sent" | "received";
export const friendRequestKey = (type: FriendRequestType) => [
  "friendRequests",
  { type },
];
 
// communities
export const communityKey = (id: number) => ["community", id];
export const subCommunitiesKey = (communityId: number) => [
  "subCommunities",
  communityId,
];
 
export const communityDiscussionsKey = (communityId: number) => [
  "communityDiscussions",
  communityId,
];
 
// Determines whether only some entities can be revealed or all can be revealed
// with a fetch more button
export type QueryType = "summary" | "all";
export const communityAdminsKey = (communityId: number, type: QueryType) => [
  "communityAdmins",
  { communityId, type },
];
 
export const communityMembersKey = (communityId: number) => [
  "communityMembers",
  communityId,
];
export const communityNearbyUsersKey = (communityId: number) => [
  "communityNearbyUsers",
  communityId,
];
 
export const communityEventsBaseKey = "communityEvents";
export const communityEventsKey = (communityId: number, type: QueryType) => [
  communityEventsBaseKey,
  communityId,
  { type },
];
 
// events
export const eventKey = (eventId: number) => ["event", eventId];
export type EventsType = "upcoming" | "past";
interface EventUsersInput {
  eventId: number;
  type: QueryType;
}
 
const eventOrganizersBaseKey = "eventOrganizers";
export const eventOrganizersKey = ({ eventId, type }: EventUsersInput) => [
  eventOrganizersBaseKey,
  eventId,
  ...(type === "summary" ? ["summary"] : []),
];
export const eventAttendeesBaseKey = "eventAttendees";
export const eventAttendeesKey = ({ eventId, type }: EventUsersInput) => [
  eventAttendeesBaseKey,
  eventId,
  { type },
];
 
export const discussionKey = (discussionId: number) => [
  "discussion",
  discussionId,
];
export const threadKey = (threadId: number) => ["thread", threadId];
 
// messaging
export const groupChatsListKey = (filters?: { onlyArchived?: boolean }) =>
  filters ? ["groupChatsList", filters] : ["groupChatsList"];
export const groupChatKey = (groupChatId: number) => ["groupChat", groupChatId];
export const groupChatMessagesKey = (groupChatId: number) => [
  "groupChatMessages",
  groupChatId,
];
export const hostRequestsListKey = (filters?: {
  onlyActive?: boolean;
  onlyArchived?: boolean;
  type?: "all" | "hosting" | "surfing";
}) => (filters ? ["hostRequests", filters] : ["hostRequests"]);
export const hostRequestKey = (id?: number) => ["hostRequest", id];
export const hostRequestMessagesKey = (id?: number) => [
  "hostRequestMessages",
  id,
];
 
// User
export const userCommunitiesKey = "userCommunities";
export const myEventsKey = (type: EventsType) => ["myEvents", { type }];
export const myCommunityEventsKey = (type: EventsType) => [
  "myCommunityEvents",
  { type },
];
export const activeLoginsKey = "activeLogins";
export const inviteCodesKey = "inviteCodes";
export const remindersKey = "reminders";
 
// Badges
interface BadgeUsersInput {
  badgeId: string;
}
export const badgeUsersKey = ({ badgeId }: BadgeUsersInput) => [
  "badgeUsers",
  badgeId,
];
 
// mod
export const newUsersListKey = "newUsersList";
 
// Public
export const volunteersKey = "volunteers";
export const donationStatsKey = "donationStats";
 
// Translate
export const showAllLanguagesQueryKey = "showAllLanguages";
 
// Gallery
export const galleryKey = (galleryId: number) => ["gallery", galleryId];
export const galleryEditInfoKey = (galleryId: number) => [
  "galleryEditInfo",
  galleryId,
];