Skip to content

Commit

Permalink
Remix: don't cache API responses (#4954)
Browse files Browse the repository at this point in the history
* unknown name

* api endpoints disable cache
  • Loading branch information
ruggi authored Feb 26, 2024
1 parent 7adcafa commit b67a46b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions utopia-remix/app/routes/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { requireUser } from '../util/api.server'
import { assertNever } from '../util/assertNever'
import { projectEditorLink } from '../util/links'
import { when } from '../util/react-conditionals'
import { multiplayerInitialsFromName } from '../util/strings'
import { UnknownPlayerName, multiplayerInitialsFromName } from '../util/strings'
import { useProjectMatchesQuery, useSortCompareProject } from '../util/use-sort-compare-project'

const SortOptions = ['title', 'dateCreated', 'dateModified'] as const
Expand Down Expand Up @@ -628,7 +628,7 @@ const ProjectCard = React.memo(
fontWeight: 700,
filter: project.deleted === true ? 'grayscale(1)' : undefined,
}}
title={collaborator.name}
title={collaborator.name ?? UnknownPlayerName}
className={sprinkles({
boxShadow: 'shadow',
color: 'white',
Expand Down Expand Up @@ -753,7 +753,7 @@ const ProjectRow = React.memo(
fontWeight: 700,
filter: project.deleted === true ? 'grayscale(1)' : undefined,
}}
title={collaborator.name}
title={collaborator.name ?? UnknownPlayerName}
className={sprinkles({
boxShadow: 'shadow',
color: 'white',
Expand Down
1 change: 1 addition & 0 deletions utopia-remix/app/util/api.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const responseHeaders: HeadersInit = {
'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Headers': 'content-type, origin, cookie',
'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,OPTIONS',
'Cache-control': 'no-cache',
}

export async function handleOptions(): Promise<TypedResponse<EmptyResponse>> {
Expand Down
7 changes: 5 additions & 2 deletions utopia-remix/app/util/strings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export function multiplayerInitialsFromName(name: string): string {
const baseName = name.trim().toUpperCase()
export const UnknownPlayerName = 'Unknown'

export function multiplayerInitialsFromName(name: string | null): string {
const nameOrUnknown = name ?? UnknownPlayerName
const baseName = nameOrUnknown.trim().toUpperCase()

const words = baseName.split(/\s+/)
if (words.length >= 2) {
Expand Down

0 comments on commit b67a46b

Please sign in to comment.