This commit is contained in:
cha0s 2020-12-09 04:03:43 -06:00
parent de0cbe1007
commit 9e66e3b1df
17 changed files with 195 additions and 135 deletions

View File

@ -4,10 +4,9 @@
.about { .about {
// height: 100%; // height: 100%;
overflow: auto; overflow: auto;
max-height: calc(100% - 3em); max-height: 100%;
padding: 1em; padding: 1em;
font-family: var(--thick-title-font-family); font-family: var(--thick-title-font-family);
scrollbar-width: none;
text-align: center; text-align: center;
word-break: break-word; word-break: break-word;
strong { strong {
@ -72,6 +71,7 @@
font-family: var(--title-font-family); font-family: var(--title-font-family);
font-size: 2em; font-size: 2em;
justify-content: space-around; justify-content: space-around;
margin: auto;
max-width: 10em; max-width: 10em;
padding: 0.5em; padding: 0.5em;
text-align: center; text-align: center;

View File

@ -13,44 +13,55 @@ import Home from 'components/home';
import Left from 'components/left'; import Left from 'components/left';
import Right from 'components/right'; import Right from 'components/right';
import useBreakpoints from 'hooks/useBreakpoints';
import pointerEvents from './pointer-events';
const App = () => { const App = () => {
const ref = useRef(null); const ref = useRef(null);
const isAnonymous = false && useSelector(isAnonymousSelector); const {desktop} = useBreakpoints();
const isAnonymous = useSelector(isAnonymousSelector);
return ( return (
<div <div
className="app" className="app"
ref={ref}
> >
<Header <Header
onButton={(type) => { onButton={(type) => {
const max = Math.min(window.innerWidth - (4 * 16), 25 * 16); 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) { 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 { 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"> <div
{/* {!isAnonymous && <Left />} */} className="app__center"
<Switch> // eslint-disable-next-line react/jsx-props-no-spreading
<Route {...(desktop ? {} : isAnonymous || pointerEvents(desktop, ref))}
component={Home} ref={ref}
exact >
path="/" {!isAnonymous && <Left />}
/> <div className="main">
<Route <Switch>
component={About} <Route
path="/about" component={Home}
/> exact
<Route path="/"
component={Chat} />
path="/chat" <Route
/> component={About}
</Switch> path="/about"
{/* {!isAnonymous && <Right />} */} />
<Route
component={Chat}
path="/chat"
/>
</Switch>
</div>
{!isAnonymous && <Right />}
</div> </div>
</div> </div>
); );

View File

@ -1,16 +1,35 @@
@import 'scss/breakpoints.scss';
@import 'scss/colors.scss'; @import 'scss/colors.scss';
.app { .app {
background-image: url('~images/transpaper.png'); background-image: url('~images/transpaper.png');
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
overflow-x: hidden;
// overflow: hidden; // overflow: hidden;
position: relative; position: relative;
} }
.app__center { .app__center {
display: flex; 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 { .panes {

View File

@ -1,11 +1,11 @@
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
export default function chatPointerEvents(desktop, ref) { export default function pointerEvents(desktop, ref) {
let lastY; let lastY;
let origin; let origin;
const abstract = { const abstract = {
down: ({pageX, pageY}) => { down: ({pageX, pageY}) => {
if (ref.current) { 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 windowWidth = window.innerWidth;
const max = Math.min(windowWidth - (4 * 16), 25 * 16); const max = Math.min(windowWidth - (4 * 16), 25 * 16);
lastY = pageY; lastY = pageY;
@ -14,9 +14,9 @@ export default function chatPointerEvents(desktop, ref) {
point: pageX, point: pageX,
}; };
if ( if (
(left === -max && pageX < windowWidth - max) (left === -(400 + max) && pageX < windowWidth - max)
|| (left === max && pageX > max)) { || (left === 400 - max && pageX > max)) {
ref.current.style.left = '0'; ref.current.style.left = '-400px';
} }
} }
}, },
@ -32,20 +32,21 @@ export default function chatPointerEvents(desktop, ref) {
} }
const snapped = Math.abs(offset) < 64 ? 0 : offset; const snapped = Math.abs(offset) < 64 ? 0 : offset;
const max = Math.min(window.innerWidth - (4 * 16), 25 * 16); 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: () => { up: () => {
const left = parseInt(ref.current.style.left, 10); const left = parseInt(ref.current.style.left, 10);
const max = Math.min(window.innerWidth - (4 * 16), 25 * 16); 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) { else if (left <= (-400 - (max / 2))) {
ref.current.style.left = `${-max}px`; ref.current.style.left = `${-(400 + max)}px`;
} }
else { else {
ref.current.style.left = '0'; ref.current.style.left = '-400px';
} }
origin = undefined; origin = undefined;
ref.current.classList.remove('moving'); ref.current.classList.remove('moving');

View File

@ -13,7 +13,7 @@ import useBreakpoints from 'hooks/useBreakpoints';
import useChannel from 'hooks/useChannel'; import useChannel from 'hooks/useChannel';
import Center from './center'; import Center from './center';
import pointerEvents from './pointer-events'; // import pointerEvents from './pointer-events';
export default function Chat() { export default function Chat() {
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -55,8 +55,6 @@ export default function Chat() {
return ( return (
<div <div
className="chat" className="chat"
// eslint-disable-next-line react/jsx-props-no-spreading
{...(desktop ? {} : pointerEvents(desktop, ref))}
ref={ref} ref={ref}
> >
{/* <Center {/* <Center

View File

@ -11,18 +11,18 @@
} }
} }
.flexed { // .flexed {
position: absolute; // position: absolute;
height: 100%; // height: 100%;
width: 0; // width: 0;
overflow: hidden; // overflow: hidden;
&:not(.center) { // &:not(.center) {
max-width: calc(100% - 4em); // max-width: calc(100% - 4em);
} // }
@include breakpoint(desktop) { // @include breakpoint(desktop) {
position: static; // position: static;
} // }
} // }
.chat .open { .chat .open {
background-image: url('~images/transpaper.png'); background-image: url('~images/transpaper.png');

View File

@ -21,7 +21,7 @@ export default function Header(props) {
const {onButton} = props; const {onButton} = props;
const channel = useChannel(); const channel = useChannel();
const id = useSelector(idSelector); const id = useSelector(idSelector);
const isUserAnonymous = false && 0 === id; const isUserAnonymous = 0 === id;
const pendingFriendship = useSelector(pendingFriendshipSelector) const pendingFriendship = useSelector(pendingFriendshipSelector)
.filter(({addeeId}) => addeeId === id).length; .filter(({addeeId}) => addeeId === id).length;
const unreadChannel = useSelector(unreadChannelSelector); const unreadChannel = useSelector(unreadChannelSelector);

View File

@ -3,7 +3,7 @@
.home { .home {
margin: auto; margin: auto;
max-height: calc(100% - 3em); max-height: 100%;
// max-width: map-get($breakpoints, desktop); // max-width: map-get($breakpoints, desktop);
overflow: auto; overflow: auto;
} }
@ -32,6 +32,8 @@
} }
.home__bar { .home__bar {
margin: auto;
max-width: 20em;
padding: 2em 0; padding: 2em 0;
} }

View File

@ -6,9 +6,9 @@
flex-shrink: 0; flex-shrink: 0;
height: 100%; height: 100%;
top: 0; top: 0;
transform: translateX(-100%); // transform: translateX(-100%);
transition: width 0.2s; transition: width 0.2s;
width: 25em; width: 25rem;
@include breakpoint(desktop) { @include breakpoint(desktop) {
transform: none; transform: none;
} }

View File

@ -47,7 +47,7 @@ export default function ChatRight() {
<div className="right__links"> <div className="right__links">
<Link className="right__link" to="/about">About</Link> <Link className="right__link" to="/about">About</Link>
<span className="right__linksBullet"></span> <span className="right__linksBullet"></span>
<Link className="right__link" to="/auth/logout">Log out</Link> <a href="/auth/logout">Log out</a>
</div> </div>
{0 === activeIndex && channelUsers.length > 0 && <Users />} {0 === activeIndex && channelUsers.length > 0 && <Users />}
{1 === activeIndex && blockedIds.length > 0 && <Blocked ids={blockedIds} />} {1 === activeIndex && blockedIds.length > 0 && <Blocked ids={blockedIds} />}

View File

@ -4,8 +4,9 @@
.right { .right {
background-color: #373737; background-color: #373737;
flex-shrink: 0; flex-shrink: 0;
right: 0; // height: 100%;
transform: translateX(100%); // right: 0;
// transform: translateX(100%);
transition: 0.2s width; transition: 0.2s width;
@include breakpoint(desktop) { @include breakpoint(desktop) {
transform: none; transform: none;
@ -13,7 +14,7 @@
} }
.right.open { .right.open {
width: 25em; width: 25rem;
} }
.right__buttons { .right__buttons {

View File

@ -921,8 +921,8 @@
"@latus/core@1.0.0", "@latus/core@^1.0.0": "@latus/core@1.0.0", "@latus/core@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@latus%2fcore/-/core-1.0.0.tgz#01f0121bb91579b8bd1bdadff8dabf8673f44a88" resolved "https://npm.i12e.cha0s.io/@latus%2fcore/-/core-1.0.0.tgz#d367fd4c96ad8cf1dff7031c509f104c1c5491da"
integrity sha512-NK7DuYoVIXmFEjazKi44vW335DFcE1pr62DXf9+9bZ8iyexptFBdfX/5sYFMGaeJlN/opFp0qFx94VPdVCsChg== integrity sha512-M2zoI45c+pTVyS9Ea/qARswwhnzdhK1pvRLgG4W9V3/HJhsFtG+XsRVKCltXH5CVIodaVLGI0qTScjbIQkBNPw==
dependencies: dependencies:
debug "4.3.1" debug "4.3.1"
js-yaml "3.14.0" js-yaml "3.14.0"
@ -930,8 +930,8 @@
"@latus/db@^1.0.0": "@latus/db@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@latus%2fdb/-/db-1.0.0.tgz#67ad19b87e2881b3b948712a2fab8025071c7941" resolved "https://npm.i12e.cha0s.io/@latus%2fdb/-/db-1.0.0.tgz#1ee299b0689f22186ea709df69c69b0d39ab2b9b"
integrity sha512-WxYmYVfAej+WDnxUKyl+zNNlwEJJUXJpzfbYFkqtpkn7Is/cADwan9ua0FUujOLkfA8sRllEPRxTcn+ZnEydTA== integrity sha512-Ir7Q8VGCiSsDNSbfnvCzmfUGH6PfnMIyCoNfylj8+PmHEKqdjIYJ7W1MF2h3WP/1oNDiegoO+21PnGJd7bL2rA==
dependencies: dependencies:
"@latus/core" "^1.0.0" "@latus/core" "^1.0.0"
debug "4.3.1" debug "4.3.1"
@ -941,8 +941,8 @@
"@latus/governor@^1.0.0": "@latus/governor@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@latus%2fgovernor/-/governor-1.0.0.tgz#7cbcc3ae04aaf7d26e78a94dd3306a3dc16b18a1" resolved "https://npm.i12e.cha0s.io/@latus%2fgovernor/-/governor-1.0.0.tgz#be19783cba2e84a900a0168c51ff0a55f4a78b3b"
integrity sha512-gZB30h/HgvyS0PWtAJaW4OpnlRJUpMcyDzDnCmuWi+zdr8EWYq7cwUOpWhD4TKIIviFYuEwvhaRzmg3c8rQM8A== integrity sha512-yH4f59TIT0yRPyKRclKXMOt0PpkHVyjHjYnMfiOUqYuX90pq264JSDn8bF4mv0J7hI6/CmgLLiOsYOvSN5w3JA==
dependencies: dependencies:
"@latus/redis" "^1.0.0" "@latus/redis" "^1.0.0"
"@latus/socket" "^1.0.0" "@latus/socket" "^1.0.0"
@ -951,8 +951,8 @@
"@latus/http@^1.0.0": "@latus/http@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@latus%2fhttp/-/http-1.0.0.tgz#ed08c6c85112ce4d66a652f5810a220a66a0a1b3" resolved "https://npm.i12e.cha0s.io/@latus%2fhttp/-/http-1.0.0.tgz#1e582cdc3040308bde4b30341e98c37273c6904f"
integrity sha512-1qSwE1vX0bg4nFJFrPjFZT1PepDuDT9RIZRt3SzpvT5OsmE+6LjxtqTbMsgpljnHuhwjWPzDnR6An7sUhR6A0A== integrity sha512-VDFbQXUj5HCvtDoIHywPZgfLcXcB6ML12zWlxYNVeo2nYTxADdWXxBVJuzA2+VFqZiDtILeFFfrI7KV10OKgBg==
dependencies: dependencies:
"@latus/core" "1.0.0" "@latus/core" "1.0.0"
"@neutrinojs/web" "^9.1.0" "@neutrinojs/web" "^9.1.0"
@ -968,8 +968,8 @@
"@latus/react@^1.0.0": "@latus/react@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@latus%2freact/-/react-1.0.0.tgz#965c0ca868f4fd83195e26f99bfd82d03ec8f361" resolved "https://npm.i12e.cha0s.io/@latus%2freact/-/react-1.0.0.tgz#4074b37bf9f149689c93e8a6a41f2f3fe8545894"
integrity sha512-ffWESmTinN2vxfxkpznysF+uU1rWSbB3AtvS2XWLzPg/X3A5yRql4J2602SHIy/xXhLWzHueDZ5pzxDiGe0S8g== integrity sha512-vktm5f4DU1/ffTBijkq8ZlPp2S1aahlcyBu6H66rdW3K9uTSGLke+a4pd4YWJ54aIJFsNNaL1mAJYbu8laeCuQ==
dependencies: dependencies:
"@neutrinojs/react" "^9.4.0" "@neutrinojs/react" "^9.4.0"
debug "4.3.1" debug "4.3.1"
@ -982,27 +982,27 @@
"@latus/redis@^1.0.0": "@latus/redis@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@latus%2fredis/-/redis-1.0.0.tgz#b54c176a02481f8f43ea383d2df665c1aa365885" resolved "https://npm.i12e.cha0s.io/@latus%2fredis/-/redis-1.0.0.tgz#f69b03746486bca8b232f7764859c2f95e4aaaa0"
integrity sha512-HSQPI57K7RZMGfehsMSRvvAY+paJ4gxeRNpcQhMhLmWH8ShartGSR7/vPEJjpdvGcSgucYb97KM913oAgDDG5g== integrity sha512-rtnPZG9xjEfdke08SgrrIg+cgqvc3izKhSJZMNZBhWH1ihTn6WKt4ZGMVovSNKGUlI80z+TB/ExiLpu81r8vig==
dependencies: dependencies:
connect-redis "^5.0.0" connect-redis "^5.0.0"
debug "4.3.1" debug "4.3.1"
express-session "^1.17.1" express-session "^1.17.1"
mkdirp "^1.0.4" mkdirp "^1.0.4"
redis "^3.0.2" redis "^3.0.2"
socket.io-redis "^6.0.1" socket.io-redis "5.3.0"
"@latus/repl@^1.0.0": "@latus/repl@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@latus%2frepl/-/repl-1.0.0.tgz#3a1c84af5980e4b6ac863eee3cd8ea467aade742" resolved "https://npm.i12e.cha0s.io/@latus%2frepl/-/repl-1.0.0.tgz#493b075991d8370cf9592a4f75bcd4db1cf259e7"
integrity sha512-cpi0hCYq2MNQ3gbxt7hbHuxeBbaeZItr5LS/EuVv+dUt/cZ3poJekxX5VGvT1hhfAfb03vCku9X1mAhhd0VVyQ== integrity sha512-hfqcepLf7RKgprE/gK0klOkgZk8xFb5TNS5dZX1iBlKjxO6ynMzxLdmSmGu50BnaF2FgWgAWSUZQbpxEWcdUgg==
dependencies: dependencies:
debug "4.3.1" debug "4.3.1"
"@latus/socket@^1.0.0": "@latus/socket@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@latus%2fsocket/-/socket-1.0.0.tgz#75e95bb522fbec52d94d72ae4a33dab75e47cb5e" resolved "https://npm.i12e.cha0s.io/@latus%2fsocket/-/socket-1.0.0.tgz#77e5d405ee144dfa8f4e48e8f64611a50d2aa033"
integrity sha512-UGmRxwkL1ZKT3oZUnQlsJSJOKAlJeaxdVS0VDTo1HBMneYP0HwoMeh7cJ7wWzV34Uj7/FhG6PWwwTz3wFz/c3A== integrity sha512-WIWQoNRmUuWG4cqw/mRcA5MgIhK+Zj4eKtqPHREE0RH5el8uQOHYxozV0kT6lVkm+iZLYcRW4YoRndfANocb4g==
dependencies: dependencies:
"@latus/core" "^1.0.0" "@latus/core" "^1.0.0"
"@latus/http" "^1.0.0" "@latus/http" "^1.0.0"
@ -1015,8 +1015,8 @@
"@latus/user@^1.0.0": "@latus/user@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@latus%2fuser/-/user-1.0.0.tgz#5eb8f3af070dbea295b3bcb35c136c4dfee7097a" resolved "https://npm.i12e.cha0s.io/@latus%2fuser/-/user-1.0.0.tgz#0c53a8300eb8a61b006bb7812c9eabf5649c0c71"
integrity sha512-O1EY81t6HIjCzhaiLwJ6D9dDWTFHZhBasuwZUxcb8d85BcCGoFRPjL39Jflm3LO150QT9rjJxAmIgKWyJIHiLA== integrity sha512-lXV8Il1gspqmj3H9y23osW2fcHnv/QhJWKTui7ZXQV9b8RI5p8pQhiW6wDNJ38A53j1fjsUEq8HclJIczAl8Hg==
dependencies: dependencies:
"@latus/db" "^1.0.0" "@latus/db" "^1.0.0"
"@latus/socket" "^1.0.0" "@latus/socket" "^1.0.0"
@ -1194,8 +1194,8 @@
"@reddichat/chat@^1.0.0": "@reddichat/chat@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@reddichat%2fchat/-/chat-1.0.0.tgz#007e210ef28021c4c5846f7d686ba83ad875f248" resolved "https://npm.i12e.cha0s.io/@reddichat%2fchat/-/chat-1.0.0.tgz#0a8c639d8dfcdba6a3c29a0380f0851f219972a0"
integrity sha512-WR32qj/o/TwFcGiqFxIGzxwjRTfReTUneu5aPkGwxVomUg/fjUhxhfEVgtEFR/FMPooF6eB+yr2YlCneHHvtcg== integrity sha512-baB8+iXfJqY7Xfk9wS0OfQhEWsXocdz8XLEG1JEKCi9zIS6GwDOFjx/eMVvNm3lbFo0G7kO5xxcdFjfLX6B8ZQ==
dependencies: dependencies:
"@latus/core" "^1.0.0" "@latus/core" "^1.0.0"
"@latus/db" "^1.0.0" "@latus/db" "^1.0.0"
@ -1232,8 +1232,8 @@
"@reddichat/user@^1.0.0": "@reddichat/user@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://npm.i12e.cha0s.io/@reddichat%2fuser/-/user-1.0.0.tgz#1bdb0ddd155a53e028178e99b3b594f09b28aeda" resolved "https://npm.i12e.cha0s.io/@reddichat%2fuser/-/user-1.0.0.tgz#f9847b3e7763938bc288760167196bd2f872aec3"
integrity sha512-Xvzs3JTrfPbJI5RYfChB2f7CSizL8ACTJ7KTpKKG0qd7kDn5nScnvTpdlsVg71pLS5bTR9tdKPNCTxSZTPcp7w== integrity sha512-c4cP3zGjNIPkOdZ0NbNEJ9dP4xzbTHxA8UnY5qmyvEGuFF2MDEs2hQeMsFfIyXFqViBDkSEgsAOc1QqQpnN4JQ==
dependencies: dependencies:
"@latus/db" "^1.0.0" "@latus/db" "^1.0.0"
"@latus/socket" "^1.0.0" "@latus/socket" "^1.0.0"
@ -1291,9 +1291,9 @@
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
"@types/node@*": "@types/node@*":
version "14.14.10" version "14.14.11"
resolved "https://npm.i12e.cha0s.io/@types%2fnode/-/node-14.14.10.tgz#5958a82e41863cfc71f2307b3748e3491ba03785" resolved "https://npm.i12e.cha0s.io/@types%2fnode/-/node-14.14.11.tgz#fc25a4248a5e8d0837019b1d170146d07334abe0"
integrity sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ== integrity sha512-BJ97wAUuU3NUiUCp44xzUFquQEvnk1wu7q4CMEUYKJWjdkr0YWYDsm4RFtAvxYsNjLsKcrFt6RvK8r+mnzMbEQ==
"@types/source-list-map@*": "@types/source-list-map@*":
version "0.1.2" 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" resolved "https://npm.i12e.cha0s.io/dottie/-/dottie-2.0.2.tgz#cc91c0726ce3a054ebf11c55fbc92a7f266dd154"
integrity sha512-fmrwR04lsniq/uSr8yikThDTrM7epXHBAAjH9TbeH3rEA8tdCO7mRzB9hdmdGyJCxF8KERo9CITcm3kGuoyMhg== 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: duplexify@^3.4.2, duplexify@^3.6.0:
version "3.7.1" version "3.7.1"
resolved "https://npm.i12e.cha0s.io/duplexify/-/duplexify-3.7.1.tgz#2a4df5317f6ccfd91f86d6fd25d8d8a103b88309" 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= integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
electron-to-chromium@^1.3.612: electron-to-chromium@^1.3.612:
version "1.3.619" version "1.3.620"
resolved "https://npm.i12e.cha0s.io/electron-to-chromium/-/electron-to-chromium-1.3.619.tgz#4dc529ae802f5c9c31e7eea830144340539b62b4" resolved "https://npm.i12e.cha0s.io/electron-to-chromium/-/electron-to-chromium-1.3.620.tgz#c6f36a7e398acc9d7d12743a6f58d536fbc58700"
integrity sha512-WFGatwtk7Fw0QcKCZzfGD72hvbcXV8kLY8aFuj0Ip0QRnOtyLYMsc+wXbSjb2w4lk1gcAeNU1/lQ20A+tvuypQ== integrity sha512-YbgWXUR2Mu+Fp6rm3GZ5YJdNo8SgZKLUTNSl2PNvdOcM8OIz07jRJnRkIaV9vdszFv9UUuGChh19w9qSuoLJgw==
elliptic@^6.5.3: elliptic@^6.5.3:
version "6.5.3" version "6.5.3"
@ -4744,9 +4749,9 @@ inherits@2.0.3:
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
ini@^1.3.4, ini@^1.3.5, ini@~1.3.0: ini@^1.3.4, ini@^1.3.5, ini@~1.3.0:
version "1.3.5" version "1.3.6"
resolved "https://npm.i12e.cha0s.io/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" resolved "https://npm.i12e.cha0s.io/ini/-/ini-1.3.6.tgz#f1c46a2a93a253e7b3905115e74d527cd23061a1"
integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== integrity sha512-IZUoxEjNjubzrmvzZU4lKP7OnYmX72XRl3sqkfJhBKweKi5rnGi5+IUdlj/H1M+Ip5JQ1WzaDMOBRY90Ajc5jg==
inquirer@^7.0.0: inquirer@^7.0.0:
version "7.3.3" 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" resolved "https://npm.i12e.cha0s.io/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== 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" version "2.1.2"
resolved "https://npm.i12e.cha0s.io/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" resolved "https://npm.i12e.cha0s.io/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== 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: multicast-dns-service-types@^1.1.0:
version "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" 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" query-string "^4.1.0"
sort-keys "^1.0.0" sort-keys "^1.0.0"
notepack.io@~2.2.0: notepack.io@~2.1.2:
version "2.2.0" version "2.1.3"
resolved "https://npm.i12e.cha0s.io/notepack.io/-/notepack.io-2.2.0.tgz#d7ea71d1cb90094f88c6f3c8d84277c2d0cd101c" resolved "https://npm.i12e.cha0s.io/notepack.io/-/notepack.io-2.1.3.tgz#cc904045c751b1a27b2dcfd838d81d0bf3ced923"
integrity sha512-9b5w3t5VSH6ZPosoYnyDONnUTF8o0UkBw7JLA6eBlYJWyGT1Q3vQa8Hmuj1/X6RYvHjjygBDgw6fJhe0JEojfw== integrity sha512-AgSt+cP5XMooho1Ppn8NB3FFaVWefV+qZoZncYTUSch2GAEwlYLcIIbT5YVkMlFeNHnfwOvc4HDlbvrB5BRxXA==
npm-bundled@^1.0.1: npm-bundled@^1.0.1:
version "1.1.1" version "1.1.1"
@ -7151,7 +7161,7 @@ redent@^1.0.0:
indent-string "^2.1.0" indent-string "^2.1.0"
strip-indent "^1.0.1" strip-indent "^1.0.1"
redis-commands@^1.5.0: redis-commands@^1.2.0, redis-commands@^1.5.0:
version "1.6.0" version "1.6.0"
resolved "https://npm.i12e.cha0s.io/redis-commands/-/redis-commands-1.6.0.tgz#36d4ca42ae9ed29815cdb30ad9f97982eba1ce23" resolved "https://npm.i12e.cha0s.io/redis-commands/-/redis-commands-1.6.0.tgz#36d4ca42ae9ed29815cdb30ad9f97982eba1ce23"
integrity sha512-2jnZ0IkjZxvguITjFTrGiLyzQZcTvaw8DAaCXxZq/dsHXz7KfMQ3OUJy7Tz9vnRtZRVz6VRCPDvruvU8Ts44wQ== 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" resolved "https://npm.i12e.cha0s.io/redis-errors/-/redis-errors-1.2.0.tgz#eb62d2adb15e4eaf4610c04afe1529384250abad"
integrity sha1-62LSrbFeTq9GEMBK/hUpOEJQq60= 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: redis-parser@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://npm.i12e.cha0s.io/redis-parser/-/redis-parser-3.0.0.tgz#b66d828cdcafe6b4b8a428a7def4c6bcac31c8b4" 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: dependencies:
redis-errors "^1.0.0" redis-errors "^1.0.0"
redis@^3.0.0, redis@^3.0.2: redis@^3.0.2:
version "3.0.2" version "3.0.2"
resolved "https://npm.i12e.cha0s.io/redis/-/redis-3.0.2.tgz#bd47067b8a4a3e6a2e556e57f71cc82c7360150a" resolved "https://npm.i12e.cha0s.io/redis/-/redis-3.0.2.tgz#bd47067b8a4a3e6a2e556e57f71cc82c7360150a"
integrity sha512-PNhLCrjU6vKVuMOyFu7oSP296mwBkcE6lrAjruBYG5LgdSqtRBoVQIylrMyVZD/lkF24RSNNatzvYag6HRBHjQ== integrity sha512-PNhLCrjU6vKVuMOyFu7oSP296mwBkcE6lrAjruBYG5LgdSqtRBoVQIylrMyVZD/lkF24RSNNatzvYag6HRBHjQ==
@ -7178,6 +7193,15 @@ redis@^3.0.0, redis@^3.0.2:
redis-errors "^1.2.0" redis-errors "^1.2.0"
redis-parser "^3.0.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: redux-thunk@^2.3.0:
version "2.3.0" version "2.3.0"
resolved "https://npm.i12e.cha0s.io/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622" 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" resolved "https://npm.i12e.cha0s.io/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz#ab3f0d6f66b8fc7fca3959ab5991f82221789be9"
integrity sha512-WzZRUj1kUjrTIrUKpZLEzFZ1OLj5FwLlAFQs9kuZJzJi5DKdU7FsWc36SNmA8iDOtwBQyT8FkrriRM8vXLYz8g== 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: socket.io-client@2.3.0:
version "2.3.0" version "2.3.0"
resolved "https://npm.i12e.cha0s.io/socket.io-client/-/socket.io-client-2.3.0.tgz#14d5ba2e00b9bcd145ae443ab96b3f86cbcc1bb4" 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" debug "~4.1.0"
isarray "2.0.1" isarray "2.0.1"
socket.io-redis@^6.0.1: socket.io-redis@5.3.0:
version "6.0.1" version "5.3.0"
resolved "https://npm.i12e.cha0s.io/socket.io-redis/-/socket.io-redis-6.0.1.tgz#0d6c82bd6e0dcbb0d70dcbc57f0c3269e6e53594" resolved "https://npm.i12e.cha0s.io/socket.io-redis/-/socket.io-redis-5.3.0.tgz#d01716d2813c25b76918cd704e1cf540b2f3985a"
integrity sha512-RvxAhVSsDQJfDUEXUER9MvsE99XZurXkAVORjym1FTReqWlvmPVjyAnrpLlH3RxvPFdFa9sN4kmaTtyzjOtRRA== integrity sha512-w2EqyGdw3oXzd1MY4sVIg2rYVooDI5sSwel8DOt38sTgaJuuXQSC847x38FvLSn2Rt6MAcdLhiNw/FqjzeC4RQ==
dependencies: dependencies:
debug "~4.1.0" debug "~4.1.0"
notepack.io "~2.2.0" notepack.io "~2.1.2"
redis "^3.0.0" redis "~2.8.0"
socket.io-adapter "~2.0.0" socket.io-adapter "~1.1.0"
uid2 "0.0.3" uid2 "0.0.3"
socket.io@2.3.0: socket.io@2.3.0:
@ -8726,9 +8745,9 @@ uuid@^3.3.2, uuid@^3.4.0:
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
uuid@^8.1.0, uuid@^8.3.1: uuid@^8.1.0, uuid@^8.3.1:
version "8.3.1" version "8.3.2"
resolved "https://npm.i12e.cha0s.io/uuid/-/uuid-8.3.1.tgz#2ba2e6ca000da60fce5a196954ab241131e05a31" resolved "https://npm.i12e.cha0s.io/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg== integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
v8-compile-cache@^2.0.3, v8-compile-cache@^2.1.1: v8-compile-cache@^2.0.3, v8-compile-cache@^2.1.1:
version "2.2.0" version "2.2.0"

View File

@ -1,3 +1,5 @@
import {parseChatChannel} from '@reddichat/core';
import Join from './packets/join.server'; import Join from './packets/join.server';
import Leave from './packets/leave.server'; import Leave from './packets/leave.server';
import Message from './packets/message.server'; import Message from './packets/message.server';
@ -9,13 +11,17 @@ export * from './state';
export default { export default {
hooks: { hooks: {
'@latus/http/request': () => (req, res, next) => {
req.channel = parseChatChannel(req.url);
next();
},
'@latus/socket/packets': (latus) => ({ '@latus/socket/packets': (latus) => ({
Join: Join(latus), Join: Join(latus),
Leave: Leave(latus), Leave: Leave(latus),
Message: Message(latus), Message: Message(latus),
}), }),
'@latus/socket/connect': async (socket) => { '@latus/socket/connect': async (socket, latus) => {
const channels = await channelsToHydrate(socket.req); const channels = await channelsToHydrate(socket.req, latus);
const joins = channels const joins = channels
.filter(({type}) => 'r' === type) .filter(({type}) => 'r' === type)
.map((channel) => joinChannel(channel, socket)); .map((channel) => joinChannel(channel, socket));

View File

@ -6,22 +6,15 @@ import {createClient, keys} from '@latus/redis';
import {channelIsAnonymous, parseChannel, renderChannel} from '@reddichat/core'; import {channelIsAnonymous, parseChannel, renderChannel} from '@reddichat/core';
export const channelUserCounts = async (req, channel) => { export const channelUserCounts = async (req, channel) => {
const clients = promisify(req.adapter.clients.bind(req.adapter)); const ids = await req.clients([renderChannel(channel)]);
const rendered = renderChannel(channel); if (0 === ids.length) {
const socketKeys = await clients([rendered]); return [];
const customRequest = promisify(req.adapter.customRequest.bind(req.adapter)); }
// eslint-disable-next-line no-nested-ternary
const replies = channelIsAnonymous(channel) const replies = channelIsAnonymous(channel)
? ( ? [ids.reduce((r, socketKey) => ({...r, [socketKey]: 0}), {})]
socketKeys.length > 0 : await req.intercom('@reddichat/user/users', ids);
? [socketKeys.reduce((r, socketKey) => ({...r, [socketKey]: 0}), {})] const uids = replies.reduce((r, m) => ({...r, ...m}), {});
: [] return Object.values(uids).reduce((r, uid) => ({...r, [uid]: 1 + (r[uid] || 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)}), {});
}; };
export const channelUsers = async (req, channel) => ( export const channelUsers = async (req, channel) => (
@ -56,7 +49,7 @@ export const channelState = async (req, latus, channel) => {
export const channelsToHydrate = async (req, latus) => { export const channelsToHydrate = async (req, latus) => {
const {channel, user} = req; const {channel, user} = req;
if (!user) { if (!user) {
return channel ? [renderChannel(channel)] : []; return channel ? [channel] : [];
} }
const {User} = ModelMap(latus); const {User} = ModelMap(latus);
const channels = await Promise.all( const channels = await Promise.all(

View File

@ -6,6 +6,10 @@ import passport from 'passport';
import {Strategy as RedditStrategy} from 'passport-reddit'; import {Strategy as RedditStrategy} from 'passport-reddit';
import UserReddichat from './models/user-reddichat'; 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 AddFavorite from './packets/add-favorite.server';
import AddFriend from './packets/add-friend.server'; import AddFriend from './packets/add-friend.server';
import Block from './packets/block.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) => ({ '@latus/db/models.decorate': (Models, latus) => ({
...Models, ...Models,
User: UserReddichat(Models.User, latus), User: UserReddichat(Models.User, latus),

View File

@ -20,7 +20,7 @@ export default (User, latus) => class UserReddichat extends User {
return (await this.getFavorites()).map(({channel}) => parseChannel(channel)); return (await this.getFavorites()).map(({channel}) => parseChannel(channel));
} }
async friendship() { async friendships() {
const {Friendship} = ModelMap(latus); const {Friendship} = ModelMap(latus);
const friendship = await Friendship.findAll({ const friendship = await Friendship.findAll({
where: { where: {

View File

@ -3,18 +3,19 @@ import {renderChannel} from '@reddichat/core';
import {channelsToHydrate} from '@reddichat/chat'; import {channelsToHydrate} from '@reddichat/chat';
export default async (req, latus) => { export default async (req, latus) => {
const {/* channel, */user} = req; const {channel, user} = req;
if (!user) { if (!user) {
return undefined; return undefined;
} }
const toHydrate = await channelsToHydrate(req, latus); const toHydrate = await channelsToHydrate(req, latus);
return { return {
// activeChannel: channel ? renderChannel(channel) : '', activeChannel: channel ? renderChannel(channel) : '',
blocked: user ? await user.blocks() : [], blocked: user ? await user.blocks() : [],
favorites: (await user.favorites()).map(renderChannel), favorites: (await user.favorites()).map(renderChannel),
friendship: user ? await user.friendships() : [], friendship: user ? await user.friendships() : [],
id: user.id, id: user.id,
redditUsername: user.redditUsername, redditUsername: user.redditUsername,
recent: toHydrate.filter(({type}) => 'r' === type).map(({name}) => name), recent: toHydrate.filter(({type}) => 'r' === type).map(({name}) => name),
unread: {},
}; };
}; };