Add 'lastViewedAnnouncement' into wallet.
This stores the hash for the last viewed announcement. The intention is so that the announcement won't re-appear when logging into another device. However, this does mean that announcements would need to wait until the first sync to decide whether to appear or not, which can be quite a delay.
This commit is contained in:
parent
245eb39892
commit
79eb28cc55
7 changed files with 28 additions and 1 deletions
1
flow-typed/content.js
vendored
1
flow-typed/content.js
vendored
|
@ -15,6 +15,7 @@ declare type ContentState = {
|
||||||
// It can/should be '?Array<string>` instead -- set it to null, then clients
|
// It can/should be '?Array<string>` instead -- set it to null, then clients
|
||||||
// can cast it to a boolean. That, or rename the variable to `shuffle` if you
|
// can cast it to a boolean. That, or rename the variable to `shuffle` if you
|
||||||
// don't care about the URLs.
|
// don't care about the URLs.
|
||||||
|
lastViewedAnnouncement: ?string, // undefined = not seen in wallet.
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type WatchHistory = {
|
declare type WatchHistory = {
|
||||||
|
|
|
@ -143,6 +143,7 @@ export const CLEAR_CONTENT_POSITION = 'CLEAR_CONTENT_POSITION';
|
||||||
export const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED';
|
export const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED';
|
||||||
export const CLEAR_CONTENT_HISTORY_URI = 'CLEAR_CONTENT_HISTORY_URI';
|
export const CLEAR_CONTENT_HISTORY_URI = 'CLEAR_CONTENT_HISTORY_URI';
|
||||||
export const CLEAR_CONTENT_HISTORY_ALL = 'CLEAR_CONTENT_HISTORY_ALL';
|
export const CLEAR_CONTENT_HISTORY_ALL = 'CLEAR_CONTENT_HISTORY_ALL';
|
||||||
|
export const SET_LAST_VIEWED_ANNOUNCEMENT = 'SET_LAST_VIEWED_ANNOUNCEMENT';
|
||||||
export const RECOMMENDATION_UPDATED = 'RECOMMENDATION_UPDATED';
|
export const RECOMMENDATION_UPDATED = 'RECOMMENDATION_UPDATED';
|
||||||
export const RECOMMENDATION_CLICKED = 'RECOMMENDATION_CLICKED';
|
export const RECOMMENDATION_CLICKED = 'RECOMMENDATION_CLICKED';
|
||||||
export const TOGGLE_LOOP_LIST = 'TOGGLE_LOOP_LIST';
|
export const TOGGLE_LOOP_LIST = 'TOGGLE_LOOP_LIST';
|
||||||
|
|
|
@ -374,3 +374,12 @@ export function doToggleShuffleList(currentUri: string, collectionId: string, sh
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function doSetLastViewedAnnouncement(hash: string) {
|
||||||
|
return (dispatch: Dispatch) => {
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.SET_LAST_VIEWED_ANNOUNCEMENT,
|
||||||
|
data: hash,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -421,6 +421,7 @@ type SharedData = {
|
||||||
editedCollections: CollectionGroup,
|
editedCollections: CollectionGroup,
|
||||||
builtinCollections: CollectionGroup,
|
builtinCollections: CollectionGroup,
|
||||||
savedCollections: Array<string>,
|
savedCollections: Array<string>,
|
||||||
|
lastViewedAnnouncement: string,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -439,6 +440,7 @@ function extractUserState(rawObj: SharedData) {
|
||||||
editedCollections,
|
editedCollections,
|
||||||
builtinCollections,
|
builtinCollections,
|
||||||
savedCollections,
|
savedCollections,
|
||||||
|
lastViewedAnnouncement,
|
||||||
} = rawObj.value;
|
} = rawObj.value;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -454,6 +456,7 @@ function extractUserState(rawObj: SharedData) {
|
||||||
...(editedCollections ? { editedCollections } : {}),
|
...(editedCollections ? { editedCollections } : {}),
|
||||||
...(builtinCollections ? { builtinCollections } : {}),
|
...(builtinCollections ? { builtinCollections } : {}),
|
||||||
...(savedCollections ? { savedCollections } : {}),
|
...(savedCollections ? { savedCollections } : {}),
|
||||||
|
...(lastViewedAnnouncement ? { lastViewedAnnouncement } : {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,6 +478,7 @@ export function doPopulateSharedUserState(sharedSettings: any) {
|
||||||
editedCollections,
|
editedCollections,
|
||||||
builtinCollections,
|
builtinCollections,
|
||||||
savedCollections,
|
savedCollections,
|
||||||
|
lastViewedAnnouncement,
|
||||||
} = extractUserState(sharedSettings);
|
} = extractUserState(sharedSettings);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.USER_STATE_POPULATE,
|
type: ACTIONS.USER_STATE_POPULATE,
|
||||||
|
@ -491,6 +495,7 @@ export function doPopulateSharedUserState(sharedSettings: any) {
|
||||||
editedCollections,
|
editedCollections,
|
||||||
builtinCollections,
|
builtinCollections,
|
||||||
savedCollections,
|
savedCollections,
|
||||||
|
lastViewedAnnouncement,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,6 +13,7 @@ const defaultState: ContentState = {
|
||||||
recommendationUrls: {},
|
recommendationUrls: {},
|
||||||
recommendationClicks: {},
|
recommendationClicks: {},
|
||||||
loopList: undefined,
|
loopList: undefined,
|
||||||
|
lastViewedAnnouncement: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[ACTIONS.SET_PRIMARY_URI] = (state, action) =>
|
reducers[ACTIONS.SET_PRIMARY_URI] = (state, action) =>
|
||||||
|
@ -118,6 +119,8 @@ reducers[ACTIONS.CLEAR_CONTENT_HISTORY_URI] = (state, action) => {
|
||||||
|
|
||||||
reducers[ACTIONS.CLEAR_CONTENT_HISTORY_ALL] = (state) => ({ ...state, history: [] });
|
reducers[ACTIONS.CLEAR_CONTENT_HISTORY_ALL] = (state) => ({ ...state, history: [] });
|
||||||
|
|
||||||
|
reducers[ACTIONS.SET_LAST_VIEWED_ANNOUNCEMENT] = (state, action) => ({ ...state, lastViewedAnnouncement: action.data });
|
||||||
|
|
||||||
// reducers[LBRY_REDUX_ACTIONS.PURCHASE_URI_FAILED] = (state, action) => {
|
// reducers[LBRY_REDUX_ACTIONS.PURCHASE_URI_FAILED] = (state, action) => {
|
||||||
// return {
|
// return {
|
||||||
// ...state,
|
// ...state,
|
||||||
|
@ -125,6 +128,11 @@ reducers[ACTIONS.CLEAR_CONTENT_HISTORY_ALL] = (state) => ({ ...state, history: [
|
||||||
// };
|
// };
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
reducers[ACTIONS.USER_STATE_POPULATE] = (state, action) => {
|
||||||
|
const { lastViewedAnnouncement } = action.data;
|
||||||
|
return { ...state, lastViewedAnnouncement };
|
||||||
|
};
|
||||||
|
|
||||||
export default function reducer(state: ContentState = defaultState, action: any) {
|
export default function reducer(state: ContentState = defaultState, action: any) {
|
||||||
const handler = reducers[action.type];
|
const handler = reducers[action.type];
|
||||||
if (handler) return handler(state, action);
|
if (handler) return handler(state, action);
|
||||||
|
|
|
@ -26,6 +26,7 @@ export const selectPlayingUri = (state: State) => selectState(state).playingUri;
|
||||||
export const selectPrimaryUri = (state: State) => selectState(state).primaryUri;
|
export const selectPrimaryUri = (state: State) => selectState(state).primaryUri;
|
||||||
export const selectListLoop = (state: State) => selectState(state).loopList;
|
export const selectListLoop = (state: State) => selectState(state).loopList;
|
||||||
export const selectListShuffle = (state: State) => selectState(state).shuffleList;
|
export const selectListShuffle = (state: State) => selectState(state).shuffleList;
|
||||||
|
export const selectLastViewedAnnouncement = (state: State) => selectState(state).lastViewedAnnouncement;
|
||||||
|
|
||||||
export const makeSelectIsPlaying = (uri: string) =>
|
export const makeSelectIsPlaying = (uri: string) =>
|
||||||
createSelector(selectPrimaryUri, (primaryUri) => primaryUri === uri);
|
createSelector(selectPrimaryUri, (primaryUri) => primaryUri === uri);
|
||||||
|
|
|
@ -45,7 +45,7 @@ function enableBatching(reducer) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentFilter = createFilter('content', ['positions', 'history']);
|
const contentFilter = createFilter('content', ['positions', 'history', 'lastViewedAnnouncement']);
|
||||||
const fileInfoFilter = createFilter('fileInfo', [
|
const fileInfoFilter = createFilter('fileInfo', [
|
||||||
'fileListPublishedSort',
|
'fileListPublishedSort',
|
||||||
'fileListDownloadedSort',
|
'fileListDownloadedSort',
|
||||||
|
@ -141,6 +141,7 @@ const triggerSharedStateActions = [
|
||||||
ACTIONS.COLLECTION_DELETE,
|
ACTIONS.COLLECTION_DELETE,
|
||||||
ACTIONS.COLLECTION_NEW,
|
ACTIONS.COLLECTION_NEW,
|
||||||
ACTIONS.COLLECTION_PENDING,
|
ACTIONS.COLLECTION_PENDING,
|
||||||
|
ACTIONS.SET_LAST_VIEWED_ANNOUNCEMENT,
|
||||||
// MAYBE COLLECTOIN SAVE
|
// MAYBE COLLECTOIN SAVE
|
||||||
// ACTIONS.SET_WELCOME_VERSION,
|
// ACTIONS.SET_WELCOME_VERSION,
|
||||||
// ACTIONS.SET_ALLOW_ANALYTICS,
|
// ACTIONS.SET_ALLOW_ANALYTICS,
|
||||||
|
@ -183,6 +184,7 @@ const sharedStateFilters = {
|
||||||
editedCollections: { source: 'collections', property: 'edited' },
|
editedCollections: { source: 'collections', property: 'edited' },
|
||||||
// savedCollections: { source: 'collections', property: 'saved' },
|
// savedCollections: { source: 'collections', property: 'saved' },
|
||||||
unpublishedCollections: { source: 'collections', property: 'unpublished' },
|
unpublishedCollections: { source: 'collections', property: 'unpublished' },
|
||||||
|
lastViewedAnnouncement: { source: 'content', property: 'lastViewedAnnouncement' },
|
||||||
};
|
};
|
||||||
|
|
||||||
const sharedStateCb = ({ dispatch, getState, syncId }) => {
|
const sharedStateCb = ({ dispatch, getState, syncId }) => {
|
||||||
|
|
Loading…
Reference in a new issue