Skip to content

Commit

Permalink
Merge pull request #289 from camphor-/archive-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dora1998 authored Jul 29, 2020
2 parents 107add8 + ba89da4 commit daf9763
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 14 deletions.
24 changes: 24 additions & 0 deletions components/atoms/SessionArchivedHeader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div class="session-archived-header">
このセッションはアーカイブ済みです
</div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
@Component({
name: 'SessionArchivedHeader'
})
export default class extends Vue {}
</script>

<style lang="scss" scoped>
.session-archived-header {
padding: 4px;
background-color: #424242;
color: #fff;
font-weight: bold;
text-align: center;
}
</style>
4 changes: 3 additions & 1 deletion components/molecules/TrackList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export default class extends Vue {
background-color: $bg-color;
}
#windowWrapper {
min-height: calc(100vh - 56px);
// 56px: Toolbar
// 12px: 再生中の曲の上margin
min-height: calc(100vh - 56px - 12px);
}
.v-subheader {
Expand Down
26 changes: 19 additions & 7 deletions components/organisms/BottomController.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<div class="bottom-controller-wrapper">
<div v-if="showController" class="bottom-controller elevation-5">
<v-layout align-center justify-space-around>
<v-btn icon large @click="openDeviceSelectDialog">
<v-btn
icon
large
:disabled="isSessionArchived || !canControlPlayback"
@click="openDeviceSelectDialog"
>
<v-icon>devices</v-icon>
</v-btn>
<v-btn icon :disabled="!canControlPlayback" @click="togglePlayback">
Expand All @@ -11,11 +16,15 @@
</v-icon>
<v-icon v-else color="accent" x-large>pause</v-icon>
</v-btn>
<nuxt-link :to="searchPageUrl">
<v-btn icon large>
<v-icon>playlist_add</v-icon>
</v-btn>
</nuxt-link>
<v-btn
icon
large
nuxt
:to="searchPageUrl"
:disabled="isSessionArchived"
>
<v-icon>playlist_add</v-icon>
</v-btn>
</v-layout>
</div>
</div>
Expand All @@ -36,7 +45,10 @@ import ActiveDeviceNotFoundDialog from '@/components/organisms/ActiveDeviceNotFo
},
computed: {
...mapState('pages/sessions/detail', ['session']),
...mapGetters('pages/sessions/detail', ['canControlPlayback'])
...mapGetters('pages/sessions/detail', [
'canControlPlayback',
'isSessionArchived'
])
}
})
export default class extends Vue {
Expand Down
5 changes: 1 addition & 4 deletions components/organisms/TrackListContainer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div id="track-list-container-root">
<div>
<template v-if="queue.tracks.length > 0">
<track-list :queue="queue" :playback="playback" class="track-list" />
</template>
Expand Down Expand Up @@ -44,9 +44,6 @@ export default class extends Vue {
</script>

<style lang="scss" scoped>
#track-list-container-root {
padding-top: 56px;
}
.track-list {
padding-bottom: calc(6vmin + 56px);
background-color: $bg-color;
Expand Down
22 changes: 20 additions & 2 deletions pages/sessions/_id/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
/>

<div class="list-container">
<session-archived-header
v-if="isSessionArchived"
class="archived-header"
/>
<track-list-container />
</div>

Expand Down Expand Up @@ -46,9 +50,11 @@ import BottomController from '@/components/organisms/BottomController.vue'
import InterruptDetectedDialog from '@/components/organisms/InterruptDetectedDialog.vue'
import { Device } from '@/api/v3/types'
import ActiveDeviceNotFoundDialog from '@/components/organisms/ActiveDeviceNotFoundDialog.vue'
import SessionArchivedHeader from '@/components/atoms/SessionArchivedHeader.vue'
@Component({
components: {
SessionArchivedHeader,
ActiveDeviceNotFoundDialog,
DeviceSelectDialog,
TrackListContainer,
Expand All @@ -59,7 +65,7 @@ import ActiveDeviceNotFoundDialog from '@/components/organisms/ActiveDeviceNotFo
},
computed: {
...mapState('pages/sessions/detail', ['isInterruptDetectedDialogOpen']),
...mapGetters('pages/sessions/detail', ['sessionName'])
...mapGetters('pages/sessions/detail', ['sessionName', 'isSessionArchived'])
},
methods: {
...mapActions('pages/sessions/detail', [
Expand Down Expand Up @@ -180,4 +186,16 @@ export default class extends Vue {
}
</script>

<style lang="scss" scoped></style>
<style lang="scss" scoped>
.list-container {
padding-top: 56px;
position: relative;
}
.archived-header {
position: fixed;
left: 0;
right: 0;
z-index: 1;
}
</style>
5 changes: 5 additions & 0 deletions store/pages/sessions/detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@ export const getters = {
return state.session.creator.id === rootState.user.me?.id
},
canControlPlayback(state: State, getters): boolean {
if (getters.isSessionArchived) return false
return (
getters.isMyOwnSession ||
// eslint-disable-next-line camelcase
(state.session?.allow_to_control_by_others ?? false)
)
},
isSessionArchived(state: State): boolean {
if (!state.session) return false
return state.session.playback.state.type === 'ARCHIVED'
}
}

Expand Down

0 comments on commit daf9763

Please sign in to comment.