Skip to content

Commit 33eae96

Browse files
authored
feat: improve google contacts sync ux (#2604)
* upgrade nuxt to latest version * feat: pre-select for google sync dialog & add button to notification success * feat: redirect to `contacts.google.com/label/label_id` on success * fix: skip account selection when only one google mining source exists
1 parent eacb295 commit 33eae96

File tree

7 files changed

+5568
-3632
lines changed

7 files changed

+5568
-3632
lines changed

backend/src/services/export/exports/google/contacts-api.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ export default class GoogleContactsSession {
8282
return chunks;
8383
}
8484

85-
async run(contacts: ContactFrontend[], updateEmptyOnly: boolean) {
85+
async run(
86+
contacts: ContactFrontend[],
87+
updateEmptyOnly: boolean
88+
): Promise<{ labelId: string | null }> {
8689
try {
8790
logger.debug('GoogleContactsSession.run(): Starting sync process', {
8891
userId: this.userId,
@@ -191,6 +194,15 @@ export default class GoogleContactsSession {
191194
created: create.size,
192195
updated: update.size
193196
});
197+
198+
const appLabelResourceName = this.labelMap.get(
199+
ENV.APP_NAME.toLowerCase()
200+
);
201+
const labelId = appLabelResourceName
202+
? appLabelResourceName.replace('contactGroups/', '')
203+
: null;
204+
205+
return { labelId };
194206
} catch (err) {
195207
logger.error(
196208
`GoogleContactsSession.run(): Error during sync: ${(err as Error).message}`,

backend/src/services/export/exports/google/index.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ export default class GoogleContactsExport
8989
ENV.APP_NAME,
9090
opts.userId
9191
);
92-
await session.run(contacts, opts.updateEmptyFieldsOnly ?? false);
92+
const { labelId } = await session.run(
93+
contacts,
94+
opts.updateEmptyFieldsOnly ?? false
95+
);
96+
97+
return {
98+
content: JSON.stringify({ labelId }),
99+
contentType: this.contentType,
100+
charset: '',
101+
extension: ''
102+
};
93103
} catch (err) {
94104
if (err instanceof GaxiosError) {
95105
logger.error(`Export error: ${err.message}`, err);
@@ -104,12 +114,5 @@ export default class GoogleContactsExport
104114
}
105115
throw err;
106116
}
107-
108-
return {
109-
content: '',
110-
contentType: this.contentType,
111-
charset: '',
112-
extension: ''
113-
};
114117
}
115118
}

backend/src/services/export/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface ExportResult {
2020
contentType: string;
2121
charset: string;
2222
extension: string;
23+
metadata?: Record<string, unknown>;
2324
}
2425

2526
export interface ExportStrategy<T> {

0 commit comments

Comments
 (0)