aboutsummaryrefslogtreecommitdiff
path: root/vnext
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-04-12 00:58:07 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:54 +0300
commit13653494f4a89d2a833b19ec0f3dc912eac96f25 (patch)
treec21d105c4d88c59613ac87e649404d9bceec7356 /vnext
parent65997943686cb65caf40218c5f7a0123ccb93935 (diff)
Fix hook dependencies warnings (some)
Diffstat (limited to 'vnext')
-rw-r--r--vnext/src/App.js2
-rw-r--r--vnext/src/components/Feeds.js55
2 files changed, 28 insertions, 29 deletions
diff --git a/vnext/src/App.js b/vnext/src/App.js
index b3d821e4..4e40f9f1 100644
--- a/vnext/src/App.js
+++ b/vnext/src/App.js
@@ -56,7 +56,7 @@ export default function App() {
es.removeEventListener('read', updateStatus);
};
setEs(es);
- }, []);
+ }, [visitor]);
let search = (history, pathname, searchString) => {
diff --git a/vnext/src/components/Feeds.js b/vnext/src/components/Feeds.js
index 5470874b..c7b857b7 100644
--- a/vnext/src/components/Feeds.js
+++ b/vnext/src/components/Feeds.js
@@ -77,35 +77,34 @@ function Feed(props) {
const [error, setError] = useState(false);
useEffect(() => {
+ let loadMessages = (hash = '', filter = '') => {
+ document.body.scrollTop = 0;
+ document.documentElement.scrollTop = 0;
+ setMsgs([]);
+ const filterParams = qs.parse(filter);
+ let params = Object.assign({}, filterParams || {}, props.query.search || {});
+ let url = props.query.baseUrl;
+ if (hash) {
+ params.hash = hash;
+ }
+ if (!params.hash && props.authRequired) {
+ props.history.push('/');
+ }
+ getMessages(url, params)
+ .then(response => {
+ const { data } = response;
+ const { pageParam } = props.query;
+ const lastMessage = data.slice(-1)[0] || {};
+ const nextpage = getPageParam(pageParam, lastMessage, filterParams);
+ setMsgs(data);
+ setLoading(false);
+ setNextpage(nextpage);
+ }).catch(ex => {
+ setError(true);
+ });
+ };
loadMessages(props.visitor.hash, props.location.search.substring(1));
- }, [props.visitor, props.location]);
-
- let loadMessages = (hash = '', filter = '') => {
- document.body.scrollTop = 0;
- document.documentElement.scrollTop = 0;
- setMsgs([]);
- const filterParams = qs.parse(filter);
- let params = Object.assign({}, filterParams || {}, props.query.search || {});
- let url = props.query.baseUrl;
- if (hash) {
- params.hash = hash;
- }
- if (!params.hash && props.authRequired) {
- props.history.push('/');
- }
- getMessages(url, params)
- .then(response => {
- const { data } = response;
- const { pageParam } = props.query;
- const lastMessage = data.slice(-1)[0] || {};
- const nextpage = getPageParam(pageParam, lastMessage, filterParams);
- setMsgs(data);
- setLoading(false);
- setNextpage(nextpage);
- }).catch(ex => {
- setError(true);
- });
- };
+ }, [props]);
let getPageParam = (pageParam, lastMessage, filterParams) => {
const pageValue = pageParam === 'before_mid' ? lastMessage.mid : pageParam === 'page' ? (Number(filterParams.page) || 0) + 1 : moment.utc(lastMessage.updated).valueOf();