mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 08:00:06 +00:00
fix(collab): a note, poll, message or link that cannot be saved offline says it needs a connection
Collab, packing bags, packing templates and imports, the category a place form creates and the place imports are not kept on the device, so offline their writes cannot wait in the queue. They failed with a bare "Error" or the generic save message. While TREK is offline the failure now reads "This needs a connection. Try again once TREK is back online.", on desktop and on the phone's Collab notes; online nothing changes. Refs #2601
This commit is contained in:
@@ -3,6 +3,7 @@ import { useState } from 'react';
|
||||
import { placesApi } from '../../api/client';
|
||||
import type { useTranslation } from '../../i18n';
|
||||
import { useAuthStore } from '../../store/authStore';
|
||||
import { offlineOr } from '../../utils/needsConnection';
|
||||
import type { useToast } from '../shared/Toast';
|
||||
|
||||
export type ListImportProvider = 'google' | 'naver';
|
||||
@@ -84,7 +85,9 @@ export function useListImport({ tripId, t, toast, loadTrip, pushUndo, onDone }:
|
||||
onDone?.();
|
||||
} catch (err: unknown) {
|
||||
const message = (err as { response?: { data?: { error?: string } } })?.response?.data?.error;
|
||||
toast.error(message || t(provider === 'google' ? 'places.googleListError' : 'places.naverListError'));
|
||||
toast.error(
|
||||
message || offlineOr(t, t(provider === 'google' ? 'places.googleListError' : 'places.naverListError'))
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useRef, useState } from 'react';
|
||||
|
||||
import type { useTranslation } from '../../i18n';
|
||||
import type { Category } from '../../types';
|
||||
import { offlineOr } from '../../utils/needsConnection';
|
||||
import type { useToast } from '../shared/Toast';
|
||||
import type { PlaceDetailsSelection } from './PlaceDetailsColumn';
|
||||
import {
|
||||
@@ -174,7 +175,7 @@ export function useNewCategory({ t, toast, onCreated, variant, create }: NewCate
|
||||
setName('');
|
||||
setOpen(false);
|
||||
} catch {
|
||||
toast.error(t('places.categoryCreateError'));
|
||||
toast.error(offlineOr(t, t('places.categoryCreateError')));
|
||||
} finally {
|
||||
if (sheet) setSaving(false);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useEffect, useEffectEvent, useState } from 'react';
|
||||
import { placesApi } from '../../api/client';
|
||||
import type { useTranslation } from '../../i18n';
|
||||
import { useAuthStore } from '../../store/authStore';
|
||||
import { offlineOr } from '../../utils/needsConnection';
|
||||
import type { useToast } from '../shared/Toast';
|
||||
|
||||
export interface PlacesImportSummary {
|
||||
@@ -230,7 +231,8 @@ export function usePlacesFileImport({
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
const message =
|
||||
(err as { response?: { data?: { error?: string } } })?.response?.data?.error || t('places.importFileError');
|
||||
(err as { response?: { data?: { error?: string } } })?.response?.data?.error ||
|
||||
offlineOr(t, t('places.importFileError'));
|
||||
errors.push(files.length > 1 ? `${f.name}: ${message}` : message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { collectionsApi } from '../../api/collections';
|
||||
import type { useTranslation } from '../../i18n';
|
||||
import { useTripStore } from '../../store/tripStore';
|
||||
import type { Place } from '../../types';
|
||||
import { offlineOr } from '../../utils/needsConnection';
|
||||
import { useToast } from '../shared/Toast';
|
||||
|
||||
/** What the pool shows: everything, what is not on a day yet, what is, or the tracks. */
|
||||
@@ -135,7 +136,7 @@ export function usePlacesPool({ tripId, places, poolPlaces, toursEnabled, t, sta
|
||||
else toast.success(t('collections.markedVisitedTrip', { count: matchedPlaces ?? 0 }));
|
||||
exitSelectMode();
|
||||
} catch {
|
||||
toast.error(t('common.error'));
|
||||
toast.error(offlineOr(t, t('common.error')));
|
||||
} finally {
|
||||
setMarkVisitedBusy(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user