Skip to content

Commit

Permalink
feat: redirect to index after add account
Browse files Browse the repository at this point in the history
  • Loading branch information
reyamir committed May 29, 2024
1 parent 41b66b1 commit 70c5143
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";

export const Route = createFileRoute("/auth/new/$account/backup")({
export const Route = createFileRoute("/auth/$account/backup")({
component: Screen,
});

Expand All @@ -33,8 +33,7 @@ function Screen() {
}

return navigate({
to: "/auth/$account/settings",
params: { account },
to: "/auth/settings",
});
}

Expand Down
2 changes: 1 addition & 1 deletion apps/desktop2/src/routes/auth/new/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function Screen() {

if (eventId) {
navigate({
to: "/auth/new/$account/backup",
to: "/auth/$account/backup",
params: { account: account.npub },
replace: true,
});
Expand Down
3 changes: 1 addition & 2 deletions apps/desktop2/src/routes/auth/privkey.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ function Screen() {

if (npub) {
navigate({
to: "/auth/$account/settings",
params: { account: npub },
to: "/auth/settings",
replace: true,
});
}
Expand Down
3 changes: 1 addition & 2 deletions apps/desktop2/src/routes/auth/remote.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ function Screen() {

if (npub) {
navigate({
to: "/auth/$account/settings",
params: { account: npub },
to: "/auth/settings",
replace: true,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";

export const Route = createFileRoute("/auth/$account/settings")({
export const Route = createFileRoute("/auth/settings")({
beforeLoad: async () => {
const settings = await NostrQuery.getSettings();
return { settings };
Expand All @@ -18,14 +18,14 @@ export const Route = createFileRoute("/auth/$account/settings")({
});

function Screen() {
const navigate = Route.useNavigate();
const { account } = Route.useParams();
const { settings } = Route.useRouteContext();
const { t } = useTranslation();

const [newSettings, setNewSettings] = useState(settings);
const [loading, setLoading] = useState(false);

const navigate = Route.useNavigate();

const toggleNofitication = async () => {
await requestPermission();
setNewSettings((prev) => ({
Expand Down Expand Up @@ -72,8 +72,7 @@ function Screen() {

if (eventId) {
return navigate({
to: "/$account/home",
params: { account },
to: "/",
replace: true,
});
}
Expand Down
17 changes: 7 additions & 10 deletions packages/system/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,31 +236,28 @@ export class NostrQuery {
}

static async getColumns() {
const systemPath = "resources/system_columns.json";
const resourcePath = await resolveResource(systemPath);
const resourceFile = await readTextFile(resourcePath);
const systemColumns: LumeColumn[] = JSON.parse(resourceFile);
const query = await commands.getNstore(NSTORE_KEYS.columns);

if (query.status === "ok") {
const columns: LumeColumn[] = query.data ? JSON.parse(query.data) : [];

if (columns.length < 1) {
const systemPath = "resources/system_columns.json";
const resourcePath = await resolveResource(systemPath);
const resourceFile = await readTextFile(resourcePath);
const systemColumns: LumeColumn[] = JSON.parse(resourceFile);

return systemColumns;
}

return columns;
} else {
return [];
return systemColumns;
}
}

static async setColumns(columns: LumeColumn[]) {
const query = await commands.setNstore(
NSTORE_KEYS.columns,
JSON.stringify(columns),
);
const content = JSON.stringify(columns);
const query = await commands.setNstore(NSTORE_KEYS.columns, content);

if (query.status === "ok") {
return query.data;
Expand Down

0 comments on commit 70c5143

Please sign in to comment.