Skip to content

Commit

Permalink
Merge branch 'main' into check_success_signature
Browse files Browse the repository at this point in the history
  • Loading branch information
melroy89 authored Sep 13, 2024
2 parents 21e3f7c + 4d930f6 commit 3226d4f
Show file tree
Hide file tree
Showing 33 changed files with 1,115 additions and 1,029 deletions.
39 changes: 39 additions & 0 deletions assets/controllers/markdown_toolbar_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-FileCopyrightText: 2023-2024 /kbin & Mbin contributors
//
// SPDX-License-Identifier: AGPL-3.0-only

import { Controller } from '@hotwired/stimulus';

/* stimulusFetch: 'lazy' */
export default class extends Controller {
addSpoiler(event) {
event.preventDefault();

const input = document.getElementById(this.element.getAttribute('for'));
let spoilerBody = 'spoiler body';
let contentAfterCursor;

const start = input.selectionStart;
const end = input.selectionEnd;

const contentBeforeCursor = input.value.substring(0, start);
if (start === end) {
contentAfterCursor = input.value.substring(start);
} else {
contentAfterCursor = input.value.substring(end);
spoilerBody = input.value.substring(start, end);
}

const spoiler = `
::: spoiler spoiler-title
${spoilerBody}
:::`;

input.value = contentBeforeCursor + spoiler + contentAfterCursor;
input.dispatchEvent(new Event('input'));

const spoilerTitlePosition = contentBeforeCursor.length + '::: spoiler '.length + 1;
input.setSelectionRange(spoilerTitlePosition, spoilerTitlePosition);
input.focus();
}
}
14 changes: 4 additions & 10 deletions assets/controllers/push_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ export default class extends Controller {

connect() {
this.applicationServerPublicKey = this.element.dataset.applicationServerPublicKey
console.log("got application server public key", this.applicationServerPublicKey)
window.navigator.serviceWorker.getRegistration()
.then((registration) => {
console.log("got service worker registration", registration)
return registration?.pushManager.getSubscription()
})
.then(pushSubscription => {
this.updateButtonVisibility(pushSubscription)
})
.catch((error) => {
console.log("there was an error in the connect method", error)
console.error("There was an error in the service worker registration method", error)
this.element.style.display = "none"
})

Expand Down Expand Up @@ -76,7 +74,6 @@ export default class extends Controller {
this.askPermission()
.then(() => window.navigator.serviceWorker.getRegistration())
.then(registration => {
console.log("got service worker registration:", registration)
const subscribeOptions = {
userVisibleOnly: true,
applicationServerKey: this.applicationServerPublicKey,
Expand All @@ -85,10 +82,8 @@ export default class extends Controller {
return registration.pushManager.subscribe(subscribeOptions)
})
.then(pushSubscription => {
console.log("Received PushSubscription: ", JSON.stringify(pushSubscription))
this.updateButtonVisibility(pushSubscription)
const jsonSub = pushSubscription.toJSON()
console.log("registering push to server")
let payload = {
endpoint: pushSubscription.endpoint,
deviceKey: this.getDeviceKey(),
Expand All @@ -106,9 +101,6 @@ export default class extends Controller {
throw response
}
return response.json()
})
.then(data => {

})
.catch(error => {
console.error(error)
Expand All @@ -122,7 +114,6 @@ export default class extends Controller {
.then(pushSubscription => pushSubscription.unsubscribe())
.then((successful) => {
if (successful) {
console.log("removed push subscription")
this.updateButtonVisibility(null)
let payload = {
deviceKey: this.getDeviceKey(),
Expand All @@ -137,6 +128,9 @@ export default class extends Controller {
})
.catch(error => console.error(error))
}
})
.catch((error) => {
console.error("There was an error in the service worker registration method, for unsubscribing", error)
})
}

Expand Down
14 changes: 6 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@
"doctrine/doctrine-migrations-bundle": "^3.3.1",
"doctrine/orm": "^2.19.6",
"embed/embed": "^4.4.12",
"endroid/qr-code": "^4.8.5",
"endroid/qr-code": "^5.1.0",
"friendsofsymfony/jsrouting-bundle": "^3.5.0",
"furqansiddiqui/bip39-mnemonic-php": "^0.1.7",
"gmostafa/php-graphql-client": "^1.13",
"gumlet/php-image-resize": "^2.0.4",
"knplabs/knp-time-bundle": "^2.4.0",
"knpuniversity/oauth2-client-bundle": "^2.18.1",
"kornrunner/blurhash": "^1.2.2",
"laminas/laminas-diactoros": "^2.26.0",
"landrok/activitypub": "^0.5.8",
"league/commonmark": "^2.5.1",
"league/flysystem-aws-s3-v3": "^3.28.0",
"league/html-to-markdown": "^5.1.1",
Expand All @@ -51,7 +49,7 @@
"nyholm/psr7": "^1.8.1",
"omines/antispam-bundle": "^0.1.8",
"oneup/flysystem-bundle": "^4.12.2",
"pagerfanta/core": "^3.8.0",
"pagerfanta/core": "^4.7.0",
"pagerfanta/doctrine-collections-adapter": "^4.6.0",
"pagerfanta/doctrine-dbal-adapter": "^4.6.0",
"pagerfanta/doctrine-orm-adapter": "^4.6.0",
Expand All @@ -63,7 +61,7 @@
"scheb/2fa-backup-code": "^7.5.0",
"scheb/2fa-bundle": "^7.5.0",
"scheb/2fa-totp": "^7.5.0",
"scienta/doctrine-json-functions": "^5.5.0",
"scienta/doctrine-json-functions": "^6.1.0",
"stevenmaguire/oauth2-keycloak": "^5.1.0",
"symfony/amqp-messenger": "7.1.*",
"symfony/asset": "7.1.*",
Expand Down Expand Up @@ -119,12 +117,12 @@
"dama/doctrine-test-bundle": "^8.2.0",
"doctrine/doctrine-fixtures-bundle": "^3.6.1",
"fakerphp/faker": "^1.23.1",
"justinrainbow/json-schema": "^5.3.0",
"justinrainbow/json-schema": "^6.0.0",
"phpstan/phpstan": "^1.11.9",
"phpunit/phpunit": "^10.5.29",
"phpunit/phpunit": "^11.3.4",
"symfony/browser-kit": "7.1.*",
"symfony/debug-bundle": "7.1.*",
"symfony/maker-bundle": "1.60.0",
"symfony/maker-bundle": "1.61.0",
"symfony/phpunit-bridge": "7.1.*",
"symfony/stopwatch": "7.1.*",
"symfony/web-profiler-bundle": "7.1.*"
Expand Down
Loading

0 comments on commit 3226d4f

Please sign in to comment.