Skip to content

Commit

Permalink
tags removed, nov each chat channel has its own stream
Browse files Browse the repository at this point in the history
  • Loading branch information
tempe-techie committed Jan 19, 2024
1 parent 7b16955 commit b923405
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 215 deletions.
114 changes: 1 addition & 113 deletions components/chat/ChatFeed.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
<template>
<div class="scroll-500">

<!-- Categories / Tags Big Button -->
<div v-if="!id && !allPosts" class="d-grid gap-2 mb-2">
<div class="btn-group dropdown-center">
<button class="btn btn-primary btn-block dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{{ getSelectedTagObject.title }}
</button>
<ul class="dropdown-menu">
<span
v-for="(tagObject, index) in filteredCategories"
:key="tagObject.slug"
class="dropdown-item cursor-pointer"
@click="changeTag(index)"
>{{ tagObject.title }}</span>
</ul>
</div>
</div>

<!-- Post/Comment Input Box -->
<div class="card mb-2 border" v-if="!hideCommentBox">
<div class="card-body">
Expand Down Expand Up @@ -105,25 +88,6 @@
</div>
</div>

<!-- Categories / Tags Small Button -->
<!--
<div v-if="!id" class="d-flex justify-content-end mb-2">
<div class="btn-group">
<button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{{ getSelectedTagObject.title }}
</button>
<ul class="dropdown-menu dropdown-menu-end">
<span
v-for="(tagObject, index) in filteredCategories"
:key="tagObject.slug"
class="dropdown-item cursor-pointer"
@click="changeTag(index)"
>{{ tagObject.title }}</span>
</ul>
</div>
</div>
-->

<div v-if="orbisPosts">
<ChatPost
@insertReply="insertReply"
Expand Down Expand Up @@ -153,7 +117,6 @@
import { useEthers } from 'vue-dapp';
import ChatPost from "~/components/chat/ChatPost.vue";
import { useToast } from "vue-toastification/dist/index.mjs";
import { useChatStore } from '~/store/chat';
import { useSiteStore } from '~/store/site';
import { useUserStore } from '~/store/user';
import ConnectWalletButton from "~/components/ConnectWalletButton.vue";
Expand All @@ -168,7 +131,6 @@ import 'emoji-mart-vue-fast/css/emoji-mart.css'
export default {
name: "ChatFeed",
props: [
"allPosts", // show all posts (all tags/categories)
"byDid", // if looking for posts by a specific user (user's DID)
"hideCommentBox", // if true, we'll hide the comment box
"id", // id (optional) is the post id that this component looks for replies to
Expand Down Expand Up @@ -219,38 +181,10 @@ export default {
}
},
filteredCategories() {
let cats = [];
for (let i = 0; i < this.$config.orbisCategories.length; i++) {
// exclude categories that are marked as hidden
if (this.$config.orbisCategories[i].hidden === false) {
cats.push({
slug: this.$config.orbisCategories[i].slug,
title: this.$config.orbisCategories[i].title
});
}
}
return cats;
},
getOrbisContext() {
return this.orbisContext;
},
getSelectedTagObject() {
if (this.chatStore.getSelectedTagIndex > 0 && this.chatStore.getSelectedTagIndex < this.filteredCategories.length) {
return this.filteredCategories[this.chatStore.getSelectedTagIndex];
} else {
return this.filteredCategories[0];
}
},
getTagFromChatStore() {
return this.chatStore.getSelectedTagIndex;
},
hasDomainOrNotRequired() {
if (this.$config.domainRequiredToPost) {
if (this.userStore.getDefaultDomain) {
Expand Down Expand Up @@ -290,10 +224,6 @@ export default {
}
},
changeTag(index) {
this.chatStore.setSelectedTagIndex(index);
},
async checkConnectionToOrbis() {
const isConn = await this.$orbis.isConnected();
this.userStore.setIsConnectedToOrbis(isConn);
Expand Down Expand Up @@ -345,26 +275,11 @@ export default {
context: this.getOrbisContext
}
// if post has tags, add them to the options
if (this.masterPost?.content?.tags) {
options["tags"] = this.masterPost.content.tags;
} else {
options["tags"] = [{ "slug": "general", "title": "General discussion" }]; // default to "General" tag
}
} else {
options = {
body: this.postText,
context: this.getOrbisContext
}
// add tags
if (this.chatStore.getSelectedTagIndex > 0 && this.chatStore.getSelectedTagIndex < this.filteredCategories.length) {
options["tags"] = [this.filteredCategories[this.chatStore.getSelectedTagIndex]];
} else {
this.changeTag(0); // change tag selection to 0 (tag may be out of bounds)
options["tags"] = [{ "slug": "general", "title": "General discussion" }]; // default to "General" tag
}
}
// post on Orbis & Ceramic
Expand Down Expand Up @@ -414,7 +329,6 @@ export default {
options = {
master: this.id, // master is the post ID
context: this.getOrbisContext, // context is the group ID
tag: this.masterPost.content.tags[0].slug, // tag is the tag of the master post
only_master: false // only get master posts (not replies), or all posts
}
} else {
Expand All @@ -424,20 +338,6 @@ export default {
context: this.getOrbisContext, // context is the group ID
only_master: this.showOnlyMasterPosts // only get master posts (not replies), or all posts
}
// search by tag/category (except on the Profile page where comment box is hidden)
if (!this.allPosts) {
if (this.chatStore.getSelectedTagIndex > 0 && this.chatStore.getSelectedTagIndex < this.filteredCategories.length) {
options["tag"] = this.filteredCategories[this.chatStore.getSelectedTagIndex].slug;
} else {
this.changeTag(0);
if (this.filteredCategories[0].slug !== "all") {
options["tag"] = this.filteredCategories[0].slug;
}
}
}
}
if (this.byDid) {
Expand Down Expand Up @@ -524,22 +424,10 @@ export default {
setup() {
const { address, chainId, isActivated, signer } = useEthers();
const toast = useToast();
const chatStore = useChatStore();
const siteStore = useSiteStore();
const userStore = useUserStore();
return { address, chainId, isActivated, signer, toast, chatStore, siteStore, userStore }
},
watch: {
getTagFromChatStore() {
// reset posts and page counter
this.orbisPosts = [];
this.pageCounter = 0;
// fetch posts
this.getOrbisPosts();
}
return { address, chainId, isActivated, signer, toast, siteStore, userStore }
}
}
</script>
5 changes: 0 additions & 5 deletions components/chat/ChatPost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,6 @@ export default {
context: this.getOrbisContext
}
// if post has tags, add them to the options
if (this.post?.content?.tags) {
options["tags"] = this.post.content.tags;
}
// post on Orbis & Ceramic
let res = await this.$orbis.createPost(options);
Expand Down
7 changes: 1 addition & 6 deletions components/minted-posts/IggyPostMint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default {
} else if (this.post?.context_details.context_id) {
return this.post.context_details.context_id;
} else {
return this.$config.orbisContext;
return this.$config.chatChannels.general;
}
}
},
Expand Down Expand Up @@ -221,11 +221,6 @@ export default {
options["master"] = this.post.stream_id;
}
// if post has tags, add them to the options
if (this.post?.content?.tags) {
options["tags"] = this.post.content.tags;
}
options["data"] = {
type: "mintedPost",
collectionAddress: this.$config.iggyPostAddress,
Expand Down
4 changes: 2 additions & 2 deletions components/profile/PunkProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@

<!-- Posts Tab -->
<div v-if="currentTab === 'posts' && uDid">
<ChatFeed :byDid="uDid" :hideCommentBox="true" :allPosts="true" :orbisContext="getOrbisContext" />
<ChatFeed :byDid="uDid" :hideCommentBox="true" :orbisContext="getOrbisContext" />
</div>

<!-- Mints Tab -->
Expand Down Expand Up @@ -337,7 +337,7 @@ export default {
if (this.$config.orbisTest) {
return this.$config.orbisTestContext;
} else {
return this.$config.orbisContext;
return this.$config.chatChannels.general;
}
},
Expand Down
74 changes: 45 additions & 29 deletions components/sidebars/SidebarLeft.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,32 @@
<NuxtLink
to="/"
class="list-group-item cursor-pointer hover-color bg-light border-0"
:class="(chatStore.getSelectedTagIndex === index && $route.path === '/') ? 'active' : ''"
v-for="(tagObject, index) in filteredCategories"
:key="tagObject.slug"
@click="selectTagIndex(index)"
:class="($route.path === '/') ? 'active' : ''"
@click="closeLeftSidebar"
>
General discussion
</NuxtLink>
</ul>

<ul class="list-group">
<NuxtLink
to="/memes-images"
class="list-group-item cursor-pointer hover-color bg-light border-0"
:class="$route.path.startsWith('/memes-images') ? 'active' : ''"
@click="closeLeftSidebar"
>
Share images & NFTs
</NuxtLink>
</ul>

<ul class="list-group">
<NuxtLink
to="/shill"
class="list-group-item cursor-pointer hover-color bg-light border-0"
:class="$route.path.startsWith('/shill') ? 'active' : ''"
@click="closeLeftSidebar"
>
{{ tagObject.title }}
Shill & discuss projects
</NuxtLink>
</ul>

Expand Down Expand Up @@ -99,6 +119,14 @@
</NuxtLink>
</li>

<!-- Shill
<li class="nav-item p-1" @click="closeLeftSidebar">
<NuxtLink class="nav-link" :class="$route.path.startsWith('/shill') ? 'active' : ''" aria-current="page" to="/shill">
<i class="bi bi-megaphone"></i> Shill projects
</NuxtLink>
</li>
-->

<!-- Send tokens -->
<li class="nav-item p-1" @click="closeLeftSidebar" v-if="$config.showFeatures.sendTokens">
<NuxtLink class="nav-link" :class="$route.path.startsWith('/send-tokens') ? 'active' : ''" aria-current="page" to="/send-tokens">
Expand Down Expand Up @@ -141,12 +169,13 @@
</a>
</li>

<!-- Find User -->
<!-- Find User
<li v-if="isActivated" class="nav-item p-1" @click="closeLeftSidebar">
<NuxtLink class="nav-link" :class="$route.path.startsWith('/find-user') ? 'active' : ''" aria-current="page" to="/find-user">
<i class="bi bi-search"></i> Find User
</NuxtLink>
</li>
-->

<!-- About -->
<li class="nav-item p-1" @click="closeLeftSidebar">
Expand Down Expand Up @@ -208,7 +237,7 @@
</ul>
</div>

</div>
</div>
</div>
</div>
</template>
Expand All @@ -217,7 +246,6 @@
import { useEthers } from 'vue-dapp';
import { useToast } from "vue-toastification/dist/index.mjs";
import { useNotificationsStore } from '~/store/notifications';
import { useChatStore } from '~/store/chat';
import { useSidebarStore } from '~/store/sidebars';
import { useUserStore } from '~/store/user';
import ProfileImage from "~/components/profile/ProfileImage.vue";
Expand All @@ -240,22 +268,6 @@ export default {
return 0;
}
},
filteredCategories() {
let cats = [];
for (let i = 0; i < this.$config.orbisCategories.length; i++) {
// exclude categories that are marked as hidden
if (this.$config.orbisCategories[i].hidden === false) {
cats.push({
slug: this.$config.orbisCategories[i].slug,
title: this.$config.orbisCategories[i].title
});
}
}
return cats;
},
},
Expand All @@ -270,9 +282,14 @@ export default {
}
},
selectTagIndex(index) {
this.chatStore.setSelectedTagIndex(index);
this.closeLeftSidebar();
async fetchActivityPoints() {
if (this.$config.activityPointsAddress && this.address) {
this.toast.info("Refreshing activity points...", { timeout: 2000 });
const activityPoints = await this.getActivityPoints(this.address);
this.userStore.setCurrentUserActivityPoints(activityPoints);
}
}
},
Expand All @@ -281,12 +298,11 @@ export default {
const toast = useToast();
const chatStore = useChatStore();
const notificationsStore = useNotificationsStore();
const sidebarStore = useSidebarStore();
const userStore = useUserStore();
return { address, chatStore, isActivated, notificationsStore, sidebarStore, toast, userStore }
return { address, isActivated, notificationsStore, sidebarStore, toast, userStore }
},
}
</script>
Loading

0 comments on commit b923405

Please sign in to comment.