Skip to content

Commit 3d21e1a

Browse files
committed
* Implement watch progress saving mode setting
1 parent 9de03bf commit 3d21e1a

12 files changed

Lines changed: 180 additions & 93 deletions

File tree

src/datastores/handlers/base.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ class Settings {
3838
await db.settings.removeAsync({ _id: 'defaultTheatreMode' })
3939
}
4040

41+
const saveWatchedProgress = await db.settings.findOneAsync({ _id: 'saveWatchedProgress' })
42+
const watchedProgressSavingMode = await db.settings.findOneAsync({ _id: 'watchedProgressSavingMode' })
43+
if (saveWatchedProgress && !watchedProgressSavingMode) {
44+
if (!saveWatchedProgress.value) {
45+
await this.upsert('watchedProgressSavingMode', 'never')
46+
}
47+
48+
await db.settings.removeAsync({ _id: 'saveWatchedProgress' })
49+
}
50+
4151
return db.settings.findAsync({ _id: { $ne: 'bounds' } })
4252
}
4353

src/renderer/components/ft-list-video/ft-list-video.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export default defineComponent({
128128
},
129129

130130
watchProgress: function () {
131-
if (!this.historyEntryExists || !this.saveWatchedProgress) {
131+
if (!this.historyEntryExists || !this.watchedProgressSavingEnabled) {
132132
return 0
133133
}
134134

@@ -388,8 +388,11 @@ export default defineComponent({
388388
return this.$store.getters.getDefaultPlayback
389389
},
390390

391-
saveWatchedProgress: function () {
392-
return this.$store.getters.getSaveWatchedProgress
391+
watchedProgressSavingEnabled: function () {
392+
return ['auto', 'semi-auto'].includes(this.$store.getters.getWatchedProgressSavingMode)
393+
},
394+
autosaveWatchedProgress: function () {
395+
return this.$store.getters.getWatchedProgressSavingMode === 'auto'
393396
},
394397

395398
saveVideoHistoryWithLastViewedPlaylist: function () {
@@ -639,7 +642,7 @@ export default defineComponent({
639642
}
640643
this.openInExternalPlayer(payload)
641644

642-
if (this.saveWatchedProgress && !this.historyEntryExists) {
645+
if (this.autosaveWatchedProgress && !this.historyEntryExists) {
643646
this.markAsWatched()
644647
}
645648
},

src/renderer/components/privacy-settings/privacy-settings.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import FtButton from '../ft-button/ft-button.vue'
55
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
66
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
77
import FtPrompt from '../FtPrompt/FtPrompt.vue'
8+
import FtSelect from '../ft-select/ft-select.vue'
89
import { MAIN_PROFILE_ID } from '../../../constants'
910
import { showToast } from '../../helpers/utils'
1011

@@ -15,7 +16,8 @@ export default defineComponent({
1516
'ft-button': FtButton,
1617
'ft-toggle-switch': FtToggleSwitch,
1718
'ft-flex-box': FtFlexBox,
18-
'ft-prompt': FtPrompt
19+
'ft-prompt': FtPrompt,
20+
'ft-select': FtSelect,
1921
},
2022
data: function () {
2123
return {
@@ -36,8 +38,15 @@ export default defineComponent({
3638
rememberHistory: function () {
3739
return this.$store.getters.getRememberHistory
3840
},
39-
saveWatchedProgress: function () {
40-
return this.$store.getters.getSaveWatchedProgress
41+
watchedProgressSavingMode() {
42+
return this.$store.getters.getWatchedProgressSavingMode
43+
},
44+
watchedProgressSavingModeValueNamePairs() {
45+
return [
46+
['auto', this.$t('Settings.Privacy Settings.Watched Progress Saving Mode.Modes.Auto')],
47+
['semi-auto', this.$t('Settings.Privacy Settings.Watched Progress Saving Mode.Modes.Semi-auto')],
48+
['never', this.$t('Settings.Privacy Settings.Watched Progress Saving Mode.Modes.Never')],
49+
]
4150
},
4251
saveVideoHistoryWithLastViewedPlaylist: function () {
4352
return this.$store.getters.getSaveVideoHistoryWithLastViewedPlaylist
@@ -69,7 +78,7 @@ export default defineComponent({
6978

7079
handleRememberHistory: function (value) {
7180
if (!value) {
72-
this.updateSaveWatchedProgress(false)
81+
this.updateWatchedProgressSavingMode('never')
7382
}
7483

7584
this.updateRememberHistory(value)
@@ -123,7 +132,7 @@ export default defineComponent({
123132
'updateRememberHistory',
124133
'removeAllHistory',
125134
'updateRememberSearchHistory',
126-
'updateSaveWatchedProgress',
135+
'updateWatchedProgressSavingMode',
127136
'updateSaveVideoHistoryWithLastViewedPlaylist',
128137
'clearSessionSearchHistory',
129138
'removeAllSearchHistoryEntries',

src/renderer/components/privacy-settings/privacy-settings.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020
/>
2121
</div>
2222
<div class="switchColumn">
23-
<ft-toggle-switch
24-
:label="$t('Settings.Privacy Settings.Save Watched Progress')"
25-
:compact="true"
23+
<ft-select
24+
:placeholder="$t('Settings.Privacy Settings.Save Watched Progress')"
25+
:value="watchedProgressSavingMode"
26+
:select-names="watchedProgressSavingModeValueNamePairs.map(p => p[1])"
27+
:select-values="watchedProgressSavingModeValueNamePairs.map(p => p[0])"
28+
:icon="['fas', 'bars-progress']"
29+
:tooltip="$t('Settings.Privacy Settings.Watched Progress Saving Mode.Tooltip')"
2630
:disabled="!rememberHistory"
27-
:default-value="saveWatchedProgress"
28-
@change="updateSaveWatchedProgress"
31+
@change="updateWatchedProgressSavingMode"
2932
/>
3033
</div>
3134
<div class="switchColumn">

src/renderer/components/watch-video-info/watch-video-info.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ export default defineComponent({
116116
required: false
117117
}
118118
},
119-
emits: ['change-format', 'pause-player', 'set-info-area-sticky', 'scroll-to-info-area'],
119+
emits: [
120+
'change-format',
121+
'pause-player',
122+
'set-info-area-sticky',
123+
'scroll-to-info-area',
124+
'save-watched-progress',
125+
],
120126
computed: {
121127
hideSharingActions: function() {
122128
return this.$store.getters.getHideSharingActions
@@ -142,6 +148,10 @@ export default defineComponent({
142148
return !this.$store.getters.getHidePlaylists
143149
},
144150

151+
watchedProgressSavingInSemiAutoMode() {
152+
return this.$store.getters.getWatchedProgressSavingMode === 'semi-auto'
153+
},
154+
145155
downloadLinkOptions: function () {
146156
return this.downloadLinks.map((download) => {
147157
return {
@@ -409,6 +419,10 @@ export default defineComponent({
409419
this.$emit('change-format', value)
410420
},
411421

422+
saveWatchedProgressManually() {
423+
this.$emit('save-watched-progress')
424+
},
425+
412426
...mapActions([
413427
'openInExternalPlayer',
414428
'downloadMedia',

src/renderer/components/watch-video-info/watch-video-info.scss

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,33 @@
6666

6767
.videoOptions {
6868
display: flex;
69-
flex-wrap: wrap;
70-
justify-content: flex-end;
7169
gap: 4px;
7270

73-
@media screen and (width <= 680px) {
71+
@media screen and (width <= 380px) {
72+
flex-direction: column;
73+
align-items: flex-start;
74+
margin-block-start: 10px;
75+
}
76+
}
77+
78+
.videoOptionsMobileRow {
79+
display: flex;
80+
gap: 4px;
81+
82+
@media screen and (width <= 730px) {
7483
:deep(.iconDropdown) {
7584
inset-inline: auto calc(50% - 20px);
7685
}
7786
}
7887

7988
@media screen and (width <= 460px) {
80-
flex-wrap: nowrap;
81-
8289
:deep(.iconDropdown) {
8390
inset-inline: auto;
8491
}
8592
}
8693
}
8794

88-
@media screen and (width <= 460px) {
95+
@media screen and (width <= 730px) {
8996
flex-direction: column;
9097
align-items: flex-start;
9198
margin-block-start: 10px;

src/renderer/components/watch-video-info/watch-video-info.vue

Lines changed: 64 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -85,60 +85,70 @@
8585
</div>
8686
</div>
8787
<div class="videoOptions">
88-
<ft-icon-button
89-
v-if="showPlaylists && !isUpcoming"
90-
:title="$t('User Playlists.Add to Playlist')"
91-
:icon="['fas', 'plus']"
92-
class="option"
93-
theme="base"
94-
@click="togglePlaylistPrompt"
95-
/>
96-
<ft-icon-button
97-
v-if="isQuickBookmarkEnabled"
98-
:title="quickBookmarkIconText"
99-
:icon="isInQuickBookmarkPlaylist ? ['fas', 'check'] : ['fas', 'bookmark']"
100-
class="quickBookmarkVideoIcon"
101-
:class="{
102-
bookmarked: isInQuickBookmarkPlaylist,
103-
}"
104-
:theme="quickBookmarkIconTheme"
105-
@click="toggleQuickBookmarked"
106-
/>
107-
<ft-icon-button
108-
v-if="externalPlayer !== ''"
109-
:title="$t('Video.External Player.OpenInTemplate', { externalPlayer })"
110-
:icon="['fas', 'external-link-alt']"
111-
class="option"
112-
theme="secondary"
113-
@click="handleExternalPlayer"
114-
/>
115-
<ft-icon-button
116-
v-if="!isUpcoming && downloadLinks.length > 0"
117-
ref="downloadButton"
118-
:title="$t('Video.Download Video')"
119-
class="option"
120-
theme="secondary"
121-
:icon="['fas', 'download']"
122-
:return-index="true"
123-
:dropdown-options="downloadLinkOptions"
124-
@click="handleDownload"
125-
/>
126-
<ft-icon-button
127-
v-if="!isUpcoming"
128-
:title="$t('Change Format.Change Media Formats')"
129-
class="option"
130-
theme="secondary"
131-
:icon="['fas', 'file-video']"
132-
:dropdown-options="formatTypeOptions"
133-
@click="changeFormat($event)"
134-
/>
135-
<ft-share-button
136-
v-if="!hideSharingActions"
137-
:id="id"
138-
:get-timestamp="getTimestamp"
139-
:playlist-id="playlistId"
140-
class="option"
141-
/>
88+
<span class="videoOptionsMobileRow">
89+
<ft-icon-button
90+
v-if="showPlaylists && !isUpcoming"
91+
:title="$t('User Playlists.Add to Playlist')"
92+
:icon="['fas', 'plus']"
93+
class="option"
94+
theme="base"
95+
@click="togglePlaylistPrompt"
96+
/>
97+
<ft-icon-button
98+
v-if="isQuickBookmarkEnabled"
99+
:title="quickBookmarkIconText"
100+
:icon="isInQuickBookmarkPlaylist ? ['fas', 'check'] : ['fas', 'bookmark']"
101+
class="quickBookmarkVideoIcon"
102+
:class="{
103+
bookmarked: isInQuickBookmarkPlaylist,
104+
}"
105+
:theme="quickBookmarkIconTheme"
106+
@click="toggleQuickBookmarked"
107+
/>
108+
<ft-icon-button
109+
v-if="watchedProgressSavingInSemiAutoMode"
110+
:title="$t('Video.Save Watched Progress')"
111+
:icon="['fas', 'bars-progress']"
112+
@click="saveWatchedProgressManually"
113+
/>
114+
</span>
115+
<span class="videoOptionsMobileRow">
116+
<ft-icon-button
117+
v-if="externalPlayer !== ''"
118+
:title="$t('Video.External Player.OpenInTemplate', { externalPlayer })"
119+
:icon="['fas', 'external-link-alt']"
120+
class="option"
121+
theme="secondary"
122+
@click="handleExternalPlayer"
123+
/>
124+
<ft-icon-button
125+
v-if="!isUpcoming && downloadLinks.length > 0"
126+
ref="downloadButton"
127+
:title="$t('Video.Download Video')"
128+
class="option"
129+
theme="secondary"
130+
:icon="['fas', 'download']"
131+
:return-index="true"
132+
:dropdown-options="downloadLinkOptions"
133+
@click="handleDownload"
134+
/>
135+
<ft-icon-button
136+
v-if="!isUpcoming"
137+
:title="$t('Change Format.Change Media Formats')"
138+
class="option"
139+
theme="secondary"
140+
:icon="['fas', 'file-video']"
141+
:dropdown-options="formatTypeOptions"
142+
@click="changeFormat($event)"
143+
/>
144+
<ft-share-button
145+
v-if="!hideSharingActions"
146+
:id="id"
147+
:get-timestamp="getTimestamp"
148+
:playlist-id="playlistId"
149+
class="option"
150+
/>
151+
</span>
142152
</div>
143153
</div>
144154
</ft-card>

src/renderer/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
faArrowRight,
2525
faArrowUp,
2626
faBars,
27+
faBarsProgress,
2728
faBorderAll,
2829
faBookmark,
2930
faCheck,
@@ -148,6 +149,7 @@ library.add(
148149
faArrowRight,
149150
faArrowUp,
150151
faBars,
152+
faBarsProgress,
151153
faBorderAll,
152154
faBookmark,
153155
faCheck,

src/renderer/store/modules/settings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ const state = {
234234
rememberHistory: true,
235235
rememberSearchHistory: true,
236236
saveWatchedProgress: true,
237+
// 'auto', 'semi-auto', 'never'
238+
watchedProgressSavingMode: 'auto',
237239
saveVideoHistoryWithLastViewedPlaylist: true,
238240
showFamilyFriendlyOnly: false,
239241
sponsorBlockShowSkippedToast: true,

0 commit comments

Comments
 (0)