How to use the kitsu/config/api.Kitsu.find function in kitsu

To help you get started, we’ve selected a few kitsu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hummingbird-me / kitsu-mobile / src / utils / deeplink.js View on Github external
if (!response || !response.id || !isNumeric(response.number)) return;

  // Fetch the media first
  store.dispatch(toggleActivityIndicatorHOC(true));
  try {
    // Check if we need to fetch media based on slug
    if (!isNumeric(response.id)) {
      const results = await Kitsu.findAll(type, {
        filter: {
          slug: response.id,
        },
      });
      media = results && results.length > 0 && results[0];
    } else {
      // Just fetch media by the id
      media = await Kitsu.find(type, response.id);
    }
  } catch (e) {
    console.log(`Failed to fetch ${type} with id: ${response.id}`, e);
    media = null;
  }

  // Make sure we have a valid media object
  if (!media) {
    store.dispatch(toggleActivityIndicatorHOC(false));
    return;
  }

  // Fetch the unit
  try {
    const idKey = unitType === 'chapters' ? 'mangaId' : 'mediaId';
    const includes = type === 'anime' ? 'videos' : null;
github hummingbird-me / kitsu-mobile / src / screens / QuickUpdateScreen / QuickUpdate.js View on Github external
async updateEntryAtIndex(index) {
    if (index >= this.state.library.length || index < 0) return;
    // Fetch the entry
    // We need to do this because the new entry that we recieved may not have the `nextUnit` or `unit` set
    const library = [...this.state.library];

    let { filterMode } = this.state;
    filterMode = filterMode === 'all' ? undefined : filterMode;

    const fields = getRequestFields(filterMode);
    const record = await Kitsu.find('libraryEntries', library[index].id, {
      fields,
      include: this._requestIncludeFields,
    });

    library[index] = record;
    this.setState({ library }, () => {
      // Reset the feed
      if (this.carousel.currentIndex === index) {
        this.resetFeed(() => this.fetchEpisodeFeed());
      }
    });
  }
github hummingbird-me / kitsu-mobile / src / utils / notifications.js View on Github external
const fetchPostLike = async (postLikeId) => {
  if (!postLikeId) return null;

  try {
    const postLike = await Kitsu.find('postLikes', postLikeId, {
      include: 'post,post.user,post.targetUser,post.targetGroup,post.media,post.uploads,post.spoiledUnit',
    });
    return postLike;
  } catch (e) {
    console.log(e);
  }

  return null;
};
github hummingbird-me / kitsu-mobile / src / utils / notifications.js View on Github external
const fetchCommentLike = async (commentLikeId) => {
  if (!commentLikeId) return null;

  try {
    const commentLike = await Kitsu.find('commentLikes', commentLikeId, {
      include: 'comment,comment.user,comment.uploads,comment.parent,comment.parent.user,comment.parent.uploads,comment.post,comment.post.user,comment.post.targetUser,comment.post.targetGroup,comment.post.media,comment.post.uploads,comment.post.spoiledUnit',
    });
    return commentLike;
  } catch (e) {
    console.log(e);
  }

  return null;
};
github hummingbird-me / kitsu-mobile / src / utils / notifications.js View on Github external
const fetchFollower = async (followsId) => {
  if (!followsId) return null;
  try {
    const follow = await Kitsu.find('follows', followsId, {
      include: 'follower',
    });
    return follow && follow.follower;
  } catch (e) {
    console.log(e);
  }
  return null;
};
github hummingbird-me / kitsu-mobile / src / utils / notifications.js View on Github external
const fetchMediaReactions = async mediaId =>
  Kitsu.find('mediaReactions', mediaId, {
    include: 'user,anime,manga',
  });