New Rules stay off lists until the person who holds the pen turns on a share link, or the team features one. Uploaded files are readable only by those readers, stripped of location metadata, and deleted with the Rule, draft, or account.
37 lines
961 B
TypeScript
37 lines
961 B
TypeScript
import type { RuleVisibility } from "./ruleVisibility";
|
|
|
|
export type SharePerson = {
|
|
email: string;
|
|
initials: string;
|
|
role: "owner" | "reader";
|
|
};
|
|
|
|
export type RuleShareSettings = {
|
|
visibility: RuleVisibility;
|
|
shareSlug: string | null;
|
|
shareUrl: string;
|
|
shareUrlDisplay: string | null;
|
|
title: string;
|
|
ownerEmail: string;
|
|
ownerInitials: string;
|
|
readers: SharePerson[];
|
|
copyEnabled: boolean;
|
|
};
|
|
|
|
export function emailInitials(email: string): string {
|
|
const local = email.split("@")[0] ?? "";
|
|
const ch = local.trim().charAt(0);
|
|
return ch.length > 0 ? ch.toUpperCase() : "?";
|
|
}
|
|
|
|
/** Owner is shown separately. List the first reader, then an overflow line. */
|
|
export function visibleShareReaders(readers: SharePerson[]): {
|
|
shown: SharePerson[];
|
|
overflowCount: number;
|
|
} {
|
|
if (readers.length <= 1) {
|
|
return { shown: readers, overflowCount: 0 };
|
|
}
|
|
return { shown: readers.slice(0, 1), overflowCount: readers.length - 1 };
|
|
}
|