-
Notifications
You must be signed in to change notification settings - Fork 0
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
Customize automatic syncing #2
Labels
enhancement
New feature or request
Comments
Scarvy
changed the title
Customize automatic syncing - daily, weekly, monthly
Customize automatic syncing
Nov 13, 2024
Code for const triggerOnLoad = Boolean(store.get('triggerOnLoad'))
console.log('Trigger on load: ', triggerOnLoad)
if (triggerOnLoad) {
// if sync is already in progress, don't start another one
if (Boolean(store.get('isSyncing'))) {
mainWindow.webContents.send('toast:show', { variant: 'default', message: 'Sync already in progress...'})
console.log('Sync already in progress')
return
}
mainWindow.webContents.send('toast:show', { variant: 'default', message: 'Initiating sync...'})
const readwiseSync = new ReadwiseSync(mainWindow, store)
readwiseSync.syncHighlights(undefined, true)
console.log('Syncing highlights on load')
} Configure sync schedule: ipcMain.handle('update-sync-frequency', async (_event, frequency: string) => {
return await configureScheduledSync(frequency)
})
async function configureScheduledSync(frequency: string) {
const minutes = parseInt(frequency)
let milliseconds = minutes * 60 * 1000 // convert minutes to milliseconds
console.log("Settings interval to ", milliseconds)
if (!milliseconds) {
// user set frequency to "Manual"
return '0'
}
setInterval(async () => {
console.log('Syncing highlights...', new Date())
const readwiseSync = new ReadwiseSync(mainWindow, store)
await readwiseSync.syncHighlights(undefined, true)
}, milliseconds)
return frequency
} |
Scarvy
added a commit
that referenced
this issue
Nov 17, 2024
Scarvy
added a commit
that referenced
this issue
Nov 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Similar to the official Obsidian-Readwise plugin settings, add an option for users to select automatic syncing at specific intervals (e.g.,
Every 1 hour
,Every 12 hours
,Every 24 hours
,Every week
).The default option would be
Manual
and these options will be stored in the user's settings likefolder
,currentAccount
, anddefaultAccount
The text was updated successfully, but these errors were encountered: