Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
merge branch develop into master

See merge request hive/condenser!396
  • Loading branch information
Gandalf-the-Grey committed Nov 5, 2023
2 parents 80a8acf + 20e8fee commit a6e742e
Show file tree
Hide file tree
Showing 14 changed files with 807 additions and 286 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
Expand All @@ -25,12 +25,12 @@ jobs:
uses: actions/checkout@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"helmet": {
"directives": {
"childSrc": "'self' 3speak.tv emb.d.tube player.twitch.tv www.youtube.com staticxx.facebook.com w.soundcloud.com player.vimeo.com",
"connectSrc": "https://images.hive.blog 'self' hive.blog https://api.hive.blog api.blocktrades.us https://anyx.io https://hivesigner.com https://hivebuzz.me https://peakd.com https://api.deathwing.me https://www.reddit.com https://gist.github.com https://rpc.ausbit.dev https://api.ha.deathwing.me *.ibytedtos.com wss://hive-auth.arcange.eu https://hiveposh.com/api/",
"connectSrc": "https://images.hive.blog 'self' hive.blog https://api.hive.blog api.blocktrades.us https://anyx.io https://hivesigner.com https://hivebuzz.me https://peakd.com https://api.deathwing.me https://www.reddit.com https://gist.github.com https://rpc.ausbit.dev https://api.ha.deathwing.me *.ibytedtos.com wss://hive-auth.arcange.eu https://hiveposh.com/api/ https://api.hive-engine.com",
"defaultSrc": "'self' img.3speakcontent.online emb.d.tube www.youtube.com staticxx.facebook.com player.vimeo.com *.streamrail.com",
"fontSrc": "data: fonts.gstatic.com cdn.embedly.com",
"frameAncestors": "'none'",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
"@babel/runtime": "^7.12.5",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@hive-engine/sscjs": "^0.0.9",
"@hiveio/hive-js": "^2.0.4",
"@hiveio/hivescript": "^1.2.9",
"@mui/icons-material": "^5.11.9",
"@mui/material": "^5.11.10",
"@quochuync/remarkable-spoiler": "^1.3.0",
"@quochuync/remarkable-spoiler": "^1.4.0",
"@steem/crypto-session": "git+https://github.com/steemit/crypto-session.git#83a90b319ce5bc6a70362d52a15a815de7e729bb",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
Expand Down
438 changes: 438 additions & 0 deletions src/app/assets/images/nft-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
432 changes: 224 additions & 208 deletions src/app/components/cards/UserProfileHeader.jsx

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions src/app/components/elements/PostCategoryBanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import { actions as fetchDataSagaActions } from 'app/redux/FetchDataSaga';
class PostCategoryBanner extends React.Component {
constructor(props) {
super(props);
const { category } = props;

this.state = {
postDestination: category,
};

const { username, subscriptions, getAccountSubscriptions } = props;

Expand All @@ -20,11 +15,9 @@ class PostCategoryBanner extends React.Component {
}

render() {
const { subscriptions, onChange } = this.props;
const { postDestination } = this.state;
const { subscriptions, onChange, category } = this.props;
const onCommunitySelected = (e) => {
const destination = e.target.value;
this.setState({ postDestination: destination });
onChange(destination);
};

Expand All @@ -36,7 +29,7 @@ class PostCategoryBanner extends React.Component {
{' '}
<select
className="PostCategoryBanner--community-selector"
value={postDestination || ''}
value={category || ''}
onChange={onCommunitySelected}
>
<option value="blog">My blog</option>
Expand Down
104 changes: 61 additions & 43 deletions src/app/components/elements/ReplyEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class ReplyEditor extends React.Component {
postTemplateName: PropTypes.string,
maxAcceptedPayout: PropTypes.number,
isStory: PropTypes.bool,
community: PropTypes.string,
};

static defaultProps = {
Expand All @@ -83,6 +84,7 @@ class ReplyEditor extends React.Component {
parent_permlink: '',
type: 'submit_comment',
maxAcceptedPayout: null,
community: 'blog',
};

constructor(props) {
Expand Down Expand Up @@ -110,45 +112,39 @@ class ReplyEditor extends React.Component {
}
}

componentDidUpdate() {
componentDidUpdate(prevProps, prevState, snapshot) {
const { formId } = this.props;
let raw = null;

// Only need to do it on first time to load drafts etc...
// This also prevents infinite rerender due to the use of setState below
if (this.state.initialized === true) {
return;
}

if (process.env.BROWSER) {
// Check for rte editor preference
let rte = this.props.isStory && JSON.parse(localStorage.getItem('replyEditorData-rte') || RTE_DEFAULT);
let raw = null;

const loadDraft = (draft) => {
// Process initial body value (if this is an edit)
const { body } = this.state;
if (body.value) {
raw = body.value;
}
// Check for rte editor preference
let rte = this.props.isStory && JSON.parse(localStorage.getItem('replyEditorData-rte') || RTE_DEFAULT);

// Check for draft data
let draft = localStorage.getItem('replyEditorData-' + formId);
let postCommunity;
if (draft) {
draft = JSON.parse(draft);
const {
tags, title, summary, altAuthor,
tags, title, summary, altAuthor, community,
} = this.state;
postCommunity = community;

if (tags) {
this.checkTagsCommunity(draft.tags);
tags.props.onChange(draft.tags);
}

if (title) title.props.onChange(draft.title);
if (summary) summary.props.onChange(draft.summary);
if (altAuthor) altAuthor.props.onChange(draft.altAuthor);
if (draft.title) title.props.onChange(draft.title);
if (draft.summary) summary.props.onChange(draft.summary);
if (draft.altAuthor) altAuthor.props.onChange(draft.altAuthor);
if (draft.payoutType) this.props.setPayoutType(formId, draft.payoutType);
if (draft.maxAcceptedPayout) this.props.setMaxAcceptedPayout(formId, draft.maxAcceptedPayout);
if (draft.beneficiaries) this.props.setBeneficiaries(formId, draft.beneficiaries);
if (draft.community) postCommunity = draft.community;

raw = draft.body;
}

Expand All @@ -157,13 +153,34 @@ class ReplyEditor extends React.Component {
rte = isHtmlTest(raw);
}

// console.log("initial reply body:", raw || '(empty)')
body.props.onChange(raw);
// eslint-disable-next-line react/no-did-update-set-state
this.setState({
rte,
rte_value: rte ? stateFromHtml(raw) : null,
...(postCommunity && { community: postCommunity }),
});
};

if (snapshot && 'template' in snapshot) {
let draft;
if (snapshot.template) {
draft = snapshot.template;
}

loadDraft(draft);
this.props.setPostTemplateName(formId, null);
}

// Only need to do it on first time to load drafts etc...
// This also prevents infinite rerender due to the use of setState below
if (this.state.initialized === true) {
return;
}

if (process.env.BROWSER) {
const draft = localStorage.getItem('replyEditorData-' + formId);
loadDraft(JSON.parse(draft));
}

// Overwrite category (even if draft loaded) if authoritative category was provided
Expand All @@ -180,7 +197,7 @@ class ReplyEditor extends React.Component {
if (
this.props.defaultBeneficiaries
&& this.props.defaultBeneficiaries.toArray().length > 0
&& this.props.referralSystem != 'disabled'
&& this.props.referralSystem !== 'disabled'
) {
this.props.defaultBeneficiaries.toArray().forEach((element) => {
const label = element.get('label');
Expand Down Expand Up @@ -246,12 +263,10 @@ class ReplyEditor extends React.Component {
const np = this.props;

if (typeof np.postTemplateName !== 'undefined' && np.postTemplateName !== null) {
const { formId } = tp;

if (np.postTemplateName.indexOf('create_') === 0) {
const { username } = this.props;
const {
body, title, summary, altAuthor, tags
body, title, summary, altAuthor, tags, community,
} = ns;
const { payoutType, beneficiaries } = np;
const userTemplates = loadUserTemplates(username);
Expand All @@ -265,6 +280,7 @@ class ReplyEditor extends React.Component {
summary: summary !== undefined ? summary.value : '',
altAuthor: altAuthor !== undefined ? altAuthor.value : '',
tags: tags !== undefined ? tags.value : '',
community: community ? community : '',
};

let updated = false;
Expand All @@ -281,24 +297,26 @@ class ReplyEditor extends React.Component {

saveUserTemplates(username, userTemplates);

this.props.setPostTemplateName(formId, null);
} else {
const userTemplates = loadUserTemplates(np.username);

for (let ti = 0; ti < userTemplates.length; ti += 1) {
const template = userTemplates[ti];
if (template.name === np.postTemplateName) {
this.state.body.props.onChange(template.markdown);
this.state.title.props.onChange(template.title);
this.state.summary.props.onChange(template.summary);
this.state.altAuthor.props.onChange(template.altAuthor);
this.state.tags.props.onChange(template.tags);
this.props.setPayoutType(formId, template.payoutType);
this.props.setBeneficiaries(formId, template.beneficiaries);

this.props.setPostTemplateName(formId, null);
break;
}
return { template: null };
}

const userTemplates = loadUserTemplates(np.username);
for (let ti = 0; ti < userTemplates.length; ti += 1) {
const template = userTemplates[ti];
if (template.name === np.postTemplateName) {
return {
template: {
altAuthor: template.altAuthor,
beneficiaries: template.beneficiaries,
body: template.markdown,
formId: 'submitStory',
maxAcceptedPayout: null,
payoutType: template.payoutType,
summary: template.summary,
tags: template.tags,
title: template.title,
}
};
}
}
}
Expand Down Expand Up @@ -335,7 +353,6 @@ class ReplyEditor extends React.Component {

clearTimeout(saveEditorTimeout);
saveEditorTimeout = setTimeout(() => {
// console.log('save formId', formId, body.value)
localStorage.setItem('replyEditorData-' + formId, JSON.stringify(data, null, 0));
this.showDraftSaved();
}, 500);
Expand Down Expand Up @@ -371,6 +388,7 @@ class ReplyEditor extends React.Component {
}

tags.props.onChange(currentTags.join(' '));
this.setState({ community: category });
};

initForm(props) {
Expand Down
24 changes: 22 additions & 2 deletions src/app/components/elements/Userpic.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Tooltip from 'react-tooltip-lite';
import { connect } from 'react-redux';
import { imageProxy } from 'app/utils/ProxifyUrl';
import tt from "counterpart";

export const SIZE_SMALL = 'small';
export const SIZE_MED = 'medium';
Expand All @@ -13,16 +15,34 @@ class Userpic extends Component {
render() {
if (this.props.hide) return null;

const { account, size } = this.props;
const { account, size, punkId } = this.props;

const url = `${imageProxy()}u/${account}/avatar${size}`;
const style = { backgroundImage: `url(${url})` };
return <div className="Userpic" style={style} />;
return (
<>
<div className="Userpic" style={style} />
{!!punkId && (
<Tooltip
content={tt('g.isPunkVerified', { punk_id: punkId })}
eventOff="onClick"
direction="down-start"
background="#ededed"
color="#000000"
>
<a href={`https://punks.usehive.com/punk/${punkId}`} target="_blank" rel="noopener noreferrer">
<img src="/images/nft-badge.svg" alt="NFT" className="Userpic__nft-badge" />
</a>
</Tooltip>
)}
</>
);
}
}

Userpic.propTypes = {
account: PropTypes.string.isRequired,
punkId: PropTypes.number,
};

export default connect((state, ownProps) => {
Expand Down
31 changes: 24 additions & 7 deletions src/app/components/elements/Userpic.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
.Userpic {
display: inline-block;
display: inline-block;

background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
border-radius: 50%;
background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
border-radius: 50%;

width: 48px;
height: 48px;
width: 48px;
height: 48px;
}

.Userpic__nft-badge {
position: absolute;
bottom: -8px;
right: -8px;
width: 32px;
transition: all 250ms ease-in-out;
}

.Userpic__nft-badge:hover {
bottom: -18px;
right: -18px;
width: 48px;
}



2 changes: 1 addition & 1 deletion src/app/components/pages/ListManagement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class ListManagement extends React.Component {
what = 'reset_follow_blacklist';
break;
case 'muted':
what = 'reset_mute_list';
what = 'reset_muted_list';
break;
case 'followed_muted_lists':
what = 'reset_follow_muted_list';
Expand Down
1 change: 1 addition & 0 deletions src/app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
"checkbox": "I understand"
},
"rcLevel": "Resource Credits (RC) level: %(rc_percent)s%%.",
"isPunkVerified": "This user owns associated 'Punk On Hive' NFT",
"rcFullIn": "Full in %(duration)s"
},
"navigation": {
Expand Down
3 changes: 0 additions & 3 deletions src/app/utils/ChainValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ export function validate_account_name(value) {
if (!/^[a-z0-9-]*$/.test(label)) {
return tt('chainvalidation_js.each_account_segment_should_have_only_letters_digits_or_dashes');
}
if (/--/.test(label)) {
return tt('chainvalidation_js.each_account_segment_should_have_only_one_dash_in_a_row');
}
if (!/[a-z0-9]$/.test(label)) {
return tt('chainvalidation_js.each_account_segment_should_end_with_a_letter_or_digit');
}
Expand Down
Loading

0 comments on commit a6e742e

Please sign in to comment.