All files / app/features queryKeys.ts

75% Statements 105/140
50% Branches 7/14
59.37% Functions 19/32
90.47% Lines 57/63

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      386x 376x 86x 86x 86x 89x 86x 253x 86x 86x 86x 86x 86x 86x 86x   815x 815x                   614x 614x     513x   86x   86x         86x               86x           86x           86x 86x       86x       86x       86x       86x               86x         86x       86x         86x 86x             86x   86x           86x 132x         86x 89x           86x       202x     86x 86x 86x       86x     2x 86x 86x           86x       86x 86x 86x           86x           86x  
import { ReferenceType } from "proto/references_pb";
 
// profiles/users
export const languagesKey = "languages";
export const regionsKey = "regions";
export const badgesKey = "badges";
export const blockedUserIdsKey = "blockedUserIds";
export const blockedUsersKey = "blockedUsers";
export const friendIdsKey = "friendIds";
export const contributorFormInfoQueryKey = "contributorFormInfo";
export const accountInfoQueryKey = "accountInfo";
export const signupInfoQueryKey = "signupInfo";
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 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 referencesReceivedKey = ({
  userId,
  type,
}: ReferencesReceivedKeyInputs) => [
  referencesReceivedBaseKey,
  { type, userId },
];
 
export const availableWriteReferencesKey = (userId: number) => [
  "availableWriteReferences",
  { userId },
];
 
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 communityGroupsKey = (communityId: number) => [
  "communityGroups",
  communityId,
];
export const communityGuidesKey = (communityId: number) => [
  "communityGuides",
  communityId,
];
export const communityPlacesKey = (communityId: number) => [
  "communityPlaces",
  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";
export const eventsKey = (type: EventsType) => ["events", { type }];
export interface EventUsersInput {
  eventId: number;
  type: QueryType;
}
 
export 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,
];
 
// Search
export const searchQueryKey = (query?: string) =>
  query ? ["search", query] : ["search"];
 
// User
export const userCommunitiesKey = "userCommunities";
export const myEventsKey = (type: EventsType) => ["myEvents", { type }];
export const activeLoginsKey = "activeLogins";
 
// Badges
export interface BadgeUsersInput {
  badgeId: string;
}
export const badgeUsersKey = ({ badgeId }: BadgeUsersInput) => [
  "badgeUsers",
  badgeId,
];
 
// mod
export const newUsersListKey = "newUsersList";