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

New Onboarding Flow #482

Merged
merged 12 commits into from
Jun 21, 2024
2 changes: 1 addition & 1 deletion app/UI/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export class AppComponent extends Component<AppProps, {
async componentDidMount() {
await this.updateAdminState();
for await (const update of this.props.eventBus.onChange()) {
if (update.type == "SelectRelay") {
if (update.type == "SelectSpace") {
this.updateAdminState();
}
}
Expand Down
16 changes: 8 additions & 8 deletions app/UI/app_update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ import { EventDetail, EventDetailItem } from "./event-detail.tsx";

import { DirectMessagePanelUpdate, SendReaction } from "./message-panel.tsx";
import { ChatMessage, parseContent } from "./message.ts";
import { InstallPrompt, NavigationModel, NavigationUpdate, SelectRelay } from "./nav.tsx";
import { InstallPrompt, NavigationModel, NavigationUpdate, SelectSpace } from "./nav.tsx";
import { notify } from "./notification.ts";
import { SpaceSetting } from "./relay-detail.tsx";
import { Search } from "./search.tsx";
import { SearchUpdate, SelectConversation } from "./search_model.ts";
import { RelayConfigChange, ViewRecommendedRelaysList, ViewRelayDetail } from "./setting.tsx";
import { RelayConfigChange, ViewRecommendedRelaysList, ViewSpaceSettings } from "./setting.tsx";
import { SignInEvent } from "./sign-in.ts";
import { TagSelected } from "./contact-tags.tsx";
import { BlockUser, UnblockUser, UserDetail } from "./user-detail.tsx";
Expand Down Expand Up @@ -78,12 +78,12 @@ export type UI_Interaction_Event =
| SignInEvent
| RelayConfigChange
| StartInvite
| ViewRelayDetail
| ViewSpaceSettings
| ViewRecommendedRelaysList
| TagSelected
| BlockUser
| UnblockUser
| SelectRelay
| SelectSpace
| HidePopOver
| SyncEvent
| FilterContent
Expand Down Expand Up @@ -180,9 +180,9 @@ const handle_update_event = async (chan: PutChannel<true>, args: {
}

// All events below are only valid after signning in
if (event.type == "SelectRelay") {
rememberCurrentRelay(event.relay.url);
model.currentRelay = event.relay.url;
if (event.type == "SelectSpace") {
rememberCurrentRelay(event.spaceURL);
model.currentRelay = event.spaceURL;
} //
// Searchx
//
Expand All @@ -204,7 +204,7 @@ const handle_update_event = async (chan: PutChannel<true>, args: {
//
// Setting
//
else if (event.type == "ViewRelayDetail") {
else if (event.type == "ViewSpaceSettings") {
const relay = pool.getRelay(event.url);
if (relay) {
app.popOverInputChan.put({
Expand Down
37 changes: 19 additions & 18 deletions app/UI/components/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LinkColor, PrimaryBackgroundColor, PrimaryTextColor } from "../style/co
import { Channel, sleep } from "https://raw.githubusercontent.com/BlowaterNostr/csp/master/csp.ts";
import { setState } from "../_helper.ts";
import { emitFunc } from "../../event-bus.ts";
import { ViewRelayDetail } from "../setting.tsx";
import { ViewSpaceSettings } from "../setting.tsx";

export type ToastChannel = Channel<() => ComponentChildren>;

Expand Down Expand Up @@ -47,23 +47,24 @@ export class Toast extends Component<Props, State> {
}
}

export const SendingEventRejection = (emit: emitFunc<ViewRelayDetail>, url: string, reason: string) => () => (
<div
class="hover:cursor-pointer"
onClick={() => {
emit({
type: "ViewRelayDetail",
url: url,
});
}}
>
sending message is rejected
<div>reason: {reason}</div>
<div>please contact the admin of relay</div>
export const SendingEventRejection =
(emit: emitFunc<ViewSpaceSettings>, url: string, reason: string) => () => (
<div
class={`text-[${LinkColor}] hover:underline`}
class="hover:cursor-pointer"
onClick={() => {
emit({
type: "ViewSpaceSettings",
url: url,
});
}}
>
{url}
sending message is rejected
<div>reason: {reason}</div>
<div>please contact the admin of relay</div>
<div
class={`text-[${LinkColor}] hover:underline`}
>
{url}
</div>
</div>
</div>
);
);
15 changes: 8 additions & 7 deletions app/UI/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import { DownloadIcon } from "./icons/download-icon.tsx";
import { Profile_Nostr_Event } from "../nostr.ts";
import { ConnectionPool } from "../../libs/nostr.ts/relay-pool.ts";
import { SingleRelayConnection } from "../../libs/nostr.ts/relay-single.ts";
import { RelaySwitchList } from "./relay-switch-list.tsx";
import { SpaceDropDownPanel } from "./space-drop-down-panel.tsx";
import { SocialIcon } from "./icons/social-icon.tsx";
import { SearchIcon } from "./icons/search-icon.tsx";
import { StartSearch } from "./search_model.ts";
import { ViewSpaceSettings } from "./setting.tsx";

export type InstallPrompt = {
event: Event | undefined;
Expand All @@ -33,9 +34,9 @@ export type NavigationUpdate = {
id: NavTabID;
};

export type SelectRelay = {
type: "SelectRelay";
relay: SingleRelayConnection;
export type SelectSpace = {
type: "SelectSpace";
spaceURL: string;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. rename from relay to space
  2. use url instead of the connection instance to reduce dependencies

};

export type NavigationModel = {
Expand All @@ -45,7 +46,7 @@ export type NavigationModel = {
type Props = {
publicKey: PublicKey;
profile: Profile_Nostr_Event | undefined;
emit: emitFunc<NavigationUpdate | SelectRelay | StartSearch>;
emit: emitFunc<NavigationUpdate | SelectSpace | StartSearch | ViewSpaceSettings>;
installPrompt: InstallPrompt;
pool: ConnectionPool;
activeNav: NavTabID;
Expand Down Expand Up @@ -140,9 +141,9 @@ export class NavBar extends Component<Props, State> {
return (
<div class={this.styles.container}>
{
<RelaySwitchList
<SpaceDropDownPanel
emit={props.emit}
pool={props.pool}
spaceList={new Set(Array.from(props.pool.getRelays()).map((r) => r.url))}
currentRelay={props.currentRelay}
/>
}
Expand Down
1 change: 1 addition & 0 deletions app/UI/relay-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export class RelayInformationComponent extends Component<Props, State> {
const pubkey = PublicKey.FromString(info.pubkey);
if (pubkey instanceof Error) {
// todo make a UI
console.log(info);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, maye the next PR, we need to use zed to runtime valid JSON shapes to prevent incorrect data from the server

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We get a {pubkey: {hex: "xxx"}} from relayed

console.error(pubkey);
} else {
nodes.push(
Expand Down
13 changes: 0 additions & 13 deletions app/UI/relay-switch-list.test.tsx

This file was deleted.

172 changes: 0 additions & 172 deletions app/UI/relay-switch-list.tsx

This file was deleted.

Loading
Loading