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

トピック編集 #539

Merged
merged 5 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
:viewer-ids="viewerIds"
:class="$style.sidebarItem"
/>
<channel-sidebar-topic :class="$style.sidebarItem" />
<channel-sidebar-topic
:class="$style.sidebarItem"
:channel-id="channelId"
/>
<channel-sidebar-pinned
:pinned-message-length="pinnedMessagesCount"
@open="context.emit('pinned-mode-toggle')"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,60 @@
<template>
<sidebar-content-container-foldable title="トピック">
<channel-sidebar-topic-content :topic-content="topicContent" />
<content-editor
:value="topic"
:is-editing="isEditing"
@edit-done="onEditDone"
@edit-start="startEdit"
/>
</sidebar-content-container-foldable>
</template>

<script lang="ts">
import { defineComponent, computed } from '@vue/composition-api'
import {
defineComponent,
Ref,
ref,
PropType,
computed
} from '@vue/composition-api'
import apis from '@/lib/apis'
import store from '@/store'
import SidebarContentContainerFoldable from '@/components/Main/MainView/MainViewSidebar/SidebarContentContainerFoldable.vue'
import ChannelSidebarTopicContent from './ChannelSidebarTopicContent.vue'
import ContentEditor from '@/components/Main/MainView/MainViewSidebar/ContentEditor.vue'
import { ChannelId } from '@/types/entity-ids'

const useEdit = (props: { channelId: string }, topic: Ref<string>) => {
const isEditing = ref(false)
const startEdit = () => {
isEditing.value = true
}
const onEditDone = async (topic: string) => {
await apis.editChannelTopic(props.channelId, { topic })
isEditing.value = false
}
return { isEditing, startEdit, onEditDone }
}

export default defineComponent({
name: 'ChannelSidebarTopic',
components: {
SidebarContentContainerFoldable,
ChannelSidebarTopicContent
ContentEditor
},
props: {
channelId: {
type: String as PropType<ChannelId>,
required: true
}
},
setup() {
const topicContent = computed(() => store.state.domain.messagesView.topic)
setup(props) {
const topic = computed(() => store.state.domain.messagesView.topic)
const { isEditing, startEdit, onEditDone } = useEdit(props, topic)
return {
topicContent
topic,
isEditing,
startEdit,
onEditDone
}
}
})
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions src/lib/websocket/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const onChannelDeleted = ({ id }: ChannelDeletedEvent['body']) => {
export const onChannelUpdated = async ({ id }: ChannelUpdatedEvent['body']) => {
const res = await apis.getChannel(id)
store.commit.entities.extendChannels({ [id]: res.data })
store.commit.domain.messagesView.setTopic(res.data.topic)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

見てるチャンネル以外も流れてくるのでその判定が必要そうです

}

export const onChannelStared = (data: ChannelStaredEvent['body']) => {
Expand Down