Release Vulpes OS 2.7 Preview 25 for Desktop, Android and Pixel 3a
This commit is contained in:
parent
6a44daeaaa
commit
3a1fba4efe
1 changed files with 1301 additions and 196 deletions
|
|
@ -11,6 +11,25 @@ export class Contacts {
|
|||
contacts: [],
|
||||
};
|
||||
}
|
||||
async importCards(app, cards) {
|
||||
if (!app.manifest.permissions?.contacts?.access?.includes('write')) throw Error('PERMISSION_DENIED');
|
||||
const commit = this.queue.then(async () => {
|
||||
const now = new Date().toISOString();
|
||||
const imported = cards.map(card => ({
|
||||
...card, id: Services.uuid.generateUUID().toString(), published: now, updated: now,
|
||||
}));
|
||||
const next = {
|
||||
contacts: this.data.contacts.concat(imported),
|
||||
revision: this.data.revision + imported.length,
|
||||
};
|
||||
await this.storage.run('vulpes-private-contacts', 'put', [next, 'state']);
|
||||
this.data = next;
|
||||
for (const contact of imported) this.notify({contactID: contact.id, reason: 'create'});
|
||||
return imported.length === 1 ? imported[0] : {count: imported.length};
|
||||
});
|
||||
this.queue = commit.catch(() => {});
|
||||
return commit;
|
||||
}
|
||||
async request(app, { operation, contact, options = {}, id }) {
|
||||
const access = app.manifest.permissions?.contacts?.access || '';
|
||||
const write = ['save', 'remove', 'clear'].includes(operation);
|
||||
|
|
|
|||
Loading…
Reference in a new issue