Skip to content

Commit

Permalink
fix: home screen scrolling to bottom
Browse files Browse the repository at this point in the history
The home screen no longer scrolls to the bottom of the page on
initial load.
  • Loading branch information
JMBeresford committed Nov 13, 2024
1 parent 0b8464a commit 373a754
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 38 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ManagedConfig = Mutex<RetromClientConfig>;

#[tauri::command]
fn set_config(app: AppHandle, new_config: RetromClientConfig) {
tracing::info!("Setting new config: {:?}", new_config);
tracing::debug!("Setting new config: {:?}", new_config);
match app.try_state::<ManagedConfig>() {
Some(config) => {
*config.lock().unwrap() = new_config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export function UpdateLibrary() {
const [open, setOpen] = useState(false);

const handleUpdate = useCallback(async () => {
console.log("start");
await updateLibrary();
console.log("end");
setOpen(false);
}, [updateLibrary, setOpen]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ function LocalConfigRow(props: {
disabled={pending || !isDirty}
type="submit"
size="icon"
onClick={() => console.log(form.formState)}
className="p-2 w-min h-min"
>
{pending ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ function parseArgs(argsString: string): string[] {
const quoteChars = ['"', "'", "`"];
const quoteStack: string[] = [];

console.log(argsString);

for (const char of argsString) {
if (quoteChars.includes(char)) {
if (quoteStack[quoteStack.length - 1] === char) {
Expand All @@ -281,6 +279,5 @@ function parseArgs(argsString: string): string[] {

args.push(current);

console.log({ args });
return args;
}
26 changes: 0 additions & 26 deletions packages/client/web/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { StrictMode } from "react";
import ReactDOM from "react-dom/client";
import { RouterProvider, createRouter } from "@tanstack/react-router";
import { init, setKeyMap } from "@noriginmedia/norigin-spatial-navigation";
import "./globals.scss";

declare module "react" {
Expand All @@ -27,31 +26,6 @@ const rootElement = document.getElementById("root")!;
if (!rootElement.innerHTML) {
const root = ReactDOM.createRoot(rootElement);

init({
// debug: import.meta.env.DEV,
// shouldFocusDOMNode: true,
// domNodeFocusOptions: {
// preventScroll: true,
// focusVisible: true,
// },
shouldUseNativeEvents: true,
// visualDebug: true,
// distanceCalculationMethod: "center",
});

setKeyMap({
// up: [87, 75], // w and k
// down: [83, 74], // s and j
// left: [65, 72], // a and h
// right: [68, 76], // d and l
// enter: 70, // f
up: 1000,
down: 1000,
left: 1000,
right: 1000,
enter: 1000,
});

root.render(
<StrictMode>
<RouterProvider router={router} />
Expand Down
2 changes: 0 additions & 2 deletions packages/client/web/src/providers/hotkeys/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ export function useHotkeys(opts: {

const { handler, zone } = handlerInfo;

console.log({ hotkey, handler, zone, layerContext, event });

const zoneActive = layerContext?.isZoneActive(zone) ?? true;
if (!zoneActive || !handler) {
return;
Expand Down
2 changes: 2 additions & 0 deletions packages/client/web/src/routes/(windowed)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import { MatchPlatformsModal } from "@/components/modals/match-platforms";
import { VersionInfoModal } from "@/components/modals/version-info";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { checkIsDesktop } from "@/lib/env";
import { destroy } from "@noriginmedia/norigin-spatial-navigation";

export const Route = createFileRoute("/(windowed)/_layout")({
component: LayoutComponent,
loader: async () => {
destroy();
if (checkIsDesktop()) {
await getCurrentWindow().setFullscreen(false);
}
Expand Down
21 changes: 20 additions & 1 deletion packages/client/web/src/routes/_fullscreenLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { z } from "zod";
import { zodSearchValidator } from "@tanstack/router-zod-adapter";
import { GroupContextProvider } from "@/providers/fullscreen/group-context";
import { GamepadProvider } from "@/providers/gamepad";
import { navigateByDirection } from "@noriginmedia/norigin-spatial-navigation";
import {
init,
navigateByDirection,
setKeyMap,
} from "@noriginmedia/norigin-spatial-navigation";
import { useHotkeys } from "@/providers/hotkeys";
import { InputDeviceProvider } from "@/providers/input-device";
import { checkIsDesktop } from "@/lib/env";
Expand All @@ -31,6 +35,21 @@ export const Route = createFileRoute("/_fullscreenLayout")({
if (checkIsDesktop()) {
await getCurrentWindow().setFullscreen(true);
}

init({
// debug: import.meta.env.DEV,
shouldUseNativeEvents: true,
// visualDebug: true,
});

// ununsed, setting to invalid keycode to keep vanilla arrow key behavior
setKeyMap({
up: 1000,
down: 1000,
left: 1000,
right: 1000,
enter: 1000,
});
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,13 @@ function Description(props: { description: string }) {
handlers={{
UP: {
handler: (event) => {
console.log(event);
ref.current?.scrollBy({ top: -100, behavior: "smooth" });
event?.stopPropagation();
event?.preventDefault();
},
},
DOWN: {
handler: (event) => {
console.log(event);
ref.current?.scrollBy({ top: 100, behavior: "smooth" });
event?.stopPropagation();
event?.preventDefault();
Expand Down

0 comments on commit 373a754

Please sign in to comment.