All files / app/features queryKeys.ts

82.4% Statements 103/125
58.33% Branches 7/12
73.07% Functions 19/26
92.98% Lines 53/57

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      381x 371x 98x 98x 98x 314x 98x 98x 98x 98x 98x 98x 98x   815x 815x                   614x 614x     519x   98x   98x           158x         98x     98x           98x 98x         98x               98x         98x       98x         98x 98x             98x             98x 138x         98x 98x           98x       204x     98x 98x 98x       98x     2x 98x 98x           98x 98x 98x 98x           98x           98x     98x 98x  
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 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 = "groupChatsList";
export const groupChatKey = (groupChatId: number) => ["groupChat", groupChatId];
export const groupChatMessagesKey = (groupChatId: number) => [
  "groupChatMessages",
  groupChatId,
];
export const hostRequestsListKey = (filters?: {
  onlyActive: 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 activeLoginsKey = "activeLogins";
export const inviteCodesKey = "inviteCodes";
 
// 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";