Use post character limit setting received from server

This commit is contained in:
silverpill 2022-02-08 21:20:24 +00:00
parent 901d788d49
commit 8213306f9b
2 changed files with 8 additions and 4 deletions

View file

@ -8,6 +8,7 @@ export interface InstanceInfo {
description: string;
registrations: boolean;
login_message: string;
post_character_limit: number;
blockchain_explorer_url: string | null;
blockchain_contract_address: string | null;
ipfs_gateway_url: string | null;

View file

@ -99,13 +99,12 @@ import {
import { User } from "@/api/users"
import Avatar from "@/components/Avatar.vue"
import VisibilityIcon from "@/components/VisibilityIcon.vue"
import { useInstanceInfo } from "@/store/instance"
import { useCurrentUser } from "@/store/user"
import { setupAutoResize } from "@/utils/autoresize"
import { renderMarkdownLite } from "@/utils/markdown"
import { fileToDataUrl, dataUrlToBase64 } from "@/utils/upload"
const POST_CHARACTER_LIMIT = 2000
@Options({
components: {
Avatar,
@ -132,7 +131,8 @@ export default class PostEditor extends Vue {
private store = setup(() => {
const { currentUser, ensureAuthToken } = useCurrentUser()
return { currentUser, ensureAuthToken }
const { instance } = useInstanceInfo()
return { currentUser, ensureAuthToken, instance }
})
get author(): User | null {
@ -175,7 +175,10 @@ export default class PostEditor extends Vue {
}
get characterCounter(): number {
return (POST_CHARACTER_LIMIT - this.content.length)
if (!this.store.instance) {
return 0
}
return (this.store.instance.post_character_limit - this.content.length)
}
async publish() {