2018-02-13 23:53:52 -06:00
|
|
|
<template>
|
2018-02-21 14:30:37 -06:00
|
|
|
<div class="nav" :style="{ display: isOpen ? 'block' : 'none' }">
|
2018-02-13 23:53:52 -06:00
|
|
|
<div class="backdrop" @click="parent.toggleDrawer"></div>
|
|
|
|
<div class="body">
|
2018-02-21 11:37:04 -06:00
|
|
|
<router-link class="me" v-if="os.isSignedIn" :to="`/${os.i.username}`">
|
|
|
|
<img class="avatar" :src="`${os.i.avatar_url}?thumbnail&size=128`" alt="avatar"/>
|
|
|
|
<p class="name">{{ os.i.name }}</p>
|
|
|
|
</router-link>
|
2018-02-13 23:53:52 -06:00
|
|
|
<div class="links">
|
|
|
|
<ul>
|
2018-02-21 11:37:04 -06:00
|
|
|
<li><router-link href="/">%fa:home%%i18n:mobile.tags.mk-ui-nav.home%%fa:angle-right%</router-link></li>
|
|
|
|
<li><router-link href="/i/notifications">%fa:R bell%%i18n:mobile.tags.mk-ui-nav.notifications%<template v-if="hasUnreadNotifications">%fa:circle%</template>%fa:angle-right%</router-link></li>
|
|
|
|
<li><router-link href="/i/messaging">%fa:R comments%%i18n:mobile.tags.mk-ui-nav.messaging%<template v-if="hasUnreadMessagingMessages">%fa:circle%</template>%fa:angle-right%</router-link></li>
|
2018-02-13 23:53:52 -06:00
|
|
|
</ul>
|
|
|
|
<ul>
|
2018-02-21 11:37:04 -06:00
|
|
|
<li><a :href="chUrl" target="_blank">%fa:tv%%i18n:mobile.tags.mk-ui-nav.ch%%fa:angle-right%</a></li>
|
|
|
|
<li><router-link href="/i/drive">%fa:cloud%%i18n:mobile.tags.mk-ui-nav.drive%%fa:angle-right%</router-link></li>
|
2018-02-13 23:53:52 -06:00
|
|
|
</ul>
|
|
|
|
<ul>
|
|
|
|
<li><a @click="search">%fa:search%%i18n:mobile.tags.mk-ui-nav.search%%fa:angle-right%</a></li>
|
|
|
|
</ul>
|
|
|
|
<ul>
|
2018-02-21 11:37:04 -06:00
|
|
|
<li><router-link href="/i/settings">%fa:cog%%i18n:mobile.tags.mk-ui-nav.settings%%fa:angle-right%</router-link></li>
|
2018-02-13 23:53:52 -06:00
|
|
|
</ul>
|
|
|
|
</div>
|
2018-02-21 11:37:04 -06:00
|
|
|
<a :href="aboutUrl"><p class="about">%i18n:mobile.tags.mk-ui-nav.about%</p></a>
|
2018-02-13 23:53:52 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
hasUnreadNotifications: false,
|
|
|
|
hasUnreadMessagingMessages: false,
|
|
|
|
connection: null,
|
|
|
|
connectionId: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2018-02-17 21:35:18 -06:00
|
|
|
if ((this as any).os.isSignedIn) {
|
|
|
|
this.connection = (this as any).os.stream.getConnection();
|
|
|
|
this.connectionId = (this as any).os.stream.use();
|
2018-02-13 23:53:52 -06:00
|
|
|
|
|
|
|
this.connection.on('read_all_notifications', this.onReadAllNotifications);
|
|
|
|
this.connection.on('unread_notification', this.onUnreadNotification);
|
|
|
|
this.connection.on('read_all_messaging_messages', this.onReadAllMessagingMessages);
|
|
|
|
this.connection.on('unread_messaging_message', this.onUnreadMessagingMessage);
|
|
|
|
|
|
|
|
// Fetch count of unread notifications
|
2018-02-17 21:35:18 -06:00
|
|
|
(this as any).api('notifications/get_unread_count').then(res => {
|
2018-02-13 23:53:52 -06:00
|
|
|
if (res.count > 0) {
|
|
|
|
this.hasUnreadNotifications = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Fetch count of unread messaging messages
|
2018-02-17 21:35:18 -06:00
|
|
|
(this as any).api('messaging/unread').then(res => {
|
2018-02-13 23:53:52 -06:00
|
|
|
if (res.count > 0) {
|
|
|
|
this.hasUnreadMessagingMessages = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2018-02-17 21:35:18 -06:00
|
|
|
if ((this as any).os.isSignedIn) {
|
2018-02-13 23:53:52 -06:00
|
|
|
this.connection.off('read_all_notifications', this.onReadAllNotifications);
|
|
|
|
this.connection.off('unread_notification', this.onUnreadNotification);
|
|
|
|
this.connection.off('read_all_messaging_messages', this.onReadAllMessagingMessages);
|
|
|
|
this.connection.off('unread_messaging_message', this.onUnreadMessagingMessage);
|
2018-02-17 21:35:18 -06:00
|
|
|
(this as any).os.stream.dispose(this.connectionId);
|
2018-02-13 23:53:52 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
search() {
|
|
|
|
const query = window.prompt('%i18n:mobile.tags.mk-ui-nav.search%');
|
|
|
|
if (query == null || query == '') return;
|
2018-02-21 12:11:24 -06:00
|
|
|
this.$router.push('/search?q=' + encodeURIComponent(query));
|
2018-02-13 23:53:52 -06:00
|
|
|
},
|
|
|
|
onReadAllNotifications() {
|
|
|
|
this.hasUnreadNotifications = false;
|
|
|
|
},
|
|
|
|
onUnreadNotification() {
|
|
|
|
this.hasUnreadNotifications = true;
|
|
|
|
},
|
|
|
|
onReadAllMessagingMessages() {
|
|
|
|
this.hasUnreadMessagingMessages = false;
|
|
|
|
},
|
|
|
|
onUnreadMessagingMessage() {
|
|
|
|
this.hasUnreadMessagingMessages = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-02-21 14:30:37 -06:00
|
|
|
.nav
|
2018-02-13 23:53:52 -06:00
|
|
|
.backdrop
|
|
|
|
position fixed
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
z-index 1025
|
|
|
|
width 100%
|
|
|
|
height 100%
|
|
|
|
background rgba(0, 0, 0, 0.2)
|
|
|
|
|
|
|
|
.body
|
|
|
|
position fixed
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
z-index 1026
|
|
|
|
width 240px
|
|
|
|
height 100%
|
|
|
|
overflow auto
|
|
|
|
-webkit-overflow-scrolling touch
|
|
|
|
color #777
|
|
|
|
background #fff
|
|
|
|
|
|
|
|
.me
|
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 16px
|
|
|
|
|
|
|
|
.avatar
|
|
|
|
display inline
|
|
|
|
max-width 64px
|
|
|
|
border-radius 32px
|
|
|
|
vertical-align middle
|
|
|
|
|
|
|
|
.name
|
|
|
|
display block
|
|
|
|
margin 0 16px
|
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
left 80px
|
|
|
|
padding 0
|
|
|
|
width calc(100% - 112px)
|
|
|
|
color #777
|
|
|
|
line-height 96px
|
|
|
|
overflow hidden
|
|
|
|
text-overflow ellipsis
|
|
|
|
white-space nowrap
|
|
|
|
|
|
|
|
ul
|
|
|
|
display block
|
|
|
|
margin 16px 0
|
|
|
|
padding 0
|
|
|
|
list-style none
|
|
|
|
|
|
|
|
&:first-child
|
|
|
|
margin-top 0
|
|
|
|
|
|
|
|
li
|
|
|
|
display block
|
|
|
|
font-size 1em
|
|
|
|
line-height 1em
|
|
|
|
|
|
|
|
a
|
|
|
|
display block
|
|
|
|
padding 0 20px
|
|
|
|
line-height 3rem
|
|
|
|
line-height calc(1rem + 30px)
|
|
|
|
color #777
|
|
|
|
text-decoration none
|
|
|
|
|
|
|
|
> [data-fa]:first-child
|
|
|
|
margin-right 0.5em
|
|
|
|
|
|
|
|
> [data-fa].circle
|
|
|
|
margin-left 6px
|
|
|
|
font-size 10px
|
|
|
|
color $theme-color
|
|
|
|
|
|
|
|
> [data-fa]:last-child
|
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
right 0
|
|
|
|
padding 0 20px
|
|
|
|
font-size 1.2em
|
|
|
|
line-height calc(1rem + 30px)
|
|
|
|
color #ccc
|
|
|
|
|
|
|
|
.about
|
|
|
|
margin 0
|
|
|
|
padding 1em 0
|
|
|
|
text-align center
|
|
|
|
font-size 0.8em
|
|
|
|
opacity 0.5
|
|
|
|
|
|
|
|
a
|
|
|
|
color #777
|
|
|
|
|
|
|
|
</style>
|