Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
perf: remove summary when marking announcement as read (#1755)
Browse files Browse the repository at this point in the history
  • Loading branch information
dated authored Mar 3, 2020
1 parent 6554499 commit 195b10f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/renderer/components/Announcements/AnnouncementsPost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export default {
required: true
},
summary: {
type: String,
required: true
required: true,
validator: value => typeof value === 'string' || value === null
},
url: {
type: String,
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/models/announcement.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ export default new BaseModel({
},
title: {},
summary: {
format: (data) => trunc(data['content:encoded'], 300).text
type: ['string', 'null'],
format: data => trunc(data['content:encoded'], 300).text
},
url: {
format: (data) => data.link
format: data => data.link
},
isRead: {
format: () => false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default store => {
const readAnnouncements = store.getters['announcements/read']
store.dispatch('announcements/markAsReadBulk', readAnnouncements)

store.dispatch('app/setLatestAppliedMigration', '2.8.2')
}
2 changes: 2 additions & 0 deletions src/renderer/store/modules/announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default {
const readAnnouncementIndex = state.announcements.findIndex(announcement => announcement.guid === readAnnouncement.guid)
Vue.set(state.announcements, readAnnouncementIndex, {
...readAnnouncement,
summary: null,
isRead: true
})
},
Expand All @@ -45,6 +46,7 @@ export default {

announcementsToUpdate.push({
...announcement,
summary: isRead ? null : announcement.summary,
isRead
})
}
Expand Down

0 comments on commit 195b10f

Please sign in to comment.