Merge branch 'unstable' into feat/ses-899/user_profile_poll
commit
97cd21a77e
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
export type ScrollToLoadedReasons =
|
||||
| 'quote-or-search-result'
|
||||
| 'go-to-bottom'
|
||||
| 'unread-indicator'
|
||||
| 'load-more-top'
|
||||
| 'load-more-bottom';
|
||||
|
||||
export const ScrollToLoadedMessageContext = createContext(
|
||||
(_loadedMessageIdToScrollTo: string, _reason: ScrollToLoadedReasons) => {}
|
||||
);
|
||||
|
||||
export function useScrollToLoadedMessage() {
|
||||
return useContext(ScrollToLoadedMessageContext);
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
/**
|
||||
* When the message is rendered as part of the detailView (right panel) we disable onClick and make some other minor UI changes
|
||||
*/
|
||||
export const IsDetailMessageViewContext = createContext<boolean>(false);
|
||||
|
||||
export function useIsDetailMessageView() {
|
||||
return useContext(IsDetailMessageViewContext);
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
export const IsMessageVisibleContext = createContext(false);
|
||||
|
||||
export function useIsMessageVisible() {
|
||||
return useContext(IsMessageVisibleContext);
|
||||
}
|
@ -1,27 +1,41 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
|
||||
import { StateType } from '../reducer';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { OnionState } from '../ducks/onion';
|
||||
import { SectionType } from '../ducks/section';
|
||||
import { StateType } from '../reducer';
|
||||
|
||||
export const getOnionPaths = (state: StateType): OnionState => state.onionPaths;
|
||||
const getOnionPaths = (state: StateType): OnionState => state.onionPaths;
|
||||
|
||||
export const getOnionPathsCount = createSelector(
|
||||
const getOnionPathsCount = createSelector(
|
||||
getOnionPaths,
|
||||
(state: OnionState): SectionType => state.snodePaths.length
|
||||
);
|
||||
|
||||
export const getFirstOnionPath = createSelector(
|
||||
const getFirstOnionPath = createSelector(
|
||||
getOnionPaths,
|
||||
(state: OnionState): Array<{ ip: string }> => state.snodePaths?.[0] || []
|
||||
);
|
||||
|
||||
export const getFirstOnionPathLength = createSelector(
|
||||
const getFirstOnionPathLength = createSelector(
|
||||
getFirstOnionPath,
|
||||
(state: Array<{ ip: string }>): number => state.length || 0
|
||||
);
|
||||
|
||||
export const getIsOnline = createSelector(
|
||||
getOnionPaths,
|
||||
(state: OnionState): boolean => state.isOnline
|
||||
);
|
||||
const getIsOnline = createSelector(getOnionPaths, (state: OnionState): boolean => state.isOnline);
|
||||
|
||||
export const useOnionPathsCount = () => {
|
||||
return useSelector(getOnionPathsCount);
|
||||
};
|
||||
|
||||
export const useIsOnline = () => {
|
||||
return useSelector(getIsOnline);
|
||||
};
|
||||
|
||||
export const useFirstOnionPathLength = () => {
|
||||
return useSelector(getFirstOnionPathLength);
|
||||
};
|
||||
|
||||
export const useFirstOnionPath = () => {
|
||||
return useSelector(getFirstOnionPath);
|
||||
};
|
||||
|
Loading…
Reference in New Issue