From 0adc0dd8ac81be5bcd02e51409fb59466c2099f9 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Thu, 12 Jan 2023 01:12:11 +0900
Subject: [PATCH] [refactor] List store
---
.../TimelineSpace/Contents/Lists/Show.spec.ts | 235 ------------------
.../TimelineSpace/Contents/Lists/Show.vue | 60 +++--
.../TimelineSpace/Contents/Lists/Show.ts | 111 +++------
3 files changed, 72 insertions(+), 334 deletions(-)
delete mode 100644 spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
deleted file mode 100644
index 30f6c1a4..00000000
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
+++ /dev/null
@@ -1,235 +0,0 @@
-import { Entity } from 'megalodon'
-import Show, { ShowState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Lists/Show'
-
-const account: Entity.Account = {
- id: '1',
- username: 'h3poteto',
- acct: 'h3poteto@pleroma.io',
- display_name: 'h3poteto',
- locked: false,
- created_at: '2019-03-26T21:30:32',
- followers_count: 10,
- following_count: 10,
- statuses_count: 100,
- note: 'engineer',
- url: 'https://pleroma.io',
- avatar: '',
- avatar_static: '',
- header: '',
- header_static: '',
- emojis: [],
- moved: null,
- fields: null,
- bot: false
-}
-const status1: Entity.Status = {
- id: '1',
- uri: 'http://example.com',
- url: 'http://example.com',
- account: account,
- in_reply_to_id: null,
- in_reply_to_account_id: null,
- reblog: null,
- content: 'hoge',
- plain_content: 'hoge',
- created_at: '2019-03-26T21:40:32',
- emojis: [],
- replies_count: 0,
- reblogs_count: 0,
- favourites_count: 0,
- reblogged: null,
- favourited: null,
- muted: null,
- sensitive: false,
- spoiler_text: '',
- visibility: 'public',
- media_attachments: [],
- mentions: [],
- tags: [],
- card: null,
- poll: null,
- application: {
- name: 'Web'
- } as Entity.Application,
- language: null,
- pinned: null,
- emoji_reactions: [],
- bookmarked: false,
- quote: false
-}
-const status2: Entity.Status = {
- id: '2',
- uri: 'http://example.com',
- url: 'http://example.com',
- account: account,
- in_reply_to_id: null,
- in_reply_to_account_id: null,
- reblog: null,
- content: 'fuga',
- plain_content: 'fuga',
- created_at: '2019-03-26T21:40:32',
- emojis: [],
- replies_count: 0,
- reblogs_count: 0,
- favourites_count: 0,
- reblogged: null,
- favourited: null,
- muted: null,
- sensitive: false,
- spoiler_text: '',
- visibility: 'public',
- media_attachments: [],
- mentions: [],
- tags: [],
- card: null,
- poll: null,
- application: {
- name: 'Web'
- } as Entity.Application,
- language: null,
- pinned: null,
- emoji_reactions: [],
- bookmarked: false,
- quote: false
-}
-
-const rebloggedStatus: Entity.Status = {
- id: '3',
- uri: 'http://example.com',
- url: 'http://example.com',
- account: account,
- in_reply_to_id: null,
- in_reply_to_account_id: null,
- reblog: status1,
- content: 'fuga',
- plain_content: 'fuga',
- created_at: '2019-03-31T21:40:32',
- emojis: [],
- replies_count: 0,
- reblogs_count: 0,
- favourites_count: 0,
- reblogged: null,
- favourited: null,
- muted: null,
- sensitive: false,
- spoiler_text: '',
- visibility: 'public',
- media_attachments: [],
- mentions: [],
- tags: [],
- card: null,
- poll: null,
- application: {
- name: 'Web'
- } as Entity.Application,
- language: null,
- pinned: null,
- emoji_reactions: [],
- bookmarked: false,
- quote: false
-}
-
-describe('TimelineSpace/Contents/Lists/Show', () => {
- describe('mutations', () => {
- let state: ShowState
-
- describe('deleteToot', () => {
- describe('message is not reblogged', () => {
- beforeEach(() => {
- state = {
- lazyLoading: false,
- heading: true,
- timeline: [status2, status1],
- unreads: []
- }
- })
- it('should be deleted', () => {
- Show.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
- expect(state.timeline).toEqual([status2])
- })
- })
-
- describe('message is reblogged', () => {
- beforeEach(() => {
- state = {
- lazyLoading: false,
- heading: true,
- timeline: [status2, rebloggedStatus],
- unreads: []
- }
- })
- it('should be deleted', () => {
- Show.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
- expect(state.timeline).toEqual([status2])
- })
- })
- })
-
- describe('appendTimeline', () => {
- describe('heading', () => {
- describe('normal', () => {
- beforeEach(() => {
- state = {
- lazyLoading: false,
- heading: true,
- timeline: [status2, status1],
- unreads: []
- }
- })
- it('should be updated timeline', () => {
- Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
- expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
- })
- })
-
- describe('duplicated status', () => {
- beforeEach(() => {
- state = {
- lazyLoading: false,
- heading: true,
- timeline: [rebloggedStatus, status2, status1],
- unreads: []
- }
- })
- it('should not be updated timeline', () => {
- Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
- expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
- })
- })
- })
-
- describe('not heading', () => {
- describe('normal', () => {
- beforeEach(() => {
- state = {
- lazyLoading: false,
- heading: false,
- timeline: [status2, status1],
- unreads: []
- }
- })
- it('should not be updated timeline', () => {
- Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
- expect(state.timeline).toEqual([status2, status1])
- expect(state.unreads).toEqual([rebloggedStatus])
- })
- })
-
- describe('duplicated status', () => {
- beforeEach(() => {
- state = {
- lazyLoading: false,
- heading: false,
- timeline: [rebloggedStatus, status2, status1],
- unreads: []
- }
- })
- it('should not be updated timeline', () => {
- Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
- expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
- })
- })
- })
- })
- })
-})
diff --git a/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue b/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue
index 7073053e..997d71ea 100644
--- a/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue
+++ b/src/renderer/components/TimelineSpace/Contents/Lists/Show.vue
@@ -1,14 +1,16 @@
-
{{ unreads.length > 0 ? unreads.length : '' }}