diff --git a/CHANGELOG.md b/CHANGELOG.md index c2b32f083..e4467558b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Support drag-and-drop file publishing _community pr!_ ([#4170](https://github.com/lbryio/lbry-desktop/pull/4170)) - Add advanced editor for comments _community pr!_ ([#4224](https://github.com/lbryio/lbry-desktop/pull/4224)) - Paid content improvements ([#4234](https://github.com/lbryio/lbry-desktop/pull/4234)) +- Add status-bar to display a link's destination _community pr!_ ([#4259](https://github.com/lbryio/lbry-desktop/pull/4259)) ### Changed @@ -27,7 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Channel selector alignment on creator analytics page _community pr!_ ([#4157](https://github.com/lbryio/lbry-desktop/pull/4157)) -- Fix inconsistent relative-date string for claims, comments, etc. ([#4172](https://github.com/lbryio/lbry-desktop/pull/4172)) +- Fix inconsistent relative-date string for claims, comments, etc. _community pr!_ ([#4172](https://github.com/lbryio/lbry-desktop/pull/4172)) - Error opening certain files with special characters in name #2777 _community pr!_ ([#4161](https://github.com/lbryio/lbry-desktop/pull/4161)) - Comic-book file page shows download button first, and then viewer after download _community pr!_ ([#4161](https://github.com/lbryio/lbry-desktop/pull/4161)) - Only show "start at" on share modal for video/audio _community pr!_ ([#4194](https://github.com/lbryio/lbry-desktop/pull/4194)) diff --git a/electron/createWindow.js b/electron/createWindow.js index 39a3d1d54..f8cb129f1 100644 --- a/electron/createWindow.js +++ b/electron/createWindow.js @@ -164,5 +164,17 @@ export default appState => { shell.openExternal(url); }); + window.webContents.on('update-target-url', (event, url) => { + // Change internal links to the lbry protocol. External (https) links should remain unchanged. + let dispUrl = url.replace(`http://localhost:${WEBPACK_ELECTRON_PORT}/`, lbryProto); + // Non-claims don't need the lbry protocol: + if (dispUrl === lbryProto) { + dispUrl = 'Home'; + } else if (dispUrl.startsWith(lbryProto + '$/')) { + dispUrl = dispUrl.replace(lbryProto, '/'); + } + window.webContents.send('update-target-url', dispUrl); + }); + return window; }; diff --git a/ui/component/common/status-bar.jsx b/ui/component/common/status-bar.jsx new file mode 100644 index 000000000..1bd607a9b --- /dev/null +++ b/ui/component/common/status-bar.jsx @@ -0,0 +1,48 @@ +// @flow +import React from 'react'; +import { ipcRenderer } from 'electron'; +import classnames from 'classnames'; + +type Props = {}; + +type State = { + hoverUrl: string, + show: boolean, +}; + +class StatusBar extends React.PureComponent { + constructor() { + super(); + this.state = { + hoverUrl: '', + show: false, + }; + (this: any).handleUrlChange = this.handleUrlChange.bind(this); + } + + componentDidMount() { + ipcRenderer.on('update-target-url', this.handleUrlChange); + } + + componentWillUnmount() { + ipcRenderer.removeListener('update-target-url', this.handleUrlChange); + } + + handleUrlChange(event: any, url: string) { + // We want to retain the previous URL so that it can fade out + // without the component collapsing. + if (url === '') { + this.setState({ show: false }); + } else { + this.setState({ show: true }); + this.setState({ hoverUrl: url }); + } + } + + render() { + const { hoverUrl, show } = this.state; + return
{hoverUrl}
; + } +} + +export default StatusBar; diff --git a/ui/component/page/view.jsx b/ui/component/page/view.jsx index a887bb5f2..a43aa0037 100644 --- a/ui/component/page/view.jsx +++ b/ui/component/page/view.jsx @@ -5,6 +5,9 @@ import classnames from 'classnames'; import SideNavigation from 'component/sideNavigation'; import Header from 'component/header'; import Footer from 'web/component/footer'; +/* @if TARGET='app' */ +import StatusBar from 'component/common/status-bar'; +/* @endif */ export const MAIN_CLASS = 'main'; type Props = { @@ -27,6 +30,9 @@ function Page(props: Props) {
{children}
{!authPage && !noSideNavigation && } + {/* @if TARGET='app' */} + + {/* @endif */}
{/* @if TARGET='web' */} {!noFooter &&