Skip to content

Commit

Permalink
chore: adding some validation and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
raaymax committed Jan 26, 2024
1 parent 932c187 commit cad1c1a
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 820 deletions.
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@quack/config": "workspace:*",
"@quack/rpc": "workspace:*",
"fuse.js": "7.0.0",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-redux": "9.0.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components';
import PropTypes from 'prop-types';

const InlineChannelLink = styled.a`
span {
Expand All @@ -26,3 +27,7 @@ export const ChannelInline = ({ channelId: id }) => {
</InlineChannelLink>
);
};

ChannelInline.propTypes = {
channelId: PropTypes.string,
};
10 changes: 10 additions & 0 deletions packages/app/src/js/components/Channels/elements/inlineChannel.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styled from 'styled-components';
import {Badge} from './badge';
import PropTypes from 'prop-types';

const Container = styled.div`
padding: 5px 5px 5px 20px;
Expand Down Expand Up @@ -38,3 +39,12 @@ export const InlineChannel = ({
{badge > 0 && <Badge>{badge}</Badge>}
</Container>
)

InlineChannel.propTypes = {
id: PropTypes.string,
children: PropTypes.any,
badge: PropTypes.number,
className: PropTypes.string,
onClick: PropTypes.func,
icon: PropTypes.string,
};
10 changes: 8 additions & 2 deletions packages/app/src/js/components/Emoji/Emoji.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import styled from 'styled-components';
import { getUrl } from '../../services/file';
import { Tooltip } from '../../elements/tooltip';
import { useEmoji } from '../../hooks';
import PropTypes from 'prop-types';

const StyledEmoji = styled.span`
img{
Expand All @@ -19,15 +20,20 @@ const StyledEmoji = styled.span`
export const Emoji = ({ shortname, big }) => {
const emoji = useEmoji(shortname);

if (!emoji || emoji.empty) return <span className='emoji' emoji={shortname}>{shortname}</span>;
if (!emoji || emoji.empty) return <span className='emoji'>{shortname}</span>;

return (
<Tooltip text={shortname}>
<StyledEmoji big={big} emoji={shortname}>
<StyledEmoji big={big} data-emoji={shortname}>
{emoji.unicode
? <span>{String.fromCodePoint(parseInt(emoji.unicode, 16))}</span>
: <img src={getUrl(emoji.fileId)} alt={shortname} />}
</StyledEmoji>
</Tooltip>
);
};

Emoji.propTypes = {
shortname: PropTypes.string,
big: PropTypes.bool,
};
1 change: 0 additions & 1 deletion packages/app/src/js/services/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { initNotifications } from './notifications';

const initApp = () => async (dispatch, getState) => {
console.log('initApp');
const {actions, methods} = dispatch;
if (navigator?.userAgentData?.mobile) {
document.body.setAttribute('class', 'mobile');
Expand Down
11 changes: 7 additions & 4 deletions packages/app/src/js/services/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ export const initNotifications = async (config) => {
};

const register = async (config, retry = false) => navigator.serviceWorker.getRegistration('/')
.then((registration) => registration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: config.vapidPublicKey,
}))
.then((registration) => {
if (!registration) throw new Error('No service worker registered');
return registration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: config.vapidPublicKey,
})
})
.then(async (subscription) => client.req({
type: 'user:push:subscribe',
...subscription.toJSON(),
Expand Down
Loading

0 comments on commit cad1c1a

Please sign in to comment.