Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {KeyChainImpl} from "../common/helper/keychain";
export interface AppWindow extends Window {
usePrivate: boolean;
nws?: WebSocket;
comTag?: {};
comTag?: {} | any;
hive_keychain?: KeyChainImpl;
twttr?: {
widgets?: {
Expand Down
41 changes: 36 additions & 5 deletions src/common/api/breakaway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,53 @@ export const getBtcTransactions = async (address: string) => {
}
};

// export const getUserByUsername = async (username: string) => {
// try {
// const response = await axios.get(`${baUrl}/user/${username}`);
// console.log("...resp....",response)
// if(!response) {
// console.log("no user found here....")

// return
// } else {
// return response.data;
// }

// } catch (error) {
// console.error('Error fetching user by username:', error);
// throw error;
// }
// };

export const getUserByUsername = async (username: string) => {
try {
const response = await axios.get(`${baUrl}/user/${username}`);
if(!response) {

return null
} else {
if (response?.status === 200 && response?.data) {
return response.data;
} else {
return null;
}
} catch (error: any) {
if (error.response && error.response.status === 404) {
return null;
}

console.error("Error fetching user by username:", error);
throw error;
}
};

export const fetchBtcUsers = async () => {
try {
const response = await axios.get(`${baUrl}/btc-users`);
return response.data
} catch (error) {
console.error('Error fetching user by username:', error);
throw error;
console.error('Error fetching BTC users:',error);
}
};


export const createFreeAccount = async (username: string, keys: any) => {
try {
const response = await axios.post(`${baUrl}/create-free-account`, {username, accountKeys: keys});
Expand Down
18 changes: 12 additions & 6 deletions src/common/components/404/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import {Link} from "react-router-dom";
import Meta from "../meta";
import { Global } from "../../store/global/types";
import isElectron from "../../util/is-electron";
import defaults from "../../constants/defaults.json";

const logoCircle = require("../../img/logo-circle.svg");
// const logoCircle = require("../../img/logo-circle.svg");

interface Props {
history: History;
Expand Down Expand Up @@ -36,6 +37,7 @@ export class NotFound extends Component<Props, State> {

render() {
const {loaded} = this.state;
const {history, global} = this.props;
if (!loaded) {
return ''
}
Expand All @@ -44,8 +46,6 @@ export class NotFound extends Component<Props, State> {
title: "404",
};

const {history, global} = this.props;

// @ts-ignore make ide happy. code compiles without error.
const entries = history.entries || {}
// @ts-ignore
Expand All @@ -57,17 +57,23 @@ export class NotFound extends Component<Props, State> {
<>
<Meta {...metaProps} />
<div className="not-found-404">
<img src={isElectron() ? "./img/logo-circle.svg" : logoCircle} className="logo" alt="Ecency"/>
<img
// src={`${defaults.imageServer}/u/${global?.hive_id}/avatar/lardge`}
src={`https://media.licdn.com/dms/image/v2/C5112AQEw1fXuabCTyQ/article-inline_image-shrink_1500_2232/article-inline_image-shrink_1500_2232/0/1581099611064?e=1747872000&v=beta&t=ZFHxBgqIAHyWajNgLLo0GyuvF1TggPYYUzAoK_-fbq8`}
// src={`https://images.hive.blog/u/${global?.hive_id}/avatar/lardge`}
className="logo"
alt=""
/>
<h1>This page doesn't exist.</h1>
<p className="links">
{canGoBack && <a href="#" onClick={(e) => {
e.preventDefault();
this.goBack();
}}>Back</a>}
<Link to="/">Home</Link>
<Link to="/created">New posts</Link>
{/* <Link to="/created">New posts</Link>
<Link to="/hot">Hot posts</Link>
<Link to="/trending">Trending posts</Link>
<Link to="/trending">Trending posts</Link> */}
</p>
</div>
</>
Expand Down
28 changes: 26 additions & 2 deletions src/common/components/comment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ setProxyBase(defaults.imageServer);
import {_t} from "../../i18n";
import {Global} from '../../store/global/types';
import * as ls from "../../util/local-storage";
import { updateUserPoints } from "../../api/breakaway";
import { getUserByUsername, updateUserPoints } from "../../api/breakaway";
import { error } from "../feedback";

interface PreviewProps {
text: string;
Expand Down Expand Up @@ -135,7 +136,30 @@ export class Comment extends Component<Props, State> {
submit = async () => {
const {text, communityData} = this.state;
const {onSubmit, activeUser} = this.props;
try {
try {
// return
//Check if user has btc
if((this.props.global.hive_id === "hive-125568" || this.props.global.hive_id === "hive-159314" )) {
const baUser = await getUserByUsername(activeUser!.username)

let btcAddress;

if(baUser?.bacUser?.bitcoinAddress) {
btcAddress = baUser?.bacUser?.bitcoinAddress
// const addressBalance = await getBtcWalletBalance(baUser?.bacUser?.bitcoinAddress);
// if(addressBalance.balance < 0.00005) {
// error("You must have at least 0.00005 btc to create a post");
// return;
// } else {
// history.push(`/submit?com=${global?.hive_id}`);
// }

} else {
error("Sorry, you have no bitcoin profile");
return
}

}
onSubmit(text);
const res = await updateUserPoints(activeUser!.username, communityData.title, "comments")
} catch (error) {
Expand Down
181 changes: 181 additions & 0 deletions src/common/components/community-menu/ObcCommunityMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import React, { Component } from "react";
import { History, Location } from "history";
import { Link } from "react-router-dom";
import { match } from "react-router";

import { EntryFilter, Global } from "../../store/global/types";
import { Community } from "../../store/communities/types";

import ListStyleToggle from "../list-style-toggle/index";
import DropDown from "../dropdown";

import { _t } from "../../i18n";
import _c from "../../util/fix-class-names";
import * as ls from "../../util/local-storage";

interface MatchParams {
filter: string;
name: string;
}

interface Props {
history: History;
location: Location;
match: match<MatchParams>;
global: Global;
community: Community;
toggleListStyle: (view: string | null) => void;
}

interface State {
selectedLabel: string;
}

export class CommunityMenu extends Component<Props, State> {
state: State = {
selectedLabel: "",
};

componentDidMount() {
const { match, community } = this.props;
const items = this.menuItems();

const savedLabel = ls.get("selectedLabel");
const currentRouteValue = match.params.filter;
const fromRoute = items.find((item) => item.value === currentRouteValue);
const fromStorage = items.find((item) => item.label === savedLabel);

let labelToUse = "";

if (fromStorage) {
labelToUse = fromStorage.label;

const expectedPath = `/${fromStorage.value}/${community.name}`;
if (this.props.location.pathname !== expectedPath) {
this.props.history.replace(expectedPath);
}
} else if (fromRoute) {
labelToUse = fromRoute.label;
} else {
labelToUse = items[0].label;
}

this.setState({ selectedLabel: labelToUse }, () => {
ls.set("selectedLabel", labelToUse);
});
}

menuItems = () => {
return (
[
{ label: "5,000sats", value: "created" },
{ label: "50,000sats", value: "created" },
{ label: "500,000sats", value: "created" },
{ label: "0.05BTC", value: "created" },
{ label: "0.5BTC", value: "created" },
{ label: "1BTC", value: "created" },
])
};

handleSelect = (label: string, value: string) => {
this.setState({ selectedLabel: label }, () => {
ls.set("selectedLabel", label);
window.location.reload()
});
};

render() {
const { community, match, global } = this.props;
const { name, filter } = match.params;
const { selectedLabel } = this.state;

const items = this.menuItems();

const showFeedInfo =
filter === "created" || filter === "hot" || filter === "trending";

return (
<>
{showFeedInfo && (
<div style={{ color: "orange" }}>
Showing feeds from {selectedLabel} and above
</div>
)}
<div className="community-menu">
<div className="menu-items">
{/* Mobile dropdown */}
<span className="d-flex d-lg-none community-menu-item selected-item">
<DropDown
history={this.props.history}
label={selectedLabel}
items={items.map((item) => ({
label: item.label,
href: `/${item.value}/${community.name}`,
active: selectedLabel === item.label,
}))}
float="left"
/>
</span>

{/* Desktop menu */}
<div className="d-none d-lg-flex align-items-center">
{items.map((item) => {
const isActive = selectedLabel === item.label;
return (
<Link
key={item.label}
to={`/${item.value}/${community.name}`}
className={_c(`community-menu-item ${isActive ? "selected-item" : ""}`)}
onClick={(e) => {
e.preventDefault();
this.handleSelect(item.label, item.value);
}}
>
{item.label}
</Link>
);
})}
</div>

{/* Subscribers */}
<Link
to={`/subscribers/${name}`}
className={_c(
`community-menu-item ${selectedLabel === "Subscribers" ? "selected-item" : ""}`
)}
onClick={(e) => {
e.preventDefault();
this.handleSelect("Subscribers", "subscribers");
}}
>
{_t("community.subscribers")}
</Link>

{/* Activities */}
<Link
to={`/activities/${name}`}
className={_c(
`community-menu-item ${selectedLabel === "Activities" ? "selected-item" : ""}`
)}
onClick={(e) => {
e.preventDefault();
this.handleSelect("Activities", "activities");
}}
>
{_t("community.activities")}
</Link>
</div>

<div className="page-tools">
<ListStyleToggle
global={this.props.global}
toggleListStyle={this.props.toggleListStyle}
/>
</div>
</div>
</>
);
}
}

export default (p: Props) => <CommunityMenu {...p} />;
21 changes: 3 additions & 18 deletions src/common/components/community-menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class CommunityMenu extends Component<Props> {
const { community, match, global } = this.props;
const { filter, name } = match.params;

/////to be removed
const customItems = [
{ label: "5,000sats", value: EntryFilter.created },
// { label: "50,000sats", value: EntryFilter.sats50000 },
Expand All @@ -66,8 +67,8 @@ export class CommunityMenu extends Component<Props> {
history: this.props.history,
label:
global.hive_id === "hive-125568"
? customItems[0].label // Use the first label when hive_id matches
: _t(`entry-filter.filter-${filter}`), // Otherwise, use translation
? customItems[0].label
: _t(`entry-filter.filter-${filter}`),

items: (global.hive_id === "hive-125568" ? customItems : defaultItems).map(
(item) => ({
Expand All @@ -77,25 +78,9 @@ export class CommunityMenu extends Component<Props> {
})
),
};

const showFeedInfo = filter === "created" || filter === "hot" || filter === "trending"

return (
<>
{showFeedInfo && (
<div style={{ color: "orange" }}>
Showing feeds from{" "}
{filter === "created"
? "5000 sats"
: filter === "trending"
? "0.5 BTC"
: filter === "hot"
? "1 BTC"
: null}{" "}
and above
</div>
)}

<div className="community-menu">
<div className="menu-items">
<>
Expand Down
Loading