fixup! Add webpush front-end support

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-05-06 18:58:59 +02:00
parent 6eb81ca253
commit 5344f96224
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
2 changed files with 18 additions and 2 deletions

View File

@ -0,0 +1,9 @@
import gql from "graphql-tag";
export const REGISTER_PUSH_MUTATION = gql`
mutation RegisterPush($endpoint: String!, $keys: PushSubscriptionKeys!) {
registerPush(endpoint: $endpoint, keys: $keys) {
status
}
}
`;

View File

@ -213,6 +213,7 @@ import RouteName from "../../router/name";
import { IFeedToken } from "@/types/feedtoken.model";
import { CREATE_FEED_TOKEN, DELETE_FEED_TOKEN } from "@/graphql/feed_tokens";
import { subscribeUserToPush } from "../../services/push-subscription";
import { REGISTER_PUSH_MUTATION } from "@/graphql/webPush";
@Component({
apollo: {
@ -318,8 +319,14 @@ export default class Notifications extends Vue {
async subscribeToWebPush(): Promise<void> {
if (this.canShowWebPush()) {
const a = await subscribeUserToPush();
console.log(a);
const subscription = await subscribeUserToPush();
const { data } = await this.$apollo.mutate({
mutation: REGISTER_PUSH_MUTATION,
variables: {
...subscription,
},
});
console.log(data);
} else {
console.log("can't do webpush");
}