Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix: route confusion entering from non-home page (#460)
Stephen Zhoua90acdabb382
diff --git a/web/src/services/locationService.ts b/web/src/services/locationService.tsindex 2a64fc404..65267c48a 100644--- a/web/src/services/locationService.ts+++ b/web/src/services/locationService.ts@@ -1,8 +1,11 @@import { stringify } from "qs";import store from "../store";-import { setQuery, setPathname, Query, updateStateWithLocation } from "../store/modules/location";+import { setQuery, setPathname, Query, updateStateWithLocation, updatePathnameStateWithLocation } from "../store/modules/location";const updateLocationUrl = (method: "replace" | "push" = "replace") => {+ // avoid pathname confusion when entering from non-home page+ store.dispatch(updatePathnameStateWithLocation());+const { query, pathname, hash } = store.getState().location;let queryString = stringify(query);if (queryString) {diff --git a/web/src/store/modules/location.ts b/web/src/store/modules/location.tsindex dabd4dd6b..108014186 100644--- a/web/src/store/modules/location.ts+++ b/web/src/store/modules/location.ts@@ -64,6 +64,13 @@ const locationSlice = createSlice({updateStateWithLocation: () => {return getStateFromLocation();},+ updatePathnameStateWithLocation: (state) => {+ const { pathname } = window.location;+ return {+ ...state,+ pathname: getValidPathname(pathname),+ };+ },setPathname: (state, action: PayloadAction<string>) => {if (state.pathname === action.payload) {return state;@@ -90,6 +97,6 @@ const locationSlice = createSlice({},});-export const { setPathname, setQuery, updateStateWithLocation } = locationSlice.actions;+export const { setPathname, setQuery, updateStateWithLocation, updatePathnameStateWithLocation } = locationSlice.actions;export default locationSlice.reducer;