Handle missing notes

This commit is contained in:
Bojan Mojsilovic 2024-03-26 11:29:37 +01:00
parent 7c13ded03c
commit 913c478e9e
3 changed files with 59 additions and 21 deletions

View File

@ -36,6 +36,21 @@
background-color: var(--background-card); background-color: var(--background-card);
} }
.missingNote {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
p {
font-weight: 700;
font-size: 18px;
line-height: 34px;
padding-inline: 20px;
margin: 2px;
color: var(--text-secondary);
}
}
@media only screen and (max-width: 720px) { @media only screen and (max-width: 720px) {
.border { .border {
height: 36px; height: 36px;

View File

@ -16,7 +16,7 @@ import { sortByRecency } from '../stores/note';
import { scrollWindowTo } from '../lib/scroll'; import { scrollWindowTo } from '../lib/scroll';
import { useIntl } from '@cookbook/solid-intl'; import { useIntl } from '@cookbook/solid-intl';
import Search from '../components/Search/Search'; import Search from '../components/Search/Search';
import { thread as t } from '../translations'; import { placeholders as tPlaceholders, thread as t } from '../translations';
import { userName } from '../stores/profile'; import { userName } from '../stores/profile';
import PageTitle from '../components/PageTitle/PageTitle'; import PageTitle from '../components/PageTitle/PageTitle';
import NavHeader from '../components/NavHeader/NavHeader'; import NavHeader from '../components/NavHeader/NavHeader';
@ -181,31 +181,42 @@ const Thread: Component = () => {
} }
</For> </For>
</div> </div>
</Show>
<Show when={primaryNote()}> <Show
<div id="primary_note"> when={primaryNote()}
<NotePrimary fallback={
note={primaryNote() as PrimalNote} <div class={styles.missingNote}>
/> <p>
<Show when={account?.hasPublicKey()}> {intl.formatMessage(tPlaceholders.missingNote.firstLine)}
<ReplyToNote </p>
<p>
{intl.formatMessage(tPlaceholders.missingNote.secondLine)}
</p>
</div>
}>
<div id="primary_note">
<NotePrimary
note={primaryNote() as PrimalNote} note={primaryNote() as PrimalNote}
onNotePosted={onNotePosted}
/> />
</Show> <Show when={account?.hasPublicKey()}>
<ReplyToNote
note={primaryNote() as PrimalNote}
onNotePosted={onNotePosted}
/>
</Show>
</div>
</Show>
<div class={styles.repliesHolder} ref={repliesHolder}>
<For each={replyNotes()}>
{note =>
<div>
<Note note={note} shorten={true} />
</div>
}
</For>
</div> </div>
</Show> </Show>
<div class={styles.repliesHolder} ref={repliesHolder}>
<For each={replyNotes()}>
{note =>
<div>
<Note note={note} shorten={true} />
</div>
}
</For>
</div>
</Show> </Show>
</div> </div>
) )

View File

@ -992,6 +992,18 @@ export const notifications = {
}; };
export const placeholders = { export const placeholders = {
missingNote: {
firstLine: {
id: 'placeholders.missingNote.firstLine',
defaultMessage: 'Oups! We can\'t seem to find this note.',
description: 'Placeholder when the note is missing',
},
secondLine: {
id: 'placeholders.missingNote.secondLine',
defaultMessage: 'It may have been deleted by the author.',
description: 'Placeholder when the note is missing',
},
},
noLikeDetails: { noLikeDetails: {
id: 'placeholders.noLikeDetails', id: 'placeholders.noLikeDetails',
defaultMessage: 'No details for likes found', defaultMessage: 'No details for likes found',