Add default page selector

This commit is contained in:
Jack Chakany
2023-02-16 09:13:36 -05:00
parent cafd820fd9
commit 4092ab90e0
4 changed files with 50 additions and 2 deletions

View File

@ -15,7 +15,7 @@ import { debounce } from "Util";
export default function RootPage() {
const { formatMessage } = useIntl();
const { loggedOut, publicKey: pubKey, follows, tags, relays } = useSelector((s: RootState) => s.login);
const { loggedOut, publicKey: pubKey, follows, tags, relays, preferences } = useSelector((s: RootState) => s.login);
const RootTab: Record<string, Tab> = {
Posts: {
text: formatMessage(messages.Posts),
@ -30,7 +30,16 @@ export default function RootPage() {
value: 2,
},
};
const [tab, setTab] = useState<Tab>(RootTab.Posts);
const [tab, setTab] = useState<Tab>(() => {
switch (preferences.defaultPage) {
case "posts":
return RootTab.Posts;
case "conversations":
return RootTab.PostsAndReplies;
case "global":
return RootTab.Global;
}
});
const [relay, setRelay] = useState<string>();
const [globalRelays, setGlobalRelays] = useState<string[]>([]);
const tagTabs = tags.map((t, idx) => {