+
+
+
+
tweet style goes here
+
+
+
- {{ fetchedPost.post.title
- }}
+ {{ fetchedPost?.post.title
+ }}
{{
- fetchedPost.post.subtitle ? fetchedPost.post.subtitle : createPostExcerpt(fetchedPost.post.excerpt)
+ fetchedPost?.post.subtitle ? fetchedPost?.post.subtitle : createPostExcerpt(fetchedPost?.post.excerpt)
}}
diff --git a/src/helpers/post.ts b/src/helpers/post.ts
index 9221615..bc6011b 100644
--- a/src/helpers/post.ts
+++ b/src/helpers/post.ts
@@ -1,4 +1,7 @@
-export function createPostExcerpt(e: string): string {
+export function createPostExcerpt(e: string | undefined): string {
+ if (!e) {
+ return ``;
+ }
const excerpt = e.slice(0, 177).trim();
if (excerpt.endsWith(`...`)) {
return excerpt;
diff --git a/src/plugins/quality.ts b/src/plugins/quality.ts
index ce09ee6..b31b4d7 100644
--- a/src/plugins/quality.ts
+++ b/src/plugins/quality.ts
@@ -102,6 +102,7 @@ export function qualityFeaturedPhotoCaption(featuredPhotoCaption: string): Check
return { success: true };
}
export function qualityTags(tag: string, tags?: Array
): CheckResult {
+ console.log(tag, tags);
if (tag.trim().length < textLimits.post_tag.min) {
return { error: `Tag length cannot be less than ${textLimits.post_tag.min} characters` };
}
diff --git a/src/store/drafts.ts b/src/store/drafts.ts
index 3ae081d..2e5854c 100644
--- a/src/store/drafts.ts
+++ b/src/store/drafts.ts
@@ -8,12 +8,22 @@ export interface DraftPost extends Post {
editorImageKeys: EditorImages;
}
+export interface IChirp {
+ authorID: string;
+ content: string;
+ timestamp: number;
+ featuredPhotoCID?: string | null;
+ tags: Tag[];
+}
+
export interface DraftStore {
drafts: DraftPost[];
activeIndex: number;
draftWidget: boolean;
hasPosted: boolean;
isPosting: boolean;
+ composeChirp: boolean;
+ chirp: IChirp;
}
export const useDraftStore = defineStore(`draftStore`, {
@@ -24,6 +34,14 @@ export const useDraftStore = defineStore(`draftStore`, {
draftWidget: false,
hasPosted: false,
isPosting: false,
+ composeChirp: false,
+ chirp: {
+ authorID: useStore().$state.id,
+ content: ``,
+ timestamp: Date.now(),
+ featuredPhotoCID: null,
+ tags: [],
+ },
};
},
persist: true,
@@ -46,8 +64,29 @@ export const useDraftStore = defineStore(`draftStore`, {
getIsPosting: (state: DraftStore) => {
return state.isPosting;
},
+ getChirp: (state: DraftStore) => {
+ return state.chirp;
+ },
},
actions: {
+ toggleChirp() {
+ this.composeChirp = !this.composeChirp;
+ },
+ updateChirp(c: string) {
+ this.chirp.content = c;
+ },
+ addChirpTag(tag: string) {
+ this.chirp.tags.push({ name: tag });
+ },
+ updateChirpImage(cid: string | null) {
+ this.chirp.featuredPhotoCID = cid;
+ },
+ removeChirpTag(tag: Tag) {
+ const i = this.chirp.tags.indexOf(tag);
+ if (i > -1) {
+ this.chirp.tags.splice(i, 1);
+ }
+ },
setActiveDraft(index: number) {
this.activeIndex = index;
},