diff options
| author | shpuld <shpuld@gmail.com> | 2017-02-18 22:37:48 +0200 |
|---|---|---|
| committer | shpuld <shpuld@gmail.com> | 2017-02-18 22:37:48 +0200 |
| commit | e6f91badfbab71ed8c924bd49a86715852886ff1 (patch) | |
| tree | 176ac77d5dfb9c3cd08cb3c56412d5d1e9a18835 /src | |
| parent | be2b90df1d3b3369d451476293749bf5d6b1457d (diff) | |
| parent | f7a38eb02175e92b2c2029c88e87d877157ffcab (diff) | |
Merge branch 'develop' of ssh.gitgud.io:lambadalambda/pleroma-fe into develop
Diffstat (limited to 'src')
| -rw-r--r-- | src/App.scss | 1 | ||||
| -rw-r--r-- | src/components/notifications/notifications.js | 26 | ||||
| -rw-r--r-- | src/components/notifications/notifications.vue | 5 | ||||
| -rw-r--r-- | src/components/status/status.vue | 1 | ||||
| -rw-r--r-- | src/main.js | 2 | ||||
| -rw-r--r-- | src/modules/config.js | 7 | ||||
| -rw-r--r-- | src/modules/statuses.js | 10 |
7 files changed, 44 insertions, 8 deletions
diff --git a/src/App.scss b/src/App.scss index 3547f258..34c7ee74 100644 --- a/src/App.scss +++ b/src/App.scss @@ -107,6 +107,7 @@ main-router { padding: 0.6em 0 0.5em; text-align: center; font-size: 1.3em; + line-height: 24px; } .panel-footer { diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index 10f987a8..7dbbf588 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -1,4 +1,4 @@ -import { sortBy, take } from 'lodash' +import { sortBy, take, filter } from 'lodash' const Notifications = { data () { @@ -7,8 +7,30 @@ const Notifications = { } }, computed: { + notifications () { + return this.$store.state.statuses.notifications + }, + unseenNotifications () { + return filter(this.notifications, ({seen}) => !seen) + }, visibleNotifications () { - return take(sortBy(this.$store.state.statuses.notifications, ({action}) => -action.id), this.visibleNotificationCount) + // Don't know why, but sortBy([seen, -action.id]) doesn't work. + let sortedNotifications = sortBy(this.notifications, ({action}) => -action.id) + sortedNotifications = sortBy(sortedNotifications, 'seen') + return take(sortedNotifications, this.visibleNotificationCount) + }, + unseenCount () { + return this.unseenNotifications.length + } + }, + watch: { + unseenCount (count) { + this.$store.dispatch('setPageTitle', `(${count})`) + } + }, + methods: { + markAsSeen () { + this.$store.commit('markNotificationsAsSeen', this.visibleNotifications) } } } diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue index 0846c27b..785cc019 100644 --- a/src/components/notifications/notifications.vue +++ b/src/components/notifications/notifications.vue @@ -1,13 +1,14 @@ <template> <div class="notifications"> <div class="panel panel-default base00-background"> - <div class="panel-heading base01-background base04">Notifications ({{visibleNotifications.length}})</div> + <div class="panel-heading base01-background base04">Notifications ({{unseenCount}}) <button @click.prevent="markAsSeen">Read!</button></div> <div class="panel-body"> - <div v-for="notification in visibleNotifications" class="notification"> + <div v-for="notification in visibleNotifications" class="notification" :class='{"base01-background": notification.seen}'> <a :href="notification.action.user.statusnet_profile_url"> <img class='avatar' :src="notification.action.user.profile_image_url_original"> </a> <div class='text'> + <timeago :since="notification.action.created_at" :auto-update="240"></timeago> <div v-if="notification.type === 'favorite'"> <h1>{{ notification.action.user.name }}<br><i class="fa icon-star"></i> favorited your <router-link :to="{ name: 'conversation', params: { id: notification.status.id } }">status</h1> <p>{{ notification.status.text }}</p> diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 85d78d2e..4d4f7046 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -107,6 +107,7 @@ a { display: inline-block; + word-wrap: break-word; } .status-content { diff --git a/src/main.js b/src/main.js index 4b367db9..841e61a7 100644 --- a/src/main.js +++ b/src/main.js @@ -29,7 +29,7 @@ Vue.use(VueTimeago, { }) const persistedStateOptions = { - paths: ['users.users'] + paths: ['users.users', 'statuses.notifications'] } const store = new Vuex.Store({ diff --git a/src/modules/config.js b/src/modules/config.js index 4365d554..8d850f2a 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -13,11 +13,14 @@ const config = { } }, actions: { - setOption ({ commit }, { name, value }) { + setPageTitle ({state}, option = '') { + document.title = `${state.name} ${option}` + }, + setOption ({ commit, dispatch }, { name, value }) { commit('setOption', {name, value}) switch (name) { case 'name': - document.title = value + dispatch('setPageTitle') break case 'theme': const fullPath = `/static/css/${value}` diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 871172b5..491d0024 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -173,7 +173,10 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us } const addNotification = ({type, status, action}) => { - state.notifications.push({type, status, action}) + // Only add a new notification if we don't have one for the same action + if (!find(state.notifications, (oldNotification) => oldNotification.action.id === action.id)) { + state.notifications.push({type, status, action, seen: false}) + } } const favoriteStatus = (favorite) => { @@ -276,6 +279,11 @@ export const mutations = { setNsfw (state, { id, nsfw }) { const newStatus = find(state.allStatuses, { id }) newStatus.nsfw = nsfw + }, + markNotificationsAsSeen (state, notifications) { + each(notifications, (notification) => { + notification.seen = true + }) } } |
