Skip to content

Commit

Permalink
TAB-489 remove isomorphic-git
Browse files Browse the repository at this point in the history
  • Loading branch information
evandor committed Feb 17, 2024
1 parent 07caefd commit 4c3db70
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 934 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"@editorjs/editorjs": "^2.27.2",
"@editorjs/header": "^2.7.0",
"@extractus/feed-extractor": "^7.0.1",
"@isomorphic-git/lightning-fs": "^4.6.0",
"@logtail/browser": "^0.4.19",
"@mozilla/readability": "^0.5.0",
"@quasar/extras": "^1.16.6",
Expand All @@ -59,7 +58,6 @@
"html-to-text": "^9.0.4",
"idb": "^8.0.0",
"idraw": "^0.3.1",
"isomorphic-git": "^1.25.5",
"jwt-decode": "^3.1.2",
"keytar": "^7.9.0",
"lodash": "^4.17.21",
Expand Down
22 changes: 2 additions & 20 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {getAuth, isSignInWithEmailLink, onAuthStateChanged, signInWithEmailLink,
import {CURRENT_USER_EMAIL, CURRENT_USER_ID} from "boot/constants";
import {useSuggestionsStore} from "stores/suggestionsStore";
import {StaticSuggestionIdent, Suggestion} from "src/models/Suggestion";
import {useRoute, useRouter} from "vue-router";
import {useRouter} from "vue-router";
import {collection, doc, getDoc, getDocs} from "firebase/firestore";
import {Account, UserData} from "src/models/Account";
import FirebaseService from "src/services/firebase/FirebaseService";
Expand All @@ -28,7 +28,6 @@ const {handleError} = useNotificationHandler()
const emitter = new EventEmitter()
emitter.setMaxListeners(12)
FirebaseService.init()
const auth = FirebaseService.getAuth()
const firestore = FirebaseService.getFirestore()
Expand All @@ -39,26 +38,9 @@ onAuthStateChanged(auth, async (user) => {
// https://firebase.google.com/docs/reference/js/auth.user
console.log("%conAuthStateChanged: about to log in", "border:1px solid green")
// --- if we do this in useAuthStore.setUser(), we cannot properly run vitest anymore (!?!)
// TODO revisit now
try {
const userDoc = await getDoc(doc(firestore, "users", user.uid))
const userData = userDoc.data() as UserData
const account = new Account(user.uid, userData)
console.log("created account object", account)
const querySnapshot = await getDocs(collection(firestore, "users", user.uid, "subscriptions"))
const products = new Set<string>()
querySnapshot.forEach((doc) => {
const subscriptionData = doc.data()
if (subscriptionData.data && subscriptionData.data.metadata) {
products.add(subscriptionData.data.metadata.product)
}
account.setProducts(Array.from(products))
//console.log("hier", account, products)
})
// --- end of statement
await AppService.init($q, router, true, user, account)
await AppService.init($q, router, true, user)
} catch (error:any) {
console.log("%ccould not initialize appService due to " + error, "background-color:orangered")
console.error("error", error, typeof error, error.code, error.message)
Expand Down
9 changes: 0 additions & 9 deletions src/pages/SidePanelPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,6 @@
<template v-slot:title v-else>
<div class="text-subtitle1">
{{ toolbarTitle(tabsets as Tabset[]) }}
<!-- <q-icon-->
<!-- v-if="LocalStorage.getItem(SYNC_TYPE) as SyncType === SyncType.GITHUB && useAuthStore().isAuthenticated()"-->
<!-- class="q-ml-none" name="sync" size="12px">-->
<!-- <q-tooltip class="tooltip-small">Tabsets synced via {{ syncSource() }}</q-tooltip>-->
<!-- </q-icon>-->
<!-- <q-icon v-if="LocalStorage.getItem(SYNC_TYPE) as SyncType === SyncType.MANAGED_GIT"-->
<!-- class="q-ml-none" name="sync" size="12px">-->
<!-- <q-tooltip class="tooltip-small">Tabsets are being synced automatically</q-tooltip>-->
<!-- </q-icon>-->
</div>
</template>

Expand Down
97 changes: 1 addition & 96 deletions src/pages/helper/SyncingSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
Your tabset data is only available on your local machine and the current browser. If you want to
use tabsets on other computers and/or browsers, you need to set up syncing.
</div>
<div class="col-7 text-caption" v-if="tempSyncOption === SyncType.GITHUB">
Sync your tabsets across browsers and computers via a <b>github repository</b>.<br>
This is suitable if you do not have too many tabsets and performance is not your first concern.<br><br>
You need to provide a github repository URL and a personal access token (e.g. for
github: <a
href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens"
target="_blank">github example</a>).<br><br>
Initially, the repository should be empty. <span class="warning">If you chose a public repository, everybody is able to access your stored tabsets</span>.
</div>
<div class="col-7 text-caption" v-if="tempSyncOption === SyncType.COUCHDB">
Sync your tabsets across browsers and computers via a database (not yet supported)
</div>
Expand All @@ -43,47 +34,6 @@

<div class="col"></div>

<template v-if="tempSyncOption === SyncType.GITHUB">

<div class="col-3">
Github Repository URL
</div>
<div class="col-7">
<q-input type="url" color="primary" filled v-model="githubRepoUrl"
lazy-rules
:rules="[
(val:string) => !!val || 'Github Repository URL is required',
(val:string) => /^https:\/\/github.com\/.*$/.test(val) || 'Must start with github'
]"
hint="The repository URL for your github repository"
label="" autocomplete="sync-url">
<template v-slot:prepend>
<q-icon name="sync"/>
</template>
</q-input>
</div>
<div class="col text-right">
<q-icon v-if="githubRepoUrl" class="cursor-pointer" name="open_in_new" size="md"
@click="NavigationService.openSingleTab(githubRepoUrl)"/>
</div>

<div class="col-3">
Github Repository Token
</div>
<div class="col-7">
<q-input type="password" color="primary" filled v-model="githubRepoToken" label=""
hint="needed for write access, for private repositories also for read access">
<template v-slot:prepend>
<q-icon name="sync"/>
</template>
</q-input>
<span v-if="showWrongTokenMessage()" class="text-negative text-caption">Seems like your github token is wrong or missing. Update or switch to "No Syncing"</span>
</div>
<div class="col text-right">

</div>
</template>

<template v-if="tempSyncOption === SyncType.COUCHDB">

<div class="col-3">
Expand Down Expand Up @@ -131,17 +81,6 @@

</template>

<template v-if="tempSyncOption === SyncType.GITHUB && githubRepoUrl ||
(tempSyncOption === SyncType.GITHUB && githubRepoUrl)">
<div class="col-3"></div>
<div class="col-7">
<q-btn
label="Test Connection" @click="testGitConnection()"/>
<span class="q-ml-md"> {{ testResult }}</span>
</div>
<div class="col text-right"></div>
</template>

<template v-if="tempSyncOption === SyncType.COUCHDB && couchdbUrl">
<div class="col-3"></div>
<div class="col-7">
Expand All @@ -152,24 +91,6 @@
<div class="col text-right"></div>
</template>

<template v-if="startSyncMessage(SyncType.GITHUB)">
<div class="col-3"></div>
<div class="col-7">
<div>You can switch to the git-based sync version of tabsets now if you wish.</div>
<div>Please follow these steps:</div>
<ul>
<li><span class="cursor-pointer text-blue-8"
@click.stop="emits('wasClicked',{tab: 'importExport'})">Export</span> your tabsets
first (if you want to keep them)
</li>
<li>Click on 'Start Syncing' below</li>
<li>Restart Tabsets (close and open again)</li>
<li>Import your tabsets again (if needed)</li>
</ul>
</div>
<div class="col text-right"></div>
</template>

<template v-if="stopSyncMessage()">
<div class="col-3"></div>
<div class="col-7">
Expand Down Expand Up @@ -315,7 +236,6 @@ import {
SYNC_GITHUB_TOKEN,
SYNC_TYPE
} from "boot/constants";
import GitPersistentService from "src/services/persistence/GitPersistentService";
import {FirebaseCall} from "src/services/firebase/FirebaseCall";
import {useUtils} from "src/services/Utils";
import {useNotificationHandler} from "src/services/ErrorHandler";
Expand Down Expand Up @@ -349,10 +269,7 @@ const testResult = ref<string | undefined>(undefined)
const acknowledgment = ref<boolean>(false)
const publish = ref<boolean>(false)
const syncOptions = useSettingsStore().isEnabled('dev') ? [
{label: 'No Syncing', value: SyncType.NONE, desc: ""},
{label: 'Syncing', value: SyncType.FIRESTORE, desc: ""},
{label: 'Syncing via github repository', value: SyncType.GITHUB}] :
const syncOptions =
[
{label: 'No Syncing', value: SyncType.NONE, desc: ""},
{label: 'Syncing', value: SyncType.FIRESTORE, desc: ""},
Expand All @@ -375,18 +292,6 @@ watchEffect(() => {
checkAndUpdate(couchdbUrl.value, SYNC_COUCHDB_URL)
})
const testGitConnection = async () => {
const url = githubRepoUrl.value
const token = tempSyncOption.value === SyncType.GITHUB ? githubRepoToken.value : githubRepoToken.value
if (url) {
console.log("testing git connection with", url, token?.substring(0, 5) + "...")
const res = await GitPersistentService.testConnection(url)//, gitRepoToken)
testResult.value = res
} else {
testResult.value = "no repo URL given"
}
}
const testDbConnection = async () => {
if (couchdbUrl.value) {
console.log("testing db connection with", couchdbUrl.value)
Expand Down
15 changes: 3 additions & 12 deletions src/services/AppService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,18 @@ import {useGroupsStore} from "stores/groupsStore";
import {FeatureIdent} from "src/models/AppFeature";
import {useMessagesStore} from "src/stores/messagesStore";
import {SyncType, useAppStore} from "stores/appStore";
import GitPersistentService from "src/services/persistence/GitPersistentService"
import {useAuthStore} from "stores/authStore";
import PersistenceService from "src/services/PersistenceService";
import {useUiStore} from "stores/uiStore";
import {User} from "firebase/auth";
import {Account} from "src/models/Account";
import FsPersistenceService from "src/services/persistence/FsPersistenceService";
import FsPersistenceService from "src/services/persistence/FirestorePersistenceService";

function dbStoreToUse(st: SyncType, su: string | undefined) {
const isAuthenticated = useAuthStore().isAuthenticated()
if (!isAuthenticated) {
console.debug("%not authenticated", "font-weight:bold")
return useDB(undefined).db
}
if (st && (st === SyncType.GITHUB) && su) {
console.debug("%csyncType " + st, "font-weight:bold")
return useDB(undefined).gitDb
}
if (st === SyncType.FIRESTORE) {
console.debug("%csyncType " + st, "font-weight:bold")
return useDB(undefined).firestore
Expand All @@ -52,7 +46,7 @@ class AppService {
router: Router = null as unknown as Router
initialized = false

async init(quasar: any, router: Router, forceRestart = false, user: User | undefined = undefined, account: Account | undefined = undefined) {
async init(quasar: any, router: Router, forceRestart = false, user: User | undefined = undefined) {

console.log(`%cinitializing AppService: first start=${!this.initialized}, forceRestart=${forceRestart}, quasar set=${quasar !== undefined}, router set=${router !== undefined}`, forceRestart ? "font-weight:bold" : "")

Expand Down Expand Up @@ -98,7 +92,7 @@ class AppService {
// init services
await useAuthStore().initialize(useDB(undefined).db)
await useAuthStore().setUser(user)
useAuthStore().upsertAccount(account)
//useAuthStore().upsertAccount(account)

await useNotificationsStore().initialize(useDB(undefined).db)
useSuggestionsStore().init(useDB(undefined).db)
Expand Down Expand Up @@ -127,9 +121,6 @@ class AppService {
uiStore.appLoading = "syncing tabsets..."
}

const gitInitResult = await GitPersistentService.init(syncType, failedGitLogin ? '' : syncUrl)
console.log("%cgitInitResult", "font-weight:bold", gitInitResult)

await FsPersistenceService.init()

await this.initCoreSerivces(quasar, persistenceStore, this.router)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function spacesCollection() {
return collection(FirebaseService.getFirestore(), "users", useAuthStore().user.uid, "spaces")
}

class FsPersistenceService implements PersistenceService {
class FirestorePersistenceService implements PersistenceService {

getServiceName(): string {
return "FirestorePersistenceService"
Expand All @@ -48,10 +48,6 @@ class FsPersistenceService implements PersistenceService {
return Promise.resolve("")
}

private async initDatabase(url: string, proxy: string, dir: string = this._dir): Promise<any> {
}


/**
* === Tabsets ========================================
*/
Expand Down Expand Up @@ -313,4 +309,4 @@ class FsPersistenceService implements PersistenceService {

}

export default new FsPersistenceService()
export default new FirestorePersistenceService()
Loading

0 comments on commit 4c3db70

Please sign in to comment.