Moved manual sync logic into synclounge module

This commit is contained in:
Travis Shivers 2020-06-22 14:57:58 -05:00
parent 6ccb2e8217
commit a176bdf492
9 changed files with 34 additions and 41 deletions

View File

@ -97,9 +97,9 @@
<div v-if="!playable">
<v-btn
v-if="!AM_I_HOST"
:disabled="manualSyncQueued"
:disabled="IS_MANUAL_SYNC_QUEUED"
color="blue"
@click.native="doManualSync"
@click="SET_IS_MANUAL_SYNC_QUEUED(true)"
>
Manual sync
</v-btn>
@ -261,7 +261,7 @@
block
style="background-color: #cc3f3f"
class="white--text"
@click.native="PRESS_STOP"
@click="PRESS_STOP"
>
<v-icon /> Stop
</v-btn>
@ -271,9 +271,9 @@
<v-btn
v-if="!AM_I_HOST"
block
:disabled="manualSyncQueued"
:disabled="IS_MANUAL_SYNC_QUEUED"
color="blue"
@click.native="doManualSync"
@click="SET_IS_MANUAL_SYNC_QUEUED(true)"
>
Manual sync
</v-btn>
@ -395,7 +395,7 @@
<v-col
v-for="ep in subsetParentData"
:key="ep.key"
sm="6"
cols="6"
md="2"
class="pb-3"
>
@ -422,7 +422,7 @@
<v-col
v-for="movie in related"
:key="movie.key"
sm="4"
cols="4"
md="1"
class="ma-1"
>
@ -548,16 +548,13 @@ export default {
...mapGetters('synclounge', [
'AM_I_HOST',
'IS_MANUAL_SYNC_QUEUED',
]),
server() {
return this.GET_PLEX_SERVER(this.GET_ACTIVE_SERVER_ID);
},
manualSyncQueued() {
return this.$store.state.manualSyncQueued;
},
hidden() {
if (this.hiddenOverride) {
return false;
@ -652,6 +649,10 @@ export default {
'SET_ACTIVE_METADATA',
]),
...mapMutations('synclounge', [
'SET_IS_MANUAL_SYNC_QUEUED',
]),
async getNewData() {
this.contents = await this.FETCH_PLEX_METADATA({
ratingKey: this.ratingKey,
@ -678,10 +679,6 @@ export default {
this.setBackground();
},
doManualSync() {
this.$store.commit('SET_VALUE', ['manualSyncQueued', true]);
},
getLittleThumb(content) {
return this.GET_MEDIA_IMAGE_URL({
machineIdentifier: this.machineIdentifier,

View File

@ -79,8 +79,8 @@
<v-icon
color="white"
class="clickable"
:disabled="manualSyncQueued"
@click="doManualSync"
:disabled="IS_MANUAL_SYNC_QUEUED"
@click="SET_IS_MANUAL_SYNC_QUEUED(true)"
>
compare_arrows
</v-icon>
@ -158,9 +158,9 @@
<v-col v-if="!AM_I_HOST">
<v-btn
block
:disabled="manualSyncQueued"
:disabled="IS_MANUAL_SYNC_QUEUED"
color="blue"
@click.native="doManualSync"
@click="SET_IS_MANUAL_SYNC_QUEUED(true)"
>
Manual sync
</v-btn>
@ -170,7 +170,7 @@
<v-btn
block
color="primary"
@click.native="dialog = !dialog"
@click="dialog = !dialog"
>
Playback Settings
</v-btn>
@ -180,7 +180,7 @@
<v-btn
block
color="error"
@click.native="DO_COMMAND_STOP"
@click="PRESS_STOP"
>
Stop playback
</v-btn>
@ -193,9 +193,7 @@
<script>
import shaka from 'shaka-player/dist/shaka-player.ui.debug';
import {
mapActions, mapGetters, mapMutations, mapState,
} from 'vuex';
import { mapActions, mapGetters, mapMutations } from 'vuex';
import sizing from '@/mixins/sizing';
import 'shaka-player/dist/controls.css';
@ -240,8 +238,6 @@ export default {
},
computed: {
...mapState(['manualSyncQueued']),
...mapGetters('slplayer', [
'GET_SUBTITLE_STREAMS',
'GET_AUDIO_STREAMS',
@ -265,6 +261,7 @@ export default {
...mapGetters('synclounge', [
'AM_I_HOST',
'IS_MANUAL_SYNC_QUEUED',
]),
...mapGetters('plexclients', [
@ -379,6 +376,10 @@ export default {
'SET_BACKGROUND',
]),
...mapMutations('synclounge', [
'SET_IS_MANUAL_SYNC_QUEUED',
]),
getCastReceiverId() {
return window.chrome && window.chrome.cast && window.chrome.cast.media
? window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID
@ -416,10 +417,6 @@ export default {
};
},
doManualSync() {
this.$store.commit('SET_VALUE', ['manualSyncQueued', true]);
},
applyPlayerWatchers() {
this.$watch('GET_SUBTITLE_STREAMS', (newStreams) => {
this.eventbus.$emit('subtitlestreamschanged', newStreams);

View File

@ -15,8 +15,6 @@ export default {
},
}),
GET_MANUAL_SYNC_QUEUED: (state) => state.manualSyncQueued,
GET_UP_NEXT_TRIGGERED: (state) => state.upNextTriggered,
GET_UP_NEXT_POST_PLAY_DATA: (state) => state.upNextPostPlayData,
GET_CONFIG: (state) => state.configuration,

View File

@ -146,9 +146,7 @@ export default {
return dispatch('SYNCHRONIZE');
},
SYNCHRONIZE: async ({
getters, commit, dispatch, rootGetters,
}) => {
SYNCHRONIZE: async ({ getters, commit, dispatch }) => {
await dispatch('plex/FETCH_PLEX_DEVICES_IF_NEEDED', null, { root: true });
/* This is data from the host, we should react to this data by potentially changing
what we're playing or seeking to get back in sync with the host.
@ -160,7 +158,8 @@ export default {
*/
// TODO: move this manual sync into this module
if (rootGetters.GET_MANUAL_SYNC_QUEUED) {
if (getters.IS_MANUAL_SYNC_QUEUED) {
// TODO: find a way to remove this event
window.EventBus.$emit('host-playerstate-change');
await dispatch('plexclients/SEEK_TO', getters.GET_HOST_TIMELINE.time, { root: true });
commit('SET_MANUAL_SYNC_QUEUED', false, { root: true });

View File

@ -108,4 +108,6 @@ export default {
GET_HOST_LAST_RATING_KEY: (state) => state.hostLastRatingKey,
GET_IS_SYNC_IN_PROGRESS: (state) => state.isSyncInProgress,
IS_MANUAL_SYNC_QUEUED: (state) => state.isManualSyncedQueued,
};

View File

@ -78,4 +78,8 @@ export default {
SET_IS_SYNC_IN_PROGRESS: (state, inProgress) => {
state.isSyncInProgress = inProgress;
},
SET_IS_MANUAL_SYNC_QUEUED: (state, isQueued) => {
state.isManualSyncQueued = isQueued;
},
};

View File

@ -22,6 +22,7 @@ const state = () => ({
// Smoothed round trip time
srtt: null,
isSyncInProgress: false,
isManualSyncedQueued: false,
});
export default state;

View File

@ -7,10 +7,6 @@ export default {
SET_RIGHT_SIDEBAR_OPEN: (state, open) => { state.isRightSidebarOpen = open; },
TOGGLE_RIGHT_SIDEBAR_OPEN: (state) => { state.isRightSidebarOpen = !state.isRightSidebarOpen; },
SET_MANUAL_SYNC_QUEUED: (state, queued) => {
state.manualSyncQueued = queued;
},
SET_UP_NEXT_TRIGGERED: (state, triggered) => {
state.upNextTriggered = triggered;
},

View File

@ -2,7 +2,6 @@ const state = () => ({
appTitle: 'SyncLounge',
appVersion: process.env.VUE_APP_VERSION,
background: null,
manualSyncQueued: false,
upNextCache: {},
configuration: JSON.parse(process.env.VUE_APP_CONFIGURATION),
configurationFetched: false,