-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better management of realtime with contacts #334
base: master
Are you sure you want to change the base?
Conversation
606b7d8
to
202505e
Compare
libs/cozy/queries.ts
Outdated
definition: Q(CONTACTS_DOCTYPE).where({ me: true }), | ||
options: { | ||
as: `${CONTACTS_DOCTYPE}/myself`, | ||
singleDocData: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Le singleDocData
est inutile ici je pense, il ne marche qu'avec .getById
libs/cozy/queries.ts
Outdated
export const fetchMyself = async (client: CozyClient): Promise<IOCozyContact> => { | ||
const myselfQuery = buildMyselfQuery(); | ||
|
||
const { data }: { data: IOCozyContact } = await client.query( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Du coup ici IOCozyContact[]
libs/cozy/sync.ts
Outdated
|
||
const contactRelatedToMe = | ||
// @ts-expect-error related added manually with an hydration | ||
me?.[0]?.relationships?.related?.data.find((relatedContact) => relatedContact._id === contact._id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
me?.
l'opérateur optionnel ne devrait pas être nécessaire ici, si ? Et il manque entre data.find
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`) | ||
|
||
await dispatchUpdate(this.client, "io.cozy.contacts", data as CouchDBDocument); | ||
this.messagingService.send("fullSync"); | ||
|
||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting new PR from cozy-contacts
New name more precisely show that we only fetch me and favorites.
It was possible to add a contact in the browser extension from realtime even if we did not want it in the browser extension.
=> a paper with potential contact inside
me[0] should exist here because every one has me. But after we should use it until the end.
I had to start with a special case for "me" update, because in Cozy Contacts, relations were stored only in the contact who created the relation. So when "me" was updated, a relation of me could have been deleted, and it was impossible to know which one easily, so it was impossible to know if the contact should be removed from the extension. With cozy/cozy-contacts#1020, relations are propagated to the target contact. So we will get a realtime event and we will be able to check if the contact must be displayed or not without any special case.
202505e
to
3c915eb
Compare
No description provided.