fix: column lose state when navigate back

This commit is contained in:
reya 2024-05-23 08:00:33 +07:00
parent 3a3f960dde
commit dc7762ca11
12 changed files with 10238 additions and 7717 deletions

View File

@ -23,11 +23,7 @@ export const Route = createFileRoute("/create-group")({
});
function Screen() {
const contacts = Route.useLoaderData();
const navigate = Route.useNavigate();
const { ark } = Route.useRouteContext();
const { label, redirect } = Route.useSearch();
const [title, setTitle] = useState("");
const [npub, setNpub] = useState("");
@ -36,6 +32,10 @@ function Screen() {
]);
const [isLoading, setIsLoading] = useState(false);
const contacts = Route.useLoaderData();
const search = Route.useSearch();
const navigate = Route.useNavigate();
const toggleUser = (pubkey: string) => {
setUsers((prev) =>
prev.includes(pubkey)
@ -56,11 +56,11 @@ function Screen() {
try {
setIsLoading(true);
const key = `lume_group_${label}`;
const key = `lume_group_${search.label}`;
const createGroup = await ark.set_nstore(key, JSON.stringify(users));
if (createGroup) {
return navigate({ to: redirect });
return navigate({ to: search.redirect, search: { ...search } });
}
} catch (e) {
setIsLoading(false);

View File

@ -18,12 +18,12 @@ export const Route = createFileRoute("/create-topic")({
});
function Screen() {
const { label, redirect } = Route.useSearch();
const { ark } = Route.useRouteContext();
const [topics, setTopics] = useState<Topic[]>([]);
const [isLoading, setIsLoading] = useState(false);
const search = Route.useSearch();
const navigate = Route.useNavigate();
const toggleTopic = (topic: Topic) => {
@ -38,11 +38,11 @@ function Screen() {
try {
setIsLoading(true);
const key = `lume_topic_${label}`;
const key = `lume_topic_${search.label}`;
const createTopic = await ark.set_nstore(key, JSON.stringify(topics));
if (createTopic) {
return navigate({ to: redirect });
return navigate({ to: search.redirect, search: { ...search } });
}
} catch (e) {
setIsLoading(false);

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -109,7 +109,13 @@ pub async fn get_local_events(
};
let authors: Vec<PublicKey> = pubkeys
.into_iter()
.map(|p| PublicKey::from_hex(p).unwrap())
.map(|p| {
if p.starts_with("npub1") {
PublicKey::from_bech32(p).unwrap()
} else {
PublicKey::from_hex(p).unwrap()
}
})
.collect();
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])