fix: call a sharee without a name unknown person in every share sheet

This commit is contained in:
Linus Rath
2026-10-31 20:46:09 +01:00
parent a832f6ca3b
commit 34c65765ba
4 changed files with 39 additions and 2 deletions
+2 -1
View File
@@ -21,6 +21,7 @@ import { spacing, radius, typography, type ThemePalette } from '../../theme/toke
import { useColors } from '../../theme/colors';
import { useLocaleStore } from '../../stores/locale-store';
import { MODAL_ORIENTATIONS } from '../../lib/modal-orientations';
import { unknownPersonLabel } from '../sharing/unknown-person';
import { useSheetInsets } from '../../lib/use-layout';
import { useSheetBottomInset } from '../../lib/sheet-bottom-inset';
@@ -172,7 +173,7 @@ export default function ShareSheet({ node, onClose, onChanged }: ShareSheetProps
// Stalwart 1.0 with directory queries off hides every principal the user
// has no relationship with, so a sharee may have no name.
const unresolved = !p && !loadingPrincipals;
return p?.description || p?.name || (unresolved ? t('sharing.unknown_user', 'Unknown user') : principalId);
return p?.description || p?.name || (unresolved ? unknownPersonLabel(t) : principalId);
};
const renderPrincipalLabel = (principalId: string) => {
@@ -21,6 +21,7 @@ import { spacing, radius, typography, type ThemePalette } from '../../theme/toke
import { useColors } from '../../theme/colors';
import { useLocaleStore } from '../../stores/locale-store';
import { MODAL_ORIENTATIONS } from '../../lib/modal-orientations';
import { unknownPersonLabel } from './unknown-person';
import { useSheetInsets } from '../../lib/use-layout';
import { useSheetBottomInset } from '../../lib/sheet-bottom-inset';
@@ -200,7 +201,7 @@ export function ShareCollectionSheet<R extends object>({
return (
<View style={styles.principalInfo}>
<Text style={styles.principalName} numberOfLines={1}>
{p?.description || p?.name || (unresolved ? t('sharing.unknown_user', 'Unknown user') : principalId)}
{p?.description || p?.name || (unresolved ? unknownPersonLabel(t) : principalId)}
</Text>
{/* Never the id in its place: Stalwart 1.0's are a letter or two
("e") and read as a broken address. */}
@@ -0,0 +1,25 @@
import { describe, expect, it } from 'vitest';
import fs from 'node:fs';
import path from 'node:path';
import { unknownPersonLabel } from '../unknown-person';
import { principalRowDisplay } from '../../../lib/delegation/display';
// Settings > Sharing said "Unknown person", the folder share sheet "Unknown user".
const t = (_key: string, fallback?: string) => fallback ?? '';
const read = (rel: string) => fs.readFileSync(path.resolve(__dirname, '..', '..', '..', rel), 'utf8');
describe('a sharee without a name', () => {
it('reads like Settings > Sharing', () => {
expect(unknownPersonLabel(t)).toBe('Unknown person');
expect(unknownPersonLabel((key) => key)).toBe(principalRowDisplay(null, (key) => key).name);
});
it('is what the folder, calendar, address book and file share sheets show', () => {
for (const file of ['components/sharing/ShareCollectionSheet.tsx', 'components/files/ShareSheet.tsx']) {
const src = read(file);
expect(src, file).not.toMatch(/sharing\.unknown_user|Unknown user/);
expect(src, file).toMatch(/unresolved \? unknownPersonLabel\(t\) : principalId/);
}
});
});
+10
View File
@@ -0,0 +1,10 @@
type Translate = (key: string, fallback?: string) => string;
/**
* A sharee the server shows no name for (Stalwart 1.0 with directory queries
* off). One wording everywhere: Settings > Sharing (lib/delegation/display)
* said "Unknown person", the folder and file share sheets "Unknown user".
*/
export function unknownPersonLabel(t: Translate): string {
return t('delegates.unknown_person', 'Unknown person');
}