Skip to content

Commit

Permalink
refactor(subtitle): turn calculatedNoSub to new getter
Browse files Browse the repository at this point in the history
1. Remove calculatedNoSub mutation and action from legacy vuex.
2. Add calculatedNoSub as new vuex getter.
  • Loading branch information
YvonTre committed Jul 16, 2019
1 parent 6f3ab2a commit 8a11c23
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 14 deletions.
4 changes: 0 additions & 4 deletions src/renderer/components/PlayingView/SubtitleControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ export default {
enabledSecondarySub(val: boolean) {
if (!val) this.updateSubtitleType(true);
},
computedAvailableItems(val: SubtitleControlListItem[]) {
this.updateNoSubtitle(!val.length);
},
list(val: SubtitleControlListItem[]) {
this.computedAvailableItems = val.map((sub: SubtitleControlListItem) => ({
...sub,
Expand Down Expand Up @@ -348,7 +345,6 @@ export default {
changeSecondarySubtitle: smActions.changeSecondarySubtitle,
refreshSubtitles: smActions.refreshSubtitles,
deleteCurrentSubtitle: smActions.deleteSubtitlesByUuid,
updateNoSubtitle: subtitleActions.UPDATE_NO_SUBTITLE,
updateSubtitleType: subtitleActions.UPDATE_SUBTITLE_TYPE,
}),
offCurrentSubtitle() {
Expand Down
1 change: 0 additions & 1 deletion src/renderer/store/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const Subtitle = {
UPDATE_SUBTITLE_STYLE: 'UPDATE_SUBTITLE_STYLE',
UPDATE_SUBTITLE_SIZE: 'UPDATE_SUBTITLE_SIZE',
UPDATE_LAST_SUBTITLE_SIZE: 'UPDATE_LAST_SUBTITLE_SIZE',
UPDATE_NO_SUBTITLE: 'UPDATE_NO_SUBTITLE',
UPDATE_SUBTITLE_TOP: 'UPDATE_SUBTITLE_TOP',
REMOVE_LOCAL_SUBTITLE: 'REMOVE_LOCAL_SUBTITLE',
UPDATE_SUBTITLE_TYPE: 'UPDATE_SUBTITLE_TYPE',
Expand Down
8 changes: 0 additions & 8 deletions src/renderer/store/modules/Subtitle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const state = {
lastChosenSize: 1,
subtitleDelay: 0,
scaleNum: 1,
calculatedNoSub: true,
subToTop: false,
isFirstSubtitle: true,
isPrimarySubSettings: true,
Expand Down Expand Up @@ -76,7 +75,6 @@ const getters = {
chosenSize: state => state.chosenSize,
lastChosenSize: state => state.lastChosenSize,
scaleNum: state => state.scaleNum,
calculatedNoSub: state => state.calculatedNoSub,
subToTop: state => state.subToTop,
isFirstSubtitle: state => state.isFirstSubtitle,
enabledSecondarySub: state => state.enabledSecondarySub,
Expand Down Expand Up @@ -150,9 +148,6 @@ const mutations = {
[subtitleMutations.SUBTITLE_SIZE_UPDATE](state, payload) {
state.chosenSize = payload;
},
[subtitleMutations.NO_SUBTITLE_UPDATE](state, payload) {
state.calculatedNoSub = payload;
},
[subtitleMutations.SUBTITLE_TOP_UPDATE](state, payload) {
state.subToTop = payload;
},
Expand Down Expand Up @@ -290,9 +285,6 @@ const actions = {
[subtitleActions.UPDATE_SUBTITLE_SIZE]({ commit }, delta) {
commit(subtitleMutations.SUBTITLE_SIZE_UPDATE, delta);
},
[subtitleActions.UPDATE_NO_SUBTITLE]({ commit }, delta) {
commit(subtitleMutations.NO_SUBTITLE_UPDATE, delta);
},
[subtitleActions.UPDATE_SUBTITLE_TOP]({ commit }, delta) {
commit(subtitleMutations.SUBTITLE_TOP_UPDATE, delta);
},
Expand Down
1 change: 1 addition & 0 deletions src/renderer/store/modules/SubtitleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const getters = {
},
primaryDelay({ primaryDelay }: SubtitleManagerState) { return primaryDelay; },
secondaryDelay({ secondaryDelay }: SubtitleManagerState) { return secondaryDelay; },
calculatedNoSub(state: any, { list }: any) { return !list.length; },
};
const mutations = {
[m.setPlaylistId](state: SubtitleManagerState, id: number) {
Expand Down
1 change: 0 additions & 1 deletion src/renderer/store/mutationTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export const Subtitle = {
SUBTITLE_STYLE_UPDATE: 'SUBTITLE_STYLE_UPDATE',
SUBTITLE_SIZE_UPDATE: 'SUBTITLE_SIZE_UPDATE',
LAST_SUBTITLE_SIZE_UPDATE: 'LAST_SUBTITLE_SIZE_UPDATE',
NO_SUBTITLE_UPDATE: 'NO_SUBTITLE_UPDATE',
SUBTITLE_TOP_UPDATE: 'SUBTITLE_TOP_UPDATE',
CURRENT_SUBTITLE_REMOVE: 'CURRENT_SUBTITLE_REMOVE',
SUBTITLE_TYPE_UPDATE: 'SUBTITLE_TYPE_UPDATE',
Expand Down

0 comments on commit 8a11c23

Please sign in to comment.