How to use the contexts.useAppContext function in contexts

To help you get started, we’ve selected a few contexts 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 mikey1384 / twinkle-network / source / containers / App / index.js View on Github external
function App({ location, history }) {
  const {
    user: {
      actions: { onCloseSigninModal, onInitSession, onLogout }
    },
    requestHelpers: { auth, initSession, uploadFileOnChat }
  } = useAppContext();
  const { signinModalShown, username } = useMyState();
  const {
    actions: {
      onPostFileUploadStatus,
      onPostUploadComplete,
      onResetChat,
      onSendFirstDirectMessage,
      onUpdateClientToApiServerProgress
    }
  } = useChatContext();
  const {
    actions: { onInitContent }
  } = useContentContext();
  const {
    state: { updateDetail, updateNoticeShown }
  } = useNotiContext();
github mikey1384 / twinkle-network / source / containers / Management / Main.js View on Github external
export default function Main() {
  const { userId, managementLevel } = useMyState();
  const canManage = useMemo(() => managementLevel > 1, [managementLevel]);
  const {
    requestHelpers: { loadAccountTypes, loadModerators }
  } = useAppContext();
  const {
    state: { accountTypes, accountTypesLoaded, moderators, moderatorsLoaded },
    actions: { onLoadAccountTypes, onLoadModerators }
  } = useManagementContext();
  const [accountTypeModalTarget, setAccountTypeModalTarget] = useState(null);
  const [moderatorModalTarget, setModeratorModalTarget] = useState(null);
  const [addAccountTypeModalShown, setAddAccountTypeModalShown] = useState(
    false
  );
  const [addModeratorModalShown, setAddModeratorModalShown] = useState(false);
  useEffect(() => {
    initModerators();
    initAccountTypes();
    async function initModerators() {
      const data = await loadModerators();
      onLoadModerators(data);
github mikey1384 / twinkle-network / source / components / VideoPlayer.js View on Github external
style = {},
  uploader,
  videoCode,
  videoId
}) {
  const {
    requestHelpers: {
      addVideoView,
      checkXPEarned,
      fetchVideoThumbUrl,
      updateCurrentlyWatching,
      updateUserXP,
      updateTotalViewDuration,
      updateVideoXPEarned
    }
  } = useAppContext();
  const { profileTheme, twinkleXP, userId } = useMyState();
  const {
    state: {
      videos: { currentVideoSlot }
    },
    actions: { onEmptyCurrentVideoSlot, onFillCurrentVideoSlot }
  } = useExploreContext();
  const {
    state: { pageVisible }
  } = useViewContext();
  const {
    actions: {
      onChangeUserXP,
      onSetVideoImageUrl,
      onSetVideoStarted,
      onSetVideoXpEarned,
github mikey1384 / twinkle-network / source / containers / Chat / index.js View on Github external
export default function Chat({ onFileUpload }) {
  const {
    requestHelpers: {
      createNewChat,
      loadChatChannel,
      loadDMChannel,
      loadMoreChannels,
      loadMoreChatMessages,
      startNewDMChannel,
      updateChatLastRead
    }
  } = useAppContext();
  const { profilePicId, userId, username } = useMyState();
  const {
    state: {
      channelLoading,
      loaded,
      selectedChannelId,
      channelsObj,
      messages,
      channelLoadMoreButton,
      loadMoreMessages,
      recepientId,
      reconnecting,
      replyTarget,
      subject
    },
    actions: {
github mikey1384 / twinkle-network / source / containers / Chat / index.js View on Github external
export default function Chat({ onFileUpload }) {
  const {
    requestHelpers: {
      createNewChat,
      loadChatChannel,
      loadDMChannel,
      loadMoreChannels,
      loadMoreChatMessages,
      startNewDMChannel,
      updateChatLastRead
    }
  } = useAppContext();
  const { profilePicId, userId, username } = useMyState();
  const {
    state: {
      loaded,
      currentChannel,
      selectedChannelId,
      channels,
      messages,
      channelLoadMoreButton,
      loadMoreMessages,
      recepientId,
      subject
    },
    actions: {
      onClearNumUnreads,
      onCreateNewChannel,
github mikey1384 / twinkle-network / source / components / ContentPanel / TargetContent / Comment.js View on Github external
export default function Comment({
  comment,
  comment: { id, content, timeStamp },
  onDelete,
  onEditDone,
  profilePicId,
  userId,
  username
}) {
  const {
    requestHelpers: { deleteContent, editContent }
  } = useAppContext();
  const {
    actions: { onSetIsEditing }
  } = useContentContext();
  const { isEditing } = useContentState({
    contentType: 'comment',
    contentId: id
  });
  const [confirmModalShown, setConfirmModalShown] = useState(false);
  return (
github mikey1384 / twinkle-network / source / components / RewardStatus / Comment.js View on Github external
export default function Comment({
  maxRewardableStars,
  noMarginForEditButton,
  onEditDone = () => {},
  star
}) {
  const {
    requestHelpers: { editRewardComment }
  } = useAppContext();
  const {
    actions: { onSetIsEditing }
  } = useContentContext();
  const { authLevel, canEdit, userId } = useMyState();
  const { isEditing } = useContentState({
    contentType: 'reward',
    contentId: star.id
  });
  const userIsUploader = star.rewarderId === userId;
  const userCanEditThis = canEdit && authLevel > star.rewarderAuthLevel;
  const editButtonShown = userIsUploader || userCanEditThis;
  const editMenuItems = [];
  if (userIsUploader || canEdit) {
    editMenuItems.push({
      label: 'Edit',
      onClick: () =>
github mikey1384 / twinkle-network / source / components / Comments / Comment.js View on Github external
function Comment({
  comment,
  innerRef,
  isPreview,
  parent,
  rootContent = {},
  subject,
  comment: { replies = [], likes = [], stars = [], uploader }
}) {
  subject = subject || comment.targetObj?.subject || {};
  const history = useHistory();
  const {
    requestHelpers: { checkIfUserResponded, editContent }
  } = useAppContext();
  const { authLevel, canDelete, canEdit, canStar, userId } = useMyState();
  const {
    actions: {
      onChangeSpoilerStatus,
      onSetIsEditing,
      onSetXpRewardInterfaceShown
    }
  } = useContentContext();
  const { deleted, isEditing, xpRewardInterfaceShown } = useContentState({
    contentType: 'comment',
    contentId: comment.id
  });
  const subjectState = useContentState({
    contentType: 'subject',
    contentId: subject.id
  });
github mikey1384 / twinkle-network / source / containers / Home / index.js View on Github external
export default function Home({ history, location }) {
  const {
    requestHelpers: { uploadProfilePic }
  } = useAppContext();
  const {
    actions: { onUploadProfilePic }
  } = useContentContext();
  const { userId } = useMyState();
  const [alertModalShown, setAlertModalShown] = useState(false);
  const [imageEditModalShown, setImageEditModalShown] = useState(false);
  const [imageUri, setImageUri] = useState(null);
  const [processing, setProcessing] = useState(false);

  return (
    
      <div>
        <div>
           setAlertModalShown(true)}</div></div>
github mikey1384 / twinkle-network / source / containers / Home / index.js View on Github external
export default function Home({ history, location }) {
  const {
    user: {
      actions: { onUploadProfilePic }
    },
    requestHelpers: { uploadProfilePic }
  } = useAppContext();
  const [alertModalShown, setAlertModalShown] = useState(false);
  const [imageEditModalShown, setImageEditModalShown] = useState(false);
  const [imageUri, setImageUri] = useState(null);
  const [processing, setProcessing] = useState(false);

  return (
    
      <div>
        <div>
           setAlertModalShown(true)}
            onLoadImage={upload =&gt; {
              setImageEditModalShown(true);
              setImageUri(upload.target.result);
            }}</div></div>

contexts

ISC
Latest version published 8 years ago

Package Health Score

40 / 100
Full package analysis