';
- const data = htmlData.split(marker);
- const propsData = `${marker}`;
- let didError = false;
+ const marker = '
'
+ const data = htmlData.split(marker)
+ const propsData = `${marker}`
+ let didError = false
const { pipe } = ReactDOMServer.renderToPipeableStream(
@@ -57,33 +57,33 @@ const serverRenderer = async (req, res) => {
, {
onShellReady() {
- res.statusCode = didError ? 500 : 200;
- res.setHeader('Content-type', 'text/html');
- res.write(data[0]);
- res.write(propsData);
- pipe(res, { end: false });
+ res.statusCode = didError ? 500 : 200
+ res.setHeader('Content-type', 'text/html')
+ res.write(data[0])
+ res.write(propsData)
+ pipe(res, { end: false })
},
onShellError() {
- didError = true;
- res.statusCode = 500;
- res.setHeader('Content-type', 'text/html');
+ didError = true
+ res.statusCode = 500
+ res.setHeader('Content-type', 'text/html')
res.send(
'
Something went wrong :(
'
- );
- res.end();
+ )
+ res.end()
},
onAllReady() {
if (!didError) {
- res.write(data[1]);
+ res.write(data[1])
}
- res.end();
+ res.end()
},
onError(err) {
- didError = true;
- console.log(err);
+ didError = true
+ console.log(err)
}
- });
- });
-};
+ })
+ })
+}
-export default serverRenderer;
+export default serverRenderer
diff --git a/vnext/server/middleware/urlexpand.js b/vnext/server/middleware/urlexpand.js
index f78d1cc0..a99f80a7 100644
--- a/vnext/server/middleware/urlexpand.js
+++ b/vnext/server/middleware/urlexpand.js
@@ -1,4 +1,4 @@
-import { expandShortenedLink } from '../../src/api';
+import { expandShortenedLink } from '../../src/api'
/**
* Expand URLs
@@ -6,8 +6,8 @@ import { expandShortenedLink } from '../../src/api';
* @param {import("next").NextApiResponse} res
*/
export default function urlExpand(req, res) {
- let url = (req.query.url || '').toString();
+ let url = (req.query.url || '').toString()
return expandShortenedLink(url).then(result => {
- res.json(result);
- });
+ res.json(result)
+ })
}
diff --git a/vnext/server/sape.js b/vnext/server/sape.js
index ad374f2b..cff9b48a 100644
--- a/vnext/server/sape.js
+++ b/vnext/server/sape.js
@@ -1,9 +1,9 @@
-import { parseStringPromise } from 'xml2js';
-import axios from 'axios';
-import { setupCache } from 'axios-cache-interceptor';
-import config from 'config';
+import { parseStringPromise } from 'xml2js'
+import axios from 'axios'
+import { setupCache } from 'axios-cache-interceptor'
+import config from 'config'
-const token = config.get('service.sape.token') || process.env.SAPE_TOKEN;
+const token = config.get('service.sape.token') || process.env.SAPE_TOKEN
/** @external Promise */
@@ -14,19 +14,19 @@ const token = config.get('service.sape.token') || process.env.SAPE_TOKEN;
*/
export const getLinks = async (uri, sapeCookie) => {
if (!token) {
- console.warn('Sape is not configured');
- return [];
+ console.warn('Sape is not configured')
+ return []
}
- const response = await sape.get(`http://dispencer-01.sape.ru/code.php?user=${token}&host=juick.com&charset=UTF-8&as_xml=true`);
- const data = await parseStringPromise(response.data);
- const showCode = token === sapeCookie;
- const requestURI = showCode ? '*' : uri;
+ const response = await sape.get(`http://dispencer-01.sape.ru/code.php?user=${token}&host=juick.com&charset=UTF-8&as_xml=true`)
+ const data = await parseStringPromise(response.data)
+ const showCode = token === sapeCookie
+ const requestURI = showCode ? '*' : uri
const page = data.sape.page.filter(page => {
- const uri = page['$']['uri'];
- return uri === requestURI;
- });
- return page.length > 0 ? showCode ? [page[0]._] : page[0].link : [];
-};
+ const uri = page['$']['uri']
+ return uri === requestURI
+ })
+ return page.length > 0 ? showCode ? [page[0]._] : page[0].link : []
+}
/** @type { import('axios-cache-interceptor').AxiosCacheInstance } */
let sape = setupCache(
@@ -36,4 +36,4 @@ let sape = setupCache(
}
}),
{ ttl: 3600 * 1000 }
-);
+)
diff --git a/vnext/server/sender.js b/vnext/server/sender.js
index 7c72cbf3..48b5fb78 100644
--- a/vnext/server/sender.js
+++ b/vnext/server/sender.js
@@ -1,11 +1,11 @@
-import PushNotifications from 'node-pushnotifications';
-import debug from 'debug';
-const log = debug('sender');
-import { deleteSubscribers } from './http';
-import { formatMessage, formatTitle, formatQuote } from './common/MessageUtils';
-import config from 'config';
+import PushNotifications from 'node-pushnotifications'
+import debug from 'debug'
+const log = debug('sender')
+import { deleteSubscribers } from './http'
+import { formatMessage, formatTitle, formatQuote } from './common/MessageUtils'
+import config from 'config'
-let cfg = /** @type { import('node-pushnotifications').Settings } */ (config);
+let cfg = /** @type { import('node-pushnotifications').Settings } */ (config)
const apnConfig = (production = true) => {
const apn = {
@@ -16,98 +16,96 @@ const apnConfig = (production = true) => {
teamId: cfg.apn?.token?.teamId || process.env.JUICK_APN_TEAM_ID
},
production: production
- };
- return apn;
-};
+ }
+ return apn
+}
const gcmConfig = {
...cfg.gcm,
id: cfg.gcm?.id || process.env.JUICK_GCM_ID
-};
+}
const push = new PushNotifications({
...config,
apn: apnConfig(true),
gcm: gcmConfig,
-});
+})
const sandbox = new PushNotifications({
...config,
apn: apnConfig(false),
gcm: gcmConfig
-});
+})
/** @type {string} */
-const application = config.get('service.application') || process.env.JUICK_APN_APPLICATION || '';
+const application = config.get('service.application') || process.env.JUICK_APN_APPLICATION || ''
/**
* send notification
- *
* @param {PushNotifications.RegistrationId[]} productionIds
* @param {PushNotifications.RegistrationId[]} sandboxIds
* @param {PushNotifications.Data} data
*/
export function sendNotification(productionIds, sandboxIds, data) {
[productionIds, sandboxIds].map((registrationIds, index) => {
- let sender = index == 0 ? push : sandbox;
+ let sender = index == 0 ? push : sandbox
if (registrationIds && registrationIds.length) {
sender.send(registrationIds, data)
.then((results) => {
results.forEach(result => {
- log(`${result.method}: ${result.success} success, ${result.failure} failure`);
+ log(`${result.method}: ${result.success} success, ${result.failure} failure`)
if (result.failure) {
- console.error(`${result.method} failure: ${JSON.stringify(result)}`);
- console.error(`Failed data: ${JSON.stringify(data)}`);
+ console.error(`${result.method} failure: ${JSON.stringify(result)}`)
+ console.error(`Failed data: ${JSON.stringify(data)}`)
}
- });
+ })
results.filter(r => r.method === 'apn')
.forEach(async r => {
- log(`Response message: ${JSON.stringify(r.message)}`);
+ log(`Response message: ${JSON.stringify(r.message)}`)
let badTokens = r.message.filter(m => m.errorMsg === 'BadDeviceToken').map(m => {
- return { 'type': 'apns', 'token': m.regId };
- });
+ return { 'type': 'apns', 'token': m.regId }
+ })
if (badTokens.length > 0) {
- await deleteSubscribers(badTokens);
- log(`${badTokens.length} APNS tokens deleted`);
+ await deleteSubscribers(badTokens)
+ log(`${badTokens.length} APNS tokens deleted`)
}
- });
+ })
results.filter(r => r.method === 'gcm')
.forEach(async r => {
let badTokens = r.message.filter(m => m.errorMsg === 'NotRegistered' || m.errorMsg === 'MismatchSenderId' || m.errorMsg === 'InvalidRegistration').map(m => {
- return { 'type': 'fcm', 'token': m.regId };
- });
+ return { 'type': 'fcm', 'token': m.regId }
+ })
if (badTokens.length > 0) {
- await deleteSubscribers(badTokens);
- log(`${badTokens.length} GCM tokens deleted`);
+ await deleteSubscribers(badTokens)
+ log(`${badTokens.length} GCM tokens deleted`)
}
- });
+ })
results.filter(r => r.method === 'mpns')
.forEach(async r => {
let badTokens = r.message.filter(m => m.errorMsg === 'The channel expired.').map(m => {
- return { 'type': 'mpns', 'token': m.regId };
- });
+ return { 'type': 'mpns', 'token': m.regId }
+ })
if (badTokens.length > 0) {
- await deleteSubscribers(badTokens);
- log(`${badTokens.length} MPNS tokens deleted`);
+ await deleteSubscribers(badTokens)
+ log(`${badTokens.length} MPNS tokens deleted`)
}
- });
+ })
results.filter(r => r.method === 'webPush')
.forEach(async r => {
let badTokens = r.message.filter(m => m.error && m.error['statusCode'] === 410).map(m => {
- return { 'type': 'web', 'token': JSON.stringify(m.regId) };
- });
+ return { 'type': 'web', 'token': JSON.stringify(m.regId) }
+ })
if (badTokens.length > 0) {
- await deleteSubscribers(badTokens);
- log(`${badTokens.length} WebPush tokens deleted`);
+ await deleteSubscribers(badTokens)
+ log(`${badTokens.length} WebPush tokens deleted`)
}
- });
+ })
})
- .catch((err) => { console.error(JSON.stringify(err)); });
+ .catch((err) => { console.error(JSON.stringify(err)) })
}
- });
+ })
}
/**
* builds notification object
- *
* @param {import('../client').SecureUser} user user
* @param {import('../client').Message} msg message
* @returns {PushNotifications.Data} notification template
@@ -119,33 +117,33 @@ export function buildNotification(user, msg) {
message: msg
},
timeToLive: 0
- };
- let { tokens, ...subscriber } = user;
+ }
+ let { tokens, ...subscriber } = user
if (msg.service) {
- template.contentAvailable = true;
- template.custom.service = true;
- template.custom.user = subscriber;
+ template.contentAvailable = true
+ template.custom.service = true
+ template.custom.user = subscriber
} else {
- const avatar = `https://i.juick.com/a/${msg.user.uid}.png`;
- const title = formatTitle(msg);
- const body = `${formatQuote(msg)}\n${formatMessage(msg)}`;
- template.custom.mid = msg.mid;
- template.custom.rid = msg.rid;
- template.custom.uname = msg.user.uname;
- template.custom.avatarUrl = avatar;
- template.image1src = avatar;
- template.text1 = title;
- template.text2 = body;
- template.title = title;
- template.body = body;
- template.badge = user.unreadCount || 0;
- template.mutableContent = 1;
- template.color = '#3c77aa';
- template.icon = 'ic_notification';
- template.clickAction = 'com.juick.NEW_EVENT_ACTION';
- const tag = msg.mid == 0 ? msg.user.uname : msg.mid;
- template.tag = `${tag}`;
- template.android_channel_id = 'default';
+ const avatar = `https://i.juick.com/a/${msg.user.uid}.png`
+ const title = formatTitle(msg)
+ const body = `${formatQuote(msg)}\n${formatMessage(msg)}`
+ template.custom.mid = msg.mid
+ template.custom.rid = msg.rid
+ template.custom.uname = msg.user.uname
+ template.custom.avatarUrl = avatar
+ template.image1src = avatar
+ template.text1 = title
+ template.text2 = body
+ template.title = title
+ template.body = body
+ template.badge = user.unreadCount || 0
+ template.mutableContent = 1
+ template.color = '#3c77aa'
+ template.icon = 'ic_notification'
+ template.clickAction = 'com.juick.NEW_EVENT_ACTION'
+ const tag = msg.mid == 0 ? msg.user.uname : msg.mid
+ template.tag = `${tag}`
+ template.android_channel_id = 'default'
}
- return template;
+ return template
}
diff --git a/vnext/server/webpack.config.js b/vnext/server/webpack.config.js
index 61f00d4d..77a86abd 100644
--- a/vnext/server/webpack.config.js
+++ b/vnext/server/webpack.config.js
@@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/no-var-requires */
-const ESLintPlugin = require('eslint-webpack-plugin');
-const TerserPlugin = require('terser-webpack-plugin');
+const ESLintPlugin = require('eslint-webpack-plugin')
+const TerserPlugin = require('terser-webpack-plugin')
module.exports = () => {
- const node_env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
- const dev = node_env !== 'production';
+ const node_env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'
+ const dev = node_env !== 'production'
const config = {
mode: node_env,
devtool: dev ? 'cheap-module-source-map' : false,
@@ -37,7 +37,7 @@ module.exports = () => {
symlinks: false,
extensions: ['.js']
}
- };
+ }
if (dev) {
config.plugins.push(
new ESLintPlugin({
@@ -46,7 +46,7 @@ module.exports = () => {
failOnWarning: false,
failOnError: true,
fix: false
- }));
+ }))
config.devServer = {
hot: true,
historyApiFallback: true,
@@ -55,7 +55,7 @@ module.exports = () => {
runtimeErrors: true
}
}
- };
+ }
}
config.optimization = {
minimize: !dev,
@@ -67,6 +67,6 @@ module.exports = () => {
terserOptions: {},
}),
]
- };
- return config;
-};
+ }
+ return config
+}
diff --git a/vnext/src/App.js b/vnext/src/App.js
index 125b6fda..e723fe9c 100644
--- a/vnext/src/App.js
+++ b/vnext/src/App.js
@@ -1,25 +1,25 @@
-import { useState, useEffect, useRef, Fragment, useCallback } from 'react';
-import { Route, Link, Routes, useSearchParams } from 'react-router-dom';
+import { useState, useEffect, useRef, Fragment, useCallback } from 'react'
+import { Route, Link, Routes, useSearchParams } from 'react-router-dom'
-import svg4everybody from 'svg4everybody';
+import svg4everybody from 'svg4everybody'
-import Icon from './ui/Icon';
-import { Discover, Discussions, Blog, Tag, Home } from './ui/Feeds';
-import { Friends, Readers } from './ui/Users';
-import Settings from './ui/Settings';
-import Contacts from './ui/Contacts';
-import Chat from './ui/Chat';
-import Header from './ui/Header';
-import Post from './ui/Post';
-import Thread from './ui/Thread';
-import Login from './ui/Login';
+import Icon from './ui/Icon'
+import { Discover, Discussions, Blog, Tag, Home } from './ui/Feeds'
+import { Friends, Readers } from './ui/Users'
+import Settings from './ui/Settings'
+import Contacts from './ui/Contacts'
+import Chat from './ui/Chat'
+import Header from './ui/Header'
+import Post from './ui/Post'
+import Thread from './ui/Thread'
+import Login from './ui/Login'
-import { useCookies } from 'react-cookie';
+import { useCookies } from 'react-cookie'
-import { me, trends } from './api';
-import { useVisitor } from './ui/VisitorContext';
-import Avatar from './ui/Avatar';
-import { Toaster } from 'react-hot-toast';
+import { me, trends } from './api'
+import { useVisitor } from './ui/VisitorContext'
+import Avatar from './ui/Avatar'
+import { Toaster } from 'react-hot-toast'
/**
*
@@ -29,34 +29,34 @@ import { Toaster } from 'react-hot-toast';
*/
export default function App({ footer }) {
- let contentRef = useRef(null);
- const [cookie, setCookie] = useCookies(['hash']);
+ let contentRef = useRef(null)
+ const [cookie, setCookie] = useCookies(['hash'])
- const [allTrends, setAllTrends] = useState([]);
+ const [allTrends, setAllTrends] = useState([])
- const [visitor, setVisitor] = useVisitor();
+ const [visitor, setVisitor] = useVisitor()
- const params = useSearchParams();
+ const params = useSearchParams()
useEffect(() => {
- svg4everybody();
+ svg4everybody()
if (params['hash']) {
- setCookie('hash', params['hash'], { path: '/' });
- let retpath = params['retpath'] || `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
- window.history.replaceState({}, document.title, retpath);
+ setCookie('hash', params['hash'], { path: '/' })
+ let retpath = params['retpath'] || `${window.location.protocol}//${window.location.host}${window.location.pathname}`
+ window.history.replaceState({}, document.title, retpath)
}
- }, [setCookie, footer, params]);
+ }, [setCookie, footer, params])
let updateStatus = useCallback(() => {
// refresh server visitor state (unread counters)
me().then(visitor => {
- setVisitor(visitor);
- }).catch(console.error);
- }, [setVisitor]);
+ setVisitor(visitor)
+ }).catch(console.error)
+ }, [setVisitor])
- const [hash, setHash] = useState(cookie.hash);
+ const [hash, setHash] = useState(cookie.hash)
- const [eventSource, setEventSource] = /** @param EventSource? */ useState({});
+ const [eventSource, setEventSource] = /** @param EventSource? */ useState({})
/**
* @param {import("./api").SecureUser} visitor
@@ -64,53 +64,53 @@ export default function App({ footer }) {
let auth = useCallback((visitor) => {
setVisitor(prevState => {
if (visitor.hash != prevState.hash) {
- setHash(visitor.hash);
+ setHash(visitor.hash)
}
- return visitor;
- });
- }, [setVisitor]);
+ return visitor
+ })
+ }, [setVisitor])
useEffect(() => {
- let es;
+ let es
const anonymousUser = {
uid: 0
- };
+ }
if (hash) {
me().then(visitor => auth(visitor))
- .catch(() => setVisitor(anonymousUser));
+ .catch(() => setVisitor(anonymousUser))
if ('EventSource' in window) {
- const eventParams = new URLSearchParams({ hash: hash });
- let url = new URL(`https://juick.com/api/events?${eventParams.toString()}`);
- console.log(url.toString());
- es = new EventSource(url.toString());
+ const eventParams = new URLSearchParams({ hash: hash })
+ let url = new URL(`https://juick.com/api/events?${eventParams.toString()}`)
+ console.log(url.toString())
+ es = new EventSource(url.toString())
es.onopen = () => {
- console.log('online');
- };
+ console.log('online')
+ }
es.onerror = () => {
- es.removeEventListener('read', updateStatus);
- es.removeEventListener('msg', updateStatus);
- };
- es.addEventListener('read', updateStatus);
- es.addEventListener('msg', updateStatus);
- setEventSource(es);
+ es.removeEventListener('read', updateStatus)
+ es.removeEventListener('msg', updateStatus)
+ }
+ es.addEventListener('read', updateStatus)
+ es.addEventListener('msg', updateStatus)
+ setEventSource(es)
}
} else {
- setVisitor(anonymousUser);
+ setVisitor(anonymousUser)
}
return (() => {
if (es && es.removeEventListener) {
- es.removeEventListener('read', updateStatus);
- es.removeEventListener('msg', updateStatus);
+ es.removeEventListener('read', updateStatus)
+ es.removeEventListener('msg', updateStatus)
}
- });
- }, [auth, hash, setVisitor, updateStatus]);
+ })
+ }, [auth, hash, setVisitor, updateStatus])
useEffect(() => {
const getTrends = async () => {
- setAllTrends(await trends());
- };
- getTrends().catch(console.error);
- }, []);
+ setAllTrends(await trends())
+ }
+ getTrends().catch(console.error)
+ }, [])
return (
<>
@@ -200,5 +200,5 @@ export default function App({ footer }) {
>
- );
+ )
}
diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js
index ef753eaf..566478a9 100644
--- a/vnext/src/api/index.js
+++ b/vnext/src/api/index.js
@@ -1,7 +1,7 @@
-import axios from 'axios';
-import Cookies from 'universal-cookie';
+import axios from 'axios'
+import Cookies from 'universal-cookie'
-const apiBaseUrl = 'https://juick.com';
+const apiBaseUrl = 'https://juick.com'
/**
* @typedef {object} Token
@@ -73,17 +73,17 @@ const apiBaseUrl = 'https://juick.com';
const client = axios.create({
baseURL: apiBaseUrl
-});
+})
client.interceptors.request.use(config => {
if (config.url.startsWith('/')) {
// only local URLs
- let cookies = new Cookies();
+ let cookies = new Cookies()
config.params = Object.assign(config.params || {}, {
hash: cookies.get('hash')
- });
+ })
}
- return config;
-});
+ return config
+})
/**
* fetch my info
@@ -92,28 +92,28 @@ client.interceptors.request.use(config => {
* @returns {Promise} me object
*/
export function me(username = '', password = '') {
- let cookies = new Cookies();
+ let cookies = new Cookies()
return new Promise((resolve, reject) => {
client.get('/api/me', {
headers: username ? {
'Authorization': 'Basic ' + window.btoa(unescape(encodeURIComponent(username + ':' + password)))
} : {}
}).then(response => {
- let visitor = response.data;
- cookies.set('hash', visitor.hash, { path: '/' });
- resolve(visitor);
+ let visitor = response.data
+ cookies.set('hash', visitor.hash, { path: '/' })
+ resolve(visitor)
}).catch(reason => {
- cookies.remove('hash', { path: '/' });
- reject(reason);
- });
- });
+ cookies.remove('hash', { path: '/' })
+ reject(reason)
+ })
+ })
}
/**
* @param {string} username
*/
export function info(username) {
- return client.get(`/api/info/${username}`);
+ return client.get(`/api/info/${username}`)
}
@@ -121,7 +121,7 @@ export function info(username) {
*
*/
export function getChats() {
- return client.get('/api/groups_pms');
+ return client.get('/api/groups_pms')
}
/**
@@ -132,7 +132,7 @@ export function getChat(userName) {
params: {
'uname': userName
}
- });
+ })
}
/**
@@ -140,10 +140,10 @@ export function getChat(userName) {
* @param {string} body
*/
export function pm(userName, body) {
- let form = new FormData();
- form.set('uname', userName);
- form.set('body', body);
- return client.post('/api/pm', form);
+ let form = new FormData()
+ form.set('uname', userName)
+ form.set('body', body)
+ return client.post('/api/pm', form)
}
/**
@@ -153,7 +153,7 @@ export function pm(userName, body) {
export function getMessages(path, params) {
return client.get(path, {
params: params
- });
+ })
}
/**
@@ -161,10 +161,10 @@ export function getMessages(path, params) {
* @param {string} attach
*/
export function post(body, attach) {
- let form = new FormData();
- form.append('attach', attach);
- form.append('body', body);
- return client.post('/api/post', form);
+ let form = new FormData()
+ form.append('attach', attach)
+ form.append('body', body)
+ return client.post('/api/post', form)
}
/**
@@ -174,12 +174,12 @@ export function post(body, attach) {
* @param {string} attach
*/
export function comment(mid, rid, body, attach) {
- let form = new FormData();
- form.append('mid', mid.toString());
- form.append('rid', rid.toString());
- form.append('body', body);
- form.append('attach', attach);
- return client.post('/api/comment', form);
+ let form = new FormData()
+ form.append('mid', mid.toString())
+ form.append('rid', rid.toString())
+ form.append('body', body)
+ form.append('attach', attach)
+ return client.post('/api/comment', form)
}
/**
* Edit message
@@ -188,48 +188,48 @@ export function comment(mid, rid, body, attach) {
* @param {string?} body
*/
export function update(mid, rid, body) {
- let form = new FormData();
- form.append('mid', mid);
- form.append('rid', rid);
- form.append('body', body);
- return client.post('/api/update', form);
+ let form = new FormData()
+ form.append('mid', mid)
+ form.append('rid', rid)
+ form.append('body', body)
+ return client.post('/api/update', form)
}
/**
* Update user avatar
* @param {string} newAvatar
*/
export function updateAvatar(newAvatar) {
- let form = new FormData();
- form.append('avatar', newAvatar);
- return client.post('/api/me/upload', form);
+ let form = new FormData()
+ form.append('avatar', newAvatar)
+ return client.post('/api/me/upload', form)
}
/**
* @param {string} network
*/
function socialLink(network) {
- return `${apiBaseUrl}/api/_${network}login?state=${window.location.protocol}//${window.location.host}${window.location.pathname}`;
+ return `${apiBaseUrl}/api/_${network}login?state=${window.location.protocol}//${window.location.host}${window.location.pathname}`
}
/**
*
*/
export function facebookLink() {
- return socialLink('fb');
+ return socialLink('fb')
}
/**
*
*/
export function vkLink() {
- return socialLink('vk');
+ return socialLink('vk')
}
/**
*
*/
export function appleLink() {
- return socialLink('apple');
+ return socialLink('apple')
}
/**
@@ -237,10 +237,10 @@ export function appleLink() {
* @param {SecureUser} visitor
*/
export function markReadTracker(msg, visitor) {
- return `${apiBaseUrl}/api/thread/mark_read/${msg.mid}-${msg.rid || 0}.gif?hash=${visitor.hash}`;
+ return `${apiBaseUrl}/api/thread/mark_read/${msg.mid}-${msg.rid || 0}.gif?hash=${visitor.hash}`
}
-let profileCache = {};
+let profileCache = {}
/**
* Fetch user profile
@@ -249,18 +249,18 @@ let profileCache = {};
export function fetchUserUri(profileUrl) {
return new Promise((resolve, reject) => {
if (profileCache[profileUrl]) {
- resolve(profileCache[profileUrl]);
+ resolve(profileCache[profileUrl])
} else {
client.get(profileUrl, {
headers: {
'Accept': 'application/ld+json'
}
}).then(response => {
- profileCache[profileUrl] = response.data;
- resolve(response.data);
- }).catch(reject);
+ profileCache[profileUrl] = response.data
+ resolve(response.data)
+ }).catch(reject)
}
- });
+ })
}
/**
@@ -269,13 +269,13 @@ export function fetchUserUri(profileUrl) {
*/
export const trends = async () => {
try {
- const response = await client.get('/api/tags');
- return response.data;
+ const response = await client.get('/api/tags')
+ return response.data
} catch (e) {
- console.error(e);
- return [];
+ console.error(e)
+ return []
}
-};
+}
/**
* Fetch Tweet content
@@ -289,9 +289,9 @@ export function fetchUserUri(profileUrl) {
'omit_script': true,
'url': url
}
- });
- return response.data;
-};
+ })
+ return response.data
+}
/**
* Checks if HTTP error code is redirection code
@@ -299,7 +299,7 @@ export function fetchUserUri(profileUrl) {
* @returns {boolean} is HTTP request redirected or not
*/
function isHttpRedirected(code = 200) {
- return [301, 302].includes(code);
+ return [301, 302].includes(code)
}
/**
@@ -308,7 +308,7 @@ function isHttpRedirected(code = 200) {
* @returns {boolean} is HTTP request successful or not
*/
function isHttpSuccessful(code = 200) {
- return code >= 200 && code < 300;
+ return code >= 200 && code < 300
}
/**
@@ -323,25 +323,25 @@ function expandShortenedLink(url = '') {
}).then(response => {
if (isHttpSuccessful(response.status)) {
// URL is not redirected
- resolve(url);
- return;
+ resolve(url)
+ return
}
if (isHttpRedirected(response.status)) {
- resolve(/** @type { string } */ (response.headers['Location']));
- return;
+ resolve(/** @type { string } */ (response.headers['Location']))
+ return
}
// Error case
- reject('Invalid response');
+ reject('Invalid response')
}).catch(error => {
- reject(error);
- });
- });
+ reject(error)
+ })
+ })
}
export {
embeddedTweet,
expandShortenedLink
-};
+}
diff --git a/vnext/src/index.js b/vnext/src/index.js
index 11a78a48..5ab543c4 100644
--- a/vnext/src/index.js
+++ b/vnext/src/index.js
@@ -1,32 +1,32 @@
-import 'core-js/modules/es.array.map';
-import 'core-js/modules/es.map';
-import 'core-js/modules/es.object.create';
-import 'core-js/modules/es.object.define-property';
-import 'core-js/modules/es.object.set-prototype-of';
-import 'core-js/modules/es.promise';
-import 'core-js/modules/es.set';
-import 'core-js/modules/es.symbol';
-import 'core-js/modules/web.dom-collections.iterator';
-import 'url-polyfill';
-import { StrictMode, lazy } from 'react';
-import { createRoot, hydrateRoot } from 'react-dom/client';
-import { BrowserRouter } from 'react-router-dom';
-import { CookiesProvider } from 'react-cookie';
+import 'core-js/modules/es.array.map'
+import 'core-js/modules/es.map'
+import 'core-js/modules/es.object.create'
+import 'core-js/modules/es.object.define-property'
+import 'core-js/modules/es.object.set-prototype-of'
+import 'core-js/modules/es.promise'
+import 'core-js/modules/es.set'
+import 'core-js/modules/es.symbol'
+import 'core-js/modules/web.dom-collections.iterator'
+import 'url-polyfill'
+import { StrictMode, lazy } from 'react'
+import { createRoot, hydrateRoot } from 'react-dom/client'
+import { BrowserRouter } from 'react-router-dom'
+import { CookiesProvider } from 'react-cookie'
-import { VisitorProvider } from './ui/VisitorContext';
+import { VisitorProvider } from './ui/VisitorContext'
-const Juick = lazy(() => import('./App'));
+const Juick = lazy(() => import('./App'))
function fromBinary(encoded) {
- const binary = window.atob(encoded);
- const bytes = new Uint8Array(binary.length);
+ const binary = window.atob(encoded)
+ const bytes = new Uint8Array(binary.length)
for (let i = 0; i < bytes.length; i++) {
- bytes[i] = binary.charCodeAt(i);
+ bytes[i] = binary.charCodeAt(i)
}
- return String.fromCharCode(...new Uint16Array(bytes.buffer));
+ return String.fromCharCode(...new Uint16Array(bytes.buffer))
}
-const props = window.__PROPS__ ? JSON.parse(fromBinary(window.__PROPS__)) : {};
+const props = window.__PROPS__ ? JSON.parse(fromBinary(window.__PROPS__)) : {}
const JuickApp = () => (
@@ -38,11 +38,11 @@ const JuickApp = () => (
-);
+)
-let root = document.getElementById('app');
+let root = document.getElementById('app')
if (window.__PROPS__) {
- hydrateRoot(root, );
+ hydrateRoot(root, )
} else {
- createRoot(root).render();
+ createRoot(root).render()
}
diff --git a/vnext/src/ui/Avatar.js b/vnext/src/ui/Avatar.js
index 9d93521f..1a8db0c3 100644
--- a/vnext/src/ui/Avatar.js
+++ b/vnext/src/ui/Avatar.js
@@ -1,7 +1,7 @@
-import { memo } from 'react';
-import { Link } from 'react-router-dom';
+import { memo } from 'react'
+import { Link } from 'react-router-dom'
-import Icon from './Icon';
+import Icon from './Icon'
/**
* @typedef {object} AvatarProps
@@ -38,7 +38,7 @@ function Avatar({ user, style, link, children }) {
{children}
- );
+ )
}
-export default memo(Avatar);
+export default memo(Avatar)
diff --git a/vnext/src/ui/Button.js b/vnext/src/ui/Button.js
index 2c315e46..dd425021 100644
--- a/vnext/src/ui/Button.js
+++ b/vnext/src/ui/Button.js
@@ -1,4 +1,4 @@
-import { memo } from 'react';
+import { memo } from 'react'
/**
* @param {import('react').ClassAttributes