Skip to content

Commit 3916efa

Browse files
Resul AvanResul Avan
Resul Avan
authored and
Resul Avan
committed
push notification initial
1 parent 95f76d8 commit 3916efa

13 files changed

+49
-9
lines changed

src/components/navbar/ProfileNavigator.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<template>
2-
<b-navbar-dropdown :boxed="true" :close-on-click="true">
2+
<b-navbar-dropdown :boxed="true" :close-on-click="true" :arrowless="true">
3+
<template slot="label">
4+
<b-icon
5+
icon="chevron-down"
6+
size="is-small">
7+
</b-icon>
8+
</template>
39
<b-navbar-item tag="router-link" :to="dynamicProfileRoute">
410
<b-icon pack="fas" icon="user" class="has-margin-right-5"/>
511
<p>{{$t('topNavbar.profileDynamic')}}</p>

src/components/profile/header/ProfileFollow.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
getCountOfFollowing,
9191
getFollowingByFollowerAndFollowing,
9292
saveFollowing
93-
} from '~/service/firebase/firestore/following-service';
93+
} from '~/service/firebase/firestore';
9494
import { sendDangerNotification, showErrorToaster, showInfoToaster } from '~/service/notification-service';
9595
import { reloadFollowing, showProfileModule } from '~/service/rx-service';
9696

src/components/profile/module/ProfileFollowers.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import PageTitle from '~/components/ui/PageTitle.vue';
3030
import SearchField from '~/components/search/SearchField.vue';
3131
import Paging from '~/components/ui/paging/Paging.vue';
32-
import { searchFollowers } from '~/service/firebase/firestore/following-service';
32+
import { searchFollowers } from '~/service/firebase/firestore';
3333
import BaseModule from '~/mixin/BaseModule';
3434
import { showErrorToaster } from '~/service/notification-service';
3535
import { reloadFollowing } from '~/service/rx-service';

src/components/profile/module/ProfileFollowings.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<script lang="ts">
2424
import { Component, Watch } from 'nuxt-property-decorator';
2525
import { SearchData, User } from '~/types';
26-
import { searchFollowings } from '~/service/firebase/firestore/following-service';
26+
import { searchFollowings } from '~/service/firebase/firestore';
2727
import { showErrorToaster } from '~/service/notification-service';
2828
import { reloadFollowing } from '~/service/rx-service';
2929
import BaseModule from '~/mixin/BaseModule';

src/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"hooks": {}
2121
},
2222
"dependencies": {
23+
"@creativebulma/bulma-badge": "^1.0.1",
2324
"@fortawesome/fontawesome-free": "^5.13.1",
2425
"@mdi/font": "^5.3.45",
2526
"@nuxt/typescript-runtime": "^0.4.10",

src/plugins/buefy-plugin.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Buefy from 'buefy'
44
import '@fortawesome/fontawesome-free/css/all.min.css'
55
import '@mdi/font/css/materialdesignicons.min.css'
66
import 'bulma-helpers/css/bulma-helpers.min.css'
7+
import '@creativebulma/bulma-badge/dist/bulma-badge.min.css'
78
import 'buefy/dist/buefy.css'
89

910
Vue.use(Buefy)

src/plugins/notification-plugin.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Plugin } from '@nuxt/types'
2+
import { notificationObservable } from '~/service/rx-service'
3+
import { PushNotification } from '~/types'
4+
import { savePushNotification } from '~/service/firebase/firestore'
5+
6+
const notificationPlugin: Plugin = () => {
7+
notificationObservable
8+
.asObservable()
9+
.subscribe((notification: PushNotification) => {
10+
savePushNotification(notification).catch((error) => console.log(error))
11+
})
12+
}
13+
14+
export default notificationPlugin

src/service/firebase/firestore/following-service.ts renamed to src/service/firebase/firestore/following-collection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
getModelsByWhereClauses,
1515
saveModel
1616
} from '~/service/firebase/firestore/firestore-service'
17-
import { getUser, toSearchDataPagingResponse, userIncludes } from '~/service/firebase/firestore/user-service'
17+
import { getUser, toSearchDataPagingResponse, userIncludes } from '~/service/firebase/firestore/user-collection'
1818

1919
const followingWhereClause = (user: User): WhereClause => {
2020
return {
+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export * from './user-service'
1+
export * from './user-collection'
2+
export * from './following-collection'
3+
export * from './push-notification-collection'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { collection, PushNotification } from '~/types';
2+
import { saveModel } from '~/service/firebase/firestore/firestore-service';
3+
4+
export const savePushNotification = async (pushNotification: PushNotification): Promise<PushNotification> => {
5+
return await saveModel(collection.FOLLOWING, pushNotification) as PushNotification
6+
}

src/service/rx-service.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Subject } from 'rxjs'
2-
import { Image, ModuleType } from '~/types'
2+
import { Image, ModuleType, PushNotification } from '~/types'
33

44
export const coverPhotoObservable = new Subject<Image>()
55
export const profilePhotoObservable = new Subject<Image>()
66
export const reauthenticateObservable = new Subject<void>()
77
export const reloadUserFromDatabase = new Subject<string>()
88
export const loadMoreSearchResult = new Subject<void>()
99
export const showProfileModule = new Subject<ModuleType>()
10-
export const reloadFollowing = new Subject<void>();
10+
export const reloadFollowing = new Subject<void>()
11+
export const notificationObservable = new Subject<PushNotification>()

src/types/firebase-types.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ export interface OrderBy {
190190
direction: OrderByDirection
191191
}
192192

193-
194193
export const orderByName: OrderBy = {
195194
field: 'name',
196195
direction: 'asc'
@@ -208,6 +207,10 @@ export const CollectionField = {
208207
}
209208
}
210209

210+
export enum PushNotificationType {
211+
FOLLOW = 'follow'
212+
}
213+
211214
export interface BaseModel {
212215
id?: string
213216
createdAt?: Date
@@ -233,3 +236,9 @@ export interface Following extends BaseModel {
233236
follower: string,
234237
following: string,
235238
}
239+
240+
export interface PushNotification extends BaseModel {
241+
from: string,
242+
to: string,
243+
notificationType: PushNotificationType
244+
}

0 commit comments

Comments
 (0)