mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2025-03-15 11:09:24 +00:00
fixup! Add webpush front-end support
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
6eb81ca253
commit
5344f96224
2 changed files with 18 additions and 2 deletions
9
js/src/graphql/webPush.ts
Normal file
9
js/src/graphql/webPush.ts
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
|
@ -213,6 +213,7 @@ import RouteName from "../../router/name";
|
||||||
import { IFeedToken } from "@/types/feedtoken.model";
|
import { IFeedToken } from "@/types/feedtoken.model";
|
||||||
import { CREATE_FEED_TOKEN, DELETE_FEED_TOKEN } from "@/graphql/feed_tokens";
|
import { CREATE_FEED_TOKEN, DELETE_FEED_TOKEN } from "@/graphql/feed_tokens";
|
||||||
import { subscribeUserToPush } from "../../services/push-subscription";
|
import { subscribeUserToPush } from "../../services/push-subscription";
|
||||||
|
import { REGISTER_PUSH_MUTATION } from "@/graphql/webPush";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
apollo: {
|
apollo: {
|
||||||
|
@ -318,8 +319,14 @@ export default class Notifications extends Vue {
|
||||||
|
|
||||||
async subscribeToWebPush(): Promise<void> {
|
async subscribeToWebPush(): Promise<void> {
|
||||||
if (this.canShowWebPush()) {
|
if (this.canShowWebPush()) {
|
||||||
const a = await subscribeUserToPush();
|
const subscription = await subscribeUserToPush();
|
||||||
console.log(a);
|
const { data } = await this.$apollo.mutate({
|
||||||
|
mutation: REGISTER_PUSH_MUTATION,
|
||||||
|
variables: {
|
||||||
|
...subscription,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(data);
|
||||||
} else {
|
} else {
|
||||||
console.log("can't do webpush");
|
console.log("can't do webpush");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue