Compare commits

...

10 Commits

Author SHA1 Message Date
DispatchCommit
d56689f11c create watchman plugin
create skeleton boilerplate
add plugin logic
2021-07-31 09:33:13 -07:00
Thomas Zarebczan
b5fec393c6 Fix crash 2021-07-31 11:08:15 -04:00
zeppi
b93caf4ebc fix logo image 2021-07-30 12:12:58 -04:00
Baltazar Gomez
9dd065a595 update lighthouse search api 2021-07-30 11:47:28 -04:00
Baltazar Gomez
172701aeba add server api to config 2021-07-30 11:47:28 -04:00
Baltazar Gomez
95c7d4f935 add search api to .env defaults 2021-07-30 11:47:28 -04:00
saltrafael
a9a0bc9462 Change warning 2021-07-30 10:24:04 -04:00
saltrafael
87ae041472 Add confirmation on comment removal 2021-07-30 10:24:04 -04:00
Baltazar Gomez
415a522805 fix notification menu button styles 2021-07-30 00:11:18 -07:00
btzr-io
fa1b1737bb fix inconsistent theme css vars: fixes #6738 2021-07-29 22:26:26 -07:00
21 changed files with 291 additions and 21 deletions

View File

@@ -12,6 +12,7 @@ LBRY_WEB_API=https://api.na-backend.odysee.com
LBRY_WEB_STREAMING_API=https://cdn.lbryplayer.xyz
LBRY_WEB_BUFFER_API=https://collector-service.api.lbry.tv/api/v1/events/video
COMMENT_SERVER_API=https://comments.odysee.com/api/v2
SEARCH_SERVER_API=https://lighthouse.odysee.com/search
THUMBNAIL_CDN_URL=https://image-processor.vanwanet.com/optimize/
WELCOME_VERSION=1.0

View File

@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Show currently active playing item on playlist _community pr!_ ([#6453](https://github.com/lbryio/lbry-desktop/pull/6453))
- Add watch later to hover action for last used playlist on popup _community pr!_ ([#6274](https://github.com/lbryio/lbry-desktop/pull/6274))
- Open in desktop (web feature) _community pr!_ ([#6667](https://github.com/lbryio/lbry-desktop/pull/6667))
- Add confirmation on comment removal _community pr!_ ([#6563](https://github.com/lbryio/lbry-desktop/pull/6563))
### Changed
- Use Canonical Url for copy link ([#6500](https://github.com/lbryio/lbry-desktop/pull/6500))

View File

@@ -13,6 +13,7 @@ const config = {
LBRY_API_URL: process.env.LBRY_API_URL, //api.lbry.com',
LBRY_WEB_STREAMING_API: process.env.LBRY_WEB_STREAMING_API, //cdn.lbryplayer.xyz',
LBRY_WEB_BUFFER_API: process.env.LBRY_WEB_BUFFER_API,
SEARCH_SERVER_API: process.env.SEARCH_SERVER_API,
COMMENT_SERVER_API: process.env.COMMENT_SERVER_API,
WELCOME_VERSION: process.env.WELCOME_VERSION,
DOMAIN: process.env.DOMAIN,

View File

@@ -120,7 +120,7 @@ function ClaimPreviewTile(props: Props) {
const signingChannel = claim && claim.signing_channel;
const isChannel = claim && claim.value_type === 'channel';
const channelUri = !isChannel ? signingChannel && signingChannel.permanent_url : claim && claim.permanent_url;
const channelTitle = signingChannel && (signingChannel.value.title || signingChannel.name);
const channelTitle = signingChannel && ((signingChannel.value && signingChannel.value.title) || signingChannel.name);
// Aria-label value for claim preview
let ariaLabelData = isChannel ? title : formatClaimPreviewTitle(title, channelTitle, date, mediaDuration);

View File

@@ -270,6 +270,7 @@ function Comment(props: Props) {
authorUri={authorUri}
commentIsMine={commentIsMine}
handleEditComment={handleEditComment}
supportAmount={supportAmount}
/>
</Menu>
</div>

View File

@@ -1,7 +1,6 @@
import { connect } from 'react-redux';
import { makeSelectChannelPermUrlForClaimUri, makeSelectClaimIsMine, makeSelectClaimForUri } from 'lbry-redux';
import {
doCommentAbandon,
doCommentPin,
doCommentModBlock,
doCommentModBlockAsAdmin,
@@ -10,6 +9,7 @@ import {
} from 'redux/actions/comments';
import { doChannelMute } from 'redux/actions/blocked';
// import { doSetActiveChannel } from 'redux/actions/app';
import { doOpenModal } from 'redux/actions/app';
import { doSetPlayingUri } from 'redux/actions/content';
import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectPlayingUri } from 'redux/selectors/content';
@@ -26,8 +26,8 @@ const select = (state, props) => ({
});
const perform = (dispatch) => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
deleteComment: (commentId, creatorChannelUrl) => dispatch(doCommentAbandon(commentId, creatorChannelUrl)),
muteChannel: (channelUri) => dispatch(doChannelMute(channelUri)),
pinComment: (commentId, claimId, remove) => dispatch(doCommentPin(commentId, claimId, remove)),
// setActiveChannel: channelId => dispatch(doSetActiveChannel(channelId)),

View File

@@ -1,5 +1,6 @@
// @flow
import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
import React from 'react';
import { MenuList, MenuItem } from '@reach/menu-button';
import ChannelThumbnail from 'component/channelThumbnail';
@@ -12,7 +13,6 @@ type Props = {
authorUri: string, // full LBRY Channel URI: lbry://@channel#123...
commentId: string, // sha256 digest identifying the comment
commentIsMine: boolean, // if this comment was signed by an owned channel
deleteComment: (string, ?string) => void,
isPinned: boolean,
pinComment: (string, string, boolean) => Promise<any>,
muteChannel: (string) => void,
@@ -28,6 +28,8 @@ type Props = {
disableEdit?: boolean,
disableRemove?: boolean,
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
openModal: (id: string, {}) => void,
supportAmount?: any,
};
function CommentMenuList(props: Props) {
@@ -36,7 +38,6 @@ function CommentMenuList(props: Props) {
authorUri,
commentIsMine,
commentId,
deleteComment,
muteChannel,
pinComment,
clearPlayingUri,
@@ -53,6 +54,8 @@ function CommentMenuList(props: Props) {
disableEdit,
disableRemove,
moderationDelegatorsById,
openModal,
supportAmount,
} = props;
const contentChannelClaim = !claim
@@ -80,7 +83,7 @@ function CommentMenuList(props: Props) {
if (playingUri && playingUri.source === 'comment') {
clearPlayingUri();
}
deleteComment(commentId, commentIsMine ? undefined : contentChannelPermanentUrl);
openModal(MODALS.CONFIRM_REMOVE_COMMENT, { commentId, commentIsMine, contentChannelPermanentUrl, supportAmount });
}
function handleCommentBlock() {

View File

@@ -26,12 +26,12 @@ export default function Logo(props: Props) {
);
if (type === 'small' || (isMobile && type !== 'embed')) {
return LOGO ? <img src={LOGO} /> : <Icon icon={ICONS.LBRY} />;
return LOGO ? <img className={'header__navigation-logo'} src={LOGO} /> : <Icon icon={ICONS.LBRY} />;
} else if (type === 'embed') {
if (LOGO_TEXT_LIGHT) {
return (
<>
<img src={LOGO_TEXT_LIGHT} />
<img className={'header__navigation-logo'} src={LOGO_TEXT_LIGHT} />
</>
);
} else {
@@ -41,7 +41,10 @@ export default function Logo(props: Props) {
if (LOGO_TEXT_LIGHT && LOGO_TEXT_DARK) {
return (
<>
<img src={currentTheme === 'light' ? LOGO_TEXT_DARK : LOGO_TEXT_LIGHT} />
<img
className={'header__navigation-logo'}
src={currentTheme === 'light' ? LOGO_TEXT_DARK : LOGO_TEXT_LIGHT}
/>
</>
);
} else {

View File

@@ -193,7 +193,7 @@ export default function Notification(props: Props) {
<div className="notification__menu">
<Menu>
<MenuButton className={'menu-button notification__menu-button'} onClick={(e) => e.stopPropagation()}>
<MenuButton className={'menu__button notification__menu-button'} onClick={(e) => e.stopPropagation()}>
<Icon size={18} icon={ICONS.MORE_VERTICAL} />
</MenuButton>
<MenuList className="menu__list">

View File

@@ -0,0 +1,192 @@
// Created by xander on 7/10/2021
import videojs from 'video.js';
const VERSION = '0.0.1';
const watchmanEndpoint = 'https://watchman.na-backend.dev.odysee.com';
let previousEventTime = Date.now();
/* Watchman */
function createWatchmanData(
url,
duration,
position,
relPosition,
rebufCount,
rebufDuration,
format,
player,
userId,
device
) {
return {
url: url,
duration: duration,
rel_position: relPosition,
rebuf_count: rebufCount,
rebuf_duration: rebufDuration,
format: format,
player: player,
user_id: userId,
device: device,
};
}
function sendWatchmanData(watchmanData) {
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'text/plain' }, // application/json
body: JSON.stringify(watchmanData),
};
try {
fetch(watchmanEndpoint, requestOptions)
.then((response) => response.json())
.then((data) => {
// Response data
});
} catch (error) {
// Response error
}
}
// Plugin default options
const defaults = {
endpoint: watchmanEndpoint,
reportRate: 15,
videoUrl: null,
userId: 0,
debug: false,
};
const Component = videojs.getComponent('Component');
const registerPlugin = videojs.registerPlugin || videojs.plugin;
class WatchmanPlugin extends Component {
constructor(player, options) {
super(player, options);
// Plugin started
if (options.debug) {
this.log(`Created watchman plugin for: videoUrl:${options.videoUrl}, userId:${options.userId}`);
}
// Plugin variables
this.player = player;
this.loadedAt = Date.now();
this.watchmanIntervalId = null;
this.bufferEventData = [];
// Plugin event listeners
player.on('tracking:firstplay', (event, data) => this.onTrackingFirstPlay(event, data));
player.on('tracking:buffered', (event, data) => this.onTrackingBuffered(event, data));
// Event trigger to send recsys event
player.on('dispose', (event) => this.onDispose(event));
}
sendWatchmanData() {
const processedData = this.bufferEventData.reduce((accumulator, current) => {
return {
secondsToLoad: accumulator.secondsToLoad + current.secondsToLoad,
bufferCount: accumulator.bufferCount + current.bufferCount,
};
}, {
secondsToLoad: 0,
bufferCount: 0,
});
const timeSinceLastEvent = Date.now() - previousEventTime;
previousEventTime = Date.now();
const currentTime = this.player.currentTime();
const totalTime = this.player.duration();
const event = createWatchmanData(
null,
timeSinceLastEvent,
currentTime,
currentTime / totalTime,
processedData.bufferCount,
processedData.secondsToLoad * 1000,
this.player.currentSource().type,
null,
null,
null,
);
console.log('[watchman] Data Payload', event);
// sendWatchmanData(event);
}
onTrackingFirstPlay(event, data) {
// data attr: secondsToLoad
console.log(`[watchman] First Play Data:`, data);
// Start analytics interval here
this.watchmanIntervalId = setInterval(() => this.onWatchmanInterval(), this.options_.reportRate * 1000);
}
onTrackingBuffered(event, data) {
const duration = this.player.duration();
const reportData = {
...data,
relativePosition: data.currentTime / duration,
};
// data attr: currentTime, readyState, secondsToLoad, bufferCount
console.log(`[watchman] Buffer Data:`, reportData);
this.bufferEventData.push(data);
}
onWatchmanInterval() {
// don't report while player is paused
if (this.player.paused()) return;
// process and send watchman data here
console.log('[watchman] interval', this.bufferEventData);
this.sendWatchmanData();
// clear processed data
this.bufferEventData = [];
}
onDispose(event) {
// Stop analytics interval
clearInterval(this.watchmanIntervalId);
}
log(...args) {
if (this.options_.debug) {
console.log(`[watchman] Debug:`, JSON.stringify(args));
}
}
}
videojs.registerComponent('watchman', WatchmanPlugin);
const onPlayerReady = (player, options) => {
player.recsys = new WatchmanPlugin(player, options);
};
/**
* Initialize the plugin.
*
* @function plugin
* @param {Object} [options={}]
*/
const plugin = function(options) {
this.ready(() => {
onPlayerReady(this, videojs.mergeOptions(defaults, options));
});
};
plugin.VERSION = VERSION;
registerPlugin('watchman', plugin);
export default plugin;

View File

@@ -46,3 +46,4 @@ export const CONFIRM_REMOVE_BTC_SWAP_ADDRESS = 'confirm_remove_btc_swap_address'
export const COLLECTION_ADD = 'collection_add';
export const COLLECTION_DELETE = 'collection_delete';
export const CONFIRM_REMOVE_CARD = 'CONFIRM_REMOVE_CARD';
export const CONFIRM_REMOVE_COMMENT = 'CONFIRM_REMOVE_COMMENT';

View File

@@ -0,0 +1,11 @@
import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app';
import ModalRemoveComment from './view';
import { doCommentAbandon } from 'redux/actions/comments';
const perform = (dispatch) => ({
closeModal: () => dispatch(doHideModal()),
deleteComment: (commentId, creatorChannelUrl) => dispatch(doCommentAbandon(commentId, creatorChannelUrl)),
});
export default connect(null, perform)(ModalRemoveComment);

View File

@@ -0,0 +1,51 @@
// @flow
import React from 'react';
import { Modal } from 'modal/modal';
import Button from 'component/button';
import Card from 'component/common/card';
type Props = {
commentId: string, // sha256 digest identifying the comment
commentIsMine: boolean, // if this comment was signed by an owned channel
contentChannelPermanentUrl: any,
closeModal: () => void,
deleteComment: (string, ?string) => void,
supportAmount?: any,
};
function ModalRemoveComment(props: Props) {
const { commentId, commentIsMine, contentChannelPermanentUrl, closeModal, deleteComment, supportAmount } = props;
return (
<Modal isOpen contentLabel={__('Confirm Comment Deletion')} type="card" onAborted={closeModal}>
<Card
title={__('Remove Comment')}
body={
<React.Fragment>
<p>{__('Are you sure you want to remove this comment?')}</p>
{Boolean(supportAmount) && (
<p className="help error__text"> {__('This comment has a tip associated with it which cannot be reverted.')}</p>
)}
</React.Fragment>
}
actions={
<>
<div className="section__actions">
<Button
button="primary"
label={__('Remove')}
onClick={() => {
deleteComment(commentId, commentIsMine ? undefined : contentChannelPermanentUrl);
closeModal();
}}
/>
<Button button="link" label={__('Cancel')} onClick={closeModal} />
</div>
</>
}
/>
</Modal>
);
}
export default ModalRemoveComment;

View File

@@ -30,6 +30,7 @@ const ModalPublish = lazyImport(() => import('modal/modalPublish' /* webpackChun
const ModalPublishPreview = lazyImport(() => import('modal/modalPublishPreview' /* webpackChunkName: "modalPublishPreview" */));
const ModalRemoveBtcSwapAddress = lazyImport(() => import('modal/modalRemoveBtcSwapAddress' /* webpackChunkName: "modalRemoveBtcSwapAddress" */));
const ModalRemoveCard = lazyImport(() => import('modal/modalRemoveCard' /* webpackChunkName: "modalRemoveCard" */));
const ModalRemoveComment = lazyImport(() => import('modal/modalRemoveComment' /* webpackChunkName: "modalRemoveComment" */));
const ModalRemoveFile = lazyImport(() => import('modal/modalRemoveFile' /* webpackChunkName: "modalRemoveFile" */));
const ModalRevokeClaim = lazyImport(() => import('modal/modalRevokeClaim' /* webpackChunkName: "modalRevokeClaim" */));
const ModalRewardCode = lazyImport(() => import('modal/modalRewardCode' /* webpackChunkName: "modalRewardCode" */));
@@ -154,6 +155,8 @@ function ModalRouter(props: Props) {
return ModalDeleteCollection;
case MODALS.CONFIRM_REMOVE_CARD:
return ModalRemoveCard;
case MODALS.CONFIRM_REMOVE_COMMENT:
return ModalRemoveComment;
default:
return null;
}

View File

@@ -5,7 +5,7 @@ import { buildURI, doResolveUris, batchActions, isURIValid, makeSelectClaimForUr
import { makeSelectSearchUris, selectSearchValue } from 'redux/selectors/search';
import handleFetchResponse from 'util/handle-fetch';
import { getSearchQueryString } from 'util/query-params';
import { SIMPLE_SITE } from 'config';
import { SIMPLE_SITE, SEARCH_SERVER_API } from 'config';
type Dispatch = (action: any) => any;
type GetState = () => { search: SearchState };
@@ -19,7 +19,7 @@ type SearchOptions = {
};
let lighthouse = {
CONNECTION_STRING: 'https://lighthouse.lbry.com/search',
CONNECTION_STRING: SEARCH_SERVER_API,
search: (queryString: string) => fetch(`${lighthouse.CONNECTION_STRING}?${queryString}`).then(handleFetchResponse),
};

View File

@@ -71,6 +71,11 @@
display: flex;
}
.header__navigation-logo {
height: var(--height-button);
max-width: fit-content;
}
.header__navigation-item {
height: var(--height-button);
display: flex;

View File

@@ -51,10 +51,7 @@
padding: 0.3rem;
.icon {
stroke: var(--color-menu);
}
.comment__menu-icon--hovering {
stroke: var(--color-menu-icon);
}
&:focus,
@@ -62,7 +59,7 @@
opacity: 1;
background-color: var(--color-button-alt-bg);
.icon {
stroke: var(--color-menu-hovering);
stroke: var(--color-menu-icon-active);
}
}
}

View File

@@ -124,8 +124,7 @@
--color-menu-background: var(--color-header-background);
--color-menu-background--active: var(--color-card-background-highlighted);
--color-menu-icon: var(--color-navigation-link);
--color-menu: var(--color-gray-3);
--color-menu-hovering: var(--color-gray-6);
--color-menu-icon-active: var(--color-gray-6);
// Comments
--color-comment-highlighted: #fff2d9;

View File

@@ -90,8 +90,7 @@
--color-menu-background: var(--color-header-background);
--color-menu-background--active: var(--color-gray-7);
--color-menu-icon: var(--color-gray-4);
--color-menu: var(--color-gray-5);
--color-menu-hovering: var(--color-gray-2);
--color-menu-icon-active: var(--color-gray-2);
// Comments
--color-comment-threadline: #434b54;

View File

@@ -90,6 +90,7 @@
--color-menu-background: var(--color-header-background);
--color-menu-background--active: var(--color-gray-7);
--color-menu-icon: var(--color-gray-4);
--color-menu-icon-active: var(--color-gray-2);
// Comments
--color-comment-menu: var(--color-gray-5);

View File

@@ -124,6 +124,7 @@
--color-menu-background: var(--color-header-background);
--color-menu-background--active: var(--color-card-background-highlighted);
--color-menu-icon: var(--color-navigation-link);
--color-menu-icon-active: var(--color-navigation-link);
// Comments
--color-comment-menu: var(--color-gray-3);