fix: confirm and version favorite institution updates
This commit is contained in:
@@ -357,13 +357,20 @@ export const AppProvider = ({ children }) => {
|
||||
|
||||
// --- Favori kurumlar (sunucu kaydı) ---
|
||||
const [favoriteKurumlar, setFavoriteKurumlar] = useState([]);
|
||||
useEffect(() => {
|
||||
if (veriSenkron) ilkYazmaDegil('favori_kurumlar', favoriteKurumlar);
|
||||
}, [favoriteKurumlar, veriSenkron]);
|
||||
const toggleFavoriteKurum = (kurum) => {
|
||||
const ad = (kurum || '').trim();
|
||||
if (!ad) return;
|
||||
setFavoriteKurumlar((prev) => (prev.includes(ad) ? prev.filter((k) => k !== ad) : [...prev, ad]));
|
||||
const favoriteSaveLock=useRef(false);
|
||||
const [favoriteSaving,setFavoriteSaving]=useState(false);
|
||||
const toggleFavoriteKurum = async kurum => {
|
||||
const ad=typeof kurum==='string' ? kurum.trim() : '';
|
||||
if(!ad || favoriteSaveLock.current)return false;
|
||||
if(!authUser||!veriSenkron){setSaveError('Hesap verileri yüklenmeden favoriler kaydedilemez.');return false;}
|
||||
const session=getToken();favoriteSaveLock.current=true;setFavoriteSaving(true);setSavingCount(n=>n+1);setSaveError(null);
|
||||
const next=favoriteKurumlar.includes(ad)?favoriteKurumlar.filter(k=>k!==ad):[...favoriteKurumlar,ad];
|
||||
try {
|
||||
const saved=await setUserData('favori_kurumlar',next,dataRevisions.current.favori_kurumlar ?? null);
|
||||
if(getToken()!==session)return false;
|
||||
dataRevisions.current.favori_kurumlar=saved.revision;setFavoriteKurumlar(next);return true;
|
||||
} catch(error){if(getToken()===session)setSaveError(error.message);return false;}
|
||||
finally{favoriteSaveLock.current=false;setFavoriteSaving(false);setSavingCount(n=>n-1);}
|
||||
};
|
||||
|
||||
// --- Ekip yönetimi (sunucu kaydı) ---
|
||||
@@ -824,7 +831,7 @@ export const AppProvider = ({ children }) => {
|
||||
markNotificationsRead,
|
||||
refreshNotifications,notificationError,notificationBusy,
|
||||
isQuietNow,
|
||||
favoriteKurumlar,
|
||||
favoriteKurumlar,favoriteSaving,
|
||||
toggleFavoriteKurum,
|
||||
teamMembers,teamSaving,teamError,
|
||||
addTeamMember,
|
||||
|
||||
Reference in New Issue
Block a user