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

Origin/stable hotfix #292

Merged
merged 2 commits into from
Jun 12, 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
57 changes: 27 additions & 30 deletions components/auth/signinModal.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
<template>
<client-only>
<form action @keyup.enter="onSubmit()">
<div class="modal-card" style="min-height: 30vh">
<header class="modal-card-head">
<b-button class="button" type="is-danger" icon-left="close" @click="$parent.close()" />
<p align="center" class="modal-card-title">{{ $t("LogIn") }}</p>
</header>
<section class="modal-card-body">
<b-field :label="$t('Email')">
<b-input data-cy="signin-email" type="email" lazy maxlength="64" v-model="username"
:placeholder="$t('PlaceHolderEmail')" required></b-input>
</b-field>
<form action @keyup.enter="onSubmit()">
<div class="modal-card" style="min-height: 30vh">
<header class="modal-card-head">
<b-button class="button" type="is-danger" icon-left="close" @click="$parent.close()" />
<p align="center" class="modal-card-title">{{ $t("LogIn") }}</p>
</header>
<section class="modal-card-body">
<b-field :label="$t('Email')">
<b-input data-cy="signin-email" type="email" lazy maxlength="64" v-model="username"
:placeholder="$t('PlaceHolderEmail')" required></b-input>
</b-field>

<b-field :label="$t('Password')">
<b-input data-cy="signin-password" type="password" lazy v-model="password" password-reveal
:placeholder="$t('PlaceHolderPassword')" required></b-input>
</b-field>
<a href="/changePassword">{{ $t("ForgotPswd") }}</a>
</section>
<footer class="modal-card-foot">
<b-button data-cy="signin-signin" class="is-primary" :loading="loading" @click="onSubmit">{{
$t("LogIn")
}}</b-button>
</footer>
</div>
</form>
</client-only>
<b-field :label="$t('Password')">
<b-input data-cy="signin-password" type="password" lazy v-model="password" password-reveal
:placeholder="$t('PlaceHolderPassword')" required></b-input>
</b-field>
<a href="/changePassword">{{ $t("ForgotPswd") }}</a>
</section>
<footer class="modal-card-foot">
<b-button data-cy="signin-signin" class="is-primary" :loading="loading" @click="onSubmit">{{
$t("LogIn")
}}</b-button>
</footer>
</div>
</form>
</template>
<script>
import signup from "@/components/auth/signupModal";
Expand All @@ -51,10 +49,9 @@ export default {
await this.$store.dispatch("getUser");

try {
if (process.client) {
const createDatabaseForUser = require("~/plugins/dexieDB").createDatabaseForUser;
createDatabaseForUser(this.$store.getters.getUser.username);
}
const createDatabaseForUser = require("~/plugins/dexieDB").createDatabaseForUser;
createDatabaseForUser(this.$store.getters.getUser.username);

} catch (err) {
console.log(err);
}
Expand Down
373 changes: 186 additions & 187 deletions components/auth/signupModal.vue

Large diffs are not rendered by default.

38 changes: 18 additions & 20 deletions components/navigation/navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,25 @@
class="bolder">{{ $t("Tutorial") }}</b> 🚀</b-navbar-item>
</template>
<template slot="end">
<client-only>
<b-navbar-dropdown tag="div" collapsible :label="getEmoji(localeIso())">
<b-navbar-item href="#" v-for="locale in availableLocales" :key="locale.code"
@click.prevent.stop="$i18n.setLocale(locale.code)">{{ getEmoji(locale.iso) }}</b-navbar-item>
</b-navbar-dropdown>
<b-navbar-item tag="div">
<div class="buttons bottomOffset">
<b-button data-cy="navbar-signin-button" class="bolder customButton" v-if="!isLogged"
@click="openSignInModal()" type="is-primary">{{ $t("LogIn") }}</b-button>
<b-button v-else class="bolder customButton" tag="nuxt-link" :to="pictalkHome" type="is-primary"
icon-right="home"></b-button>
<b-navbar-dropdown tag="div" collapsible :label="getEmoji(localeIso())">
<b-navbar-item href="#" v-for="locale in availableLocales" :key="locale.code"
@click.prevent.stop="$i18n.setLocale(locale.code)">{{ getEmoji(locale.iso) }}</b-navbar-item>
</b-navbar-dropdown>
<b-navbar-item tag="div">
<div class="buttons bottomOffset">
<b-button data-cy="navbar-signin-button" class="bolder customButton" v-if="!isLogged"
@click="openSignInModal()" type="is-primary">{{ $t("LogIn") }}</b-button>
<b-button v-else class="bolder customButton" tag="nuxt-link" :to="pictalkHome" type="is-primary"
icon-right="home"></b-button>

<b-button class="bolder customButton" v-if="!isLogged" @click="openSignUpModal()" type="is-success"
outlined>{{ $t("SignUp") }}</b-button>
<b-button v-else class="bolder customButton" type="is-light" icon-right="logout" @click="onLogout" />
<b-button class="bolder customButton" outlined v-if="!isLogged" tag="nuxt-link"
to="/public?fatherCollectionId=346" type="is-primary" icon-right="arrow-right-box">{{
$t("TryPictalk") }}</b-button>
</div>
</b-navbar-item>
</client-only>
<b-button class="bolder customButton" v-if="!isLogged" @click="openSignUpModal()" type="is-success"
outlined>{{ $t("SignUp") }}</b-button>
<b-button v-else class="bolder customButton" type="is-light" icon-right="logout" @click="onLogout" />
<b-button class="bolder customButton" outlined v-if="!isLogged" tag="nuxt-link"
to="/public?fatherCollectionId=346" type="is-primary" icon-right="arrow-right-box">{{
$t("TryPictalk") }}</b-button>
</div>
</b-navbar-item>
</template>
</b-navbar>
</div>
Expand Down
78 changes: 38 additions & 40 deletions components/navigation/pictalk-navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,53 +171,51 @@ export default {
Security,
},
async created() {
if (process.client) {
if ('BroadcastChannel' in window) {
const bc = new BroadcastChannel("offline-ready");
bc.onmessage = (event) => {
if (event.isTrusted) {
this.offlineReadyTotal = event.data.total;
this.offlineReadyProgress = event.data.progress;
}
};
const bc1 = new BroadcastChannel("authenticated-webworker");
console.log("Posting message to webworker")
if (this.$store.getters.getJwtFromCookie && this.$store.getters.getJwtExpDateFromCookie) {
bc1.postMessage({ jwt: this.$store.getters.getJwtFromCookie, expDate: this.$store.getters.getJwtExpDateFromCookie });
if ('BroadcastChannel' in window) {
const bc = new BroadcastChannel("offline-ready");
bc.onmessage = (event) => {
if (event.isTrusted) {
this.offlineReadyTotal = event.data.total;
this.offlineReadyProgress = event.data.progress;
}
bc1.onmessage = (event) => {
console.log("Received authenticated event from webworker")
if (event.isTrusted) {
if (event.data === "authenticated") {
bc1.postMessage({ jwt: this.$store.getters.getJwtFromCookie, expDate: this.$store.getters.getJwtExpDateFromCookie });
}
}
};
};
const bc1 = new BroadcastChannel("authenticated-webworker");
console.log("Posting message to webworker")
if (this.$store.getters.getJwtFromCookie && this.$store.getters.getJwtExpDateFromCookie) {
bc1.postMessage({ jwt: this.$store.getters.getJwtFromCookie, expDate: this.$store.getters.getJwtExpDateFromCookie });
}
this.intervalId = setInterval(async () => {
if (window.navigator.onLine) {
try {
let notifCount = this.$store.getters.getUser.notifications.length;
await this.$store.dispatch("getNotifications");
if (notifCount < this.$store.getters.getUser.notifications.length) {
this.$buefy.notification.open({
message: this.$t("UnreadNotifications"),
type: "is-info",
});
}
} catch (err) {
console.log(err);
clearInterval(this.intervalId);
return [];
bc1.onmessage = (event) => {
console.log("Received authenticated event from webworker")
if (event.isTrusted) {
if (event.data === "authenticated") {
bc1.postMessage({ jwt: this.$store.getters.getJwtFromCookie, expDate: this.$store.getters.getJwtExpDateFromCookie });
}
}
}, 60000);
};
}
this.intervalId = setInterval(async () => {
if (window.navigator.onLine) {
try {
let notifCount = this.$store.getters.getUser.notifications.length;
await this.$store.dispatch("getNotifications");
if (notifCount < this.$store.getters.getUser.notifications.length) {
this.$buefy.notification.open({
message: this.$t("UnreadNotifications"),
type: "is-info",
});
}
} catch (err) {
console.log(err);
clearInterval(this.intervalId);
return [];
}
}
}, 60000);

},
async fetch() {
if (process.client) {
this.notifications = await this.$store.dispatch("getNotifications");
}
this.notifications = await this.$store.dispatch("getNotifications");

},
data() {
return {
Expand Down
26 changes: 12 additions & 14 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,20 @@ export default {
},
middleware: ["axios"],
created() {
if (process.client) {
// Matomo tag manager
var _mtm = window._mtm = window._mtm || [];
_mtm.push({ 'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start' });
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.async = true; g.src = 'https://analytics.picmind.org//js/container_V1sL8eXl.js'; s.parentNode.insertBefore(g, s);
// Matomo tag manager
var _mtm = window._mtm = window._mtm || [];
_mtm.push({ 'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start' });
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.async = true; g.src = 'https://analytics.picmind.org//js/container_V1sL8eXl.js'; s.parentNode.insertBefore(g, s);
if (
this.$store.getters.isAuthenticated &&
this.$store.getters.getUser &&
this.$store.getters.getUser.displayLanguage.match(/[a-z]{2}/g)
) {
if (
this.$store.getters.isAuthenticated &&
this.$store.getters.getUser &&
this.$store.getters.getUser.displayLanguage.match(/[a-z]{2}/g)
this.$i18n.locale.code != this.$store.getters.getUser.displayLanguage
) {
if (
this.$i18n.locale.code != this.$store.getters.getUser.displayLanguage
) {
this.$i18n.setLocale(this.$store.getters.getUser.displayLanguage);
}
this.$i18n.setLocale(this.$store.getters.getUser.displayLanguage);
}
}
},
Expand Down
108 changes: 52 additions & 56 deletions layouts/pictalk.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<template>
<div>
<link rel="preconnect" href="https://cdn.jsdelivr.net" />
<client-only>
<div class="wrapper">
<pictalkNavbar />
<hr class="margins" />
<nuxt />
</div>
</client-only>
<div class="wrapper">
<pictalkNavbar />
<hr class="margins" />
<nuxt />
</div>
</div>
</template>

Expand All @@ -24,63 +22,61 @@ export default {
};
},
async created() {
if (process.client) {

// Matomo tag manager
var _mtm = window._mtm = window._mtm || [];
_mtm.push({ 'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start' });
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.async = true; g.src = 'https://analytics.picmind.org//js/container_V1sL8eXl.js'; s.parentNode.insertBefore(g, s);
// Matomo tag manager
var _mtm = window._mtm = window._mtm || [];
_mtm.push({ 'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start' });
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.async = true; g.src = 'https://analytics.picmind.org//js/container_V1sL8eXl.js'; s.parentNode.insertBefore(g, s);

if ('BroadcastChannel' in window) {
const bc2 = new BroadcastChannel("sync");
bc2.onmessage = (event) => {
if (event.isTrusted) {
this.$store.dispatch("downloadCollections", event.data.collections);
}
};
}
if (!this.$store.getters.getUser.username) {
try {
await this.$store.dispatch("getUser");
} catch (err) {
console.log(err);
throw new Error(err);
if ('BroadcastChannel' in window) {
const bc2 = new BroadcastChannel("sync");
bc2.onmessage = (event) => {
if (event.isTrusted) {
this.$store.dispatch("downloadCollections", event.data.collections);
}
};
}
if (!this.$store.getters.getUser.username) {
try {
await this.$store.dispatch("getUser");
} catch (err) {
console.log(err);
throw new Error(err);
}
}
if (
this.$store.getters.isAuthenticated &&
this.$store.getters.getUser &&
this.$store.getters.getUser.displayLanguage.match(/[a-z]{2}/g)
) {
if (
this.$store.getters.isAuthenticated &&
this.$store.getters.getUser &&
this.$store.getters.getUser.displayLanguage.match(/[a-z]{2}/g)
this.$i18n.locale.code != this.$store.getters.getUser.displayLanguage
) {
if (
this.$i18n.locale.code != this.$store.getters.getUser.displayLanguage
) {
this.$i18n.setLocale(this.$store.getters.getUser.displayLanguage);
}
}
const workbox = await window.$workbox;
if (workbox) {
workbox.addEventListener('installed', (event) => {
// If we don't do this we'll be displaying the notification after the initial installation, which isn't perferred.
if (event.isUpdate) {
const notif = this.$buefy.notification.open({
duration: 4500,
message: this.$t("NewVersionAvailable"),
position: "is-top-right",
type: "is-success",
hasIcon: true,
iconSize: "is-small",
iconSize: "medium",
icon: "gift",
});
setTimeout(() => {
this.$router.push('/').then(() => window.location.reload(true));
}, 4500);
}
});
this.$i18n.setLocale(this.$store.getters.getUser.displayLanguage);
}
}
const workbox = await window.$workbox;
if (workbox) {
workbox.addEventListener('installed', (event) => {
// If we don't do this we'll be displaying the notification after the initial installation, which isn't perferred.
if (event.isUpdate) {
const notif = this.$buefy.notification.open({
duration: 4500,
message: this.$t("NewVersionAvailable"),
position: "is-top-right",
type: "is-success",
hasIcon: true,
iconSize: "is-small",
iconSize: "medium",
icon: "gift",
});
setTimeout(() => {
this.$router.push('/').then(() => window.location.reload(true));
}, 4500);
}
});
}
},
destroyed() {
clearInterval(this.intervalId);
Expand Down
Loading
Loading