flow
This commit is contained in:
parent
de0cbe1007
commit
9e66e3b1df
|
@ -4,10 +4,9 @@
|
|||
.about {
|
||||
// height: 100%;
|
||||
overflow: auto;
|
||||
max-height: calc(100% - 3em);
|
||||
max-height: 100%;
|
||||
padding: 1em;
|
||||
font-family: var(--thick-title-font-family);
|
||||
scrollbar-width: none;
|
||||
text-align: center;
|
||||
word-break: break-word;
|
||||
strong {
|
||||
|
@ -72,6 +71,7 @@
|
|||
font-family: var(--title-font-family);
|
||||
font-size: 2em;
|
||||
justify-content: space-around;
|
||||
margin: auto;
|
||||
max-width: 10em;
|
||||
padding: 0.5em;
|
||||
text-align: center;
|
||||
|
|
|
@ -13,44 +13,55 @@ import Home from 'components/home';
|
|||
import Left from 'components/left';
|
||||
import Right from 'components/right';
|
||||
|
||||
import useBreakpoints from 'hooks/useBreakpoints';
|
||||
|
||||
import pointerEvents from './pointer-events';
|
||||
|
||||
const App = () => {
|
||||
const ref = useRef(null);
|
||||
const isAnonymous = false && useSelector(isAnonymousSelector);
|
||||
const {desktop} = useBreakpoints();
|
||||
const isAnonymous = useSelector(isAnonymousSelector);
|
||||
return (
|
||||
<div
|
||||
className="app"
|
||||
ref={ref}
|
||||
>
|
||||
<Header
|
||||
onButton={(type) => {
|
||||
const max = Math.min(window.innerWidth - (4 * 16), 25 * 16);
|
||||
const offset = parseInt(ref.current.style.left || '0px', 10);
|
||||
const offset = parseInt(ref.current.style.left || '-400px', 10);
|
||||
if ('right' === type) {
|
||||
ref.current.style.left = offset > -(max / 2) ? `-${max}px` : '0';
|
||||
ref.current.style.left = offset > -(400 + (max / 2)) ? `-${400 + max}px` : '-400px';
|
||||
}
|
||||
else {
|
||||
ref.current.style.left = offset < (max / 2) ? `${max}px` : '0';
|
||||
ref.current.style.left = offset > -max ? '-400px' : `-${400 - max}px`;
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<div className="app__center">
|
||||
{/* {!isAnonymous && <Left />} */}
|
||||
<Switch>
|
||||
<Route
|
||||
component={Home}
|
||||
exact
|
||||
path="/"
|
||||
/>
|
||||
<Route
|
||||
component={About}
|
||||
path="/about"
|
||||
/>
|
||||
<Route
|
||||
component={Chat}
|
||||
path="/chat"
|
||||
/>
|
||||
</Switch>
|
||||
{/* {!isAnonymous && <Right />} */}
|
||||
<div
|
||||
className="app__center"
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
{...(desktop ? {} : isAnonymous || pointerEvents(desktop, ref))}
|
||||
ref={ref}
|
||||
>
|
||||
{!isAnonymous && <Left />}
|
||||
<div className="main">
|
||||
<Switch>
|
||||
<Route
|
||||
component={Home}
|
||||
exact
|
||||
path="/"
|
||||
/>
|
||||
<Route
|
||||
component={About}
|
||||
path="/about"
|
||||
/>
|
||||
<Route
|
||||
component={Chat}
|
||||
path="/chat"
|
||||
/>
|
||||
</Switch>
|
||||
</div>
|
||||
{!isAnonymous && <Right />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -1,16 +1,35 @@
|
|||
@import 'scss/breakpoints.scss';
|
||||
@import 'scss/colors.scss';
|
||||
|
||||
.app {
|
||||
background-image: url('~images/transpaper.png');
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
overflow-x: hidden;
|
||||
// overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.app__center {
|
||||
display: flex;
|
||||
max-height: calc(100% - 3em);
|
||||
height: calc(100% - 3em);
|
||||
position: relative;
|
||||
left: -25rem;
|
||||
&:not(.moving) {
|
||||
transition: 0.2s left;
|
||||
}
|
||||
width: calc(100% + 50rem);
|
||||
@include breakpoint(desktop) {
|
||||
left: 0 !important;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.main {
|
||||
flex-grow: 1;
|
||||
> * {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
.panes {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* eslint-disable no-param-reassign */
|
||||
export default function chatPointerEvents(desktop, ref) {
|
||||
export default function pointerEvents(desktop, ref) {
|
||||
let lastY;
|
||||
let origin;
|
||||
const abstract = {
|
||||
down: ({pageX, pageY}) => {
|
||||
if (ref.current) {
|
||||
const left = parseInt(ref.current.style.left || 0, 10);
|
||||
const left = parseInt(ref.current.style.left || -400, 10);
|
||||
const windowWidth = window.innerWidth;
|
||||
const max = Math.min(windowWidth - (4 * 16), 25 * 16);
|
||||
lastY = pageY;
|
||||
|
@ -14,9 +14,9 @@ export default function chatPointerEvents(desktop, ref) {
|
|||
point: pageX,
|
||||
};
|
||||
if (
|
||||
(left === -max && pageX < windowWidth - max)
|
||||
|| (left === max && pageX > max)) {
|
||||
ref.current.style.left = '0';
|
||||
(left === -(400 + max) && pageX < windowWidth - max)
|
||||
|| (left === 400 - max && pageX > max)) {
|
||||
ref.current.style.left = '-400px';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -32,20 +32,21 @@ export default function chatPointerEvents(desktop, ref) {
|
|||
}
|
||||
const snapped = Math.abs(offset) < 64 ? 0 : offset;
|
||||
const max = Math.min(window.innerWidth - (4 * 16), 25 * 16);
|
||||
ref.current.style.left = `${Math.max(-max, Math.min(max, snapped))}px`;
|
||||
ref.current.style.left = `${Math.min(0, Math.max(-(400 + max), snapped))}px`;
|
||||
}
|
||||
},
|
||||
up: () => {
|
||||
const left = parseInt(ref.current.style.left, 10);
|
||||
const max = Math.min(window.innerWidth - (4 * 16), 25 * 16);
|
||||
if (left >= max / 2) {
|
||||
ref.current.style.left = `${max}px`;
|
||||
|
||||
if (left >= (-400 + (max / 2))) {
|
||||
ref.current.style.left = `${400 - max}px`;
|
||||
}
|
||||
else if (left <= -max / 2) {
|
||||
ref.current.style.left = `${-max}px`;
|
||||
else if (left <= (-400 - (max / 2))) {
|
||||
ref.current.style.left = `${-(400 + max)}px`;
|
||||
}
|
||||
else {
|
||||
ref.current.style.left = '0';
|
||||
ref.current.style.left = '-400px';
|
||||
}
|
||||
origin = undefined;
|
||||
ref.current.classList.remove('moving');
|
|
@ -13,7 +13,7 @@ import useBreakpoints from 'hooks/useBreakpoints';
|
|||
import useChannel from 'hooks/useChannel';
|
||||
|
||||
import Center from './center';
|
||||
import pointerEvents from './pointer-events';
|
||||
// import pointerEvents from './pointer-events';
|
||||
|
||||
export default function Chat() {
|
||||
const dispatch = useDispatch();
|
||||
|
@ -55,8 +55,6 @@ export default function Chat() {
|
|||
return (
|
||||
<div
|
||||
className="chat"
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
{...(desktop ? {} : pointerEvents(desktop, ref))}
|
||||
ref={ref}
|
||||
>
|
||||
{/* <Center
|
||||
|
|
|
@ -11,18 +11,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
.flexed {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
width: 0;
|
||||
overflow: hidden;
|
||||
&:not(.center) {
|
||||
max-width: calc(100% - 4em);
|
||||
}
|
||||
@include breakpoint(desktop) {
|
||||
position: static;
|
||||
}
|
||||
}
|
||||
// .flexed {
|
||||
// position: absolute;
|
||||
// height: 100%;
|
||||
// width: 0;
|
||||
// overflow: hidden;
|
||||
// &:not(.center) {
|
||||
// max-width: calc(100% - 4em);
|
||||
// }
|
||||
// @include breakpoint(desktop) {
|
||||
// position: static;
|
||||
// }
|
||||
// }
|
||||
|
||||
.chat .open {
|
||||
background-image: url('~images/transpaper.png');
|
||||
|
|
|
@ -21,7 +21,7 @@ export default function Header(props) {
|
|||
const {onButton} = props;
|
||||
const channel = useChannel();
|
||||
const id = useSelector(idSelector);
|
||||
const isUserAnonymous = false && 0 === id;
|
||||
const isUserAnonymous = 0 === id;
|
||||
const pendingFriendship = useSelector(pendingFriendshipSelector)
|
||||
.filter(({addeeId}) => addeeId === id).length;
|
||||
const unreadChannel = useSelector(unreadChannelSelector);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
.home {
|
||||
margin: auto;
|
||||
max-height: calc(100% - 3em);
|
||||
max-height: 100%;
|
||||
// max-width: map-get($breakpoints, desktop);
|
||||
overflow: auto;
|
||||
}
|
||||
|
@ -32,6 +32,8 @@
|
|||
}
|
||||
|
||||
.home__bar {
|
||||
margin: auto;
|
||||
max-width: 20em;
|
||||
padding: 2em 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
flex-shrink: 0;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
transform: translateX(-100%);
|
||||
// transform: translateX(-100%);
|
||||
transition: width 0.2s;
|
||||
width: 25em;
|
||||
width: 25rem;
|
||||
@include breakpoint(desktop) {
|
||||
transform: none;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ export default function ChatRight() {
|
|||
<div className="right__links">
|
||||
<Link className="right__link" to="/about">About</Link>
|
||||
<span className="right__linksBullet">•</span>
|
||||
<Link className="right__link" to="/auth/logout">Log out</Link>
|
||||
<a href="/auth/logout">Log out</a>
|
||||
</div>
|
||||
{0 === activeIndex && channelUsers.length > 0 && <Users />}
|
||||
{1 === activeIndex && blockedIds.length > 0 && <Blocked ids={blockedIds} />}
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
.right {
|
||||
background-color: #373737;
|
||||
flex-shrink: 0;
|
||||
right: 0;
|
||||
transform: translateX(100%);
|
||||
// height: 100%;
|
||||
// right: 0;
|
||||
// transform: translateX(100%);
|
||||
transition: 0.2s width;
|
||||
@include breakpoint(desktop) {
|
||||
transform: none;
|
||||
|
@ -13,7 +14,7 @@
|
|||
}
|
||||
|
||||
.right.open {
|
||||
width: 25em;
|
||||
width: 25rem;
|
||||
}
|
||||
|
||||
.right__buttons {
|
||||
|
|
127
app/yarn.lock
127
app/yarn.lock
|
@ -921,8 +921,8 @@
|
|||
|
||||
"@latus/core@1.0.0", "@latus/core@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fcore/-/core-1.0.0.tgz#01f0121bb91579b8bd1bdadff8dabf8673f44a88"
|
||||
integrity sha512-NK7DuYoVIXmFEjazKi44vW335DFcE1pr62DXf9+9bZ8iyexptFBdfX/5sYFMGaeJlN/opFp0qFx94VPdVCsChg==
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fcore/-/core-1.0.0.tgz#d367fd4c96ad8cf1dff7031c509f104c1c5491da"
|
||||
integrity sha512-M2zoI45c+pTVyS9Ea/qARswwhnzdhK1pvRLgG4W9V3/HJhsFtG+XsRVKCltXH5CVIodaVLGI0qTScjbIQkBNPw==
|
||||
dependencies:
|
||||
debug "4.3.1"
|
||||
js-yaml "3.14.0"
|
||||
|
@ -930,8 +930,8 @@
|
|||
|
||||
"@latus/db@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fdb/-/db-1.0.0.tgz#67ad19b87e2881b3b948712a2fab8025071c7941"
|
||||
integrity sha512-WxYmYVfAej+WDnxUKyl+zNNlwEJJUXJpzfbYFkqtpkn7Is/cADwan9ua0FUujOLkfA8sRllEPRxTcn+ZnEydTA==
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fdb/-/db-1.0.0.tgz#1ee299b0689f22186ea709df69c69b0d39ab2b9b"
|
||||
integrity sha512-Ir7Q8VGCiSsDNSbfnvCzmfUGH6PfnMIyCoNfylj8+PmHEKqdjIYJ7W1MF2h3WP/1oNDiegoO+21PnGJd7bL2rA==
|
||||
dependencies:
|
||||
"@latus/core" "^1.0.0"
|
||||
debug "4.3.1"
|
||||
|
@ -941,8 +941,8 @@
|
|||
|
||||
"@latus/governor@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fgovernor/-/governor-1.0.0.tgz#7cbcc3ae04aaf7d26e78a94dd3306a3dc16b18a1"
|
||||
integrity sha512-gZB30h/HgvyS0PWtAJaW4OpnlRJUpMcyDzDnCmuWi+zdr8EWYq7cwUOpWhD4TKIIviFYuEwvhaRzmg3c8rQM8A==
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fgovernor/-/governor-1.0.0.tgz#be19783cba2e84a900a0168c51ff0a55f4a78b3b"
|
||||
integrity sha512-yH4f59TIT0yRPyKRclKXMOt0PpkHVyjHjYnMfiOUqYuX90pq264JSDn8bF4mv0J7hI6/CmgLLiOsYOvSN5w3JA==
|
||||
dependencies:
|
||||
"@latus/redis" "^1.0.0"
|
||||
"@latus/socket" "^1.0.0"
|
||||
|
@ -951,8 +951,8 @@
|
|||
|
||||
"@latus/http@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fhttp/-/http-1.0.0.tgz#ed08c6c85112ce4d66a652f5810a220a66a0a1b3"
|
||||
integrity sha512-1qSwE1vX0bg4nFJFrPjFZT1PepDuDT9RIZRt3SzpvT5OsmE+6LjxtqTbMsgpljnHuhwjWPzDnR6An7sUhR6A0A==
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fhttp/-/http-1.0.0.tgz#1e582cdc3040308bde4b30341e98c37273c6904f"
|
||||
integrity sha512-VDFbQXUj5HCvtDoIHywPZgfLcXcB6ML12zWlxYNVeo2nYTxADdWXxBVJuzA2+VFqZiDtILeFFfrI7KV10OKgBg==
|
||||
dependencies:
|
||||
"@latus/core" "1.0.0"
|
||||
"@neutrinojs/web" "^9.1.0"
|
||||
|
@ -968,8 +968,8 @@
|
|||
|
||||
"@latus/react@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2freact/-/react-1.0.0.tgz#965c0ca868f4fd83195e26f99bfd82d03ec8f361"
|
||||
integrity sha512-ffWESmTinN2vxfxkpznysF+uU1rWSbB3AtvS2XWLzPg/X3A5yRql4J2602SHIy/xXhLWzHueDZ5pzxDiGe0S8g==
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2freact/-/react-1.0.0.tgz#4074b37bf9f149689c93e8a6a41f2f3fe8545894"
|
||||
integrity sha512-vktm5f4DU1/ffTBijkq8ZlPp2S1aahlcyBu6H66rdW3K9uTSGLke+a4pd4YWJ54aIJFsNNaL1mAJYbu8laeCuQ==
|
||||
dependencies:
|
||||
"@neutrinojs/react" "^9.4.0"
|
||||
debug "4.3.1"
|
||||
|
@ -982,27 +982,27 @@
|
|||
|
||||
"@latus/redis@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fredis/-/redis-1.0.0.tgz#b54c176a02481f8f43ea383d2df665c1aa365885"
|
||||
integrity sha512-HSQPI57K7RZMGfehsMSRvvAY+paJ4gxeRNpcQhMhLmWH8ShartGSR7/vPEJjpdvGcSgucYb97KM913oAgDDG5g==
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fredis/-/redis-1.0.0.tgz#f69b03746486bca8b232f7764859c2f95e4aaaa0"
|
||||
integrity sha512-rtnPZG9xjEfdke08SgrrIg+cgqvc3izKhSJZMNZBhWH1ihTn6WKt4ZGMVovSNKGUlI80z+TB/ExiLpu81r8vig==
|
||||
dependencies:
|
||||
connect-redis "^5.0.0"
|
||||
debug "4.3.1"
|
||||
express-session "^1.17.1"
|
||||
mkdirp "^1.0.4"
|
||||
redis "^3.0.2"
|
||||
socket.io-redis "^6.0.1"
|
||||
socket.io-redis "5.3.0"
|
||||
|
||||
"@latus/repl@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2frepl/-/repl-1.0.0.tgz#3a1c84af5980e4b6ac863eee3cd8ea467aade742"
|
||||
integrity sha512-cpi0hCYq2MNQ3gbxt7hbHuxeBbaeZItr5LS/EuVv+dUt/cZ3poJekxX5VGvT1hhfAfb03vCku9X1mAhhd0VVyQ==
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2frepl/-/repl-1.0.0.tgz#493b075991d8370cf9592a4f75bcd4db1cf259e7"
|
||||
integrity sha512-hfqcepLf7RKgprE/gK0klOkgZk8xFb5TNS5dZX1iBlKjxO6ynMzxLdmSmGu50BnaF2FgWgAWSUZQbpxEWcdUgg==
|
||||
dependencies:
|
||||
debug "4.3.1"
|
||||
|
||||
"@latus/socket@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fsocket/-/socket-1.0.0.tgz#75e95bb522fbec52d94d72ae4a33dab75e47cb5e"
|
||||
integrity sha512-UGmRxwkL1ZKT3oZUnQlsJSJOKAlJeaxdVS0VDTo1HBMneYP0HwoMeh7cJ7wWzV34Uj7/FhG6PWwwTz3wFz/c3A==
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fsocket/-/socket-1.0.0.tgz#77e5d405ee144dfa8f4e48e8f64611a50d2aa033"
|
||||
integrity sha512-WIWQoNRmUuWG4cqw/mRcA5MgIhK+Zj4eKtqPHREE0RH5el8uQOHYxozV0kT6lVkm+iZLYcRW4YoRndfANocb4g==
|
||||
dependencies:
|
||||
"@latus/core" "^1.0.0"
|
||||
"@latus/http" "^1.0.0"
|
||||
|
@ -1015,8 +1015,8 @@
|
|||
|
||||
"@latus/user@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fuser/-/user-1.0.0.tgz#5eb8f3af070dbea295b3bcb35c136c4dfee7097a"
|
||||
integrity sha512-O1EY81t6HIjCzhaiLwJ6D9dDWTFHZhBasuwZUxcb8d85BcCGoFRPjL39Jflm3LO150QT9rjJxAmIgKWyJIHiLA==
|
||||
resolved "https://npm.i12e.cha0s.io/@latus%2fuser/-/user-1.0.0.tgz#0c53a8300eb8a61b006bb7812c9eabf5649c0c71"
|
||||
integrity sha512-lXV8Il1gspqmj3H9y23osW2fcHnv/QhJWKTui7ZXQV9b8RI5p8pQhiW6wDNJ38A53j1fjsUEq8HclJIczAl8Hg==
|
||||
dependencies:
|
||||
"@latus/db" "^1.0.0"
|
||||
"@latus/socket" "^1.0.0"
|
||||
|
@ -1194,8 +1194,8 @@
|
|||
|
||||
"@reddichat/chat@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@reddichat%2fchat/-/chat-1.0.0.tgz#007e210ef28021c4c5846f7d686ba83ad875f248"
|
||||
integrity sha512-WR32qj/o/TwFcGiqFxIGzxwjRTfReTUneu5aPkGwxVomUg/fjUhxhfEVgtEFR/FMPooF6eB+yr2YlCneHHvtcg==
|
||||
resolved "https://npm.i12e.cha0s.io/@reddichat%2fchat/-/chat-1.0.0.tgz#0a8c639d8dfcdba6a3c29a0380f0851f219972a0"
|
||||
integrity sha512-baB8+iXfJqY7Xfk9wS0OfQhEWsXocdz8XLEG1JEKCi9zIS6GwDOFjx/eMVvNm3lbFo0G7kO5xxcdFjfLX6B8ZQ==
|
||||
dependencies:
|
||||
"@latus/core" "^1.0.0"
|
||||
"@latus/db" "^1.0.0"
|
||||
|
@ -1232,8 +1232,8 @@
|
|||
|
||||
"@reddichat/user@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/@reddichat%2fuser/-/user-1.0.0.tgz#1bdb0ddd155a53e028178e99b3b594f09b28aeda"
|
||||
integrity sha512-Xvzs3JTrfPbJI5RYfChB2f7CSizL8ACTJ7KTpKKG0qd7kDn5nScnvTpdlsVg71pLS5bTR9tdKPNCTxSZTPcp7w==
|
||||
resolved "https://npm.i12e.cha0s.io/@reddichat%2fuser/-/user-1.0.0.tgz#f9847b3e7763938bc288760167196bd2f872aec3"
|
||||
integrity sha512-c4cP3zGjNIPkOdZ0NbNEJ9dP4xzbTHxA8UnY5qmyvEGuFF2MDEs2hQeMsFfIyXFqViBDkSEgsAOc1QqQpnN4JQ==
|
||||
dependencies:
|
||||
"@latus/db" "^1.0.0"
|
||||
"@latus/socket" "^1.0.0"
|
||||
|
@ -1291,9 +1291,9 @@
|
|||
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
|
||||
|
||||
"@types/node@*":
|
||||
version "14.14.10"
|
||||
resolved "https://npm.i12e.cha0s.io/@types%2fnode/-/node-14.14.10.tgz#5958a82e41863cfc71f2307b3748e3491ba03785"
|
||||
integrity sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ==
|
||||
version "14.14.11"
|
||||
resolved "https://npm.i12e.cha0s.io/@types%2fnode/-/node-14.14.11.tgz#fc25a4248a5e8d0837019b1d170146d07334abe0"
|
||||
integrity sha512-BJ97wAUuU3NUiUCp44xzUFquQEvnk1wu7q4CMEUYKJWjdkr0YWYDsm4RFtAvxYsNjLsKcrFt6RvK8r+mnzMbEQ==
|
||||
|
||||
"@types/source-list-map@*":
|
||||
version "0.1.2"
|
||||
|
@ -3173,6 +3173,11 @@ dottie@^2.0.0:
|
|||
resolved "https://npm.i12e.cha0s.io/dottie/-/dottie-2.0.2.tgz#cc91c0726ce3a054ebf11c55fbc92a7f266dd154"
|
||||
integrity sha512-fmrwR04lsniq/uSr8yikThDTrM7epXHBAAjH9TbeH3rEA8tdCO7mRzB9hdmdGyJCxF8KERo9CITcm3kGuoyMhg==
|
||||
|
||||
double-ended-queue@^2.1.0-0:
|
||||
version "2.1.0-0"
|
||||
resolved "https://npm.i12e.cha0s.io/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz#103d3527fd31528f40188130c841efdd78264e5c"
|
||||
integrity sha1-ED01J/0xUo9AGIEwyEHv3XgmTlw=
|
||||
|
||||
duplexify@^3.4.2, duplexify@^3.6.0:
|
||||
version "3.7.1"
|
||||
resolved "https://npm.i12e.cha0s.io/duplexify/-/duplexify-3.7.1.tgz#2a4df5317f6ccfd91f86d6fd25d8d8a103b88309"
|
||||
|
@ -3197,9 +3202,9 @@ ee-first@1.1.1:
|
|||
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
|
||||
|
||||
electron-to-chromium@^1.3.612:
|
||||
version "1.3.619"
|
||||
resolved "https://npm.i12e.cha0s.io/electron-to-chromium/-/electron-to-chromium-1.3.619.tgz#4dc529ae802f5c9c31e7eea830144340539b62b4"
|
||||
integrity sha512-WFGatwtk7Fw0QcKCZzfGD72hvbcXV8kLY8aFuj0Ip0QRnOtyLYMsc+wXbSjb2w4lk1gcAeNU1/lQ20A+tvuypQ==
|
||||
version "1.3.620"
|
||||
resolved "https://npm.i12e.cha0s.io/electron-to-chromium/-/electron-to-chromium-1.3.620.tgz#c6f36a7e398acc9d7d12743a6f58d536fbc58700"
|
||||
integrity sha512-YbgWXUR2Mu+Fp6rm3GZ5YJdNo8SgZKLUTNSl2PNvdOcM8OIz07jRJnRkIaV9vdszFv9UUuGChh19w9qSuoLJgw==
|
||||
|
||||
elliptic@^6.5.3:
|
||||
version "6.5.3"
|
||||
|
@ -4744,9 +4749,9 @@ inherits@2.0.3:
|
|||
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
|
||||
|
||||
ini@^1.3.4, ini@^1.3.5, ini@~1.3.0:
|
||||
version "1.3.5"
|
||||
resolved "https://npm.i12e.cha0s.io/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
|
||||
integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==
|
||||
version "1.3.6"
|
||||
resolved "https://npm.i12e.cha0s.io/ini/-/ini-1.3.6.tgz#f1c46a2a93a253e7b3905115e74d527cd23061a1"
|
||||
integrity sha512-IZUoxEjNjubzrmvzZU4lKP7OnYmX72XRl3sqkfJhBKweKi5rnGi5+IUdlj/H1M+Ip5JQ1WzaDMOBRY90Ajc5jg==
|
||||
|
||||
inquirer@^7.0.0:
|
||||
version "7.3.3"
|
||||
|
@ -5761,11 +5766,16 @@ ms@2.1.1:
|
|||
resolved "https://npm.i12e.cha0s.io/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
|
||||
integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
|
||||
|
||||
ms@2.1.2, ms@^2.1.1:
|
||||
ms@2.1.2:
|
||||
version "2.1.2"
|
||||
resolved "https://npm.i12e.cha0s.io/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
|
||||
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
|
||||
|
||||
ms@^2.1.1:
|
||||
version "2.1.3"
|
||||
resolved "https://npm.i12e.cha0s.io/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
|
||||
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
|
||||
|
||||
multicast-dns-service-types@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://npm.i12e.cha0s.io/multicast-dns-service-types/-/multicast-dns-service-types-1.1.0.tgz#899f11d9686e5e05cb91b35d5f0e63b773cfc901"
|
||||
|
@ -6031,10 +6041,10 @@ normalize-url@1.9.1:
|
|||
query-string "^4.1.0"
|
||||
sort-keys "^1.0.0"
|
||||
|
||||
notepack.io@~2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://npm.i12e.cha0s.io/notepack.io/-/notepack.io-2.2.0.tgz#d7ea71d1cb90094f88c6f3c8d84277c2d0cd101c"
|
||||
integrity sha512-9b5w3t5VSH6ZPosoYnyDONnUTF8o0UkBw7JLA6eBlYJWyGT1Q3vQa8Hmuj1/X6RYvHjjygBDgw6fJhe0JEojfw==
|
||||
notepack.io@~2.1.2:
|
||||
version "2.1.3"
|
||||
resolved "https://npm.i12e.cha0s.io/notepack.io/-/notepack.io-2.1.3.tgz#cc904045c751b1a27b2dcfd838d81d0bf3ced923"
|
||||
integrity sha512-AgSt+cP5XMooho1Ppn8NB3FFaVWefV+qZoZncYTUSch2GAEwlYLcIIbT5YVkMlFeNHnfwOvc4HDlbvrB5BRxXA==
|
||||
|
||||
npm-bundled@^1.0.1:
|
||||
version "1.1.1"
|
||||
|
@ -7151,7 +7161,7 @@ redent@^1.0.0:
|
|||
indent-string "^2.1.0"
|
||||
strip-indent "^1.0.1"
|
||||
|
||||
redis-commands@^1.5.0:
|
||||
redis-commands@^1.2.0, redis-commands@^1.5.0:
|
||||
version "1.6.0"
|
||||
resolved "https://npm.i12e.cha0s.io/redis-commands/-/redis-commands-1.6.0.tgz#36d4ca42ae9ed29815cdb30ad9f97982eba1ce23"
|
||||
integrity sha512-2jnZ0IkjZxvguITjFTrGiLyzQZcTvaw8DAaCXxZq/dsHXz7KfMQ3OUJy7Tz9vnRtZRVz6VRCPDvruvU8Ts44wQ==
|
||||
|
@ -7161,6 +7171,11 @@ redis-errors@^1.0.0, redis-errors@^1.2.0:
|
|||
resolved "https://npm.i12e.cha0s.io/redis-errors/-/redis-errors-1.2.0.tgz#eb62d2adb15e4eaf4610c04afe1529384250abad"
|
||||
integrity sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=
|
||||
|
||||
redis-parser@^2.6.0:
|
||||
version "2.6.0"
|
||||
resolved "https://npm.i12e.cha0s.io/redis-parser/-/redis-parser-2.6.0.tgz#52ed09dacac108f1a631c07e9b69941e7a19504b"
|
||||
integrity sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs=
|
||||
|
||||
redis-parser@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://npm.i12e.cha0s.io/redis-parser/-/redis-parser-3.0.0.tgz#b66d828cdcafe6b4b8a428a7def4c6bcac31c8b4"
|
||||
|
@ -7168,7 +7183,7 @@ redis-parser@^3.0.0:
|
|||
dependencies:
|
||||
redis-errors "^1.0.0"
|
||||
|
||||
redis@^3.0.0, redis@^3.0.2:
|
||||
redis@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://npm.i12e.cha0s.io/redis/-/redis-3.0.2.tgz#bd47067b8a4a3e6a2e556e57f71cc82c7360150a"
|
||||
integrity sha512-PNhLCrjU6vKVuMOyFu7oSP296mwBkcE6lrAjruBYG5LgdSqtRBoVQIylrMyVZD/lkF24RSNNatzvYag6HRBHjQ==
|
||||
|
@ -7178,6 +7193,15 @@ redis@^3.0.0, redis@^3.0.2:
|
|||
redis-errors "^1.2.0"
|
||||
redis-parser "^3.0.0"
|
||||
|
||||
redis@~2.8.0:
|
||||
version "2.8.0"
|
||||
resolved "https://npm.i12e.cha0s.io/redis/-/redis-2.8.0.tgz#202288e3f58c49f6079d97af7a10e1303ae14b02"
|
||||
integrity sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==
|
||||
dependencies:
|
||||
double-ended-queue "^2.1.0-0"
|
||||
redis-commands "^1.2.0"
|
||||
redis-parser "^2.6.0"
|
||||
|
||||
redux-thunk@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://npm.i12e.cha0s.io/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622"
|
||||
|
@ -7802,11 +7826,6 @@ socket.io-adapter@~1.1.0:
|
|||
resolved "https://npm.i12e.cha0s.io/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz#ab3f0d6f66b8fc7fca3959ab5991f82221789be9"
|
||||
integrity sha512-WzZRUj1kUjrTIrUKpZLEzFZ1OLj5FwLlAFQs9kuZJzJi5DKdU7FsWc36SNmA8iDOtwBQyT8FkrriRM8vXLYz8g==
|
||||
|
||||
socket.io-adapter@~2.0.0:
|
||||
version "2.0.3"
|
||||
resolved "https://npm.i12e.cha0s.io/socket.io-adapter/-/socket.io-adapter-2.0.3.tgz#372b7cde7a535fc4f4f0d5ac7f73952a3062d438"
|
||||
integrity sha512-2wo4EXgxOGSFueqvHAdnmi5JLZzWqMArjuP4nqC26AtLh5PoCPsaRbRdah2xhcwTAMooZfjYiNVNkkmmSMaxOQ==
|
||||
|
||||
socket.io-client@2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://npm.i12e.cha0s.io/socket.io-client/-/socket.io-client-2.3.0.tgz#14d5ba2e00b9bcd145ae443ab96b3f86cbcc1bb4"
|
||||
|
@ -7845,15 +7864,15 @@ socket.io-parser@~3.4.0:
|
|||
debug "~4.1.0"
|
||||
isarray "2.0.1"
|
||||
|
||||
socket.io-redis@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://npm.i12e.cha0s.io/socket.io-redis/-/socket.io-redis-6.0.1.tgz#0d6c82bd6e0dcbb0d70dcbc57f0c3269e6e53594"
|
||||
integrity sha512-RvxAhVSsDQJfDUEXUER9MvsE99XZurXkAVORjym1FTReqWlvmPVjyAnrpLlH3RxvPFdFa9sN4kmaTtyzjOtRRA==
|
||||
socket.io-redis@5.3.0:
|
||||
version "5.3.0"
|
||||
resolved "https://npm.i12e.cha0s.io/socket.io-redis/-/socket.io-redis-5.3.0.tgz#d01716d2813c25b76918cd704e1cf540b2f3985a"
|
||||
integrity sha512-w2EqyGdw3oXzd1MY4sVIg2rYVooDI5sSwel8DOt38sTgaJuuXQSC847x38FvLSn2Rt6MAcdLhiNw/FqjzeC4RQ==
|
||||
dependencies:
|
||||
debug "~4.1.0"
|
||||
notepack.io "~2.2.0"
|
||||
redis "^3.0.0"
|
||||
socket.io-adapter "~2.0.0"
|
||||
notepack.io "~2.1.2"
|
||||
redis "~2.8.0"
|
||||
socket.io-adapter "~1.1.0"
|
||||
uid2 "0.0.3"
|
||||
|
||||
socket.io@2.3.0:
|
||||
|
@ -8726,9 +8745,9 @@ uuid@^3.3.2, uuid@^3.4.0:
|
|||
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
|
||||
|
||||
uuid@^8.1.0, uuid@^8.3.1:
|
||||
version "8.3.1"
|
||||
resolved "https://npm.i12e.cha0s.io/uuid/-/uuid-8.3.1.tgz#2ba2e6ca000da60fce5a196954ab241131e05a31"
|
||||
integrity sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==
|
||||
version "8.3.2"
|
||||
resolved "https://npm.i12e.cha0s.io/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||
|
||||
v8-compile-cache@^2.0.3, v8-compile-cache@^2.1.1:
|
||||
version "2.2.0"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import {parseChatChannel} from '@reddichat/core';
|
||||
|
||||
import Join from './packets/join.server';
|
||||
import Leave from './packets/leave.server';
|
||||
import Message from './packets/message.server';
|
||||
|
@ -9,13 +11,17 @@ export * from './state';
|
|||
|
||||
export default {
|
||||
hooks: {
|
||||
'@latus/http/request': () => (req, res, next) => {
|
||||
req.channel = parseChatChannel(req.url);
|
||||
next();
|
||||
},
|
||||
'@latus/socket/packets': (latus) => ({
|
||||
Join: Join(latus),
|
||||
Leave: Leave(latus),
|
||||
Message: Message(latus),
|
||||
}),
|
||||
'@latus/socket/connect': async (socket) => {
|
||||
const channels = await channelsToHydrate(socket.req);
|
||||
'@latus/socket/connect': async (socket, latus) => {
|
||||
const channels = await channelsToHydrate(socket.req, latus);
|
||||
const joins = channels
|
||||
.filter(({type}) => 'r' === type)
|
||||
.map((channel) => joinChannel(channel, socket));
|
||||
|
|
|
@ -6,22 +6,15 @@ import {createClient, keys} from '@latus/redis';
|
|||
import {channelIsAnonymous, parseChannel, renderChannel} from '@reddichat/core';
|
||||
|
||||
export const channelUserCounts = async (req, channel) => {
|
||||
const clients = promisify(req.adapter.clients.bind(req.adapter));
|
||||
const rendered = renderChannel(channel);
|
||||
const socketKeys = await clients([rendered]);
|
||||
const customRequest = promisify(req.adapter.customRequest.bind(req.adapter));
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
const ids = await req.clients([renderChannel(channel)]);
|
||||
if (0 === ids.length) {
|
||||
return [];
|
||||
}
|
||||
const replies = channelIsAnonymous(channel)
|
||||
? (
|
||||
socketKeys.length > 0
|
||||
? [socketKeys.reduce((r, socketKey) => ({...r, [socketKey]: 0}), {})]
|
||||
: []
|
||||
)
|
||||
: await customRequest({type: 'socketUsers', payload: socketKeys});
|
||||
const socketUsers = replies.reduce((r, m) => ({...r, ...m}), {});
|
||||
return 0 === socketKeys.length
|
||||
? []
|
||||
: Object.values(socketUsers).reduce((r, uid) => ({...r, [uid]: 1 + (r[uid] || 0)}), {});
|
||||
? [ids.reduce((r, socketKey) => ({...r, [socketKey]: 0}), {})]
|
||||
: await req.intercom('@reddichat/user/users', ids);
|
||||
const uids = replies.reduce((r, m) => ({...r, ...m}), {});
|
||||
return Object.values(uids).reduce((r, uid) => ({...r, [uid]: 1 + (r[uid] || 0)}), {});
|
||||
};
|
||||
|
||||
export const channelUsers = async (req, channel) => (
|
||||
|
@ -56,7 +49,7 @@ export const channelState = async (req, latus, channel) => {
|
|||
export const channelsToHydrate = async (req, latus) => {
|
||||
const {channel, user} = req;
|
||||
if (!user) {
|
||||
return channel ? [renderChannel(channel)] : [];
|
||||
return channel ? [channel] : [];
|
||||
}
|
||||
const {User} = ModelMap(latus);
|
||||
const channels = await Promise.all(
|
||||
|
|
|
@ -6,6 +6,10 @@ import passport from 'passport';
|
|||
import {Strategy as RedditStrategy} from 'passport-reddit';
|
||||
|
||||
import UserReddichat from './models/user-reddichat';
|
||||
import BlockModel from './models/block';
|
||||
import FavoriteModel from './models/favorite';
|
||||
import FriendshipModel from './models/friendship';
|
||||
|
||||
import AddFavorite from './packets/add-favorite.server';
|
||||
import AddFriend from './packets/add-friend.server';
|
||||
import Block from './packets/block.server';
|
||||
|
@ -51,6 +55,11 @@ export default {
|
|||
},
|
||||
));
|
||||
},
|
||||
'@latus/db/models': () => ({
|
||||
Block: BlockModel,
|
||||
Favorite: FavoriteModel,
|
||||
Friendship: FriendshipModel,
|
||||
}),
|
||||
'@latus/db/models.decorate': (Models, latus) => ({
|
||||
...Models,
|
||||
User: UserReddichat(Models.User, latus),
|
||||
|
|
|
@ -20,7 +20,7 @@ export default (User, latus) => class UserReddichat extends User {
|
|||
return (await this.getFavorites()).map(({channel}) => parseChannel(channel));
|
||||
}
|
||||
|
||||
async friendship() {
|
||||
async friendships() {
|
||||
const {Friendship} = ModelMap(latus);
|
||||
const friendship = await Friendship.findAll({
|
||||
where: {
|
||||
|
|
|
@ -3,18 +3,19 @@ import {renderChannel} from '@reddichat/core';
|
|||
import {channelsToHydrate} from '@reddichat/chat';
|
||||
|
||||
export default async (req, latus) => {
|
||||
const {/* channel, */user} = req;
|
||||
const {channel, user} = req;
|
||||
if (!user) {
|
||||
return undefined;
|
||||
}
|
||||
const toHydrate = await channelsToHydrate(req, latus);
|
||||
return {
|
||||
// activeChannel: channel ? renderChannel(channel) : '',
|
||||
activeChannel: channel ? renderChannel(channel) : '',
|
||||
blocked: user ? await user.blocks() : [],
|
||||
favorites: (await user.favorites()).map(renderChannel),
|
||||
friendship: user ? await user.friendships() : [],
|
||||
id: user.id,
|
||||
redditUsername: user.redditUsername,
|
||||
recent: toHydrate.filter(({type}) => 'r' === type).map(({name}) => name),
|
||||
unread: {},
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user