Skip to content

Commit

Permalink
Merge pull request #972 from YuRiJinX/incognito-mode
Browse files Browse the repository at this point in the history
feat(incognito): incognito mode
  • Loading branch information
ipy authored Sep 19, 2019
2 parents 200b78f + d6bb54c commit f856c0d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
10 changes: 3 additions & 7 deletions src/renderer/containers/LandingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,9 @@ export default {
this.createTouchBar();
window.addEventListener('mousemove', this.globalMoveHandler);
// Get all data and show
if (!this.incognitoMode) {
recentPlayService.getRecords().then((results) => {
this.landingViewItems = results;
});
} else {
this.infoDB.clearAll();
}
recentPlayService.getRecords().then((results) => {
this.landingViewItems = results;
});
this.$bus.$on('clean-landingViewItems', () => {
// just for delete thumbnail display
this.firstIndex = 0;
Expand Down
31 changes: 27 additions & 4 deletions src/renderer/containers/VideoCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default {
...mapGetters([
'videoId', 'nextVideoId', 'originSrc', 'convertedSrc', 'volume', 'muted', 'rate', 'paused', 'duration', 'ratio', 'currentAudioTrackId', 'enabledSecondarySub', 'lastChosenSize', 'subToTop',
'winSize', 'winPos', 'winAngle', 'isFullScreen', 'winWidth', 'winHeight', 'chosenStyle', 'chosenSize', 'nextVideo', 'loop', 'playinglistRate', 'isFolderList', 'playingList', 'playingIndex', 'playListId', 'items',
'previousVideo', 'previousVideoId', 'smartMode', 'isTranslating', 'nsfwProcessDone',
'previousVideo', 'previousVideoId', 'smartMode', 'incognitoMode', 'isTranslating', 'nsfwProcessDone',
]),
...mapGetters({
videoWidth: 'intrinsicWidth',
Expand All @@ -95,6 +95,16 @@ export default {
this.changeWindowRotate(val);
},
async playListId(val: number, oldVal: number) {
if (this.incognitoMode && oldVal) {
const playlistItem = await playInfoStorageService.getPlaylistRecord(oldVal);
const mediaItem = await playInfoStorageService
.getMediaItem(playlistItem.items[playlistItem.playedIndex]);
if (mediaItem.lastPlayedTime) return;
await playInfoStorageService.deleteRecentPlayedBy(oldVal);
return;
}
if (oldVal && !this.isFolderList) {
const screenshot: ShortCut = await this.generateScreenshot();
if (!(await this.handleNSFW(screenshot.shortCut, oldVal))) {
Expand All @@ -103,6 +113,7 @@ export default {
}
},
async videoId(val: number, oldVal: number) {
if (this.incognitoMode) return;
const screenshot: ShortCut = await this.generateScreenshot();
await this.saveScreenshot(oldVal, screenshot);
},
Expand Down Expand Up @@ -387,8 +398,20 @@ export default {
},
async handleLeaveVideo(videoId: number) {
const playListId = this.playListId;
// incognito mode
if (this.incognitoMode) {
const playlistItem = await playInfoStorageService.getPlaylistRecord(playListId);
const mediaItem = await playInfoStorageService
.getMediaItem(playlistItem.items[playlistItem.playedIndex]);
if (mediaItem.lastPlayedTime) return;
await playInfoStorageService.deleteRecentPlayedBy(playListId);
return;
}
const screenshot: ShortCut = await this.generateScreenshot();
if (await this.handleNSFW(screenshot.shortCut, playListId)) return null;
if (await this.handleNSFW(screenshot.shortCut, playListId)) return;
let savePromise = this.saveScreenshot(videoId, screenshot)
.then(() => this.updatePlaylist(playListId));
Expand All @@ -397,9 +420,9 @@ export default {
await playInfoStorageService.deleteRecentPlayedBy(playListId);
});
}
return savePromise
await (savePromise
.then(this.saveSubtitleStyle)
.then(this.savePlaybackStates);
.then(this.savePlaybackStates));
},
beforeUnloadHandler(e: BeforeUnloadEvent) {
// 如果当前有翻译任务进行,而不是再后台进行
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export default {
async openPlayList(id) {
const playlist = await this.infoDB.get('recent-played', id);
if (!playlist) return;
await this.infoDB.update('recent-played', { ...playlist, lastOpened: Date.now() }, playlist.id);
if (!this.$store.getters.incognitoMode) await this.infoDB.update('recent-played', { ...playlist, lastOpened: Date.now() }, playlist.id);
if (playlist.items.length > 1) {
let currentVideo = await this.infoDB.get('media-item', playlist.items[playlist.playedIndex]);

Expand Down Expand Up @@ -444,7 +444,7 @@ export default {
let playlist;
const quickHash = await mediaQuickHash.try(videoFile);
playlist = await this.infoDB.get('recent-played', 'hpaths', [`${quickHash}-${videoFile}`]);
if (quickHash && playlist) {
if (quickHash && playlist && !this.$store.getters.incognitoMode) {
id = playlist.id;
playlist.lastOpened = Date.now();
this.infoDB.update('recent-played', playlist, playlist.id);
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/locales/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
"smartMode": "Intelligent Mode",
"smartDescription": "Offline identify sensitive or not-suitable-for-work contents, and clear the playback history when playing in a folder playlist or when quitting.",
"incognitoMode": "Incognito Mode",
"incognitoDescription": "No playback history will be saved."
"incognitoDescription": "Your playback history will not be stored anymore."
}
},
"privacyBubble": {
Expand Down

0 comments on commit f856c0d

Please sign in to comment.