Edit: Add from phone contacts
This commit is contained in:
@@ -99,12 +99,15 @@ function draftFromParts(input: {
|
||||
};
|
||||
}
|
||||
|
||||
export async function pickPhoneContacts(): Promise<PhoneContactDraft[]> {
|
||||
export async function pickPhoneContacts(options?: {
|
||||
multiple?: boolean;
|
||||
}): Promise<PhoneContactDraft[]> {
|
||||
const api = contactsApi();
|
||||
if (!api) {
|
||||
throw new Error('CONTACT_PICKER_UNSUPPORTED');
|
||||
}
|
||||
const rows = await api.select(['name', 'email', 'tel'], { multiple: true });
|
||||
const multiple = options?.multiple !== false;
|
||||
const rows = await api.select(['name', 'email', 'tel'], { multiple });
|
||||
const drafts: PhoneContactDraft[] = [];
|
||||
const seen = new Set<string>();
|
||||
for (const row of rows) {
|
||||
@@ -121,6 +124,12 @@ export async function pickPhoneContacts(): Promise<PhoneContactDraft[]> {
|
||||
return drafts;
|
||||
}
|
||||
|
||||
/** یک مخاطب برای پر کردن فرم (نه ورود گروهی) */
|
||||
export async function pickOnePhoneContact(): Promise<PhoneContactDraft | null> {
|
||||
const rows = await pickPhoneContacts({ multiple: false });
|
||||
return rows[0] ?? null;
|
||||
}
|
||||
|
||||
function unfoldVcard(text: string): string[] {
|
||||
const raw = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
|
||||
const lines: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user