Skip to content

Commit

Permalink
Merge pull request #660 from osushi-academy/front/nagata/getinfo-fini…
Browse files Browse the repository at this point in the history
…shed

終了時にアーカイブを取得
  • Loading branch information
yuta-ike authored Jan 19, 2022
2 parents 2dfd532 + e4c1876 commit 43f9853
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions app/front/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default Vue.extend({
},
computed: {
isRoomStarted(): boolean {
return this.room.state === "ongoing"
return this.room.state === "ongoing" || this.room.state === "finished"
},
isAdmin(): boolean {
return UserItemStore.userItems.isAdmin
Expand Down Expand Up @@ -162,19 +162,42 @@ export default Vue.extend({
this.roomState = res.data.state
TopicStore.set(res.data.topics)
// 開催中の時
if (this.room.state === "ongoing") {
// 開催中
if (this.isAdmin) {
this.adminEnterRoom()
} else {
// ユーザーの入室
this.$modal.show("sushi-modal")
}
} else if (this.room.state === "finished") {
// 終了時。すべてのトピックが閉じたルームのアーカイブが閲覧できる。
const history = await this.$apiClient
.get({
pathname: "/room/:id/history",
params: { id: this.room.id },
})
.catch((e) => {
throw new Error(e)
})
if (history.result === "error") {
console.error(history.error)
return
}
// 入室
ChatItemStore.setChatItems(
history.data.chatItems.map((chatItem) => ({
...chatItem,
status: "success",
})),
)
history.data.pinnedChatItemIds.forEach((pinnedChatItem) => {
if (pinnedChatItem) {
PinnedChatItemsStore.add(pinnedChatItem)
}
})
this.isRoomEnter = true
}
if (this.room.state === "finished") {
// 本当はRESTでアーカイブデータを取ってきて表示する
}
// NOTE: もしかして:archivedも返ってくる?
},
// socket.ioのセットアップ。配信を受け取る
async socketSetUp() {
Expand Down

0 comments on commit 43f9853

Please sign in to comment.