File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 214214 <pagination v-if =" threadData.data?.board" :page =" threadData.data.page" :limit =" threadData.data.limit" :count =" threadData.data.board.thread_count" ></pagination >
215215 </div >
216216 <set-moderators-modal v-if =" threadData.data?.board" :board =" threadData.data.board" :show =" showSetModerators" @close =" showSetModerators = false" ></set-moderators-modal >
217- <editor :showEditor =" showEditor" @close =" showEditor = false" threadEditorMode =" true" :thread =" { title: '' } " />
217+ <editor v-if = " threadData.data?.board " :showEditor =" showEditor" @close =" showEditor = false" threadEditorMode =" true" :thread =" { title: '', board_id: threadData?.data?.board.id } " :createAction = " createThread " />
218218</template >
219219
220220<script >
@@ -231,6 +231,7 @@ import { PreferencesStore, localStoragePrefs } from '@/composables/stores/prefs'
231231import { processThreads } from ' @/composables/utils/boardUtils'
232232import BanStore from ' @/composables/stores/ban'
233233import Editor from ' @/components/layout/Editor.vue'
234+ import slugify from ' slugify'
234235
235236export default {
236237 name: ' Threads' ,
@@ -345,6 +346,16 @@ export default {
345346 return v .threadData .data ? .write_access && v .permissionUtils .hasPermission (' threads.create.allow' )
346347 }
347348
349+ const createThread = thread => {
350+ // slugify title
351+ let slug = slugify (slugify (thread .title , { remove: / [*'"~!@)(+. :] / g , lower: true }))
352+ // Handles slugs of foreign languages, these will get a random hash for their slug
353+ if (slug === ' ' ) slug = Math .random ().toString (36 ).substring (6 )
354+ thread .slug = slug
355+ return threadsApi .create (thread)
356+ .then (getThreads)
357+ .then (data => v .threadData .data = data)
358+ }
348359 /* Internal Data */
349360 const $route = useRoute ()
350361 const $router = useRouter ()
You can’t perform that action at this time.
0 commit comments