Skip to main content

React hooks

Enumerations

Interfaces

Variables

ThemeWrapper

Const ThemeWrapper: React.FC<RootComponentProps>

React component that fetches the user selected theme name from the localstorage and passes it to the ThemeSelector component along with all available themes.

Defined in

ui/hooks/src/utils/theme-wrapper.tsx:10


constants

constants: Object

Type declaration

NameType
BASE_DECISION_URLstring
BASE_MODERATOR_URLstring
BASE_REASONS_URLstring
BASE_REPORT_URLstring
BASE_STATUS_URLstring
CHECK_MODERATOR_KEYstring
CONNECT_PROVIDER_KEYstring
DEFAULT_FETCH_TIMEOUTnumber
DELISTED_ITEMS_KEYstring
INJECTED_PROVIDER_KEYstring
KEPT_ITEMS_KEYstring
LOG_ITEMS_KEYstring
MODERATED_CACHE_KEY_PREFIXstring
MODERATION_COUNT_CACHE_KEY_PREFIXstring
MODERATION_ITEMS_COUNT_KEYstring
MODERATION_ITEM_FLAGS_KEYstring
MODERATION_STATUS_KEYstring
PENDING_CACHE_KEY_PREFIXstring
PENDING_ITEMS_KEYstring
REQUIRED_NETWORK_KEYstring
TOKEN_VALIDATION_KEYstring

Defined in

ui/hooks/src/constants.ts:29

Functions

checkPostActive

checkPostActive(entry): boolean

Utility to check whether a post is active or not

Parameters

NameType
entryPick<PostResponse, "content" | "delisted">

Returns

boolean

Defined in

ui/hooks/src/utils/checkPostActive.ts:6


createPendingEntry

createPendingEntry(author, entryPublishData): PendingEntry

Utility to create an entry yet to be published

Parameters

NameType
authorIProfileData
entryPublishDataIPublishData & { entryId?: string }

Returns

PendingEntry

Defined in

ui/hooks/src/utils/entry-utils.ts:268


getLinkPreview

getLinkPreview(url): Promise<LinkPreview>

Utility to get preview of a specified url

Parameters

NameType
urlstring

Returns

Promise<LinkPreview>

Defined in

ui/hooks/src/utils/media-utils.ts:108


getMediaUrl

getMediaUrl(hash?): Object

Utility to build gateway links to ipfs content

Parameters

NameType
hash?string

Returns

Object

NameType
fallbackLinkstring
originLinkstring
pathLinkstring

Defined in

ui/hooks/src/utils/media-utils.ts:17


logError

logError(name, errorInfo): void

Utility to log error to a specified logger

Parameters

NameType
namestring
errorInfoError

Returns

void

Defined in

ui/hooks/src/utils/error-handler.ts:21


mapEntry

mapEntry(entry, logger?): IEntryData

Remap entry data coming from a response to the format expected by EntryCard content - from b64 to slate format profile images - append ipfs gateway entry images - append ipfs gateway

Parameters

NameType
entryPostResponse | CommentResponse
logger?ILogger

Returns

IEntryData

Defined in

ui/hooks/src/utils/entry-utils.ts:99


switchToRequiredNetwork

switchToRequiredNetwork(): Promise<void>

An utility function to switch to required network - Metamask

Returns

Promise<void>

Defined in

ui/hooks/src/use-injected-provider.ts:37


uploadMediaToTextile

uploadMediaToTextile(data, isUrl?): Promise<{ data: { originalSrc: string ; size: { height: number ; naturalHeight: number ; naturalWidth: number ; width: number } = res.size; src: { fallbackUrl: string = ipfsLinks.fallbackLink; url: string = ipfsLinks.originLink } } ; error: undefined = error } | { data: undefined ; error: any = error }>

Utility to upload media to textile bucket

Parameters

NameTypeDefault value
dataFileundefined
isUrlbooleanfalse

Returns

Promise<{ data: { originalSrc: string ; size: { height: number ; naturalHeight: number ; naturalWidth: number ; width: number } = res.size; src: { fallbackUrl: string = ipfsLinks.fallbackLink; url: string = ipfsLinks.originLink } } ; error: undefined = error } | { data: undefined ; error: any = error }>

Defined in

ui/hooks/src/utils/media-utils.ts:62


useAnalytics

useAnalytics(): [UseAnalyticsActions]

Hook to handle analytics

example useAnalytics hook

const [analyticsActions] = useAnalytics();

analyticsActions.trackEvent({
category: 'some-category',
action: 'some-action',
});

Returns

[UseAnalyticsActions]

Defined in

ui/hooks/src/use-analytics.tsx:44


useAppDescription

useAppDescription(ipfsLink): UseQueryResult<string, Error>

Hook to get detailed description for app

example useAppDescription hook

const detailedDescriptionQuery = useAppDescription('ipfslinktodescription');

const description = detailedDescriptionQuery.data

Parameters

NameType
ipfsLinkstring

Returns

UseQueryResult<string, Error>

Defined in

ui/hooks/src/use-app-description.ts:23


useCheckModerator

useCheckModerator(loggedUser): UseQueryResult<number, Error>

Hook to check if a user is a moderator

example useCheckModerator hook

const checkModeratorQuery = useCheckModerator('logged-in-user-eth-address');

const isModerator = checkModeratorQuery.data === 200;

Parameters

NameType
loggedUserstring

Returns

UseQueryResult<number, Error>

Defined in

ui/hooks/src/use-moderation.ts:207


useCheckNewNotifications

useCheckNewNotifications(loggedEthAddress): UseQueryResult<boolean, Error>

Hook to check for new notifications

example useCheckNewNotifications hook

const checkNewNotificationsQuery = useCheckNewNotifications('logged-in-user-eth-address');

const hasNewNotifications = checkNewNotificationsQuery.data;

Parameters

NameType
loggedEthAddressstring

Returns

UseQueryResult<boolean, Error>

Defined in

ui/hooks/src/use-notifications.ts:127


useCheckSignup

useCheckSignup(ethAddress): UseQueryResult<boolean, Error>

Hook to check if a user is already registered

example useCheckSignup hook

const checkSignupQuery = useCheckSignup('0x42b35jk53ifq');
// checkSignupQuery.data returns a boolean value which determines if one should proceed with signup process or not

Parameters

NameType
ethAddressstring

Returns

UseQueryResult<boolean, Error>

Defined in

ui/hooks/src/use-login.ts:379


useComment

useComment(commentID, enabler?): UseQueryResult<CommentResponse, Error>

Hook for fetching data for a specific comment

example useComment hook

const itemType = 'COMMENT';
const commentQuery = useComment('some-comment-id', true);

const itemData = React.useMemo(() => {
if (itemType === 'COMMENT' && commentQuery.isSuccess) {
// mapEntry is a utility function that transforms the comment/post data into required format.
return mapEntry(commentQuery.data);
}
}, [itemType, commentQuery.data, commentQuery.isSuccess]);

Parameters

NameTypeDefault value
commentIDstringundefined
enablerbooleantrue

Returns

UseQueryResult<CommentResponse, Error>

Defined in

ui/hooks/src/use-comments.ts:116


useConnectProvider

useConnectProvider(provider): UseQueryResult<boolean, unknown>

Hook to connect with one of the supported providers

example useConnectProvider hook

const connectProviderQuery = useConnectProvider('selectedProvider');

// can be used as enabler for useNetworkState hook; so this check works only if provider has been connected.
const networkStateQuery = useNetworkState(connectProviderQuery.data);

Parameters

NameType
providerEthProviders

Returns

UseQueryResult<boolean, unknown>

Defined in

ui/hooks/src/use-injected-provider.ts:78


useCreateComment

useCreateComment(): UseMutationResult<string, unknown, IPublishData & { postID: string }, { entryId: string = pendingID; optimisticComment: IPublishData & { postID: string } }>

Hook for creating a new comment

example useCreateComment hook

const createCommentQuery = useCreateComment('some-comment-id');
const newCommentData = { textContent: 'some text content', author: 'comment author', pubKey: 'comment-author-pubkey' }

createCommentQuery.mutate({ ...newCommentData , postID: 'some-post-id' });

Returns

UseMutationResult<string, unknown, IPublishData & { postID: string }, { entryId: string = pendingID; optimisticComment: IPublishData & { postID: string } }>

Defined in

ui/hooks/src/use-comments.ts:207


useCreatePost

useCreatePost(): UseMutationResult<string, unknown, IPublishData, { entryId: string = pendingID; optimisticEntry: IPublishData & { isPublishing: boolean = true } }>

Hook to create a new post pass the publish data from the editor to the mutate function

example useCreatePost hook

const publishPostQuery = useCreatePost();

publishPostQuery.mutate({ pubKey: 'author-public-key', ...});

Returns

UseMutationResult<string, unknown, IPublishData, { entryId: string = pendingID; optimisticEntry: IPublishData & { isPublishing: boolean = true } }>

Defined in

ui/hooks/src/use-posts.ts:416


useCurrentNetwork

useCurrentNetwork(enabler?): UseQueryResult<string, unknown>

Hook to check the user's current web3 network

example useCurrentNetwork hook

const currentNetworkQuery = useCurrentNetwork(true);

const network = currentNetworkQuery.data;

Parameters

NameType
enabler?boolean

Returns

UseQueryResult<string, unknown>

network name

Defined in

ui/hooks/src/use-network-state.ts:53


useDeleteBookmark

useDeleteBookmark(): UseMutationResult<{ data: string[] }, unknown, string, { prevBmks: { entryId: string ; type: EntityTypes }[] }>

Hook used to delete a bookmark

example useDeleteBookmark hook

const deleteBookmarkQuery = useDeleteBookmark();

deleteBookmarkQuery.mutate('dbkjjouyahljfe');

Returns

UseMutationResult<{ data: string[] }, unknown, string, { prevBmks: { entryId: string ; type: EntityTypes }[] }>

Defined in

ui/hooks/src/use-bookmarks.ts:111


useDeleteComment

useDeleteComment(commentID): UseMutationResult<true, unknown, string, { previousComment: CommentResponse }>

Hook for deleting a specific comment

example useDeleteComment hook

const deleteCommentQuery = useDeleteComment('some-comment-id');

deleteCommentQuery.mutate('some-comment-id');

Parameters

NameType
commentIDstring

Returns

UseMutationResult<true, unknown, string, { previousComment: CommentResponse }>

Defined in

ui/hooks/src/use-comments.ts:147


useDeletePost

useDeletePost(postID): UseMutationResult<{ data: { removePost: boolean } }, unknown, string, { previousPost: Post_Response }>

Hook to delete a post

example useDeletePost hook

const deletePostQuery = useDeletePost('some-post-id');

deletePostQuery.mutate('some-post-id');

Parameters

NameType
postIDstring

Returns

UseMutationResult<{ data: { removePost: boolean } }, unknown, string, { previousPost: Post_Response }>

Defined in

ui/hooks/src/use-posts.ts:350


useEditComment

useEditComment(commentID, hasCommentData): UseMutationResult<void | { data: { editComment: boolean } }, unknown, IPublishData & { postID: string }, { comment: IPublishData & { postID: string } }>

Hook for editing a comment

example useEditComment hook

const editCommentQuery = useEditComment('some-comment-id', true);
const editedCommentData = { textContent: 'some text content', author: 'comment author', pubKey: 'comment-author-pubkey' }

editCommentQuery.mutate({ ...editedCommentData, postID: 'some-post-id' });

Parameters

NameType
commentIDstring
hasCommentDataboolean

Returns

UseMutationResult<void | { data: { editComment: boolean } }, unknown, IPublishData & { postID: string }, { comment: IPublishData & { postID: string } }>

Defined in

ui/hooks/src/use-comments.ts:259


useEditPost

useEditPost(): UseMutationResult<boolean, Error, IPublishData & { entryID: string }, { editedPost: IPublishData & { entryID: string } }>

Hook to edit a post pass the edited post data to the mutate function

example useEditPost hook

const editPostQuery = useEditPost();

editPostQuery.mutate({ entryID: 'some-entry-id', ...});

Returns

UseMutationResult<boolean, Error, IPublishData & { entryID: string }, { editedPost: IPublishData & { entryID: string } }>

Defined in

ui/hooks/src/use-posts.ts:470


useEnsByAddress

useEnsByAddress(ethAddress): UseQueryResult<string, Error>

Hook to resolve an ethereum address to an ENS name

example useEnsByAddress hook

const ensByAddressQuery = useEnsByAddress('logged-in-user-eth-address');

// do something with the returned status of the query
const querySuccess = ensByAddressQuery.isSuccess

Parameters

NameType
ethAddressstring

Returns

UseQueryResult<string, Error>

Defined in

ui/hooks/src/use-username.ts:241


useEnsRegistration

useEnsRegistration(pubKey?): UseMutationResult<{ makeDefaultProvider: string }, Error, { userName: string }, { currentProfile: IProfileData }>

Hook to register a new ENS name. Pass as payload, the username to the mutate function

example useEnsRegistration hook

const registerEnsQuery = useEnsRegistration('logged-in-user-pubkey');

// do something with the returned status of the query
React.useEffect(()=> {
if (registerEnsQuery.status === 'success') {
// perform an action
}
}, [registerEnsQuery])

Parameters

NameType
pubKey?string

Returns

UseMutationResult<{ makeDefaultProvider: string }, Error, { userName: string }, { currentProfile: IProfileData }>

Defined in

ui/hooks/src/use-username.ts:162


useEntryNavigation

useEntryNavigation(navigateFn?, currentPostId?): (navigationDetails: IContentClickDetails, itemType: EntityTypes) => void

Hook to navigation to entry's page

example useEntryNavigation hook

// navigateFn handles the actual navigation
const handleEntryNavigate = useEntryNavigation(navigateTo, 'current-post-id');

Parameters

NameType
navigateFn?(args: NavigateToParams) => void
currentPostId?string

Returns

fn

▸ (navigationDetails, itemType): void

Parameters
NameType
navigationDetailsIContentClickDetails
itemTypeEntityTypes
Returns

void

Defined in

ui/hooks/src/use-navigation.ts:17


useFetchNotifications

useFetchNotifications(loggedEthAddress): UseQueryResult<any[], Error>

Hook to get a user's notifications

example useFetchNotifications hook

const fetchNotificationsQuery = useFetchNotifications('logged-in-user-eth-address');

const notifications = fetchNotificationsQuery.data;

Parameters

NameType
loggedEthAddressstring

Returns

UseQueryResult<any[], Error>

Defined in

ui/hooks/src/use-notifications.ts:57


useFollow

useFollow(): UseMutationResult<{ data: { follow: boolean } }, unknown, string, { previousFollowedProfiles: string[] }>

Hook to follow another user

example useFollow hook

const followQuery = useFollow();

followQuery.mutate('pubkey-of-user-to-follow');

Returns

UseMutationResult<{ data: { follow: boolean } }, unknown, string, { previousFollowedProfiles: string[] }>

Defined in

ui/hooks/src/use-follow.ts:279


useFollowers

useFollowers(pubKey, limit, offset?): UseInfiniteQueryResult<{ nextIndex: number = res.data.getFollowers.nextIndex; results: { _id: string ; avatar: { fallbackUrl: string ; url: string } ; coverImage: { fallbackUrl: string ; url: string } ; creationDate: string ; default: [DataProviderInput] ; description: string ; ethAddress: string ; name: string ; providers: [DataProviderInput] ; pubKey: string ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string }[] = followersWithMediaLinks; total: number = res.data.getFollowers.total }, Error>

Hook to get followers for a user

example useFollowers hook

const followersQuery = useFollowers('some-pubkey', 10);

const followers = React.useMemo(
() => followersQuery.data?.pages?.reduce((acc, curr) => [...acc, ...curr.results], []),
[followersQuery.data?.pages],
);

Parameters

NameType
pubKeystring
limitnumber
offset?number

Returns

UseInfiniteQueryResult<{ nextIndex: number = res.data.getFollowers.nextIndex; results: { _id: string ; avatar: { fallbackUrl: string ; url: string } ; coverImage: { fallbackUrl: string ; url: string } ; creationDate: string ; default: [DataProviderInput] ; description: string ; ethAddress: string ; name: string ; providers: [DataProviderInput] ; pubKey: string ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string }[] = followersWithMediaLinks; total: number = res.data.getFollowers.total }, Error>

Defined in

ui/hooks/src/use-profile.ts:205


useFollowing

useFollowing(pubKey, limit, offset?): UseInfiniteQueryResult<{ nextIndex: number = res.data.getFollowing.nextIndex; results: { _id: string ; avatar: { fallbackUrl: string ; url: string } ; coverImage: { fallbackUrl: string ; url: string } ; creationDate: string ; default: [DataProviderInput] ; description: string ; ethAddress: string ; name: string ; providers: [DataProviderInput] ; pubKey: string ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string }[] = followingWithMediaLinks; total: number = res.data.getFollowing.total }, Error>

Hook to get a list of profiles following the user

example useFollowing hook

const followingQuery = useFollowing('some-pubkey', 10);

const following = React.useMemo(
() => followingQuery.data?.pages?.reduce((acc, curr) => [...acc, ...curr.results], []),
[followingQuery.data?.pages],
);

Parameters

NameType
pubKeystring
limitnumber
offset?number

Returns

UseInfiniteQueryResult<{ nextIndex: number = res.data.getFollowing.nextIndex; results: { _id: string ; avatar: { fallbackUrl: string ; url: string } ; coverImage: { fallbackUrl: string ; url: string } ; creationDate: string ; default: [DataProviderInput] ; description: string ; ethAddress: string ; name: string ; providers: [DataProviderInput] ; pubKey: string ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string }[] = followingWithMediaLinks; total: number = res.data.getFollowing.total }, Error>

Defined in

ui/hooks/src/use-profile.ts:247


useGetAllInstalledApps

useGetAllInstalledApps(enabler?): UseQueryResult<any, Error>

Hook to get all the user's installed apps

example useGetAllInstalledApps hook

const installedAppsQuery = useGetAllInstalledApps(true);

const installedApps = installedAppsQuery.data

Parameters

NameType
enabler?boolean

Returns

UseQueryResult<any, Error>

Defined in

ui/hooks/src/use-app-settings.ts:47


useGetAllIntegrationReleaseIds

useGetAllIntegrationReleaseIds(integrationName, offset?): UseQueryResult<{ nextIndex: any = data.next; releaseIds: any }, Error>

Hook to get all the release ids for an integration

example useGetAllIntegrationReleaseIds hook

const releaseIdsQuery = useGetAllIntegrationReleaseIds('awesome integration');

const releaseIds = releaseIdsQuery.data?.releaseIds

Parameters

NameType
integrationNamestring
offset?number

Returns

UseQueryResult<{ nextIndex: any = data.next; releaseIds: any }, Error>

Defined in

ui/hooks/src/use-integration-registry.ts:178


useGetAllIntegrationsIds

useGetAllIntegrationsIds(enabler?, offset?): UseQueryResult<any, Error>

Hook to get all the published integrations ids

example useGetAllIntegrationsIds hook

const availableIntegrationsQuery = useGetAllIntegrationsIds(true);

const availableIntegrations = availableIntegrationsQuery.data

Parameters

NameTypeDefault value
enablerbooleantrue
offset?numberundefined

Returns

UseQueryResult<any, Error>

Defined in

ui/hooks/src/use-integration-registry.ts:152


useGetAppConfig

useGetAppConfig(appName, enabler?): UseQueryResult<any, Error>

Hook to get configuration object for an installed app

example useGetAppConfig hook

const appConfigQuery = useGetAppConfig('app name', true);

const appConfig = appConfigQuery.data

Parameters

NameType
appNamestring
enabler?boolean

Returns

UseQueryResult<any, Error>

Defined in

ui/hooks/src/use-app-settings.ts:24


useGetBookmarks

useGetBookmarks(loggedEthAddress, enabler?): UseQueryResult<Record<string, unknown>[], unknown>

Hook for gettting a user's saved posts and comments

example useGetBookmarks hook

const getBookmarksQuery = useGetBookmarks('0x243kb4bret');

const bookmarks = getBookmarksQuery.data;

Parameters

NameTypeDefault value
loggedEthAddressstringundefined
enablerbooleantrue

Returns

UseQueryResult<Record<string, unknown>[], unknown>

Defined in

ui/hooks/src/use-bookmarks.ts:20


useGetCount

useGetCount(): UseQueryResult<{ delisted: number = 0; kept: number = 0; pending: number = 0 }, Error>

Hook to get moderation counters

example useGetCount hook

const getCountQuery = useGetCount();

const count = getCountQuery.data || { delisted: 0, kept: 0, pending: 0 };

Returns

UseQueryResult<{ delisted: number = 0; kept: number = 0; pending: number = 0 }, Error>

Defined in

ui/hooks/src/use-moderation.ts:224


useGetEntryAuthor

useGetEntryAuthor(entryId): UseQueryResult<IProfileData | { _id: string ; avatar: { fallbackUrl: string ; url: string } ; coverImage: { fallbackUrl: string ; url: string } ; creationDate: string ; default: [DataProviderInput] ; description: string ; ethAddress: string ; name: string ; providers: [DataProviderInput] ; pubKey: string ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string }, Error>

Hook to get an entry author's profile data

example useGetEntryAuthor hook

const getEntryAuthorQuery = useGetEntryAuthor( 'some-entry-id');

const profile = getEntryAuthorQuery.data;

Parameters

NameType
entryIdstring

Returns

UseQueryResult<IProfileData | { _id: string ; avatar: { fallbackUrl: string ; url: string } ; coverImage: { fallbackUrl: string ; url: string } ; creationDate: string ; default: [DataProviderInput] ; description: string ; ethAddress: string ; name: string ; providers: [DataProviderInput] ; pubKey: string ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string }, Error>

Defined in

ui/hooks/src/use-profile.ts:167


useGetFlags

useGetFlags(entryId): UseQueryResult<EntryReport[], Error>

Hook to get report flags for a specific entry

example useGetFlags hook

const getFlagsQuery = useGetFlags('some-entry-id');

const flagEntries = getFlagsQuery.data;

Parameters

NameType
entryIdstring

Returns

UseQueryResult<EntryReport[], Error>

Defined in

ui/hooks/src/use-moderation.ts:240


useGetIntegrationId

useGetIntegrationId(integrationName): UseQueryResult<{ id: string = data }, Error>

Hook to get integration id by its name

example useGetIntegrationId hook

const integrationIdQuery = useGetIntegrationId('awesome integration');

const integrationId = integrationIdQuery.data;

Parameters

NameType
integrationNamestring

Returns

UseQueryResult<{ id: string = data }, Error>

Defined in

ui/hooks/src/use-integration-registry.ts:92


useGetIntegrationInfo

useGetIntegrationInfo(integrationId): UseQueryResult<IntegrationInfo, Error>

Hook to get integration package info

example useGetIntegrationInfo hook

const integrationInfoQuery = useGetIntegrationInfo('some-integration-id');

const integrationInfo = integrationInfoQuery.data;

Parameters

NameType
integrationIdstring

Returns

UseQueryResult<IntegrationInfo, Error>

Defined in

ui/hooks/src/use-integration-registry.ts:24


useGetIntegrationReleaseId

useGetIntegrationReleaseId(integrationName, version, enabler?): UseQueryResult<{ id: string = data }, Error>

Hook to get integration release id by its name and version

example useGetIntegrationReleaseId hook

const integrationReleaseIdQuery = useGetIntegrationReleaseId('awesome integration', '0.1.1', true);

const integrationReleaseId = integrationReleaseIdQuery.data;

Parameters

NameType
integrationNamestring
versionstring
enabler?boolean

Returns

UseQueryResult<{ id: string = data }, Error>

Defined in

ui/hooks/src/use-integration-registry.ts:114


useGetIntegrationReleaseInfo

useGetIntegrationReleaseInfo(releaseId): UseQueryResult<ReleaseInfo, Error>

Hook to get integration release info

example useGetIntegrationReleaseInfo hook

const latestReleaseInfoQuery = useGetIntegrationReleaseInfo('some-release-id');

const latestReleaseInfo = latestReleaseInfoQuery.data

Parameters

NameType
releaseIdstring

Returns

UseQueryResult<ReleaseInfo, Error>

Defined in

ui/hooks/src/use-integration-registry.ts:205


useGetIntegrationsCount

useGetIntegrationsCount(): UseQueryResult<{ totalCount: any = data.totalCount }, Error>

Hook to get the number of published integrations

example useGetIntegrationsCount hook

const integrationsCountQuery = useGetIntegrationsCount();

const integrationCount = integrationsCountQuery.data;

Returns

UseQueryResult<{ totalCount: any = data.totalCount }, Error>

Defined in

ui/hooks/src/use-integration-registry.ts:70


useGetIntegrationsInfo

useGetIntegrationsInfo(opt): UseQueryResult<{ getIntegrationInfo: IntegrationInfo[] }, Error>

Hook to get package info for multiple integrations by name or id

example useGetIntegrationsInfo hook

const integrationsInfoQuery = useGetIntegrationsInfo([{ name: 'some-integration-name-1' }, { name: 'some-integration-name-2' }]);

const integrationsInfo = integrationsInfoQuery.data;

Parameters

NameType
opt{ id?: string ; name?: string }[]

Returns

UseQueryResult<{ getIntegrationInfo: IntegrationInfo[] }, Error>

Defined in

ui/hooks/src/use-integration-registry.ts:47


useGetIntegrationsReleaseInfo

useGetIntegrationsReleaseInfo(releaseIds): UseQueryResult<any[], Error>

Hook to get multiple integrations release info

example useGetIntegrationsReleaseInfo hook

const releaseInfoQuery = useGetIntegrationsReleaseInfo(['some-release-id-1', 'some-release-id-2', 'some-release-id-3']);

const releasesInfo = releaseInfoQuery.data

example mock data for an integration to test locally

if (!res.data.getLatestRelease.some(rel => rel.name === '@akashaorg/app-messaging')) {
res.data.getLatestRelease.push({
id: '0x82d31f280645cb2f74a47115a36f1e1b4370eda1812cf4d38d9107996bb60560',
name: '@akashaorg/app-messaging',
version: 'v0.1.0',
integrationType: 0,
sources: [],
integrationID: '0x0f7b806cb610e298f4108f77c5454edafdd48a213ac6df2466816442b2814061',
author: '0xADE0510E72f60789DD17aAFc28629Ee4D9C0Ba72',
enabled: true,
links: {
publicRepository: 'https://github.com/AKASHAorg/akasha-framework#readme',
documentation: '',
detailedDescription: '',
},
manifestData: {
mainFile: 'index.js',
license: 'AGPL-3.0',
keywords: [],
description:
'The AKASHA team builds this application so you can privately message friends.',
displayName: 'Messages',
},
createdAt: null,
});
}

Parameters

NameType
releaseIdsstring[]

Returns

UseQueryResult<any[], Error>

Defined in

ui/hooks/src/use-integration-registry.ts:262


useGetLatestReleaseInfo

useGetLatestReleaseInfo(opt): UseQueryResult<{ getLatestRelease: ReleaseInfo[] }, Error>

Hook to get latest release info for integrations

example useGetLatestReleaseInfo hook

const latestReleaseInfoQuery = useGetLatestReleaseInfo([{ id: 'some-release-id-1' }, { id: 'some-release-id-2' }, { id: 'some-release-id-3' }]);

const latestReleasesInfo = React.useMemo(() => {
return latestReleaseInfoQuery.data?.getLatestRelease;
}, [latestReleaseInfoQuery.data?.getLatestRelease]);

Parameters

NameType
opt{ id?: string ; name?: string }[]

Returns

UseQueryResult<{ getLatestRelease: ReleaseInfo[] }, Error>

Defined in

ui/hooks/src/use-integration-registry.ts:288


useGetLogin

useGetLogin(onError?): UseQueryResult<LoginState, unknown>

Hook for retrieving the current authentication state of the user

example useGetLogin hook

const loginQuery = useGetLogin();
// can be used with useGetProfile hook to get the logged profile data
const profileDataQuery = useGetProfile(loginQuery.data?.pubKey);

const loggedProfileData = profileDataQuery.data;

Parameters

NameType
onError?(error: Error) => void

Returns

UseQueryResult<LoginState, unknown>

Defined in

ui/hooks/src/use-login.ts:76


useGetProfile

useGetProfile(pubKey, loggedUser?, enabler?): UseQueryResult<IProfileData, Error>

Hook to get a user's profile data

example useGetProfile hook

const getProfileQuery = useGetProfile('some-pubkey');

const profile = getProfileQuery.data;

Parameters

NameTypeDefault value
pubKeystringundefined
loggedUser?stringundefined
enablerbooleantrue

Returns

UseQueryResult<IProfileData, Error>

Defined in

ui/hooks/src/use-profile.ts:97


useGetProfileByEthAddress

useGetProfileByEthAddress(ethAddress, loggedUser?, enabler?): UseQueryResult<IProfileData, Error>

Hook to get a user's profile data

example useGetProfileByEthAddress hook

const getProfileByEthAddressQuery = useGetProfileByEthAddress( 'some-eth-address');

const profile = getProfileByEthAddressQuery.data;

Parameters

NameTypeDefault value
ethAddressstringundefined
loggedUser?stringundefined
enablerbooleantrue

Returns

UseQueryResult<IProfileData, Error>

Defined in

ui/hooks/src/use-profile.ts:133


useGetTag

useGetTag(tagName, enabler?): UseQueryResult<Tag_Response, Error>

Hook to get a specific tag by name

example useGetTag hook

const getTagQuery = useGetTag('awesometag', true);

const tag = getTagQuery.data

Parameters

NameTypeDefault value
tagNamestringundefined
enablerbooleantrue

Returns

UseQueryResult<Tag_Response, Error>

Defined in

ui/hooks/src/use-tag.ts:139


useGlobalLogin

useGlobalLogin(props): void

Hook that will fire an action when the sign in is called

example useGlobalLogin hook

useGlobalLogin({
onLogin: payload => {},
onLogout: () => {},
waitForAuth: payload => {}.
onReady: payload => {},
onLoadFromCache: payload => {},
onError: payload => {},
})

Parameters

NameType
propsUseGlobalLoginProps

Returns

void

Defined in

ui/hooks/src/use-global-login.ts:34


useInfiniteComments

useInfiniteComments(limit, postID, offset?): UseInfiniteQueryResult<{ nextIndex: string ; results: string[] ; total: number }, Error>

Hook to get the comments for a specific post

example useInfiniteComments hook

const commentsQuery = useInfiniteComments(10, 'some-post-id', 'optional-comment-id-to-start-from');

const commentPages = React.useMemo(() => {
if (commentsQuery.data) {
return commentsQuery.data.pages;
}
return [];
}, [commentsQuery.data]);

Parameters

NameType
limitnumber
postIDstring
offset?string

Returns

UseInfiniteQueryResult<{ nextIndex: string ; results: string[] ; total: number }, Error>

Defined in

ui/hooks/src/use-comments.ts:61


useInfiniteCustomPosts

useInfiniteCustomPosts(enabler, limit, offset?): UseInfiniteQueryResult<{ nextIndex: string ; results: string[] ; total: number }, Error>

Hook to get posts for personalised user feed from followed profiles and subscribed tags, sorted chronologically

example useInfiniteCustomPosts hook

const customPostsQuery = useInfiniteCustomPosts(true, 15);

const postPages = React.useMemo(() => {
if (customPostsQuery.data) {
return customPostsQuery.data.pages;
}
return [];
}, [customPostsQuery.data]);

// load more posts
const handleLoadMore = React.useCallback(() => {
if (!customPostsQuery.isLoading && customPostsQuery.hasNextPage && loginState?.fromCache) {
customPostsQuery.fetchNextPage();
}
}, [customPostsQuery, loginState?.fromCache]);

Parameters

NameType
enablerboolean
limitnumber
offset?string

Returns

UseInfiniteQueryResult<{ nextIndex: string ; results: string[] ; total: number }, Error>

Defined in

ui/hooks/src/use-posts.ts:149


useInfiniteDelisted

useInfiniteDelisted(limit, offset?): UseInfiniteQueryResult<ModeratedItemsReponse, Error>

Hook to get delisted moderated items

example useInfiniteDelisted hook

const infiniteDelistedQuery = useInfiniteDelisted(10);

const delistedItemPages = React.useMemo(() => {
if (infiniteDelistedQuery.data) {
return infiniteDelistedQuery.data.pages;
}
return [];
}, [infiniteDelistedQuery.data]);

// load more items
const handleLoadMore = React.useCallback(() => {
if (!infiniteDelistedQuery.isLoading && infiniteDelistedQuery.hasNextPage) {
infiniteDelistedQuery.fetchNextPage();
}
}, [infiniteDelistedQuery]);

Parameters

NameType
limitnumber
offset?string

Returns

UseInfiniteQueryResult<ModeratedItemsReponse, Error>

Defined in

ui/hooks/src/use-moderation.ts:383


useInfiniteKept

useInfiniteKept(limit, offset?): UseInfiniteQueryResult<ModeratedItemsReponse, Error>

Hook to get kept moderated items

example useInfiniteKept hook

const infiniteKeptQuery = useInfiniteKept(10);

const keptItemPages = React.useMemo(() => {
if (infiniteKeptQuery.data) {
return infiniteKeptQuery.data.pages;
}
return [];
}, [infiniteKeptQuery.data]);

// load more items
const handleLoadMore = React.useCallback(() => {
if (!infiniteKeptQuery.isLoading && infiniteKeptQuery.hasNextPage) {
infiniteKeptQuery.fetchNextPage();
}
}, [infiniteKeptQuery]);

Parameters

NameType
limitnumber
offset?string

Returns

UseInfiniteQueryResult<ModeratedItemsReponse, Error>

Defined in

ui/hooks/src/use-moderation.ts:343


useInfiniteLog

useInfiniteLog(limit, offset?): UseInfiniteQueryResult<LogItemsReponse, Error>

Hook to get log of moderated items

example useInfiniteLog hook

const infiniteLogQuery = useInfiniteLog(10);

const logItemPages = React.useMemo(() => {
if (infiniteLogQuery.data) {
return infiniteLogQuery.data.pages;
}
return [];
}, [infiniteLogQuery.data]);

// load more items
const handleLoadMore = React.useCallback(() => {
if (!infiniteLogQuery.isLoading && infiniteLogQuery.hasNextPage) {
infiniteLogQuery.fetchNextPage();
}
}, [infiniteLogQuery]);

Parameters

NameType
limitnumber
offset?string

Returns

UseInfiniteQueryResult<LogItemsReponse, Error>

Defined in

ui/hooks/src/use-moderation.ts:269


useInfinitePending

useInfinitePending(limit, offset?): UseInfiniteQueryResult<PendingItemsReponse, Error>

Hook to get pending moderation items

example useInfinitePending hook

const infinitePendingQuery = useInfinitePending(10);

const pendingItemPages = React.useMemo(() => {
if (infinitePendingQuery.data) {
return infinitePendingQuery.data.pages;
}
return [];
}, [infinitePendingQuery.data]);

// load more items
const handleLoadMore = React.useCallback(() => {
if (!infinitePendingQuery.isLoading && infinitePendingQuery.hasNextPage) {
infinitePendingQuery.fetchNextPage();
}
}, [infinitePendingQuery]);

Parameters

NameType
limitnumber
offset?string

Returns

UseInfiniteQueryResult<PendingItemsReponse, Error>

Defined in

ui/hooks/src/use-moderation.ts:308


useInfinitePosts

useInfinitePosts(limit, offset?): UseInfiniteQueryResult<{ nextIndex: string ; results: string[] ; total: number }, Error>

Hook to get posts for feed, sorted chronologically

example useInfinitePosts hook

const postsQuery = useInfinitePosts(15);

const postPages = React.useMemo(() => {
if (postsQuery.data) {
return postsQuery.data.pages;
}
return [];
}, [postsQuery.data]);

// load more posts
const handleLoadMore = React.useCallback(() => {
if (!postsQuery.isLoading && postsQuery.hasNextPage && loginState?.fromCache) {
postsQuery.fetchNextPage();
}
}, [postsQuery, loginState?.fromCache]);

Parameters

NameType
limitnumber
offset?string

Returns

UseInfiniteQueryResult<{ nextIndex: string ; results: string[] ; total: number }, Error>

Defined in

ui/hooks/src/use-posts.ts:94


useInfinitePostsByAuthor

useInfinitePostsByAuthor(pubKey, limit, enabled?, offset?): UseInfiniteQueryResult<{ nextIndex: string ; results: string[] ; total: number }, Error>

Hook to get an author's posts

example useInfinitePostsByAuthor hook

const authorPostsQuery = useInfinitePostsByAuthor('author-public-key', 15);

const postPages = React.useMemo(() => {
if (authorPostsQuery.data) {
return authorPostsQuery.data.pages;
}
return [];
}, [authorPostsQuery.data]);

// load more posts
const handleLoadMore = React.useCallback(() => {
if (!authorPostsQuery.isLoading && authorPostsQuery.hasNextPage && loginState?.fromCache) {
authorPostsQuery.fetchNextPage();
}
}, [authorPostsQuery, loginState?.fromCache]);

Parameters

NameTypeDefault value
pubKeystringundefined
limitnumberundefined
enabledbooleantrue
offset?numberundefined

Returns

UseInfiniteQueryResult<{ nextIndex: string ; results: string[] ; total: number }, Error>

Defined in

ui/hooks/src/use-posts.ts:255


useInfinitePostsByTag

useInfinitePostsByTag(tagName, limit, offset?): UseInfiniteQueryResult<{ nextIndex: string ; results: string[] ; total: number }, Error>

Hook to get posts that contain a specific tag

example useInfinitePostsByTag hook

const tagPostsQuery = useInfinitePostsByTag('awesometag', 15);

const postPages = React.useMemo(() => {
if (tagPostsQuery.data) {
return tagPostsQuery.data.pages;
}
return [];
}, [tagPostsQuery.data]);

// load more posts
const handleLoadMore = React.useCallback(() => {
if (!tagPostsQuery.isLoading && tagPostsQuery.hasNextPage && loginState?.fromCache) {
tagPostsQuery.fetchNextPage();
}
}, [tagPostsQuery, loginState?.fromCache]);

Parameters

NameType
tagNamestring
limitnumber
offset?string

Returns

UseInfiniteQueryResult<{ nextIndex: string ; results: string[] ; total: number }, Error>

Defined in

ui/hooks/src/use-posts.ts:202


useInjectedProvider

useInjectedProvider(): UseQueryResult<{ details: { iconType: string = ''; subtitleLabel: string = ''; titleLabel: string = '' } ; name: INJECTED_PROVIDERS = INJECTED_PROVIDERS.NOT_DETECTED }, Error>

A hook to get injected provider from the SDK

example useInjectedProvider hook

const injectedProviderQuery = useInjectedProvider('selectedProvider');

const injectedProvider = React.useMemo(
() => injectedProviderQuery.data,
[injectedProviderQuery.data],
);

Returns

UseQueryResult<{ details: { iconType: string = ''; subtitleLabel: string = ''; titleLabel: string = '' } ; name: INJECTED_PROVIDERS = INJECTED_PROVIDERS.NOT_DETECTED }, Error>

Defined in

ui/hooks/src/use-injected-provider.ts:54


useInstallApp

useInstallApp(): UseMutationResult<string[], unknown, { id?: string ; name?: string }, unknown>

Hook to persist an installed app config to a user's profile

example useInstallApp hook

const installAppQuery = useInstallApp();

installAppQuery.mutate({ name: 'awesome integration', id: 'fhyuhjfhyrtl' });

Returns

UseMutationResult<string[], unknown, { id?: string ; name?: string }, unknown>

Defined in

ui/hooks/src/use-app-settings.ts:76


useInterests

useInterests(pubKey): UseQueryResult<Tag_Response[], Error>

Fetch the list of subscribed tags for a specific pub key

example useInterests hook

const interestsQuery = useInterests('some-pubkey');

const interests = interestsQuery.data;

Parameters

NameType
pubKeystring

Returns

UseQueryResult<Tag_Response[], Error>

Defined in

ui/hooks/src/use-profile.ts:289


useIsContactMultiple

useIsContactMultiple(mainProfile, checkIfContactsPubkeys): UseQueryResult<string[], Error>

Hook to check if a list of profiles are contacts for a specific user A contact relationship is defined by each of the two profiles following each other

example useIsContactMultiple hook

const isContactMultipleQuery = useIsContactMultiple('user-pubkey', ['some-pubkey-1', 'some-pubkey-2']);

const contactList = isContactMultipleQuery.data;

Parameters

NameType
mainProfilestring
checkIfContactsPubkeysstring[]

Returns

UseQueryResult<string[], Error>

Defined in

ui/hooks/src/use-follow.ts:181


useIsFollowingMultiple

useIsFollowingMultiple(followerPubKey, followingPubKeyArray): UseQueryResult<string[], Error>

Hook to check if a user is following other users

example useIsFollowingMultiple hook

const isFollowingMultipleQuery = useIsFollowingMultiple('user-pubkey', ['some-pubkey-1', 'some-pubkey-2']);

const followedProfiles = isFollowingMultipleQuery.data;

Parameters

NameType
followerPubKeystring
followingPubKeyArraystring[]

Returns

UseQueryResult<string[], Error>

Defined in

ui/hooks/src/use-follow.ts:63


useIsSubscribedToTag

useIsSubscribedToTag(tagName, loggedEthAddress): UseQueryResult<boolean, Error>

Hook to check if a user is subscribed to a tag

example useIsSubscribedToTag hook

const isSubscribedToTagQuery = useIsSubscribedToTag('awesome tag', 'logged-in-user-eth-address');

const isSubscribedToTag = isSubscribedToTagQuery.data;

Parameters

NameType
tagNamestring
loggedEthAddressstring

Returns

UseQueryResult<boolean, Error>

Defined in

ui/hooks/src/use-tag.ts:51


useIsValidToken

useIsValidToken(props): UseQueryResult<{ data: boolean }, Error>

Hook to validate invitation token

example useIsValidToken hook

const inviteTokenQuery = useIsValidToken({ inviteToken: '5b71c9dd7bdea84c9ff2564a', enabler: true });

const isValidToken = inviteTokenQuery.isSuccess;

Parameters

NameType
propsIUseIsValidTokenProps

Returns

UseQueryResult<{ data: boolean }, Error>

Defined in

ui/hooks/src/use-invite-token-validation.ts:30


useLegalDoc

useLegalDoc(docName): UseQueryResult<never, Error>

Hook to get legal docs stored on ipfs

example useLegalDoc hook

const termsOfUseDocQuery = useLegalDoc('TermsOfUse');

const termsOfUseDoc = termsOfUseDocQuery.data;

Parameters

NameType
docNameLEGAL_DOCS

Returns

UseQueryResult<never, Error>

Defined in

ui/hooks/src/use-legal.ts:24


useLogin

useLogin(onError?): UseMutationResult<CurrentUser & { isNewUser: boolean }, Error, { checkRegistered: boolean ; selectedProvider: EthProviders }, unknown>

Hook to sign in a user

Parameters

NameType
onError?(err: Error) => void

Returns

UseMutationResult<CurrentUser & { isNewUser: boolean }, Error, { checkRegistered: boolean ; selectedProvider: EthProviders }, unknown>

Defined in

ui/hooks/src/use-login.ts:137


useLogout

useLogout(): UseMutationResult<true, Error, void, unknown>

Hook to sign out the current user

example useLogout hook

const logoutMutation = useLogout();

// sample logout handler
const handleLogout = async () => {
await logoutMutation.mutateAsync();
// add other logic after logout
};

Returns

UseMutationResult<true, Error, void, unknown>

Defined in

ui/hooks/src/use-login.ts:348


useMarkAsRead

useMarkAsRead(): UseMutationResult<{ data: boolean }, unknown, string, { previousCheckNotifs: boolean ; previousNotifs: IMessage[] }>

Hook to mark a notification as read pass the messageId to the mutate function

example useMarkAsRead hook

const markAsReadQuery = useMarkAsRead();

markAsReadQuery.mutate('message id');

Returns

UseMutationResult<{ data: boolean }, unknown, string, { previousCheckNotifs: boolean ; previousNotifs: IMessage[] }>

Defined in

ui/hooks/src/use-notifications.ts:75


useMentionSearch

useMentionSearch(mention): UseQueryResult<(IProfileData | { _id: string ; avatar: { fallbackUrl: string ; url: string } ; coverImage: { fallbackUrl: string ; url: string } ; creationDate: string ; default: [DataProviderInput] ; description: string ; ethAddress: string ; name: string ; providers: [DataProviderInput] ; pubKey: string ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string })[], Error>

Hook to search for profiles

example useMentionSearch hook

const mentionQuery = useMentionSearch('awesomemention');

const mentions = mentionQuery.data;

Parameters

NameType
mentionstring

Returns

UseQueryResult<(IProfileData | { _id: string ; avatar: { fallbackUrl: string ; url: string } ; coverImage: { fallbackUrl: string ; url: string } ; creationDate: string ; default: [DataProviderInput] ; description: string ; ethAddress: string ; name: string ; providers: [DataProviderInput] ; pubKey: string ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string })[], Error>

Defined in

ui/hooks/src/use-mentions.ts:32


useModeration

useModeration(): UseMutationResult<number, Error, UseModerationParam, unknown>

Hook for creating a moderation decision

example useModeration hook

const moderateMutation = useModeration();

moderateMutation.mutate({ dataToSign: { explanation: 'no violations detected', ... }, contentId: 'some-content-id', contentType: 'item type', url: 'https://apiendpoint', isPending: true });

Returns

UseMutationResult<number, Error, UseModerationParam, unknown>

Defined in

ui/hooks/src/use-moderation.ts:78


useMutationListener

useMutationListener<TVars>(mutationKey): Mutation<unknown, unknown, TVars, unknown>

Hook to detect changes to a mutation

example useMutationListener hook

const sampleMutation = useMutationListener('mutation key');

const variables = sampleMutation.state.variables;

Type parameters

Name
TVars

Parameters

NameType
mutationKeyMutationKey

Returns

Mutation<unknown, unknown, TVars, unknown>

Mutation | undefined

Defined in

ui/hooks/src/use-query-listener.ts:21


useNetworkState

useNetworkState(enabler?): UseQueryResult<{ networkNotSupported: boolean = true }, unknown>

Hook to check if the web3 provider is set to function on the Rinkeby test network

example useNetworkState hook

const networkStateQuery = useNetworkState(true);

const networkNotSupported = networkStateQuery.data.networkNotSupported;

Parameters

NameType
enabler?boolean

Returns

UseQueryResult<{ networkNotSupported: boolean = true }, unknown>

networkNotSupported: true if web3 provider is not on the specified network

Defined in

ui/hooks/src/use-network-state.ts:29


usePlaformHealthCheck

usePlaformHealthCheck(): UseQueryResult<{ statusCode: number = response.status; success: boolean = response.ok }, Error>

Returns

UseQueryResult<{ statusCode: number = response.status; success: boolean = response.ok }, Error>

Defined in

ui/hooks/src/use-health-check.ts:13


usePost

usePost(__namedParameters): UseQueryResult<{ _id: string ; author: { _id: string ; avatar: string ; contentId: string ; coverImage: string ; creationDate: string ; default: [DataProviderInput] ; delisted: boolean ; description: string ; ethAddress: string ; moderated: boolean ; name: string ; providers: [DataProviderInput] ; pubKey: string ; reason: string ; reported: boolean ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string } ; content: [DataProviderInput] ; contentId: string ; creationDate: string ; delisted: boolean ; mentions: [string] ; moderated: boolean ; quotedBy: [string] ; quotedByAuthors: [UserProfile_Response] ; quotes: [Post_Response] ; reason: string ; reported: boolean ; tags: [string] ; title: string ; totalComments: string ; type: PostType ; updatedAt: string }, Error>

Hook to get data for a specific post

example usePost hook

const postQuery = usePost('some-post-id', 'logged-user-pubkey', true);

const entryData = React.useMemo(() => {
if (postQuery.data) {
// mapEntry is a utility function that transforms the comment/post data into required format.
return mapEntry(postQuery.data);
}
return undefined;
}, [postQuery.data]);

Parameters

NameType
__namedParametersusePostParam

Returns

UseQueryResult<{ _id: string ; author: { _id: string ; avatar: string ; contentId: string ; coverImage: string ; creationDate: string ; default: [DataProviderInput] ; delisted: boolean ; description: string ; ethAddress: string ; moderated: boolean ; name: string ; providers: [DataProviderInput] ; pubKey: string ; reason: string ; reported: boolean ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string } ; content: [DataProviderInput] ; contentId: string ; creationDate: string ; delisted: boolean ; mentions: [string] ; moderated: boolean ; quotedBy: [string] ; quotedByAuthors: [UserProfile_Response] ; quotes: [Post_Response] ; reason: string ; reported: boolean ; tags: [string] ; title: string ; totalComments: string ; type: PostType ; updatedAt: string }, Error>

Defined in

ui/hooks/src/use-posts.ts:309


usePosts

usePosts(__namedParameters): UseQueryResult<{ _id: string ; author: { _id: string ; avatar: string ; contentId: string ; coverImage: string ; creationDate: string ; default: [DataProviderInput] ; delisted: boolean ; description: string ; ethAddress: string ; moderated: boolean ; name: string ; providers: [DataProviderInput] ; pubKey: string ; reason: string ; reported: boolean ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string } ; content: [DataProviderInput] ; contentId: string ; creationDate: string ; delisted: boolean ; mentions: [string] ; moderated: boolean ; quotedBy: [string] ; quotedByAuthors: [UserProfile_Response] ; quotes: [Post_Response] ; reason: string ; reported: boolean ; tags: [string] ; title: string ; totalComments: string ; type: PostType ; updatedAt: string }, Error>[]

Hook to get an array of post data

example usePosts hook

const postQueries = usePost({ postIds: ['some-post-id', 'some-other-post-id'], loggedUser: 'logged-user-pubkey', enabler: true });

const entryData = postQueries.map(postQuery=>postQuery.data);

Parameters

NameType
__namedParametersusePostsParam

Returns

UseQueryResult<{ _id: string ; author: { _id: string ; avatar: string ; contentId: string ; coverImage: string ; creationDate: string ; default: [DataProviderInput] ; delisted: boolean ; description: string ; ethAddress: string ; moderated: boolean ; name: string ; providers: [DataProviderInput] ; pubKey: string ; reason: string ; reported: boolean ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string } ; content: [DataProviderInput] ; contentId: string ; creationDate: string ; delisted: boolean ; mentions: [string] ; moderated: boolean ; quotedBy: [string] ; quotedByAuthors: [UserProfile_Response] ; quotes: [Post_Response] ; reason: string ; reported: boolean ; tags: [string] ; title: string ; totalComments: string ; type: PostType ; updatedAt: string }, Error>[]

Defined in

ui/hooks/src/use-posts.ts:326


useProfileUpdate

useProfileUpdate(pubKey): UseMutationResult<void, unknown, UpdateProfileFormData, { currentProfile: IProfileData }>

Hook to update a user's profile data. Pass updated profile form data to the mutate function

example useProfileUpdate hook

const profileUpdateMutation = useProfileUpdate('logged-in-user-pubkey');

// call mutate on form submit
profileUpdateMutation.mutate({ profileData: { username: 'awesomeusername', ethAddress: 'logged-in-user-eth-address', ... }, changedFields: ['username', 'ethAddress'] });

// reset mutation, if needed, for example on modal close;
profileUpdateMutation.reset();

Parameters

NameType
pubKeystring

Returns

UseMutationResult<void, unknown, UpdateProfileFormData, { currentProfile: IProfileData }>

Defined in

ui/hooks/src/use-profile.ts:435


useQueryListener

useQueryListener<TData>(queryKey): QueryObserverResult<TData, unknown>

Hook to detect changes to a query

example useQueryListener hook

const sampleQuery = useQueryListener('query key');

const result = sampleQuery.data;

Type parameters

Name
TData

Parameters

NameType
queryKeyQueryKey

Returns

QueryObserverResult<TData, unknown>

Defined in

ui/hooks/src/use-query-listener.ts:47


useReasons

useReasons(): [string[], UseReasonsActions]

A hook to get predefined reasons from moderation API

example useReasons hook

const [reasons, reasonsActions] = useReasons();

// fetch reasons on mount
React.useEffect(() => {
reasonsActions.fetchReasons({ active: true });
}, []);

console.log(reasons);

Returns

[string[], UseReasonsActions]

Defined in

ui/hooks/src/use-reasons.ts:58


useReport

useReport(): UseMutationResult<number, Error, UseModerationParam, unknown>

Hook for reporting a post, reply or account

example useReport hook

const reportMutation = useReport();

reportMutation.mutate({ dataToSign: { explanation: 'no violations detected', ... }, contentId: 'some-content-id', contentType: 'item type', url: 'https://apiendpoint' });

Returns

UseMutationResult<number, Error, UseModerationParam, unknown>

Defined in

ui/hooks/src/use-moderation.ts:141


useRequiredNetworkName

useRequiredNetworkName(): UseQueryResult<string, unknown>

A hook to get required network name from the SDK

example useRequiredNetworkName hook

const requiredNetworkQuery = useRequiredNetworkName();

const requiredNetworkName = requiredNetworkQuery.data;

Returns

UseQueryResult<string, unknown>

Defined in

ui/hooks/src/use-injected-provider.ts:95


useSaveBookmark

useSaveBookmark(): UseMutationResult<string[], unknown, { entryId: string ; itemType: EntityTypes }, { prevBmks: { entryId: string ; type: EntityTypes }[] }>

Hook used to bookmark resources. Pass as payload, entryData containing the resource id and itemType to the mutate function.

example useSaveBookmark hook

const saveBookmarkQuery = useSaveBookmark();

saveBookmarkQuery.mutate({entryId: 'dbkjjouyahljfe', itemType: 'item type'});

Returns

UseMutationResult<string[], unknown, { entryId: string ; itemType: EntityTypes }, { prevBmks: { entryId: string ; type: EntityTypes }[] }>

Defined in

ui/hooks/src/use-bookmarks.ts:60


useSearch

useSearch(searchQuery, loggedUser?, enabler?): UseQueryResult<{ comments: IEntryData[] ; entries: IEntryData[] ; profiles: any[] ; tags: [] | [GlobalSearchResultTagItem] }, Error>

Hook for fetching search results for a specific query

example useSearch hook

const searchQuery = useSearch('search keyword', 'logged-in-user-pubkey');

const result = searchQuery.data;

Parameters

NameTypeDefault value
searchQuerystringundefined
loggedUser?stringundefined
enablerbooleantrue

Returns

UseQueryResult<{ comments: IEntryData[] ; entries: IEntryData[] ; profiles: any[] ; tags: [] | [GlobalSearchResultTagItem] }, Error>

search results for posts, comments, tags and profiles

Defined in

ui/hooks/src/use-search.ts:332


useSearchComments

useSearchComments(searchQuery, page, loggedUser?, enabler?, pageSize?): UseQueryResult<IEntryData[], Error>

Hook to search for comments

example useSearchComments hook

const searchCommentsQuery = useSearchComments('search keyword', 1, 'logged-in-user-pubkey');

const result = searchCommentsQuery.data;

Parameters

NameTypeDefault value
searchQuerystringundefined
pagenumberundefined
loggedUser?stringundefined
enablerbooleantrue
pageSizenumber5

Returns

UseQueryResult<IEntryData[], Error>

search results for comments

Defined in

ui/hooks/src/use-search.ts:187


useSearchPosts

useSearchPosts(searchQuery, page, loggedUser?, enabler?, pageSize?): UseQueryResult<IEntryData[], Error>

Hook to search for posts

example useSearchPosts hook

const searchPostsQuery = useSearchPosts('search keyword', 1, 'logged-in-user-pubkey');

const result = searchPostsQuery.data;

Parameters

NameTypeDefault value
searchQuerystringundefined
pagenumberundefined
loggedUser?stringundefined
enablerbooleantrue
pageSizenumber5

Returns

UseQueryResult<IEntryData[], Error>

search results for posts

Defined in

ui/hooks/src/use-search.ts:122


useSearchProfiles

useSearchProfiles(searchQuery, page, loggedUser?, enabler?, pageSize?): UseQueryResult<any[], Error>

Hook to search for profiles

example useSearchProfiles hook

const searchProfilesQuery = useSearchProfiles('search keyword', 1, 'logged-in-user-pubkey');

const result = searchProfilesQuery.data;

Parameters

NameTypeDefault value
searchQuerystringundefined
pagenumberundefined
loggedUser?stringundefined
enablerbooleantrue
pageSizenumber5

Returns

UseQueryResult<any[], Error>

search results for profiles, containing full profile data

Defined in

ui/hooks/src/use-search.ts:60


useSearchTags

useSearchTags(searchQuery, enabler?): UseQueryResult<SearchTagsResult_Response[], Error>

Hook to search for tags

example useSearchTags hook

const searchTagsQuery = useSearchTags('search keyword');

const result = searchTagsQuery.data;

Parameters

NameTypeDefault value
searchQuerystringundefined
enablerbooleantrue

Returns

UseQueryResult<SearchTagsResult_Response[], Error>

search results for posts, comments, tags and profiles

Defined in

ui/hooks/src/use-search.ts:225


useSignUp

useSignUp(provider, checkRegistered?, analyticsActions?): Object

Hook to sign up a user

example useSignUp hook

const { signUpState, ethAddress, fireRemainingMessages, error, fullSignUp, resetState } = useSignUp('selected provider', true);

Parameters

NameTypeDefault value
providerEthProvidersundefined
checkRegisteredbooleanfalse
analyticsActions?UseAnalyticsActionsundefined

Returns

Object

NameType
connectWalletUseMutationResult<{ data: string }, WalletTransactionError, void, unknown>
errorErrorTypes
ethAddressstring
fireRemainingMessages() => Promise<void>
fullSignUpUseMutationResult<{ data: CurrentUser & { isNewUser: boolean } }, WalletTransactionError, void, unknown>
resetState() => void
signUpStatenumber

Defined in

ui/hooks/src/use-login.ts:173


useTagSearch

useTagSearch(tagName): UseQueryResult<SearchTagsResult_Response[], Error>

Hook to search for tags

example useTagSearch hook

const tagSearchQuery = useTagSearch('awesometag');

const result = tagSearchQuery.data

Parameters

NameType
tagNamestring

Returns

UseQueryResult<SearchTagsResult_Response[], Error>

Defined in

ui/hooks/src/use-tag.ts:164


useTagSubscriptions

useTagSubscriptions(loggedEthAddress): UseQueryResult<string[], Error>

Hook to get a user's subscribed tags

example useTagSubscriptions hook

const subscribedTagsQuery = useTagSubscriptions('logged-in-user-eth-address');

const subscribedTags = subscribedTagsQuery.data;

Parameters

NameType
loggedEthAddressstring

Returns

UseQueryResult<string[], Error>

Defined in

ui/hooks/src/use-tag.ts:27


useToggleTagSubscription

useToggleTagSubscription(): UseMutationResult<{ data: { toggleInterestSub: boolean } }, unknown, string, { previousTagSubs: string[] }>

Hook to toggle a user's tag subscription. Pass the tagName to the mutate function

example useToggleTagSubscription hook

const toggleTagSubscriptionQuery = useToggleTagSubscription();

toggleTagSubscriptionQuery.mutate('awesome tag');

Returns

UseMutationResult<{ data: { toggleInterestSub: boolean } }, unknown, string, { previousTagSubs: string[] }>

Defined in

ui/hooks/src/use-tag.ts:69


useTrendingProfiles

useTrendingProfiles(): UseQueryResult<(IProfileData | { _id: string ; avatar: { fallbackUrl: string ; url: string } ; coverImage: { fallbackUrl: string ; url: string } ; creationDate: string ; default: [DataProviderInput] ; description: string ; ethAddress: string ; name: string ; providers: [DataProviderInput] ; pubKey: string ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string })[], Error>

Hook to fetch trending profiles

example useTrendingProfiles hook

const trendingProfilesQuery = useTrendingProfiles();

const trendingProfiles = trendingProfilesQuery.data;

Returns

UseQueryResult<(IProfileData | { _id: string ; avatar: { fallbackUrl: string ; url: string } ; coverImage: { fallbackUrl: string ; url: string } ; creationDate: string ; default: [DataProviderInput] ; description: string ; ethAddress: string ; name: string ; providers: [DataProviderInput] ; pubKey: string ; totalFollowers: number ; totalFollowing: number ; totalInterests: number ; totalPosts: string ; userName: string })[], Error>

Defined in

ui/hooks/src/use-trending.ts:57


useTrendingTags

useTrendingTags(): UseQueryResult<SearchTagsResult_Response[], Error>

Hook to fetch trending tags

example useTrendingTags hook

const trendingTagsQuery = useTrendingTags();

const trendingTags = trendingTagsQuery.data;

Returns

UseQueryResult<SearchTagsResult_Response[], Error>

Defined in

ui/hooks/src/use-trending.ts:27


useUnfollow

useUnfollow(): UseMutationResult<{ data: { unFollow: boolean } }, unknown, string, { previousFollowedProfiles: string[] }>

Hook to unfollow another user

example useUnfollow hook

const unfollowQuery = useUnfollow();

unfollowQuery.mutate('pubkey-of-user-to-unfollow');

Returns

UseMutationResult<{ data: { unFollow: boolean } }, unknown, string, { previousFollowedProfiles: string[] }>

Defined in

ui/hooks/src/use-follow.ts:358


useUninstallApp

useUninstallApp(): UseMutationResult<void, unknown, string, unknown>

Hook to uninstall an app

example useUninstallApp hook

const uninstallAppQuery = useUninstallApp();

uninstallAppQuery.mutate('awesome integration');

Returns

UseMutationResult<void, unknown, string, unknown>

Defined in

ui/hooks/src/use-app-settings.ts:107


useUpdateUsernameProvider

useUpdateUsernameProvider(pubKey?): UseMutationResult<void | { makeDefaultProvider: string }, Error, { provider: ProfileProviders ; userName: string }, { currentProfile: IProfileData }>

Hook to register a username for the user. Pass as payload, the username and provider details to the mutate function

example useUpdateUsernameProvider hook

const updateUsernameProviderQuery = useUpdateUsernameProvider('logged-in-user-pubkey');

// do something with the returned status of the query
React.useEffect(()=> {
if (updateUsernameProviderQuery.status === 'success') {
// perform an action
}
}, [updateUsernameProviderQuery])

Parameters

NameType
pubKey?string

Returns

UseMutationResult<void | { makeDefaultProvider: string }, Error, { provider: ProfileProviders ; userName: string }, { currentProfile: IProfileData }>

Defined in

ui/hooks/src/use-username.ts:77


useUsernameValidation

useUsernameValidation(username, enabler?): UseQueryResult<any, unknown>

Hook to check if a username is available

example useUsernameValidation hook

const usernameValidationQuery = useUsernameValidation('awesomeusername', true);

// do something with the returned status of the query
const querySuccess = usernameValidationQuery.isSuccess

Parameters

NameTypeDefault value
usernamestringundefined
enablerbooleantrue

Returns

UseQueryResult<any, unknown>

Defined in

ui/hooks/src/use-username.ts:225


validateType

validateType<T>(arg1, type): boolean

Type parameters

Name
T

Parameters

NameType
arg1T
typestring

Returns

boolean

Defined in

ui/hooks/src/utils/generic-utils.ts:1


withProviders

withProviders<T>(WrappedComponent): (props: any) => Element

Higher order component that wraps a component with all necessary providers

Type parameters

Name
T

Parameters

NameType
WrappedComponentComponentType<T>

Returns

fn

▸ (props): Element

Parameters
NameType
propsany
Returns

Element

NameType
displayNamestring

Defined in

ui/hooks/src/utils/provider-hoc.tsx:26