Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion web/components/AppDrawer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { navigateTo, useClient, useNotebaseConfig, useUser } from '#imports'
import { navigateTo, useClient, useNotebaseConfig, useToast, useUser } from '#imports'

import { ref } from 'vue'

Expand All @@ -9,13 +9,19 @@ const open = ref(false)

const pb = useClient()
const user = useUser()
const toast = useToast()

const onLogout = async () => {
await pb.clearAuth()
user.value.isAuthenticated = false
await navigateTo({ name: 'login' })
}

const restartSync = async () => {
await pb.restartSync()
toast.add({ title: 'Restart complete' })
}

const closeSlideover = () => {
open.value = false
}
Expand Down Expand Up @@ -88,6 +94,9 @@ const navigationItems = ref([
<USeparator class="my-2" />

<div class="flex flex-col gap-2 mt-auto">
<UButton @click="restartSync">
Restart sync
</UButton>
<UCheckbox
v-model="notebaseConfig.config.value.showExtra"
label="Show extra"
Expand Down
5 changes: 5 additions & 0 deletions web/modules/pocketbase/runtime/utils/pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export function createPocketBaseClient(url: string): BaseClient {
await pb.collection('files').update(id, { content: data })
}

const restartSync = async () => {
await pb.send('/sync/restart', {})
}

return {
isAuthenticated,
clearAuth,
Expand All @@ -40,5 +44,6 @@ export function createPocketBaseClient(url: string): BaseClient {
updateContent,
getList,
getItem,
restartSync,
}
}
5 changes: 5 additions & 0 deletions web/modules/pocketbase/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export interface BaseClient {
*/
updateContent: (id: string, data: string) => Promise<void>

/**
* Restarts the sync process also clearing the storage and rebuilding it
*/
restartSync: () => Promise<void>

/**
* Checks if the current client has valid authentication
* @returns Promise resolving to authentication status (true/false)
Expand Down