From 70ce037a77461f4d3160045886aeb326a172bb81 Mon Sep 17 00:00:00 2001 From: Rustem Mussabekov Date: Thu, 16 May 2024 15:30:45 +0300 Subject: [PATCH] Thinking status for suggestions --- src/data/modules/persistConfig.js | 2 +- src/data/reducers/predictions.js | 3 +++ src/data/sagas/predictions.js | 5 ++--- src/routes/suggestions/predictions/empty.js | 12 ++++++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/data/modules/persistConfig.js b/src/data/modules/persistConfig.js index 6822d17b..e22860f1 100644 --- a/src/data/modules/persistConfig.js +++ b/src/data/modules/persistConfig.js @@ -19,7 +19,7 @@ if (RAINDROP_ENVIRONMENT == 'browser') else storage = require('@react-native-async-storage/async-storage').default -const version = 38 +const version = 39 export default { key: 'primary', diff --git a/src/data/reducers/predictions.js b/src/data/reducers/predictions.js index b13e8e42..bb76b6eb 100644 --- a/src/data/reducers/predictions.js +++ b/src/data/reducers/predictions.js @@ -20,6 +20,7 @@ export default function(state = initialState, action){switch (action.type) { case c.PREDICTIONS_LOAD_REQ:{ return state .set('status', 'loading') + .set('updateDate', null) } case c.PREDICTIONS_LOAD_SUCCESS:{ @@ -29,6 +30,7 @@ export default function(state = initialState, action){switch (action.type) { return state .set('status', 'loaded') .set('items', items) + .set('updateDate', action.updateDate) } case c.PREDICTIONS_LOAD_ERROR:{ @@ -78,5 +80,6 @@ export default function(state = initialState, action){switch (action.type) { const initialState = Immutable({ status: 'idle', //idle|loading|loaded|error items: [], + updateDate: null, apply_status: {} // _id: loading|success|error }) \ No newline at end of file diff --git a/src/data/sagas/predictions.js b/src/data/sagas/predictions.js index b557e10b..519857b6 100644 --- a/src/data/sagas/predictions.js +++ b/src/data/sagas/predictions.js @@ -9,12 +9,11 @@ export default function* () { function* load() { try { - const { predictions, raindrops } = yield call(Api.get, 'predictions?version=1') + const res = yield call(Api.get, 'predictions?version=1') yield put({ type: c.PREDICTIONS_LOAD_SUCCESS, - predictions, - raindrops + ...res }) } catch (error) { yield put({ diff --git a/src/routes/suggestions/predictions/empty.js b/src/routes/suggestions/predictions/empty.js index 967894fd..78023d92 100644 --- a/src/routes/suggestions/predictions/empty.js +++ b/src/routes/suggestions/predictions/empty.js @@ -1,8 +1,20 @@ import React from 'react' import links from '~config/links' +import { useSelector } from 'react-redux' + import Alert from '~co/common/alert' export default function MySuggestionsPredictionsEmpty() { + const updateDate = useSelector(state=>state.predictions.updateDate) + + if (!updateDate) + return ( + + 💭 Thinking…
+ Check back later for suggestions tailored to your bookmarks +
+ ) + return ( Not enough data yet