From fe7fd25f696daf58e3ae5964095123ce429dcbc7 Mon Sep 17 00:00:00 2001 From: leprechaun Date: Mon, 28 Nov 2022 19:04:04 -0300 Subject: [PATCH 1/9] * allow showing extra post information according to flags set in the defaults file --- .../components/entry-list-item/index.tsx | 31 +++++++++++-- .../components/entry-read-time/index.tsx | 15 +++++++ src/common/constants/defaults.json | 5 ++- src/common/helper/test-helper.ts | 5 ++- src/common/i18n/locales/en-US.json | 1 + src/common/pages/entry.tsx | 45 ++++++++++++++++--- src/common/store/global/index.ts | 5 ++- src/common/store/global/types.ts | 3 ++ 8 files changed, 99 insertions(+), 11 deletions(-) diff --git a/src/common/components/entry-list-item/index.tsx b/src/common/components/entry-list-item/index.tsx index c60507bf50f..5e3d400e30c 100644 --- a/src/common/components/entry-list-item/index.tsx +++ b/src/common/components/entry-list-item/index.tsx @@ -45,12 +45,12 @@ import { menuDownSvg } from "../../img/svg"; -import defaults from "../../constants/defaults.json"; +import defaults from "./../../constants/defaults.json"; import { ProfilePopover } from "../profile-popover"; import { match } from "react-router-dom"; import { getPost } from "../../api/bridge"; import { SearchResult } from "../../api/search-api"; - +import appName from "./../../helper/app-name"; setProxyBase(defaults.imageServer); interface MatchParams { @@ -207,7 +207,7 @@ export default class EntryListItem extends Component { // const account = accounts?.find((x) => x.name === accountUsername) as FullAccount const pageAccount = account as FullAccount; const pinned = account && pageAccount.profile?.pinned; - + const { showSelfVote, showRewardSplit, lowRewardThreshold } = global; const fallbackImage = global.isElectron ? "./img/fallback.png" : require("../../img/fallback.png"); @@ -286,6 +286,13 @@ export default class EntryListItem extends Component { const cls = `entry-list-item ${promoted ? "promoted-item" : ""} ${global.filter}`; + const self_vote_entry = entry.active_votes.find((x) => x.voter == entry.author); + const self_vote = self_vote_entry ? self_vote_entry.rshares : false; + const hp_portion = 100 * (1 - entry.percent_hbd / 20000); + const max_payout: number = parseFloat(entry.max_accepted_payout); + const app = appName(entry.json_metadata.app); + const appShort = app.split("/")[0].split(" ")[0]; + return mounted ? (
{(() => { @@ -361,6 +368,24 @@ export default class EntryListItem extends Component { {dateRelative} + {showSelfVote && self_vote &&
{_t("entry.self_voted")}
} + {showRewardSplit && max_payout > 0 &&
{hp_portion}% HP
} + {app && ( + <> + + + + + + + )} + {max_payout > 0 && max_payout < lowRewardThreshold && ( +
≤ {max_payout} HBD
+ )}
{isPinned && ( diff --git a/src/common/components/entry-read-time/index.tsx b/src/common/components/entry-read-time/index.tsx index c514dc7c417..c83d48682ca 100644 --- a/src/common/components/entry-read-time/index.tsx +++ b/src/common/components/entry-read-time/index.tsx @@ -3,13 +3,25 @@ import { OverlayTrigger, Tooltip } from "react-bootstrap"; import { _t } from "../../i18n"; import { informationVariantSvg } from "../../img/svg"; +import appName from "../../helper/app-name"; export const ReadTime = (props: any) => { const { entry, global, isVisible, toolTip } = props; + const { showSelfVote, showRewardSplit, lowRewardThreshold } = global; const [readTime, setReadTime] = useState(0); const [wordCount, setWordCount] = useState(0); + const self_vote_entry = entry.active_votes.find( + // @ts-ignore + (x) => x.voter == entry.author + ); + const self_vote = self_vote_entry ? true : false; + const hp_portion = 100 * (1 - entry.percent_hbd / 20000); + const max_payout: number = parseFloat(entry.max_accepted_payout); + const app = appName(entry.json_metadata.app); + const appShort = app.split("/")[0].split(" ")[0]; + useEffect(() => { calculateExtras(); }, [entry]); @@ -38,6 +50,9 @@ export const ReadTime = (props: any) => {

{_t("entry.post-read-time")} {readTime} {_t("entry.post-read-minuites")}

+ {self_vote &&

{_t("entry.self_voted")}

} + {max_payout > 0 &&

{hp_portion}% HP

} + {max_payout > 0 && max_payout < lowRewardThreshold &&

≤ {max_payout} HBD

}
diff --git a/src/common/constants/defaults.json b/src/common/constants/defaults.json index be371d14b80..d352772f689 100644 --- a/src/common/constants/defaults.json +++ b/src/common/constants/defaults.json @@ -14,5 +14,8 @@ "name": "Ecency", "title": "Ecency - smart, decentralized, rewarding social network without limits", "description": "Discover and build a community, niche and be rewarded for blogs, votes, contributions and reward esteemed friends and followers.", - "twitterHandle": "@ecency_official" + "twitterHandle": "@ecency_official", + "showSelfVote": true, + "showRewardSplit": true, + "lowRewardThreshold": 100 } diff --git a/src/common/helper/test-helper.ts b/src/common/helper/test-helper.ts index 34c2324d0df..1446c7bae8a 100644 --- a/src/common/helper/test-helper.ts +++ b/src/common/helper/test-helper.ts @@ -152,7 +152,10 @@ export const globalInstance: Global = { newVersion: null, usePrivate: true, lastIndexPath: null, - hsClientId: "ecency.app" + hsClientId: "ecency.app", + showSelfVote: true, + showRewardSplit: true, + lowRewardThreshold: 100 }; export const TrendingTagsInstance: TrendingTags = { diff --git a/src/common/i18n/locales/en-US.json b/src/common/i18n/locales/en-US.json index b2c67eb92e3..b29d79b309c 100644 --- a/src/common/i18n/locales/en-US.json +++ b/src/common/i18n/locales/en-US.json @@ -417,6 +417,7 @@ "sort-percent": "Percentage" }, "entry": { + "self_voted": "self voted", "via-app": "via {{app}}", "author-reputation": "Author's reputation", "comment-entry-title": "You are viewing a single comment's thread from: ", diff --git a/src/common/pages/entry.tsx b/src/common/pages/entry.tsx index 3719b847dd9..71811a11ce2 100644 --- a/src/common/pages/entry.tsx +++ b/src/common/pages/entry.tsx @@ -76,12 +76,12 @@ import dmca from "../constants/dmca.json"; import { getFollowing } from "../api/hive"; import { history } from "../store"; -import { deleteForeverSvg, pencilOutlineSvg, informationVariantSvg } from "../img/svg"; +import { deleteForeverSvg, pencilOutlineSvg } from "../img/svg"; import entryDeleteBtn from "../components/entry-delete-btn"; import { SelectionPopover } from "../components/selection-popover"; import { commentHistory } from "../api/private-api"; import { getPost } from "../api/bridge"; - +import formattedNumber from "../util/formatted-number"; setProxyBase(defaults.imageServer); interface MatchParams { @@ -514,6 +514,7 @@ class EntryPage extends BaseComponent { showWordCount } = this.state; const { global, history, match, location } = this.props; + const { showSelfVote, showRewardSplit, lowRewardThreshold } = global; let navBar = global.isElectron ? NavBarElectron({ @@ -540,6 +541,23 @@ class EntryPage extends BaseComponent { } const entry = this.getEntry(); + const { self_vote, hp_portion, max_payout, appShort, app } = (() => { + if (entry === undefined) { + return { self_vote: true, hp_portion: 50, max_payout: 1000000, appShort: "?", app: "?" }; + } + try { + const self_vote_entry = entry.active_votes.find((x) => x.voter == entry.author); + const self_vote = self_vote_entry ? self_vote_entry.rshares : false; + const hp_portion = 100 * (1 - entry.percent_hbd / 20000); + const max_payout: number = parseFloat(entry.max_accepted_payout); + const app = appName(entry.json_metadata.app); + const appShort = app.split("/")[0].split(" ")[0]; + return { self_vote, hp_portion, max_payout, appShort, app }; + } catch (e) { + return { self_vote: true, hp_portion: 50, max_payout: 1000000, appShort: "?", app: "?" }; + } + })(); + if (postIsDeleted) { const { username, permlink } = match.params; const author = username.replace("@", ""); @@ -622,8 +640,6 @@ class EntryPage extends BaseComponent { if (entry.category && tags && tags[0] !== entry.category) { tags.splice(0, 0, entry.category); } - const app = appName(entry.json_metadata.app); - const appShort = app.split("/")[0].split(" ")[0]; const { activeUser } = this.props; @@ -1085,7 +1101,6 @@ class EntryPage extends BaseComponent { {showProfileBox && } )} -
{tags && @@ -1163,7 +1178,27 @@ class EntryPage extends BaseComponent {
)} + + {showSelfVote && self_vote && ( + {_t("entry.self_voted")} + )} + + {showRewardSplit && max_payout > 0 && ( +
+ {hp_portion}% HP +
+ )} + + {max_payout > 0 && max_payout < lowRewardThreshold && ( + +
+ ≤{" "} + {formattedNumber(max_payout, { suffix: "HBD", fractionDigits: 0 })}{" "} +
+
+ )}
+
{EntryVoteBtn({ ...this.props, diff --git a/src/common/store/global/index.ts b/src/common/store/global/index.ts index 818e270183d..5544ca2eb7c 100644 --- a/src/common/store/global/index.ts +++ b/src/common/store/global/index.ts @@ -49,7 +49,10 @@ export const initialState: Global = { isMobile: false, usePrivate: true, hsClientId: "ecency.app", - lastIndexPath: null + lastIndexPath: null, + showSelfVote: defaults.showSelfVote, + showRewardSplit: defaults.showRewardSplit, + lowRewardThreshold: defaults.lowRewardThreshold }; export default (state: Global = initialState, action: Actions): Global => { diff --git a/src/common/store/global/types.ts b/src/common/store/global/types.ts index 9e10213b989..6461ab25b4b 100644 --- a/src/common/store/global/types.ts +++ b/src/common/store/global/types.ts @@ -70,6 +70,9 @@ export interface Global { usePrivate: boolean; hsClientId: string; lastIndexPath: string | null; + showSelfVote: boolean; + showRewardSplit: boolean; + lowRewardThreshold: number; } export enum ActionTypes { From a76a87493eb03fa3171a400079186efe0ddfee36 Mon Sep 17 00:00:00 2001 From: leprechaun Date: Mon, 28 Nov 2022 19:10:33 -0300 Subject: [PATCH 2/9] * connecting new postingflags to the preferences pane. --- src/common/components/preferences/index.tsx | 64 +++++++++++++++++++++ src/common/constants/defaults.json | 2 +- src/common/i18n/locales/en-US.json | 6 ++ src/common/pages/common.ts | 11 +++- src/common/store/global/index.ts | 53 ++++++++++++++++- src/common/store/global/types.ts | 25 +++++++- 6 files changed, 156 insertions(+), 5 deletions(-) diff --git a/src/common/components/preferences/index.tsx b/src/common/components/preferences/index.tsx index 70b2762db97..25c70a36cca 100644 --- a/src/common/components/preferences/index.tsx +++ b/src/common/components/preferences/index.tsx @@ -22,6 +22,7 @@ interface Props { setNsfw: (value: boolean) => void; activeUser: ActiveUser; toggleTheme: (theme_key?: string) => void; + setShowSelfVote: (value: boolean) => void; } interface State { @@ -98,6 +99,34 @@ export class Preferences extends BaseComponent { success(_t("preferences.updated")); }; + showSelfVoteChanged = (e: React.ChangeEvent) => { + const { setShowSelfVote } = this.props.global; + const { value } = e.target; + console.log(value); + const parsedValue = JSON.parse(value); + setShowSelfVote(parsedValue); + success(_t("preferences.updated")); + }; + /* + showRewardSplitChanged = (e: React.ChangeEvent) => { + const { setShowRewardSplit } = this.props; + const { value } = e.target; + + setRewardSplit(JSON.parse(value)); + success(_t("preferences.updated")); + }; + + lowRewardThresholdChanged = (e: React.ChangeEvent) => { + const { setLowRewardThreshold } = this.props; + const { value } = e.target; + try { + setLowRewardThreshold(JSON.parse(value)); + } catch (e) { + console.log(value, "Couldn't get it done boss"); + } + success(_t("preferences.updated")); + };*/ + copyToClipboard = (text: string) => { const textField = document.createElement("textarea"); textField.innerText = text; @@ -114,6 +143,8 @@ export class Preferences extends BaseComponent { if (use_system_theme) { theme = "system"; } + this.showSelfVoteChanged = this.showSelfVoteChanged.bind(this); + this.setState({ ...this.state, defaultTheme: theme }); } @@ -244,6 +275,39 @@ export class Preferences extends BaseComponent { + + + {_t("preferences.show-self-vote")} + + + + + + + + + {_t("preferences.show-reward-split")} + + + + + + + + + {_t("preferences.low-reward-threshold")} + + + )} diff --git a/src/common/constants/defaults.json b/src/common/constants/defaults.json index d352772f689..216fea16763 100644 --- a/src/common/constants/defaults.json +++ b/src/common/constants/defaults.json @@ -17,5 +17,5 @@ "twitterHandle": "@ecency_official", "showSelfVote": true, "showRewardSplit": true, - "lowRewardThreshold": 100 + "lowRewardThreshold": 1000000000 } diff --git a/src/common/i18n/locales/en-US.json b/src/common/i18n/locales/en-US.json index b29d79b309c..e88989be471 100644 --- a/src/common/i18n/locales/en-US.json +++ b/src/common/i18n/locales/en-US.json @@ -632,6 +632,8 @@ "uploaded": "Image uploaded" }, "preferences": { + "show-self-vote": "Show Self Vote flag", + "show-reward-split": "Show Hive Power/Hive Dollar Breakdown", "title": "Preferences", "notifications": "Notification alerts", "currency": "Currency", @@ -642,6 +644,10 @@ "theme-system-default": "System Default", "theme-day": "Day mode", "theme-night": "Night mode", + "show-self-vote-true": "On", + "show-self-vote-false": "Off", + "show-reward-split-true": "On", + "show-reward-split-false": "Off", "updated": "Preference updated!" }, "wallet": { diff --git a/src/common/pages/common.ts b/src/common/pages/common.ts index b7b16aa7055..e3dec9b1b9e 100644 --- a/src/common/pages/common.ts +++ b/src/common/pages/common.ts @@ -29,7 +29,10 @@ import { setCurrency, setLang, setNsfw, - setLastIndexPath + setLastIndexPath, + setShowSelfVote, + setShowRewardSplit, + setLowRewardThreshold } from "../store/global"; import { fetchTrendingTags } from "../store/trending-tags"; import { updateSubscriptions } from "../store/subscriptions"; @@ -87,6 +90,9 @@ export interface PageProps { setLang: (lang: string) => void; setNsfw: (value: boolean) => void; setLastIndexPath: (path: string | null) => void; + setShowSelfVote: (value: boolean) => void; + setShowRewardSplit: (value: boolean) => void; + setLowRewardThreshold: (value: number) => void; dynamicProps: DynamicProps; @@ -186,6 +192,9 @@ export const pageMapDispatchToProps = (dispatch: Dispatch) => setLang, setNsfw, setLastIndexPath, + setShowSelfVote, + setShowRewardSplit, + setLowRewardThreshold, dismissNewVersion, fetchTrendingTags, updateSubscriptions, diff --git a/src/common/store/global/index.ts b/src/common/store/global/index.ts index 5544ca2eb7c..d3c3530a38b 100644 --- a/src/common/store/global/index.ts +++ b/src/common/store/global/index.ts @@ -21,7 +21,10 @@ import { NsfwSetAction, SetLastIndexPathAction, Theme, - ThemeChangeAction + ThemeChangeAction, + SetShowSelfVoteAction, + SetShowRewardSplitAction, + SetLowRewardThresholdAction } from "./types"; import { CommonActionTypes } from "../common"; import * as ls from "../../util/local-storage"; @@ -108,6 +111,18 @@ export default (state: Global = initialState, action: Actions): Global => { case ActionTypes.SET_LAST_INDEX_PATH: { return { ...state, lastIndexPath: action.path }; } + case ActionTypes.SET_SHOW_SELF_VOTE: { + const { showSelfVote } = action; + return { ...state, showSelfVote }; + } + case ActionTypes.SET_SHOW_REWARD_SPLIT: { + const { showRewardSplit } = action; + return { ...state, showRewardSplit }; + } + case ActionTypes.SET_LOW_REWARD_THRESHOLD: { + const { lowRewardThreshold } = action; + return { ...state, lowRewardThreshold }; + } default: return state; } @@ -222,6 +237,21 @@ export const setLastIndexPath = (path: string | null) => (dispatch: Dispatch) => dispatch(setLastIndexPathAct(path)); }; +export const setShowSelfVote = (value: boolean) => (dispatch: Dispatch) => { + ls.set("showSelfVote", value); + dispatch(setShowSelfVoteAct(value)); +}; + +export const setShowRewardSplit = (value: boolean) => (dispatch: Dispatch) => { + ls.set("showRewardSplit", value); + dispatch(setShowRewardSplitAct(value)); +}; + +export const setLowRewardThreshold = (value: number) => (dispatch: Dispatch) => { + ls.set("lowRewardThreshold", value); + dispatch(setLowRewardThresholdAct(value)); +}; + /* Action Creators */ export const themeChangeAct = (theme: Theme): ThemeChangeAction => { return { @@ -299,3 +329,24 @@ export const setLastIndexPathAct = (path: string | null): SetLastIndexPathAction type: ActionTypes.SET_LAST_INDEX_PATH, path }); + +export const setShowSelfVoteAct = (value: boolean): SetShowSelfVoteAction => { + return { + type: ActionTypes.SET_SHOW_SELF_VOTE, + showSelfVote: value + }; +}; + +export const setShowRewardSplitAct = (value: boolean): SetShowRewardSplitAction => { + return { + type: ActionTypes.SET_SHOW_REWARD_SPLIT, + showRewardSplit: value + }; +}; + +export const setLowRewardThresholdAct = (value: number): SetLowRewardThresholdAction => { + return { + type: ActionTypes.SET_LOW_REWARD_THRESHOLD, + lowRewardThreshold: value + }; +}; diff --git a/src/common/store/global/types.ts b/src/common/store/global/types.ts index 6461ab25b4b..89c3d30281f 100644 --- a/src/common/store/global/types.ts +++ b/src/common/store/global/types.ts @@ -86,7 +86,10 @@ export enum ActionTypes { LANG_SET = "@global/LANG_SET", NEW_VERSION_CHANGE = "@global/NEW_VERSION_CHANGE", NSFW_SET = "@global/NSFW_SET", - SET_LAST_INDEX_PATH = "@global/SET_LAST_INDEX_PATH" + SET_LAST_INDEX_PATH = "@global/SET_LAST_INDEX_PATH", + SET_SHOW_SELF_VOTE = "@global/SET_SHOW_SELF_VOTE", + SET_SHOW_REWARD_SPLIT = "@global/SET_SHOW_REWARD_SPLIT", + SET_LOW_REWARD_THRESHOLD = "@global/SET_LOW_REWARD_THRESHOLD" } export interface ThemeChangeAction { @@ -142,6 +145,21 @@ export interface SetLastIndexPathAction { path: string | null; } +export interface SetShowSelfVoteAction { + type: ActionTypes.SET_SHOW_SELF_VOTE; + showSelfVote: boolean; +} + +export interface SetShowRewardSplitAction { + type: ActionTypes.SET_SHOW_REWARD_SPLIT; + showRewardSplit: boolean; +} + +export interface SetLowRewardThresholdAction { + type: ActionTypes.SET_LOW_REWARD_THRESHOLD; + lowRewardThreshold: number; +} + export type Actions = | LocationChangeAction | ThemeChangeAction @@ -154,4 +172,7 @@ export type Actions = | LangSetAction | NsfwSetAction | HasKeyChainAction - | SetLastIndexPathAction; + | SetLastIndexPathAction + | SetShowSelfVoteAction + | SetShowRewardSplitAction + | SetLowRewardThresholdAction; From 6b10ca88007e41d91f9df8113b90526f499eb75f Mon Sep 17 00:00:00 2001 From: leprechaun Date: Mon, 28 Nov 2022 20:21:43 -0300 Subject: [PATCH 3/9] * progress: able to set showSelfVote, showRewardSplit and lowRewardThreshold, but preference dialog doesn't get updated. --- src/common/components/preferences/index.tsx | 22 ++++++++++++----- .../components/profile-settings/index.tsx | 8 ++++++- src/common/i18n/locales/en-US.json | 2 ++ src/common/store/helper.ts | 24 ++++++++++++++++++- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/common/components/preferences/index.tsx b/src/common/components/preferences/index.tsx index 25c70a36cca..a1b6cffe61e 100644 --- a/src/common/components/preferences/index.tsx +++ b/src/common/components/preferences/index.tsx @@ -107,12 +107,12 @@ export class Preferences extends BaseComponent { setShowSelfVote(parsedValue); success(_t("preferences.updated")); }; - /* + showRewardSplitChanged = (e: React.ChangeEvent) => { const { setShowRewardSplit } = this.props; const { value } = e.target; - setRewardSplit(JSON.parse(value)); + setShowRewardSplit(JSON.parse(value)); success(_t("preferences.updated")); }; @@ -122,10 +122,10 @@ export class Preferences extends BaseComponent { try { setLowRewardThreshold(JSON.parse(value)); } catch (e) { - console.log(value, "Couldn't get it done boss"); + console.log(value, "Couldn't get it done boss"); } success(_t("preferences.updated")); - };*/ + }; copyToClipboard = (text: string) => { const textField = document.createElement("textarea"); @@ -144,6 +144,8 @@ export class Preferences extends BaseComponent { theme = "system"; } this.showSelfVoteChanged = this.showSelfVoteChanged.bind(this); + this.showRewardSplitChanged = this.showRewardSplitChanged.bind(this); + this.lowRewardThresholdChanged = this.lowRewardThresholdChanged.bind(this); this.setState({ ...this.state, defaultTheme: theme }); } @@ -296,6 +298,7 @@ export class Preferences extends BaseComponent { type="text" value={JSON.stringify(global.showRewardSplit)} as="select" + onChange={this.showRewardSplitChanged} > @@ -305,7 +308,11 @@ export class Preferences extends BaseComponent { {_t("preferences.low-reward-threshold")} - + @@ -326,7 +333,10 @@ export default (p: Props) => { setCurrency: p.setCurrency, setLang: p.setLang, setNsfw: p.setNsfw, - toggleTheme: p.toggleTheme + toggleTheme: p.toggleTheme, + setShowSelfVote: p.setShowSelfVote, + setShowRewardSplit: p.setShowRewardSplit, + setLowRewardThreshold: p.setLowRewardThreshold }; return ; diff --git a/src/common/components/profile-settings/index.tsx b/src/common/components/profile-settings/index.tsx index 67cc5d4b117..c44483b5573 100644 --- a/src/common/components/profile-settings/index.tsx +++ b/src/common/components/profile-settings/index.tsx @@ -23,6 +23,9 @@ interface Props { setCurrency: (currency: string, rate: number, symbol: string) => void; setLang: (lang: string) => void; setNsfw: (value: boolean) => void; + setShowSelfVote: (value: boolean) => void; + setShowRewardSplit: (value: boolean) => void; + setLowRewardThreshold: (value: number) => void; toggleTheme: (theme_key?: string) => void; } @@ -68,7 +71,10 @@ export default (p: Props) => { setCurrency: p.setCurrency, setLang: p.setLang, setNsfw: p.setNsfw, - toggleTheme: p.toggleTheme + toggleTheme: p.toggleTheme, + setShowSelfVote: p.setShowSelfVote, + setShowRewardSplit: p.setShowRewardSplit, + setLowRewardThreshold: p.setLowRewardThreshold }; return ; diff --git a/src/common/i18n/locales/en-US.json b/src/common/i18n/locales/en-US.json index e88989be471..4ff4eb78f32 100644 --- a/src/common/i18n/locales/en-US.json +++ b/src/common/i18n/locales/en-US.json @@ -634,6 +634,8 @@ "preferences": { "show-self-vote": "Show Self Vote flag", "show-reward-split": "Show Hive Power/Hive Dollar Breakdown", + "low-reward-threshold": "Low maximum accepted reward threshold", + "low-reward-threshold-info": "The maximum accepted reward for a post will be displayed when this maximum is less than or equal to this threshold value", "title": "Preferences", "notifications": "Notification alerts", "currency": "Currency", diff --git a/src/common/store/helper.ts b/src/common/store/helper.ts index f82d96dfa31..d9ce77629c8 100644 --- a/src/common/store/helper.ts +++ b/src/common/store/helper.ts @@ -19,7 +19,10 @@ import { setCurrencyAct as setCurrency, muteNotificationsAct as muteNotifications, setLangAct as setLang, - setNsfwAct as setNsfw + setNsfwAct as setNsfw, + setShowSelfVoteAct as setShowSelfVote, + setShowRewardSplitAct, + setLowRewardThresholdAct } from "./global"; import { getCurrencyRate } from "../api/misc"; @@ -177,4 +180,23 @@ export const clientStoreTasks = (store: Store) => { if (ls.get("nsfw") === true) { store.dispatch(setNsfw(true)); } + + // Show Self Votes + const showSelfVote = ls.get("showSelfVote"); + if (typeof showSelfVote === "boolean") { + store.dispatch(setShowSelfVote(showSelfVote)); + } + + // Show Self Votes + const showRewardSplit = ls.get("showRewardSplit"); + if (typeof showRewardSplit === "boolean") { + console.log({ showRewardSplit }); + store.dispatch(setShowRewardSplitAct(setShowRewardSplit)); + } + + // Show Self Votes + const lowRewardThreshold = ls.get("lowRewardThreshold"); + if (typeof lowRewardThreshold === "number") { + store.dispatch(setLowRewardThresholdAct(lowRewardThreshold)); + } }; From d532713575c7d84150d121f841618d9d8e1ba604 Mon Sep 17 00:00:00 2001 From: leprechaun Date: Mon, 28 Nov 2022 21:47:08 -0300 Subject: [PATCH 4/9] * fixed bugs: now the settings page updates --- src/common/components/entry-list-item/index.tsx | 10 +++++----- src/common/components/preferences/index.tsx | 2 ++ src/common/store/helper.ts | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/common/components/entry-list-item/index.tsx b/src/common/components/entry-list-item/index.tsx index 5e3d400e30c..38bb8caa624 100644 --- a/src/common/components/entry-list-item/index.tsx +++ b/src/common/components/entry-list-item/index.tsx @@ -51,6 +51,7 @@ import { match } from "react-router-dom"; import { getPost } from "../../api/bridge"; import { SearchResult } from "../../api/search-api"; import appName from "./../../helper/app-name"; +import formattedNumber from "../../util/formatted-number"; setProxyBase(defaults.imageServer); interface MatchParams { @@ -368,11 +369,10 @@ export default class EntryListItem extends Component { {dateRelative} - {showSelfVote && self_vote &&
{_t("entry.self_voted")}
} - {showRewardSplit && max_payout > 0 &&
{hp_portion}% HP
} + {showSelfVote && self_vote && <> {_t("entry.self_voted")}} + {showRewardSplit && max_payout > 0 && <> {hp_portion}% HP} {app && ( <> - @@ -383,8 +383,8 @@ export default class EntryListItem extends Component {
)} - {max_payout > 0 && max_payout < lowRewardThreshold && ( -
≤ {max_payout} HBD
+ {max_payout > 0 && max_payout <= lowRewardThreshold && ( + <>  ≤ {formattedNumber(max_payout, { fractionDigits: 0, suffix: "HBD" })} )}
diff --git a/src/common/components/preferences/index.tsx b/src/common/components/preferences/index.tsx index a1b6cffe61e..1188be0ef9f 100644 --- a/src/common/components/preferences/index.tsx +++ b/src/common/components/preferences/index.tsx @@ -23,6 +23,8 @@ interface Props { activeUser: ActiveUser; toggleTheme: (theme_key?: string) => void; setShowSelfVote: (value: boolean) => void; + setShowRewardSplit: (value: boolean) => void; + setLowRewardThreshold: (value: number) => void; } interface State { diff --git a/src/common/store/helper.ts b/src/common/store/helper.ts index d9ce77629c8..83f0ce508b2 100644 --- a/src/common/store/helper.ts +++ b/src/common/store/helper.ts @@ -190,8 +190,7 @@ export const clientStoreTasks = (store: Store) => { // Show Self Votes const showRewardSplit = ls.get("showRewardSplit"); if (typeof showRewardSplit === "boolean") { - console.log({ showRewardSplit }); - store.dispatch(setShowRewardSplitAct(setShowRewardSplit)); + store.dispatch(setShowRewardSplitAct(showRewardSplit)); } // Show Self Votes From 881f351d52a3b43ffc16d88028113b84b3927ea8 Mon Sep 17 00:00:00 2001 From: leprechaun Date: Mon, 28 Nov 2022 23:47:10 -0300 Subject: [PATCH 5/9] * test updates --- .../comment/__snapshots__/index.spec.tsx.snap | 16 ++ .../__snapshots__/index.spec.tsx.snap | 156 ++++++++++++ .../__snapshots__/index.spec.tsx.snap | 222 ++++++++++-------- .../__snapshots__/index.spec.tsx.snap | 111 +++++---- .../swap-amount-control.spec.tsx.snap | 14 +- .../__snapshots__/index.spec.tsx.snap | 79 +++++++ .../components/preferences/index.spec.tsx | 5 +- src/common/components/preferences/index.tsx | 2 +- .../global/__snapshots__/index.test.ts.snap | 30 +++ 9 files changed, 479 insertions(+), 156 deletions(-) diff --git a/src/common/components/comment/__snapshots__/index.spec.tsx.snap b/src/common/components/comment/__snapshots__/index.spec.tsx.snap index b4397364a56..46c1d499a8f 100644 --- a/src/common/components/comment/__snapshots__/index.spec.tsx.snap +++ b/src/common/components/comment/__snapshots__/index.spec.tsx.snap @@ -270,6 +270,11 @@ exports[`(1) Default render 1`] = ` >