Skip to content

Commit

Permalink
Set sync DL to trigger on successful login
Browse files Browse the repository at this point in the history
- This was prev managed by the sync FB backend, though not enough control with it triggering on every single auth state change
  • Loading branch information
poltak committed Apr 6, 2024
1 parent 56f7305 commit 3add6c9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
3 changes: 3 additions & 0 deletions src/background-mv3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ async function main() {
process.env.NODE_ENV === 'production' ? 'production' : 'staging',
})
pushMessagingClient.bgModules = backgroundModules
authServices.auth.events.on('loginSuccess', () => {
backgroundModules.personalCloud.triggerSyncContinuation()
})

registerBackgroundModuleCollections({
storageManager,
Expand Down
5 changes: 4 additions & 1 deletion src/personal-cloud/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ export class PersonalCloudBackground {
async integrateContinuously() {
const { backend, settingStore } = this.options
try {
for await (const { batch, lastSeen } of backend.streamUpdates()) {
for await (const { batch, lastSeen } of backend.streamUpdates({
mode: 'continuous-invocation',
skipInvocationOnUserChange: true,
})) {
try {
await keepWorkerAlive(
(async () => {
Expand Down

0 comments on commit 3add6c9

Please sign in to comment.