Skip to content

Commit

Permalink
style: Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
zatteo committed Nov 15, 2024
1 parent dd2aab3 commit 202505e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
18 changes: 11 additions & 7 deletions apps/browser/src/cozy/realtime/RealtimeNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ export class RealTimeNotifications {
const contactMustBeDisplayed = await shouldDisplayContact(this.client, data);

if (contactMustBeDisplayed) {
this.logService.info(`Contact ${data.displayName} (${data._id}) added from realtime`)
this.logService.info(`Contact ${data.displayName} (${data._id}) added from realtime`);
await this.upsertContactData(data);

await dispatchCreate(this.client, "io.cozy.contacts", data as CouchDBDocument);
} else {
this.logService.info(`Contact ${data.displayName} (${data._id}) not added from realtime`)
this.logService.info(`Contact ${data.displayName} (${data._id}) not added from realtime`);
}
}

async dispatchUpdateContact(data: IOCozyContact) {
if (data.me) {
// We need to do a fullSync here because we have no other way to know
// if a contact related to me was removed of the me relation
this.logService.info(`Starting full sync from realtime because me`)
this.logService.info(`Starting full sync from realtime because me`);

this.messagingService.send("fullSync");

Expand All @@ -92,11 +92,15 @@ export class RealTimeNotifications {

await dispatchUpdate(this.client, "io.cozy.contacts", data as CouchDBDocument);

this.logService.info(`Contact ${data.displayName} (${data._id}) added or updated from realtime because changed`)
this.logService.info(
`Contact ${data.displayName} (${data._id}) added or updated from realtime because changed`,
);
} else {
await this.dispatchDeleteContact(data);

this.logService.info(`Contact ${data.displayName} (${data._id}) removed from realtime because changed`)
this.logService.info(
`Contact ${data.displayName} (${data._id}) removed from realtime because changed`,
);
}
}

Expand Down Expand Up @@ -125,7 +129,7 @@ export class RealTimeNotifications {
every case.
*/

this.logService.info(`Starting full sync from realtime because paper updated`)
this.logService.info(`Starting full sync from realtime because paper updated`);

this.messagingService.send("fullSync");
}
Expand All @@ -146,7 +150,7 @@ export class RealTimeNotifications {
every case.
*/

this.logService.info(`Starting full sync from realtime because paper deleted`)
this.logService.info(`Starting full sync from realtime because paper deleted`);

this.messagingService.send("fullSync");
}
Expand Down
8 changes: 5 additions & 3 deletions libs/cozy/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ export const shouldDisplayContact = async (client: CozyClient, contact: IOCozyCo

const me = await fetchMyself(client);

const contactRelatedToMe =
// @ts-expect-error related added manually with an hydration
me?.[0]?.relationships?.related?.data.find((relatedContact) => relatedContact._id === contact._id);
const contactRelatedToMe = // @ts-expect-error related added manually with an hydration
me?.[0]?.relationships?.related?.data.find(
// @ts-expect-error related added manually with an hydration
(relatedContact) => relatedContact._id === contact._id,
);

if (contactRelatedToMe) {
return true;
Expand Down

0 comments on commit 202505e

Please sign in to comment.