Skip to content

Commit

Permalink
fix(frontend): favor remote instead of local when retrieving item
Browse files Browse the repository at this point in the history
  • Loading branch information
guilbep committed Mar 27, 2024
1 parent 7ad2eb1 commit 1e19041
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions frontend/src/store/GhgModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,16 @@ const actions: ActionTree<ProjectsState, RootState> = {
getDoc: async (context: ActionContext<ProjectsState, RootState>, id) => {
const db = context.state.localCouch?.remoteDB;
const localDB = context.state.localCouch?.localDB; // for guest user only
if (localDB) {
if (db) {
context.commit("SET_PROJECT_LOADING", true);
try {
const result = await localDB.get(id);
const result = await db.get(id);
context.commit("SET_PROJECT", result);
return result;
} catch (errL: unknown) {
try {
if (db) {
const result = await db.get(id);
if (localDB) {
const result = await localDB.get(id);
context.commit("SET_PROJECT", result);
return result;
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/store/ShelterModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,13 @@ const actions: ActionTree<ShelterState, RootState> = {
const db = context.state.localCouch?.remoteDB;
const localDB = context.state.localCouch?.localDB; // for guest user only
let result: Shelter | undefined;
if (localDB) {
if (db) {
try {
result = await localDB.get(id);
result = await db.get(id);
} catch (errL: unknown) {
try {
if (db) {
result = await db.get(id);
if (localDB) {
result = await localDB.get(id);
}
} catch (err: unknown) {
if (err instanceof Error) {
Expand Down

0 comments on commit 1e19041

Please sign in to comment.