refactor(join): remove recent rooms

This commit is contained in:
Travis Shivers 2020-10-25 21:57:30 -05:00
parent b760215bd2
commit 5233b3310e
No known key found for this signature in database
GPG Key ID: EE4CC2891B8FCD33
7 changed files with 3 additions and 95 deletions

View File

@ -41,7 +41,6 @@ const defaults = {
plex_auth_check_interval: 1000, plex_auth_check_interval: 1000,
socket_server_health_timeout: 2000, socket_server_health_timeout: 2000,
synclounge_max_recent_room_history: 100,
// TODO: investigate the average length of closing credits // TODO: investigate the average length of closing credits
synclounge_upnext_trigger_time_from_end: 45000, synclounge_upnext_trigger_time_from_end: 45000,

View File

@ -27,7 +27,6 @@ const persistedState = createPersistedState({
'plexservers.lastServerId', 'plexservers.lastServerId',
'plexservers.blockedServerIds', 'plexservers.blockedServerIds',
'synclounge.recentRooms',
'synclounge.areNotificationsEnabled', 'synclounge.areNotificationsEnabled',
'synclounge.areSoundNotificationsEnabled', 'synclounge.areSoundNotificationsEnabled',

View File

@ -82,9 +82,7 @@ export default {
return rest; return rest;
}, },
JOIN_ROOM_AND_INIT: async ({ JOIN_ROOM_AND_INIT: async ({ rootGetters, dispatch, commit }) => {
getters, rootGetters, dispatch, commit,
}) => {
// Note: this is also called on rejoining, so be careful not to register handlers twice // Note: this is also called on rejoining, so be careful not to register handlers twice
// or duplicate tasks // or duplicate tasks
const { const {
@ -92,16 +90,6 @@ export default {
} = await dispatch('JOIN_ROOM'); } = await dispatch('JOIN_ROOM');
const updatedAt = Date.now(); const updatedAt = Date.now();
// Add this item to our recently-connected list
await dispatch(
'ADD_RECENT_ROOM',
{
server: getters.GET_SERVER,
room: getters.GET_ROOM,
time: Date.now(),
},
);
commit('SET_HOST_ID', hostId); commit('SET_HOST_ID', hostId);
commit('SET_USERS', Object.fromEntries( commit('SET_USERS', Object.fromEntries(
@ -228,22 +216,6 @@ export default {
commit('SET_SERVERS_HEALTH', aliveServerHealths); commit('SET_SERVERS_HEALTH', aliveServerHealths);
}, },
ADD_RECENT_ROOM: ({ commit, getters, rootGetters }, newRoom) => commit(
'SET_RECENT_ROOMS',
Array.of(newRoom).concat(
getters.GET_RECENT_ROOMS.filter(
(room) => room.server !== newRoom.server || room.room !== newRoom.room,
),
).slice(0, rootGetters.GET_CONFIG.synclounge_max_recent_room_history),
),
REMOVE_RECENT_ROOM: ({ commit, getters }, roomToRemove) => commit(
'SET_RECENT_ROOMS',
getters.GET_RECENT_ROOMS.filter(
(room) => room.server !== roomToRemove.server || room.room !== roomToRemove.room,
),
),
ADD_EVENT_HANDLERS: ({ dispatch }) => { ADD_EVENT_HANDLERS: ({ dispatch }) => {
const makeHandler = (action) => (data) => dispatch(action, data); const makeHandler = (action) => (data) => dispatch(action, data);

View File

@ -60,8 +60,6 @@ export default {
GET_SYNC_CANCEL_TOKEN: (state) => state.syncCancelToken, GET_SYNC_CANCEL_TOKEN: (state) => state.syncCancelToken,
GET_RECENT_ROOMS: (state) => state.recentRooms,
IS_IN_ROOM: (state) => state.isInRoom, IS_IN_ROOM: (state) => state.isInRoom,
// Note: the host should really always have a playback rate of 1 // Note: the host should really always have a playback rate of 1

View File

@ -42,10 +42,6 @@ export default {
state.syncCancelToken = token; state.syncCancelToken = token;
}, },
SET_RECENT_ROOMS: (state, rooms) => {
state.recentRooms = rooms;
},
SET_IS_IN_ROOM: (state, isInRoom) => { SET_IS_IN_ROOM: (state, isInRoom) => {
state.isInRoom = isInRoom; state.isInRoom = isInRoom;
}, },

View File

@ -10,7 +10,6 @@ const state = () => ({
isAutoHostEnabled: null, isAutoHostEnabled: null,
serversHealth: null, serversHealth: null,
syncCancelToken: null, syncCancelToken: null,
recentRooms: [],
isInRoom: false, isInRoom: false,
upnextTimeoutId: null, upnextTimeoutId: null,

View File

@ -56,54 +56,6 @@
<v-row <v-row
justify="center" justify="center"
> >
<v-col
v-if="GET_RECENT_ROOMS.length"
cols="12"
class="pa-4"
>
<v-subheader>Recent Rooms</v-subheader>
<v-list class="pa-0">
<v-list-item
v-for="(item, index) in GET_RECENT_ROOMS.slice(0, 3)"
:key="index"
@click="connect(item.server, item.room)"
>
<v-list-item-avatar
width="32px"
>
<v-img
src="@/assets/images/logos/logo-small-light.png"
/>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title>{{ item.name || item.server || 'Custom' }}</v-list-item-title>
<v-list-item-subtitle>
<b>{{ item.room }}</b>
<span style="opacity: 0.5; float: right;">{{ sinceNow(item.time) }}</span>
</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action>
<v-tooltip top>
<template #activator="{ on, attrs }">
<v-icon
v-bind="attrs"
v-on="on"
@click.stop="REMOVE_RECENT_ROOM(item)"
>
close
</v-icon>
</template>
Remove
</v-tooltip>
</v-list-item-action>
</v-list-item>
</v-list>
</v-col>
<v-col <v-col
cols="12" cols="12"
class="pa-4" class="pa-4"
@ -254,7 +206,6 @@
</template> </template>
<script> <script>
import { formatDistanceToNow } from 'date-fns';
import { import {
mapActions, mapGetters, mapMutations, mapState, mapActions, mapGetters, mapMutations, mapState,
} from 'vuex'; } from 'vuex';
@ -289,7 +240,6 @@ export default {
]), ]),
...mapGetters('synclounge', [ ...mapGetters('synclounge', [
'GET_RECENT_ROOMS',
'GET_SERVER_HEALTH', 'GET_SERVER_HEALTH',
]), ]),
@ -316,16 +266,11 @@ export default {
]), ]),
...mapActions('synclounge', [ ...mapActions('synclounge', [
'REMOVE_RECENT_ROOM',
'FETCH_SERVERS_HEALTH', 'FETCH_SERVERS_HEALTH',
'SET_AND_CONNECT_AND_JOIN_ROOM', 'SET_AND_CONNECT_AND_JOIN_ROOM',
'DISCONNECT_IF_CONNECTED', 'DISCONNECT_IF_CONNECTED',
]), ]),
sinceNow(x) {
return formatDistanceToNow(x);
},
connectionQualityClass(value) { connectionQualityClass(value) {
if (value < 50) { if (value < 50) {
return ['green--text', 'text--lighten-1']; return ['green--text', 'text--lighten-1'];
@ -352,14 +297,14 @@ export default {
return ['white--text']; return ['white--text'];
}, },
async connect(server, room) { async connect(server) {
this.serverError = null; this.serverError = null;
this.connectionPending = true; this.connectionPending = true;
try { try {
await this.SET_AND_CONNECT_AND_JOIN_ROOM({ await this.SET_AND_CONNECT_AND_JOIN_ROOM({
server, server,
room: room || getRandomRoomId(), room: getRandomRoomId(),
}); });
if (this.$route.name === 'AdvancedRoomJoin') { if (this.$route.name === 'AdvancedRoomJoin') {