Allow to create posts with followers-only visibility setting
This commit is contained in:
parent
4dbb59c587
commit
7cf63c9333
4 changed files with 36 additions and 18 deletions
|
@ -25,6 +25,18 @@ export async function uploadAttachment(
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum Visibility {
|
||||||
|
Public = "public",
|
||||||
|
Followers = "private",
|
||||||
|
Direct = "direct",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const VISIBILITY_MAP = {
|
||||||
|
[Visibility.Public]: "Public",
|
||||||
|
[Visibility.Followers]: "Followers",
|
||||||
|
[Visibility.Direct]: "Direct",
|
||||||
|
}
|
||||||
|
|
||||||
export interface Mention {
|
export interface Mention {
|
||||||
id: string;
|
id: string;
|
||||||
username: string;
|
username: string;
|
||||||
|
@ -40,7 +52,7 @@ export interface Post {
|
||||||
content: string;
|
content: string;
|
||||||
in_reply_to_id: string | null;
|
in_reply_to_id: string | null;
|
||||||
reblog: Post | null;
|
reblog: Post | null;
|
||||||
visibility: "public" | "direct";
|
visibility: Visibility;
|
||||||
replies_count: number;
|
replies_count: number;
|
||||||
favourites_count: number;
|
favourites_count: number;
|
||||||
reblogs_count: number;
|
reblogs_count: number;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<a
|
<a
|
||||||
class="icon icon-small"
|
class="icon icon-small"
|
||||||
:href="post.uri"
|
:href="post.uri"
|
||||||
:title="'Visibility: ' + post.visibility"
|
:title="visibilityDisplay"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
>
|
>
|
||||||
|
@ -202,6 +202,7 @@ import { Prop } from "vue-property-decorator"
|
||||||
|
|
||||||
import { makePermanent, getSignature, mintToken, onTokenMinted } from "@/api/nft"
|
import { makePermanent, getSignature, mintToken, onTokenMinted } from "@/api/nft"
|
||||||
import {
|
import {
|
||||||
|
VISIBILITY_MAP,
|
||||||
Mention,
|
Mention,
|
||||||
Post,
|
Post,
|
||||||
getPost,
|
getPost,
|
||||||
|
@ -285,6 +286,10 @@ export default class PostComponent extends Vue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get visibilityDisplay(): string {
|
||||||
|
return VISIBILITY_MAP[this.post.visibility]
|
||||||
|
}
|
||||||
|
|
||||||
formatDate(isoDate: string): string {
|
formatDate(isoDate: string): string {
|
||||||
return formatDate(isoDate)
|
return formatDate(isoDate)
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,24 +48,14 @@
|
||||||
<visibility-icon :visibility="visibility"></visibility-icon>
|
<visibility-icon :visibility="visibility"></visibility-icon>
|
||||||
</button>
|
</button>
|
||||||
<ul v-if="visibilityMenuVisible" class="dropdown-menu">
|
<ul v-if="visibilityMenuVisible" class="dropdown-menu">
|
||||||
<li>
|
<li v-for="[value, display] in visibilityMap" :key="value">
|
||||||
<a
|
<a
|
||||||
class="icon"
|
class="icon"
|
||||||
title="Public"
|
:title="display"
|
||||||
@click="hideVisibilityMenu(); visibility = 'public'"
|
@click="hideVisibilityMenu(); visibility = value"
|
||||||
>
|
>
|
||||||
<visibility-icon :visibility="'public'"></visibility-icon>
|
<visibility-icon :visibility="value"></visibility-icon>
|
||||||
<span>Public</span>
|
<span>{{ display }}</span>
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a
|
|
||||||
class="icon"
|
|
||||||
title="Direct"
|
|
||||||
@click="hideVisibilityMenu(); visibility = 'direct'"
|
|
||||||
>
|
|
||||||
<visibility-icon :visibility="'direct'"></visibility-icon>
|
|
||||||
<span>Direct</span>
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -99,7 +89,13 @@
|
||||||
import { Options, Vue, setup } from "vue-class-component"
|
import { Options, Vue, setup } from "vue-class-component"
|
||||||
import { Prop } from "vue-property-decorator"
|
import { Prop } from "vue-property-decorator"
|
||||||
|
|
||||||
import { Post, createPost, Attachment, uploadAttachment } from "@/api/posts"
|
import {
|
||||||
|
VISIBILITY_MAP,
|
||||||
|
Post,
|
||||||
|
createPost,
|
||||||
|
Attachment,
|
||||||
|
uploadAttachment,
|
||||||
|
} from "@/api/posts"
|
||||||
import { User } from "@/api/users"
|
import { User } from "@/api/users"
|
||||||
import Avatar from "@/components/Avatar.vue"
|
import Avatar from "@/components/Avatar.vue"
|
||||||
import VisibilityIcon from "@/components/VisibilityIcon.vue"
|
import VisibilityIcon from "@/components/VisibilityIcon.vue"
|
||||||
|
@ -166,6 +162,10 @@ export default class PostEditor extends Vue {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get visibilityMap() {
|
||||||
|
return Object.entries(VISIBILITY_MAP)
|
||||||
|
}
|
||||||
|
|
||||||
toggleVisibilityMenu() {
|
toggleVisibilityMenu() {
|
||||||
this.visibilityMenuVisible = !this.visibilityMenuVisible
|
this.visibilityMenuVisible = !this.visibilityMenuVisible
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<img v-if="visibility === 'public'" :src="require('@/assets/feather/globe.svg')">
|
<img v-if="visibility === 'public'" :src="require('@/assets/feather/globe.svg')">
|
||||||
|
<img v-else-if="visibility === 'private'" :src="require('@/assets/feather/lock.svg')">
|
||||||
<img v-else-if="visibility === 'direct'" :src="require('@/assets/forkawesome/envelope-o.svg')">
|
<img v-else-if="visibility === 'direct'" :src="require('@/assets/forkawesome/envelope-o.svg')">
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue