mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-02 10:15:11 +00:00
fixes #3744 by allowing the user to navigate forward and backward using the respective mouse keys
This commit is contained in:
parent
ffd2c4f793
commit
119bda85dc
1 changed files with 27 additions and 1 deletions
|
@ -30,6 +30,10 @@ export const IS_MAC = process.platform === 'darwin';
|
||||||
// @endif
|
// @endif
|
||||||
const SYNC_INTERVAL = 1000 * 60 * 5; // 5 minutes
|
const SYNC_INTERVAL = 1000 * 60 * 5; // 5 minutes
|
||||||
|
|
||||||
|
// button numbers pulled from https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
||||||
|
const MOUSE_BACK_BTN = 3;
|
||||||
|
const MOUSE_FORWARD_BTN = 4;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
alertError: (string | {}) => void,
|
alertError: (string | {}) => void,
|
||||||
pageTitle: ?string,
|
pageTitle: ?string,
|
||||||
|
@ -38,7 +42,13 @@ type Props = {
|
||||||
theme: string,
|
theme: string,
|
||||||
user: ?{ id: string, has_verified_email: boolean, is_reward_approved: boolean },
|
user: ?{ id: string, has_verified_email: boolean, is_reward_approved: boolean },
|
||||||
location: { pathname: string, hash: string, search: string },
|
location: { pathname: string, hash: string, search: string },
|
||||||
history: { push: string => void },
|
history: {
|
||||||
|
goBack: () => void,
|
||||||
|
goForward: () => void,
|
||||||
|
index: number,
|
||||||
|
length: number,
|
||||||
|
push: string => void,
|
||||||
|
},
|
||||||
fetchTransactions: (number, number) => void,
|
fetchTransactions: (number, number) => void,
|
||||||
fetchAccessToken: () => void,
|
fetchAccessToken: () => void,
|
||||||
fetchChannelListMine: () => void,
|
fetchChannelListMine: () => void,
|
||||||
|
@ -127,6 +137,22 @@ function App(props: Props) {
|
||||||
return () => window.removeEventListener('beforeunload', handleBeforeUnload);
|
return () => window.removeEventListener('beforeunload', handleBeforeUnload);
|
||||||
}, [uploadCount]);
|
}, [uploadCount]);
|
||||||
|
|
||||||
|
// allows user to navigate history using the forward and backward buttons on a mouse
|
||||||
|
useEffect(() => {
|
||||||
|
const handleForwardAndBackButtons = e => {
|
||||||
|
switch (e.button) {
|
||||||
|
case MOUSE_BACK_BTN:
|
||||||
|
history.index > 0 && history.goBack();
|
||||||
|
break;
|
||||||
|
case MOUSE_FORWARD_BTN:
|
||||||
|
history.index < history.length - 1 && history.goForward();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.addEventListener('mouseup', handleForwardAndBackButtons);
|
||||||
|
return () => window.removeEventListener('mouseup', handleForwardAndBackButtons);
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (referredRewardAvailable && sanitizedReferrerParam && isRewardApproved) {
|
if (referredRewardAvailable && sanitizedReferrerParam && isRewardApproved) {
|
||||||
setReferrer(sanitizedReferrerParam, true);
|
setReferrer(sanitizedReferrerParam, true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue