All files / app/features queryKeys.ts

82.91% Statements 131/158
50% Branches 8/16
69.69% Functions 23/33
91.66% Lines 66/72

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        130x 130x 130x 130x 130x 1297x 130x 130x 130x 130x 130x 130x 130x 130x 130x   465x 465x                   1053x 1053x     606x   130x   130x           130x   130x     130x     241x 130x   130x         130x   130x 130x   130x 130x             130x             130x 201x         130x 130x   152x 662x       130x   130x   130x 130x 130x       14x 130x 130x     130x 130x 130x 130x 130x 130x 130x           130x     130x     130x     130x 130x 130x 130x 130x     130x     130x 130x  
import { ReferenceType } from "proto/references_pb";
import { MessageFilterType } from "routes";
 
// 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 listMyCommunitiesDiscussionsKey = "myCommunitiesDiscussions";
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
// onlyArchived is derivable from the filter ("archived"), so the filter alone keys the cache
export const messageThreadsListKey = (filter?: MessageFilterType) =>
  filter ? ["messageThreads", filter] : ["messageThreads"];
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 userCommunitiesListKey = "userCommunitiesListV2";
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";
 
// Public Trips
export const publicTripsBaseKey = "publicTrips";
export const publicTripsKey = (communityId: number) => [publicTripsBaseKey, communityId];
export const publicTripsByUserBaseKey = "publicTripsByUser";
export const publicTripsByUserKey = (userId: number) => [publicTripsByUserBaseKey, userId];
export const donationStatsKey = "donationStats";
 
// Translate
export const showAllLanguagesQueryKey = "showAllLanguages";
 
// Gallery
export const galleryKey = (galleryId: number) => ["gallery", galleryId];
export const galleryEditInfoKey = (galleryId: number) => ["galleryEditInfo", galleryId];