Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix remove show #9563

Merged
merged 6 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#### Fixes
- Add support for new synology download station api. Credits to Benjv. ([9555](https://github.com/pymedusa/Medusa/pull/9555))
- Fix shows not being removed from UI. ([9563](https://github.com/pymedusa/Medusa/pull/9563))

-----

Expand Down
3 changes: 3 additions & 0 deletions medusa/queues/show_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,9 @@ def run(self):
log.exception('Exception occurred while trying to delete show {show}, error: {error',
{'show': self.show.name, 'error': error})

# Send showRemoved to frontend, so we can remove it from localStorage.
ws.Message('QueueItemShowRemove', self.show.to_json(detailed=False)).push() # Send ws update to client

self.show.delete_show(full=self.full)

self.finish()
3 changes: 0 additions & 3 deletions medusa/server/web/home/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,6 @@ def deleteShow(self, showslug=None, full=0):
# Remove show from 'RECENT SHOWS' in 'Shows' menu
app.SHOWS_RECENT = [show for show in app.SHOWS_RECENT if show['showSlug'] != showslug]

# Don't redirect to the default page, so the user can confirm that the show was deleted
return self.redirect('/home/')

def refreshShow(self, showslug=None):
# @TODO: Replace with status=refresh from PATCH /api/v2/show/{id}
identifier = SeriesIdentifier.from_slug(showslug)
Expand Down
24 changes: 20 additions & 4 deletions themes-default/slim/src/components/sub-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import { apiRoute } from '../api';
import { mapActions, mapGetters } from 'vuex';
import { AppLink, ShowSelector } from './helpers';

export default {
Expand Down Expand Up @@ -53,6 +54,9 @@ export default {
}
},
methods: {
...mapActions({
removeShow: 'removeShow'
}),
clickEventCond(menuItem) {
return menuItem.confirm ? 'click' : null;
},
Expand All @@ -69,12 +73,24 @@ export default {
};

if (action === 'removeshow') {
const { getCurrentShow } = this;
const { getCurrentShow, removeShow, $router } = this;
options.title = 'Remove Show';
options.text = `Are you sure you want to remove <span class="footerhighlight">${getCurrentShow.title}</span> from the database?<br><br>
<input type="checkbox" id="deleteFiles"> <span class="red-text">Check to delete files as well. IRREVERSIBLE</span>`;
options.confirm = $element => {
window.location.href = $element[0].href + (document.querySelector('#deleteFiles').checked ? '&full=1' : '');
options.confirm = async () => {
// Already remove show from frontend store + localStorage
removeShow(getCurrentShow);

const params = { showslug: getCurrentShow.id.slug };
if (document.querySelector('#deleteFiles').checked) {
params.full = 1;
}

// Start removal of show in backend
await apiRoute.get('home/deleteShow', { params });

// Navigate back to /home
$router.push({ name: 'home', query: undefined });
};
} else if (action === 'clearhistory') {
options.title = 'Clear History';
Expand Down
2 changes: 2 additions & 0 deletions themes-default/slim/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ const passToStoreHandler = function(eventName, event, next) {
this.store.dispatch('updateQueueItem', data);
} else if (event === 'QueueItemShowAdd') {
this.store.dispatch('updateShowQueueItem', data);
} else if (event === 'QueueItemShowRemove') {
this.store.dispatch('removeShow', data);
} else if (event === 'historyUpdate') {
this.store.dispatch('updateHistory', data);
} else {
Expand Down
12 changes: 11 additions & 1 deletion themes-default/slim/src/store/modules/shows.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
ADD_SHOWS,
ADD_SHOW_EPISODE,
ADD_SHOW_SCENE_EXCEPTION,
REMOVE_SHOW_SCENE_EXCEPTION
REMOVE_SHOW_SCENE_EXCEPTION,
REMOVE_SHOW
} from '../mutation-types';

/**
Expand Down Expand Up @@ -160,6 +161,11 @@ const mutations = {
Vue.set(state.queueitems, state.queueitems.length, queueItem);
}
},
[REMOVE_SHOW](state, removedShow) {
state.shows = state.shows.filter(existingShow => removedShow.id.slug !== existingShow.id.slug);
// Update localStorage
localStorage.setItem('shows', JSON.stringify(state.shows));
},
initShowsFromStore(state) {
// Check if the ID exists
if (localStorage.getItem('shows')) {
Expand Down Expand Up @@ -458,6 +464,10 @@ const actions = {
// Update store's search queue item. (provided through websocket)
const { commit } = context;
return commit(ADD_SHOW_QUEUE_ITEM, queueItem);
},
removeShow({ commit }, show) {
// Remove the show from store and localStorage (provided through websocket)
return commit(REMOVE_SHOW, show);
}
};

Expand Down
2 changes: 2 additions & 0 deletions themes-default/slim/src/store/mutation-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const ADD_PROVIDER_CACHE = '⛽ Provider cache results added to store';
const ADD_SEARCH_RESULTS = '⛽ New search results added for provider';
const ADD_QUEUE_ITEM = '🔍 Search queue item updated';
const ADD_SHOW_QUEUE_ITEM = '📺 Show queue item added to store';
const REMOVE_SHOW = '📺 Show removed from store';
const UPDATE_SHOWLIST_DEFAULT = '⚙️ Anime config showlist default updated';
const ADD_SCHEDULE = '📅 Schedule information added';

Expand Down Expand Up @@ -72,6 +73,7 @@ export {
ADD_SEARCH_RESULTS,
ADD_QUEUE_ITEM,
ADD_SHOW_QUEUE_ITEM,
REMOVE_SHOW,
UPDATE_SHOWLIST_DEFAULT,
ADD_SCHEDULE
};
10 changes: 5 additions & 5 deletions themes/dark/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions themes/light/assets/js/medusa-runtime.js

Large diffs are not rendered by default.