Skip to content
This repository was archived by the owner on May 11, 2023. It is now read-only.

Commit a7161f7

Browse files
committed
Performance fixes and bug fixes, Tip modal now defaults to 10 sats
1 parent 4448c70 commit a7161f7

File tree

8 files changed

+20
-33
lines changed

8 files changed

+20
-33
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXTEND_ESLINT=true

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
EXTEND_ESLINT=true
12
PEERS=['http://gun.shock.network:8765/gun']

.eslintrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
"eject": "react-scripts eject"
3434
},
3535
"eslintConfig": {
36-
"extends": "react-app"
36+
"extends": "react-app",
37+
"rules": {
38+
"react-hooks/exhaustive-deps": "warn",
39+
"array-callback-return": "off",
40+
"no-throw-literal": "off"
41+
}
3742
},
3843
"browserslist": {
3944
"production": [

src/components/Counter.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ const Counter = ({ value = 0 }) => {
77
const [counterAnimation, setCounterAnimation] = useState("initial");
88

99
useEffect(() => {
10-
console.log("Value changed!", value, currentValue);
1110
setTimeout(() => setCounterAnimation("goUp"), 0);
1211
setTimeout(() => setCurrentValue(value), 200);
1312
setTimeout(() => setCounterAnimation("waitDown"), 200);
1413
setTimeout(() => setCounterAnimation("initial"), 400);
15-
}, [value]);
14+
}, [currentValue, value]);
1615

1716
return (
1817
<div className="counter-container">

src/components/Post.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const Post = ({
5555
<div className="media-container" key={`${key}-${index}`}>
5656
<img
5757
className={`torrent-img-${id}-${key}`}
58+
alt="Post Media"
5859
data-torrent={item.magnetURI}
5960
data-file-key={index}
6061
key={key}
@@ -176,7 +177,7 @@ const Post = ({
176177
);
177178
}
178179
});
179-
}, [dispatch]);
180+
}, [dispatch, id, page, publicKey]);
180181

181182
useEffect(() => {
182183
if (!carouselAPI) return;
@@ -189,7 +190,7 @@ const Post = ({
189190
window.removeEventListener("keydown", handleUserKeyDown);
190191
carouselAPI.off("scroll", updateActiveSlide);
191192
};
192-
}, [carouselAPI, sliderLength]);
193+
}, [carouselAPI, sliderLength, handleUserKeyDown, updateActiveSlide]);
193194

194195
const tipPost = useCallback(() => {
195196
if (!isOnlineNode) {
@@ -200,7 +201,7 @@ const Post = ({
200201
targetType: "post",
201202
postID: id
202203
});
203-
}, [id]);
204+
}, [id, isOnlineNode, openTipModal]);
204205

205206
useEffect(() => {
206207
Tooltip.rebuild();

src/pages/User/index.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useEffect, useState, useCallback, Suspense } from "react";
22
import { useSelector, useDispatch } from "react-redux";
33
import { useParams } from "react-router-dom";
4-
import InfiniteScroll from "react-infinite-scroller";
54
import QRCode from "react-qr-code";
65
import Moment from "moment";
76

@@ -40,12 +39,13 @@ const UserPage = () => {
4039
const paymentRequest = useSelector(
4140
({ transaction }) => transaction.paymentRequest
4241
);
43-
// Reserved for future use @eslint-disable-next-line no-undef
42+
// Reserved for future use
43+
// eslint-disable-next-line no-unused-vars
4444
const [userLoading, setUserLoading] = useState(true);
4545
const [wallLoading, setWallLoading] = useState(true);
4646
const [tipModalOpen, setTipModalOpen] = useState(false);
4747
const [tipLoading, setTipLoading] = useState(false);
48-
const [tipAmount, setTipAmount] = useState(0);
48+
const [tipAmount, setTipAmount] = useState(10);
4949
const [isOnlineApp, setIsOnlineApp] = useState(false);
5050
const [isOnlineNode, setIsOnlineNode] = useState(false);
5151

@@ -85,22 +85,6 @@ const UserPage = () => {
8585
}
8686
}, [dispatch, publicKey]);
8787

88-
const loadMorePosts = useCallback(
89-
async page => {
90-
try {
91-
console.log("Setting Loading status to (loadMorePosts):", true);
92-
setWallLoading(true);
93-
const posts = await dispatch(getUserWall(publicKey, page));
94-
console.log("Setting Loading status to (loadMorePosts):", false, posts);
95-
setWallLoading(false);
96-
} catch (error) {
97-
console.log("Setting Loading status to (loadMorePosts):", false);
98-
setWallLoading(false);
99-
}
100-
},
101-
[dispatch, publicKey]
102-
);
103-
10488
const sendTip = useCallback(async () => {
10589
try {
10690
setTipLoading(true);
@@ -176,7 +160,7 @@ const UserPage = () => {
176160
displayNameListener.off();
177161
bioListener.off();
178162
};
179-
}, [fetchUserData]);
163+
}, [dispatch, fetchUserData, fetchUserWall, publicKey]);
180164

181165
useEffect(() => {
182166
const userWallInitializer = initializeUserWall();
@@ -186,7 +170,7 @@ const UserPage = () => {
186170

187171
useEffect(() => {
188172
attachMedia(wall.posts, false);
189-
}, [wall.posts.length]);
173+
}, [wall.posts]);
190174

191175
useEffect(() => {
192176
if (onlineCheckTimer) {
@@ -209,6 +193,7 @@ const UserPage = () => {
209193
setOnlineCheckTimer(timer);
210194

211195
return () => clearTimeout(onlineCheckTimer);
196+
// eslint-disable-next-line react-hooks/exhaustive-deps
212197
}, [profile]);
213198

214199
useEffect(() => {

src/utils/Torrents.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const attachMedia = (posts = [], torrentMode = true) => {
6464
options.formats.includes(extension)
6565
)[0];
6666
if (supportedFileType) {
67-
const [_, fileType] = supportedFileType;
67+
const [, fileType] = supportedFileType;
6868
const matched = fileType.formats.includes(extension);
6969
return matched;
7070
}

0 commit comments

Comments
 (0)