Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): minor routes fixes #145

Merged
merged 1 commit into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/src/components/HoloLogin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ watch(
() => client.agent.isAvailable,
(isLoggedIn) => {
if (isLoggedIn) {
router.replace({ name: ROUTES.home, force: true });
router.replace({ name: ROUTES.feed, force: true });
}
}
);
Expand Down
8 changes: 4 additions & 4 deletions ui/src/components/SearchEverythingInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@
</QSelect>
</template>
<script setup lang="ts">
import { isHashtag, TAG_SYMBOLS } from "@/utils/tags";
import { isHashtag } from "@/utils/tags";
import { SearchResult, SearchResultOption } from "@/types/types";
import { ROUTES, PATH, router } from "@/router";
import { ROUTES, router } from "@/router";
import { useSearchProfiles } from "@/utils/profiles";
import { showError } from "@/utils/toasts";
import { AppAgentClient, encodeHashToBase64 } from "@holochain/client";
Expand Down Expand Up @@ -148,7 +148,7 @@ const search = (
return {
resultType: SearchResult.Hashtag,
value: {
name: ROUTES[PATH[TAG_SYMBOLS.HASHTAG]],
name: ROUTES.hashtag,
params: { tag: tag.replace("#", "") },
},
label: tag,
Expand All @@ -157,7 +157,7 @@ const search = (
return {
resultType: SearchResult.Cashtag,
value: {
name: ROUTES[PATH[TAG_SYMBOLS.CASHTAG]],
name: ROUTES.cashtag,
params: { tag: tag.replace("$", "") },
},
label: tag,
Expand Down
5 changes: 2 additions & 3 deletions ui/src/pages/AgentProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
color="secondary"
@click="
router.push({
name: ROUTES[PATH[TAG_SYMBOLS.MENTION]],
name: ROUTES.mention,
params: {
tag: profile.nickname,
agentPubKey: encodeHashToBase64(agentPubKey),
Expand All @@ -138,8 +138,7 @@ import { PROFILE_FIELDS } from "@/types/types";
import isEqual from "lodash/isEqual";
import { showError } from "@/utils/toasts";
import { pageHeightCorrection } from "@/utils/page-layout";
import { PATH, ROUTES } from "@/router";
import { TAG_SYMBOLS } from "@/utils/tags";
import { ROUTES } from "@/router";
import {
AgentPubKey,
decodeHashFromBase64,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/NotFound.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
color="accent"
label="Come back home, Kitty"
size="md"
:to="{ name: ROUTES.home }"
:to="{ name: ROUTES.feed }"
/>
</QPage>
</template>
Expand Down
26 changes: 10 additions & 16 deletions ui/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,20 @@ import MewsFeed from "./pages/MewsFeed.vue";
import AgentProfile from "./pages/AgentProfile.vue";
import MewYarn from "./pages/MewYarn.vue";
import CashtagMewsFeed from "./pages/CashtagMewsFeed.vue";
import HashtagMewsFeed from "./pages/CashtagMewsFeed.vue";
import HashtagMewsFeed from "./pages/HashtagMewsFeed.vue";
import MentionMewsFeed from "./pages/MentionMewsFeed.vue";
import NotFound from "./pages/NotFound.vue";
import MyNotifications from "./pages/MyNotifications.vue";

export const PATH = {
[TAG_SYMBOLS.CASHTAG]: "cashtag",
[TAG_SYMBOLS.HASHTAG]: "hashtag",
[TAG_SYMBOLS.MENTION]: "handle",
};

export const ROUTES = {
discover: "discover",
profile: "profile",
notifications: "notifications",
feed: "feed",
yarn: "yarn",
[PATH[TAG_SYMBOLS.CASHTAG]]: PATH[TAG_SYMBOLS.CASHTAG],
[PATH[TAG_SYMBOLS.HASHTAG]]: PATH[TAG_SYMBOLS.HASHTAG],
[PATH[TAG_SYMBOLS.MENTION]]: PATH[TAG_SYMBOLS.MENTION],
hashtag: "hashtag",
cashtag: "cashtag",
mention: "mention",
};

export const routes: RouteRecordRaw[] = [
Expand Down Expand Up @@ -54,20 +48,20 @@ export const routes: RouteRecordRaw[] = [
component: MewYarn,
},
{
path: `/${PATH[TAG_SYMBOLS.CASHTAG]}/:tag`,
name: ROUTES[PATH[TAG_SYMBOLS.CASHTAG]],
path: `/cashtag/:tag`,
name: ROUTES.cashtag,
component: CashtagMewsFeed,
meta: { tag: TAG_SYMBOLS.CASHTAG },
},
{
path: `/${PATH[TAG_SYMBOLS.HASHTAG]}/:tag`,
name: ROUTES[PATH[TAG_SYMBOLS.HASHTAG]],
path: `/hashtag/:tag`,
name: ROUTES.hashtag,
component: HashtagMewsFeed,
meta: { tag: TAG_SYMBOLS.HASHTAG },
},
{
path: `/${PATH[TAG_SYMBOLS.MENTION]}/:tag/:agentPubKey`,
name: ROUTES[PATH[TAG_SYMBOLS.MENTION]],
path: `/mention/:tag/:agentPubKey`,
name: ROUTES.mention,
component: MentionMewsFeed,
meta: { tag: TAG_SYMBOLS.MENTION },
},
Expand Down
8 changes: 4 additions & 4 deletions ui/src/utils/tags.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PATH, ROUTES } from "@/router";
import { ROUTES } from "@/router";
import {
LinkTarget,
LinkTargetName,
Expand Down Expand Up @@ -86,7 +86,7 @@ export const splitMewTextIntoContentParts = (
] as AgentPubKey;

const route: RouteLocationRaw = {
name: ROUTES[PATH[part[0]]],
name: ROUTES.mention,
params: {
tag: part.substring(1),
agentPubKey: encodeHashToBase64(agentPubKey),
Expand All @@ -108,7 +108,7 @@ export const splitMewTextIntoContentParts = (
};
} else if (partIsTag && part[0] === TAG_SYMBOLS.HASHTAG) {
const route: RouteLocationRaw = {
name: ROUTES[PATH[part[0]]],
name: ROUTES.hashtag,
params: { tag: part.substring(1) },
};

Expand All @@ -119,7 +119,7 @@ export const splitMewTextIntoContentParts = (
};
} else if (partIsTag && part[0] === TAG_SYMBOLS.CASHTAG) {
const route: RouteLocationRaw = {
name: ROUTES[PATH[part[0]]],
name: ROUTES.cashtag,
params: { tag: part.substring(1) },
};

Expand Down