Skip to content
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

Tab 484 #142

Merged
merged 12 commits into from
Feb 7, 2024
Merged
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"@types/pouchdb": "^6.4.2",
"@types/rangy": "^0.0.38",
"@types/sanitize-html": "^2.9.0",
"@xenova/transformers": "^2.12.1",
"axios": "^1.3.4",
"buffer": "^6.0.3",
"date-fns": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion qodana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ profile:
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-jvm:latest
linter: jetbrains/qodana:latest
include:
- name: DuplicatedCode
- name: JsCoverageInspection
Expand Down
25 changes: 17 additions & 8 deletions src-bex/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ chrome.runtime.onInstalled.addListener((callback) => {
// getting error: "Service worker registration failed. Status code: 15"
// Analytics.fireEvent('install-' + callback.reason);
if (callback.reason !== OnInstalledReason.CHROME_UPDATE) {
chrome.tabs.create({
active: true,
url: callback.previousVersion ?
"https://tabsets.web.app/#/updatedFrom/" + callback.previousVersion :
"https://tabsets.web.app/#/installed/"
})
chrome.tabs.create({
active: true,
url: callback.previousVersion ?
"https://tabsets.web.app/#/updatedFrom/" + callback.previousVersion :
"https://tabsets.web.app/#/installed/"
})
}
});

chrome.omnibox.onInputEntered.addListener((text) => {
const newURL = chrome.runtime.getURL("/www/index.html#/searchresult?t=" + encodeURIComponent(text))
chrome.tabs.create({ url: newURL })
chrome.tabs.create({url: newURL})
.catch((err) => console.log("background.js error", err))
});

Expand Down Expand Up @@ -88,6 +88,15 @@ chrome.runtime.onStartup.addListener(() => {
}
})

chrome.runtime.onConnect.addListener(function (port) {
if (port.name === 'tabsetsSidepanel') {
//console.log("port3", port)
port.onDisconnect.addListener(async () => {
//alert('Sidepanel closed.');
});
}
});

export default bexBackground((bridge, cons/* , allActiveConnections */) => {
// bridge.on('some.event', ({data, respond}) => {
// console.log('Event receieved, responding...')
Expand All @@ -98,7 +107,7 @@ export default bexBackground((bridge, cons/* , allActiveConnections */) => {
// bridge.send('highlight.content', { url: tab.url })
// })

bridge.on('quasar.detect', ({ data, respond }) => {
bridge.on('quasar.detect', ({data, respond}) => {
console.log("quasar.detect2", data)
// Let's resolve the `send()` call's promise, this way we can await it on the other side then display a notification.
respond()
Expand Down
95 changes: 44 additions & 51 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@

<script setup lang="ts">

//window.global ||= window;

import {LocalStorage, useQuasar} from "quasar";
import AppService from "src/services/AppService";
import {useAuthStore} from "stores/authStore";
import {EventEmitter} from "events";
import {logtail} from "boot/logtail";
import {getAuth, isSignInWithEmailLink, onAuthStateChanged, signInWithEmailLink, UserCredential} from "firebase/auth";
import {CURRENT_USER_EMAIL} from "boot/constants";
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 {collection, doc, getDoc, getDocs} from "firebase/firestore";
import {firestore} from "boot/firebase";
import {Account} from "src/models/Account";
import {useSuggestionsStore} from "stores/suggestionsStore";
import {StaticSuggestionIdent, Suggestion} from "src/models/Suggestion";
import {useRouter} from "vue-router";

const $q = useQuasar()
const router = useRouter()
Expand All @@ -29,57 +27,38 @@ emitter.setMaxListeners(12)

const auth = getAuth();

onAuthStateChanged(auth, (user) => {
onAuthStateChanged(auth, async (user) => {
if (user) {
// User is signed in, see docs for a list of available properties
// https://firebase.google.com/docs/reference/js/auth.user
console.log("%conAuthStateChanged: logged in", "border:1px solid green")
useAuthStore().setUser(user)

getDoc(doc(firestore, "users", user.uid))
.then(userDoc => {
//console.log("userDoc", userDoc)
const userData = userDoc.data()
console.log("userData", userData)

const account = new Account(user.uid, userData)

getDocs(collection(firestore, "users", user.uid, "subscriptions"))
.then((querySnapshot) => {
//console.log("querySnapshot", querySnapshot)
const products = new Set<string>()
querySnapshot.forEach((doc) => {
//console.log(doc.id, " => ", doc.data());
//key += doc.id + "|"
const subscriptionData = doc.data()
if (subscriptionData.status === "active") {
const items = subscriptionData.items
for (const i of items) {
//console.log("checking item", i)
if (i.plan.product) {
products.add(i.plan.product)
}
}
}
account.setProducts(Array.from(products))
// TODO we do not need to store that much
//account.addSubscription(subscriptionData)
})
useAuthStore().upsertAccount(account)
useAuthStore().setProducts(Array.from(products))

//AppService.restart("restarted=true")
AppService.init($q, router)
})

})
console.log("%conAuthStateChanged: about to log in", "border:1px solid green")

// --- if we do this in useAuthStore.setUser(), we cannot properly run vitest any more
const userDoc = await getDoc(doc(firestore, "users", user.uid))
const userData = userDoc.data()
const account = new Account(user.uid, userData)
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)

} else {
// User is signed out
console.log("%conAuthStateChanged: logged out", "border:1px solid green")
useAuthStore().setUser(undefined)
AppService.init($q, router)
await AppService.init($q, router, true, undefined)
if (!router.currentRoute.value.path.startsWith("/mainpanel")) {
await router.push("/")
}
}
});

Expand All @@ -101,7 +80,7 @@ if (isSignInWithEmailLink(auth, window.location.href)) {
logtail.info("found email link redirection")
})
.catch((error) => {
console.error("error", error)
console.error("error in email link redirection", error)
logtail.error("error in email link redirection", error)
useSuggestionsStore().addSuggestion(Suggestion.getStaticSuggestion(StaticSuggestionIdent.RESTART_SUGGESTED))
});
Expand All @@ -111,7 +90,21 @@ if (isSignInWithEmailLink(auth, window.location.href)) {

$q.dark.set($q.localStorage.getItem('darkMode') || false)

AppService.init($q, router)
const currentUser = $q.localStorage.getItem(CURRENT_USER_ID)
if (currentUser) {
console.log("current user id found, waiting for auto-login")
// we should be logged in any second
} else {

setTimeout(() => {
// triggers, but app should already have been started, no restart enforced
console.debug("app start fallback after 2000ms")
AppService.init($q, router, false)
}, 2000)


}


logtail.info("tabsets started", {
"mode": process.env.MODE,
Expand Down
2 changes: 1 addition & 1 deletion src/components/SavedPdfs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
</div>
<div class="col-9 text-body2 ellipsis">
{{ pdf.title }}
{{ pdf['title' as keyof object] }}
</div>
<div class="col-1">
<!-- <q-icon name="close" @click.stop="deleteMHtml(pdf)"/>-->
Expand Down
57 changes: 37 additions & 20 deletions src/components/SidePanelFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@
</template>

</div>
<div class="col text-right text-black">
<div class="col text-right text-black" v-if="useUiStore().appLoading">
&nbsp;
</div>
<div v-else class="col text-right text-black">
<q-btn icon="o_help" v-if="usePermissionsStore().hasFeature(FeatureIdent.HELP)"
:class="rightButtonClass()"
flat
Expand All @@ -68,7 +71,7 @@
@click="openHelpView()">
</q-btn>

<q-btn icon="o_settings" v-if="useTabsStore().tabsets.size > 0"
<q-btn icon="o_settings" v-if="useTabsStore().tabsets.size > 0 || useAuthStore().isAuthenticated()"
:class="rightButtonClass()"
flat
color="black"
Expand All @@ -77,13 +80,14 @@
<q-tooltip class="tooltip" anchor="top left" self="bottom left">{{ settingsTooltip() }}</q-tooltip>
</q-btn>

<q-btn v-if="useWindowsStore().currentWindows.length > 1"
icon="o_grid_view"
:class="rightButtonClass()"
flat
color="black"
:size="getButtonSize()"
@click="toggleShowWindowTable()">
<q-btn
icon="o_grid_view"
data-testid="buttonManageWindows"
:class="rightButtonClass()"
flat
color="black"
:size="getButtonSize()"
@click="toggleShowWindowTable()">
<q-tooltip class="tooltip" anchor="top left" self="bottom left">Manage Windows</q-tooltip>
</q-btn>

Expand All @@ -95,7 +99,8 @@
flat
color="black"
size="20px">
<q-tooltip :delay="2000" anchor="center left" self="center right" class="tooltip-small">Alternative Access</q-tooltip>
<q-tooltip :delay="2000" anchor="center left" self="center right"
class="tooltip-small">Alternative Access</q-tooltip>
</q-icon>
<q-menu :offset="[0, 7]" fit>
<q-list dense style="min-width: 200px;min-height:50px">
Expand Down Expand Up @@ -125,8 +130,11 @@
<q-menu :offset="[0, 7]" fit>
<q-list dense style="min-width: 150px;min-height:50px">
<q-item clickable v-close-popup>
<q-item-section @click="subscribe()">Subscribe</q-item-section>
<q-item-section @click="gotoStripe()">Subscriptions</q-item-section>
</q-item>
<!-- <q-item clickable v-close-popup>-->
<!-- <q-item-section @click="subscribe()">Subscribe</q-item-section>-->
<!-- </q-item>-->
<q-item clickable v-close-popup>
<q-item-section @click="logout()">Logout</q-item-section>
</q-item>
Expand All @@ -152,12 +160,12 @@
import {SidePanelView, useUiStore} from "src/stores/uiStore";
import {useTabsStore} from "src/stores/tabsStore";
import {Tab} from "src/models/Tab";
import {ref, watch, watchEffect} from "vue";
import {ref, watchEffect} from "vue";
import {useRouter} from "vue-router";
import {usePermissionsStore} from "src/stores/permissionsStore";
import {FeatureIdent} from "src/models/AppFeature";
import NavigationService from "src/services/NavigationService";
import {LocalStorage, openURL, uid, useQuasar} from "quasar";
import {openURL, uid, useQuasar} from "quasar";
import {useUtils} from "src/services/Utils";
import {useWindowsStore} from "src/stores/windowsStore";
import {useSuggestionsStore} from "stores/suggestionsStore";
Expand All @@ -169,10 +177,10 @@ import {ToastType} from "src/models/Toast";
import SidePanelFooterLeftButtons from "components/helper/SidePanelFooterLeftButtons.vue";
import {useAuthStore} from "stores/authStore";
import {Account} from "src/models/Account";
import {NotificationType, useNotificationHandler} from "src/services/ErrorHandler";
import {useNotificationHandler} from "src/services/ErrorHandler";
import SidePanelLoginWidget from "components/helper/SidePanelLoginWidget.vue";
import SidePanelWindowMarkupTable from "components/helper/SidePanelWindowMarkupTable.vue";
import {Browser} from '@capacitor/browser';
import {Window} from "src/models/Window"

const {handleSuccess, handleError} = useNotificationHandler()

Expand All @@ -199,13 +207,15 @@ const account = ref<Account | undefined>(undefined)
const randomKey = ref<string>(uid())

watchEffect(() => {
account.value = authStore.getAccount()
const windowId = useWindowsStore().currentChromeWindow?.id || 0
if (useWindowsStore().windowForId(windowId)?.open) {
//console.log("setting showWindowTable to ", useWindowsStore().windowForId(windowId)?.open)
showWindowTable.value = useWindowsStore().windowForId(windowId)?.open || false
}
})

watchEffect(() => {
if (useWindowsStore().currentWindows.length === 1) {
showWindowTable.value = false
}
account.value = authStore.getAccount()
})

watchEffect(() => {
Expand Down Expand Up @@ -238,7 +248,7 @@ watchEffect(() => {
if (!inBexMode()) {
return
}
const windowId = useWindowsStore().currentWindow?.id || 0
const windowId = useWindowsStore().currentChromeWindow?.id || 0
currentChromeTab.value = useTabsStore().getCurrentChromeTab(windowId) || useTabsStore().currentChromeTab
})

Expand Down Expand Up @@ -343,6 +353,12 @@ const toggleShowWindowTable = () => {
if (showWindowTable.value) {
randomKey.value = uid()
}
const windowId = useWindowsStore().currentChromeWindow?.id || 0
const currentWindow: Window | undefined = useWindowsStore().windowForId(windowId)
if (currentWindow) {
currentWindow.open = showWindowTable.value
useWindowsStore().upsertTabsetWindow(currentWindow)
}
}

const logout = () => {
Expand All @@ -363,6 +379,7 @@ const subscribe = () => router.push("/subscribe")

const offsetBottom = () => ($q.platform.is.capacitor || $q.platform.is.cordova) ? 'margin-bottom:20px;' : ''

const gotoStripe = () => openURL("https://billing.stripe.com/p/login/test_5kA9EHf2Da596HuaEE")

</script>

Expand Down
8 changes: 7 additions & 1 deletion src/components/dialogues/NewTabsetDialog.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<template>
<q-dialog ref="dialogRef" @hide="onDialogHide">
<NewTabsetDialogBody :space-id="props.spaceId" :from-panel="props.fromPanel"/>
<NewTabsetDialogBody
:space-id="props.spaceId"
:name="props.name"
:window-id="props.windowId"
:from-panel="props.fromPanel"/>
</q-dialog>
</template>

Expand All @@ -15,6 +19,8 @@ defineEmits([

const props = defineProps({
spaceId: {type: String, required: false},
name: {type: String, default: ""},
windowId: {type: Number, required: false},
fromPanel: {type: Boolean, default: false}
})

Expand Down
Loading
Loading