From 554cad9605776b85ba651acca02aeb3fd6fc0cb9 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Mon, 27 Dec 2021 01:11:20 +0900
Subject: [PATCH] refs #574 Divide use marker settings for each timelines
---
.../store/Preferences/General.spec.ts | 2 +-
.../store/TimelineSpace/Contents/Home.spec.ts | 3 +-
.../Contents/Notifications.spec.ts | 3 +-
.../unit/store/Preferences/General.spec.ts | 2 +-
src/config/locales/en/translation.json | 3 +-
src/constants/initializer/preferences.ts | 2 +-
.../components/Preferences/General.vue | 13 ++++---
src/renderer/store/App.ts | 10 ++---
src/renderer/store/Preferences/General.ts | 2 +-
.../store/TimelineSpace/Contents/Home.ts | 4 +-
.../TimelineSpace/Contents/Notifications.ts | 4 +-
src/types/timeline.ts | 2 +-
yarn.lock | 38 -------------------
13 files changed, 26 insertions(+), 62 deletions(-)
diff --git a/spec/renderer/integration/store/Preferences/General.spec.ts b/spec/renderer/integration/store/Preferences/General.spec.ts
index ad0a6959..a11916b5 100644
--- a/spec/renderer/integration/store/Preferences/General.spec.ts
+++ b/spec/renderer/integration/store/Preferences/General.spec.ts
@@ -17,7 +17,7 @@ const state = (): GeneralState => {
cw: false,
nsfw: false,
hideAllAttachments: false,
- useMarker: false
+ useMarkerTimeline: []
},
other: {
launch: false
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts
index 2027ff76..2b1710b1 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts
@@ -148,7 +148,8 @@ const timelineState = {
const appState = {
namespaced: true,
state: {
- proxyConfiguration: false
+ proxyConfiguration: false,
+ useMarkerTimeline: []
}
}
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts
index 90dc151c..b0df9f8e 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts
@@ -222,7 +222,8 @@ const timelineState = {
const appState = {
namespaced: true,
state: {
- proxyConfiguration: false
+ proxyConfiguration: false,
+ useMarkerTimeline: []
}
}
diff --git a/spec/renderer/unit/store/Preferences/General.spec.ts b/spec/renderer/unit/store/Preferences/General.spec.ts
index a6c38a7c..d7502fd2 100644
--- a/spec/renderer/unit/store/Preferences/General.spec.ts
+++ b/spec/renderer/unit/store/Preferences/General.spec.ts
@@ -13,7 +13,7 @@ describe('Preferences/General', () => {
cw: false,
nsfw: false,
hideAllAttachments: false,
- useMarker: false
+ useMarkerTimeline: []
},
other: {
launch: false
diff --git a/src/config/locales/en/translation.json b/src/config/locales/en/translation.json
index 9bb3bef7..7a6a558a 100644
--- a/src/config/locales/en/translation.json
+++ b/src/config/locales/en/translation.json
@@ -163,8 +163,7 @@
"cw": "Always ignore contents warnings",
"nsfw": "Always ignore NSFW of medias",
"hideAllAttachments": "Hide all medias",
- "useMarker": "Load timeline from the last reading position",
- "useMarkerNotice": "This feature only supports home and notifications"
+ "useMarker": "Load timeline from the last reading position"
},
"other": {
"title": "Other options",
diff --git a/src/constants/initializer/preferences.ts b/src/constants/initializer/preferences.ts
index fde40570..6731257b 100644
--- a/src/constants/initializer/preferences.ts
+++ b/src/constants/initializer/preferences.ts
@@ -21,7 +21,7 @@ const timeline: Timeline = {
cw: false,
nsfw: false,
hideAllAttachments: false,
- useMarker: false
+ useMarkerTimeline: ['notifications']
}
const other: Other = {
diff --git a/src/renderer/components/Preferences/General.vue b/src/renderer/components/Preferences/General.vue
index 75459836..f9ce208d 100644
--- a/src/renderer/components/Preferences/General.vue
+++ b/src/renderer/components/Preferences/General.vue
@@ -24,11 +24,11 @@
-
+
+
+
+
-
- {{ $t('preferences.general.timeline.useMarkerNotice') }}
-
{{ $t('preferences.general.other.title') }}
@@ -107,11 +107,12 @@ export default {
},
timeline_use_marker: {
get() {
- return this.$store.state.Preferences.General.general.timeline.useMarker
+ return this.$store.state.Preferences.General.general.timeline.useMarkerTimeline
},
set(value) {
+ console.log(value)
this.$store.dispatch('Preferences/General/updateTimeline', {
- useMarker: value
+ useMarkerTimeline: value
})
}
},
diff --git a/src/renderer/store/App.ts b/src/renderer/store/App.ts
index 74253c24..68497141 100644
--- a/src/renderer/store/App.ts
+++ b/src/renderer/store/App.ts
@@ -27,7 +27,7 @@ export type AppState = {
hideAllAttachments: boolean
tootPadding: number
userAgent: string
- useMarker: boolean
+ useMarkerTimeline: Array
}
const state = (): AppState => ({
@@ -53,7 +53,7 @@ const state = (): AppState => ({
ignoreNSFW: false,
hideAllAttachments: false,
userAgent: 'Whalebird',
- useMarker: false
+ useMarkerTimeline: ['notifications']
})
const MUTATION_TYPES = {
@@ -106,8 +106,8 @@ const mutations: MutationTree = {
[MUTATION_TYPES.UPDATE_HIDE_ALL_ATTACHMENTS]: (state: AppState, hideAllAttachments: boolean) => {
state.hideAllAttachments = hideAllAttachments
},
- [MUTATION_TYPES.UPDATE_USE_MARKER]: (state: AppState, useMarker: boolean) => {
- state.useMarker = useMarker
+ [MUTATION_TYPES.UPDATE_USE_MARKER]: (state: AppState, useMarkerTimeline: Array) => {
+ state.useMarkerTimeline = useMarkerTimeline
}
}
@@ -133,7 +133,7 @@ const actions: ActionTree = {
commit(MUTATION_TYPES.UPDATE_IGNORE_CW, conf.general.timeline.cw)
commit(MUTATION_TYPES.UPDATE_IGNORE_NSFW, conf.general.timeline.nsfw)
commit(MUTATION_TYPES.UPDATE_HIDE_ALL_ATTACHMENTS, conf.general.timeline.hideAllAttachments)
- commit(MUTATION_TYPES.UPDATE_USE_MARKER, conf.general.timeline.useMarker)
+ commit(MUTATION_TYPES.UPDATE_USE_MARKER, conf.general.timeline.useMarkerTimeline)
return conf
},
updateTheme: async ({ commit }, appearance: Appearance) => {
diff --git a/src/renderer/store/Preferences/General.ts b/src/renderer/store/Preferences/General.ts
index 642f7131..6f37dcb5 100644
--- a/src/renderer/store/Preferences/General.ts
+++ b/src/renderer/store/Preferences/General.ts
@@ -22,7 +22,7 @@ const state = (): GeneralState => ({
cw: false,
nsfw: false,
hideAllAttachments: false,
- useMarker: false
+ useMarkerTimeline: ['notifications']
},
other: {
launch: false
diff --git a/src/renderer/store/TimelineSpace/Contents/Home.ts b/src/renderer/store/TimelineSpace/Contents/Home.ts
index b0bb4ebd..6f114046 100644
--- a/src/renderer/store/TimelineSpace/Contents/Home.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Home.ts
@@ -134,7 +134,7 @@ const actions: ActionTree = {
console.error(err)
})
- if (rootState.App.useMarker && localMarker !== null) {
+ if (rootState.App.useMarkerTimeline.includes('home') && localMarker !== null) {
const last = await client.getStatus(localMarker.last_read_id)
const lastReadStatus = last.data
@@ -240,7 +240,7 @@ const actions: ActionTree = {
return res.data
},
getMarker: async ({ rootState }): Promise => {
- if (!rootState.App.useMarker) {
+ if (!rootState.App.useMarkerTimeline.includes('home')) {
return null
}
const client = generator(
diff --git a/src/renderer/store/TimelineSpace/Contents/Notifications.ts b/src/renderer/store/TimelineSpace/Contents/Notifications.ts
index c71af9d8..e325db39 100644
--- a/src/renderer/store/TimelineSpace/Contents/Notifications.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Notifications.ts
@@ -120,7 +120,7 @@ const actions: ActionTree = {
console.error(err)
})
- if (rootState.App.useMarker && localMarker !== null) {
+ if (rootState.App.useMarkerTimeline.includes('notifications') && localMarker !== null) {
// The result does not contain max_id's notification, when we specify max_id parameter in get notifications.
// So we need to get max_id's notification.
const last = await client.getNotification(localMarker.last_read_id)
@@ -224,7 +224,7 @@ const actions: ActionTree = {
win.ipcRenderer.send('reset-badge')
},
getMarker: async ({ rootState }): Promise => {
- if (!rootState.App.useMarker) {
+ if (!rootState.App.useMarkerTimeline.includes('notifications')) {
return null
}
const client = generator(
diff --git a/src/types/timeline.ts b/src/types/timeline.ts
index 6e219239..1a8d9282 100644
--- a/src/types/timeline.ts
+++ b/src/types/timeline.ts
@@ -2,5 +2,5 @@ export type Timeline = {
cw: boolean
nsfw: boolean
hideAllAttachments: boolean
- useMarker: boolean
+ useMarkerTimeline: Array
}
diff --git a/yarn.lock b/yarn.lock
index e1c198a6..1e3ba4e9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1352,14 +1352,6 @@
lodash "^4.17.15"
tmp-promise "^3.0.2"
-"@mapbox/stylelint-processor-arbitrary-tags@^0.4.0":
- version "0.4.0"
- resolved "https://registry.yarnpkg.com/@mapbox/stylelint-processor-arbitrary-tags/-/stylelint-processor-arbitrary-tags-0.4.0.tgz#da45723d8ce75140d08efe3bddd284eba3a3fe53"
- integrity sha512-HTyW4vLgCVrAvmbV4TtXVpkrg3gkRR4WMEveNOo4OBxzA5wl5xQdxe0Iow8B5FRI3ose5yFLA8jvbfU8ZayPJQ==
- dependencies:
- execall "^1.0.0"
- split-lines "^1.1.0"
-
"@nodelib/fs.scandir@2.1.3":
version "2.1.3"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b"
@@ -3448,14 +3440,6 @@ clone-deep@^4.0.1:
kind-of "^6.0.2"
shallow-clone "^3.0.0"
-clone-regexp@^1.0.0:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/clone-regexp/-/clone-regexp-1.0.1.tgz#051805cd33173375d82118fc0918606da39fd60f"
- integrity sha512-Fcij9IwRW27XedRIJnSOEupS7RVcXtObJXbcUOX93UCLqqOdRpkvzKywOOSizmEK/Is3S/RHX9dLdfo6R1Q1mw==
- dependencies:
- is-regexp "^1.0.0"
- is-supported-regexp-flag "^1.0.0"
-
clone-regexp@^2.1.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/clone-regexp/-/clone-regexp-2.2.0.tgz#7d65e00885cd8796405c35a737e7a86b7429e36f"
@@ -5122,13 +5106,6 @@ execa@^5.0.0:
signal-exit "^3.0.3"
strip-final-newline "^2.0.0"
-execall@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/execall/-/execall-1.0.0.tgz#73d0904e395b3cab0658b08d09ec25307f29bb73"
- integrity sha1-c9CQTjlbPKsGWLCNCewlMH8pu3M=
- dependencies:
- clone-regexp "^1.0.0"
-
execall@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/execall/-/execall-2.0.0.tgz#16a06b5fe5099df7d00be5d9c06eecded1663b45"
@@ -6812,11 +6789,6 @@ is-regex@^1.1.4:
call-bind "^1.0.2"
has-tostringtag "^1.0.0"
-is-regexp@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069"
- integrity sha1-/S2INUXEa6xaYz57mgnof6LLUGk=
-
is-regexp@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-2.1.0.tgz#cd734a56864e23b956bf4e7c66c396a4c0b22c2d"
@@ -6849,11 +6821,6 @@ is-string@^1.0.7:
dependencies:
has-tostringtag "^1.0.0"
-is-supported-regexp-flag@^1.0.0:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/is-supported-regexp-flag/-/is-supported-regexp-flag-1.0.1.tgz#21ee16518d2c1dd3edd3e9a0d57e50207ac364ca"
- integrity sha512-3vcJecUUrpgCqc/ca0aWeNu64UGgxcvO60K/Fkr1N6RSvfGCTU60UKN68JDmKokgba0rFFJs12EnzOQa14ubKQ==
-
is-symbol@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937"
@@ -10499,11 +10466,6 @@ specificity@^0.4.1:
resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.4.1.tgz#aab5e645012db08ba182e151165738d00887b019"
integrity sha512-1klA3Gi5PD1Wv9Q0wUoOQN1IWAuPu0D1U03ThXTr0cJ20+/iq2tHSDnK7Kk/0LXJ1ztUB2/1Os0wKmfyNgUQfg==
-split-lines@^1.1.0:
- version "1.1.0"
- resolved "https://registry.yarnpkg.com/split-lines/-/split-lines-1.1.0.tgz#3abba8f598614142f9db8d27ab6ab875662a1e09"
- integrity sha1-Oruo9ZhhQUL5240nq2q4dWYqHgk=
-
split-string@^3.0.1, split-string@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"