Skip to content

Commit

Permalink
[E] Remove option to show others' highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
1aurend committed Jan 23, 2025
1 parent e1842ec commit d472d7b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 deletions.
3 changes: 2 additions & 1 deletion client/src/config/app/locale/en-US/json/reader/reader.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
},
"visibility": {
"all_reading_groups": "All $t(glossary.reading_group_title_case_other)",
"show_the_following": "Show the following:"
"show_the_following": "Show the following:",
"highlights_label": "Your highlights"
},
"notes": {
"delete_notation": "$t(actions.delete) $t(glossary.notation_title_case_other)",
Expand Down
30 changes: 14 additions & 16 deletions client/src/reader/components/control-menu/VisibilityMenuBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ class VisibilityMenuBody extends PureComponent {

showAll = () => {
const filter = {
highlight: { yours: true, others: true },
annotation: { yours: true, others: true },
annotation: { yours: true, others: true, highlights: true },
resource: { all: true },
readingGroups: Object.assign(this.readingGroupFilterBase(false), {
all: true,
Expand All @@ -69,8 +68,7 @@ class VisibilityMenuBody extends PureComponent {

hideAll = () => {
const filter = {
highlight: { yours: false, others: false },
annotation: { yours: false, others: false },
annotation: { yours: false, others: false, highlights: false },
resource: { all: false },
readingGroups: Object.assign(this.readingGroupFilterBase(false), {
all: false,
Expand Down Expand Up @@ -107,8 +105,6 @@ class VisibilityMenuBody extends PureComponent {
switch (format) {
case "annotation":
return "comment24";
case "highlight":
return "annotate24";
case "resource":
return "resource24";
case "reading-group":
Expand All @@ -119,7 +115,7 @@ class VisibilityMenuBody extends PureComponent {
};

renderFilter(format, label, children) {
const flex = format !== "reading-group";
const flex = format !== "reading-group" && format !== "annotation";
return (
<li key={`visibility-${format}`} className="visibility-menu__section">
<fieldset className="visibility-menu__group">
Expand Down Expand Up @@ -237,8 +233,13 @@ class VisibilityMenuBody extends PureComponent {

renderCheckbox(key, label, filterState, format, index, flex) {
const checkboxId = format + "-checkbox-" + index;
/* eslint-disable no-nested-ternary */
const adjustedLabel =
key === "all" ? this.props.t("actions.show_all") : label;
key === "all"
? this.props.t("actions.show_all")
: key === "highlights"
? this.props.t("reader.menus.visibility.highlights_label")
: label;
const checkboxClasses = classNames({
"checkbox checkbox--white": true,
"visibility-menu__checkbox": true,
Expand Down Expand Up @@ -269,20 +270,18 @@ class VisibilityMenuBody extends PureComponent {
}

showAllPressed(filters) {
const { annotation, highlight, readingGroups, resource } = filters ?? {};
if (!annotation || !highlight || !readingGroups || !resource) return false;
const { annotation, readingGroups, resource } = filters ?? {};
if (!annotation || !readingGroups || !resource) return false;
if (Object.values(annotation).some(val => !val)) return false;
if (Object.values(highlight).some(val => !val)) return false;
if (Object.values(resource).some(val => !val)) return false;
if (!readingGroups?.all) return false;
return true;
}

hideAllPressed(filters) {
const { annotation, highlight, readingGroups, resource } = filters ?? {};
if (!annotation || !highlight || !readingGroups || !resource) return false;
const { annotation, readingGroups, resource } = filters ?? {};
if (!annotation || !readingGroups || !resource) return false;
if (Object.values(annotation).some(val => val)) return false;
if (Object.values(highlight).some(val => val)) return false;
if (Object.values(resource).some(val => val)) return false;
if (Object.values(readingGroups).some(val => val)) return false;
return true;
Expand Down Expand Up @@ -319,8 +318,7 @@ class VisibilityMenuBody extends PureComponent {
</h2>
</div>
<ul className="visibility-menu__section-list">
{this.renderCheckboxGroup("highlight", filter.highlight)}
{this.renderCheckboxGroup("annotation", filter.annotation)}
{this.renderCheckboxGroup("annotation", filter.annotation, true)}
{this.renderCheckboxGroup("resource", filter.resource)}
{(this.canAccessReadingGroups || this.canEngagePublicly) &&
this.renderReadingGroups()}
Expand Down
12 changes: 2 additions & 10 deletions client/src/reader/components/section/helpers/filter-annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AnnotationsFilter {
}

get showYourHighlights() {
return this.filters.highlight.yours;
return this.filters.annotation.highlights;
}

get hideYourHighlights() {
Expand All @@ -39,14 +39,6 @@ class AnnotationsFilter {
return !this.showOthersAnnotations;
}

get showOthersHighlights() {
return this.filters.highlight.others;
}

get hideOthersHighlights() {
return !this.showOthersHighlights;
}

get showResources() {
return this.filters.resource.all;
}
Expand Down Expand Up @@ -82,7 +74,7 @@ class AnnotationsFilter {
const isResource = format === "resource";
const isInGroup = Boolean(readingGroupId);
if (isHighlight && isCreator && this.hideYourHighlights) return false;
if (isHighlight && !isCreator && this.hideOthersHighlights) return false;
if (isHighlight && !isCreator) return false;
if (isAnnotation && isCreator && this.hideYourAnnotations) return false;
if (isAnnotation && !isCreator && this.hideOthersAnnotations)
return false;
Expand Down
3 changes: 1 addition & 2 deletions client/src/store/reducers/ui/transitory/visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ export const initialState = {
loginOverlay: false,
userMenu: false,
visibilityFilters: {
highlight: { yours: true, others: false },
annotation: { yours: true, others: true },
annotation: { yours: true, others: true, highlights: true },
resource: { all: true },
readingGroups: { all: true }
},
Expand Down

0 comments on commit d472d7b

Please sign in to comment.