Skip to content

Commit

Permalink
Remove unnecessary async stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
thsparks committed May 9, 2024
1 parent a58b3a3 commit c169068
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
12 changes: 4 additions & 8 deletions teachertool/src/components/CatalogOverlay.tsx
Expand Up @@ -14,11 +14,7 @@ import { announceToScreenReader } from "../transforms/announceToScreenReader";
import { FocusTrap } from "react-common/components/controls/FocusTrap";
import { logError } from "../services/loggingService";
import { ErrorCode } from "../types/errorCode";
import {
addExpandedCatalogTagAsync,
getExpandedCatalogTags,
removeExpandedCatalogTagAsync,
} from "../services/storageService";
import { addExpandedCatalogTag, getExpandedCatalogTags, removeExpandedCatalogTag } from "../services/storageService";
import css from "./styling/CatalogOverlay.module.scss";

interface CatalogHeaderProps {
Expand Down Expand Up @@ -163,9 +159,9 @@ const CatalogList: React.FC = () => {

function onTagExpandToggled(tag: string, expanded: boolean) {
if (expanded) {
/* await */ addExpandedCatalogTagAsync(tag);
addExpandedCatalogTag(tag);
} else {
/* await */ removeExpandedCatalogTagAsync(tag);
removeExpandedCatalogTag(tag);
}
}

Expand All @@ -177,7 +173,7 @@ const CatalogList: React.FC = () => {
let expandedTags = getExpandedCatalogTags();
if (!expandedTags) {
// If we haven't saved an expanded set, default expand the first one.
addExpandedCatalogTagAsync(tags[0]);
addExpandedCatalogTag(tags[0]);
expandedTags = [tags[0]];
}

Expand Down
12 changes: 6 additions & 6 deletions teachertool/src/services/storageService.ts
Expand Up @@ -206,32 +206,32 @@ export function getExpandedCatalogTags(): string[] | undefined {
}
}

export async function setExpandedCatalogTagsAsync(tags: string[]) {
export function setExpandedCatalogTags(tags: string[]) {
try {
setValue(EXPANDED_CATALOG_TAGS_KEY, JSON.stringify(tags));
} catch (e) {
logError(ErrorCode.localStorageWriteError, e);
}
}

export async function addExpandedCatalogTagAsync(tag: string) {
export function addExpandedCatalogTag(tag: string) {
let expandedTags = getExpandedCatalogTags();
if (!expandedTags) {
expandedTags = [];
}
expandedTags.push(tag);
await setExpandedCatalogTagsAsync(expandedTags);
setExpandedCatalogTags(expandedTags);
}

export async function removeExpandedCatalogTagAsync(tag: string) {
export function removeExpandedCatalogTag(tag: string) {
let expandedTags = getExpandedCatalogTags();
if (!expandedTags) {
await setExpandedCatalogTagsAsync([]);
setExpandedCatalogTags([]);
} else {
const index = expandedTags.indexOf(tag);
if (index !== -1) {
expandedTags.splice(index, 1);
await setExpandedCatalogTagsAsync(expandedTags);
setExpandedCatalogTags(expandedTags);
}
}
}

0 comments on commit c169068

Please sign in to comment.