Skip to content

Commit

Permalink
Merge pull request #108 from Chloe070196/fix_search_facet_location_fi…
Browse files Browse the repository at this point in the history
…lter

fix: extract branch name
  • Loading branch information
Chloe070196 authored Aug 16, 2024
2 parents bfcf337 + 32747ec commit 317e983
Show file tree
Hide file tree
Showing 89 changed files with 1,678 additions and 332 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: docker/solr/Dockerfile
file: docker/files/solr/Dockerfile
push: true
tags: |
aspendiscovery/solr:latest
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: docker/solr/Dockerfile
file: docker/files/solr/Dockerfile
push: true
tags: |
quay.io/aspen-discovery/solr:latest
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: docker/tunnel/Dockerfile
file: docker/files/tunnel/Dockerfile
push: true
tags: |
aspendiscovery/tunnel:latest
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: docker/tunnel/Dockerfile
file: docker/files/tunnel/Dockerfile
push: true
tags: |
quay.io/aspen-discovery/tunnel:latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,4 @@ code/aspen_app/updateEASTestApps.sh
code/aspen_app/updateTestApps.sh
code/cron/.idea/misc.xml
tests/phpunit/.phpunit.result.cache
install/unit_tests_local.ini
20 changes: 20 additions & 0 deletions code/aspen_app/src/context/initialContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export const UserContext = React.createContext({
updateNotificationOnboardStatus: () => {},
appPreferences: [],
updateAppPreferences: () => {},
notificationHistory: [],
updateNotificationHistory: () => {},
inbox: [],
updateInbox: () => {},
});
export const LibrarySystemContext = React.createContext({
updateLibrary: () => {},
Expand Down Expand Up @@ -373,6 +377,8 @@ export const UserProvider = ({ children }) => {
const [expoToken, setExpoToken] = useState(false);
const [aspenToken, setAspenToken] = useState(false);
const [seenNotificationOnboardPrompt, setSeenNotificationOnboardPrompt] = useState(true);
const [notificationHistory, setNotificationHistory] = useState([]);
const [inbox, setInbox] = useState([]);

const updateUser = (data) => {
if (user !== data) {
Expand Down Expand Up @@ -580,6 +586,16 @@ export const UserProvider = ({ children }) => {
console.log('updated notification onboard status in UserContext');
};

const updateNotificationHistory = (data) => {
setNotificationHistory(data);
console.log('updated notification history in UserContext');
};

const updateInbox = (data) => {
setInbox(data);
console.log('updated notification inbox in UserContext');
};

return (
<UserContext.Provider
value={{
Expand Down Expand Up @@ -616,6 +632,10 @@ export const UserProvider = ({ children }) => {
updateSeenNotificationOnboardPrompt,
updateAppPreferences,
appPreferences,
notificationHistory,
updateNotificationHistory,
inbox,
updateInbox,
}}>
{children}
</UserContext.Provider>
Expand Down
37 changes: 35 additions & 2 deletions code/aspen_app/src/navigations/drawer/DrawerContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { fetchSavedEvents } from '../../util/api/event';
import { getCatalogStatus } from '../../util/api/library';
import { getLists } from '../../util/api/list';
import { getLocations } from '../../util/api/location';
import { fetchReadingHistory, fetchSavedSearches, getLinkedAccounts, getPatronCheckedOutItems, getPatronHolds, getViewerAccounts, reloadProfile, revalidateUser, validateSession } from '../../util/api/user';
import { fetchNotificationHistory, fetchReadingHistory, fetchSavedSearches, getLinkedAccounts, getPatronCheckedOutItems, getPatronHolds, getViewerAccounts, reloadProfile, revalidateUser, validateSession } from '../../util/api/user';
import { passUserToDiscovery } from '../../util/apiAuth';
import { GLOBALS } from '../../util/globals';
import { formatDiscoveryVersion, getPickupLocations, reloadBrowseCategories } from '../../util/loadLibrary';
Expand All @@ -45,7 +45,7 @@ export const DrawerContent = () => {
const [userLongitude, setUserLongitude] = React.useState(0);
const linkTo = useLinkTo();
const queryClient = useQueryClient();
const { user, accounts, viewers, cards, lists, updateUser, updateLanguage, updatePickupLocations, updateLinkedAccounts, updateLists, updateSavedEvents, updateLibraryCards, updateLinkedViewerAccounts, updateReadingHistory, notificationSettings, expoToken, updateNotificationOnboard, notificationOnboard } = React.useContext(UserContext);
const { user, accounts, viewers, cards, lists, updateUser, updateLanguage, updatePickupLocations, updateLinkedAccounts, updateLists, updateSavedEvents, updateLibraryCards, updateLinkedViewerAccounts, updateReadingHistory, notificationSettings, expoToken, updateNotificationOnboard, notificationOnboard, notificationHistory, updateNotificationHistory } = React.useContext(UserContext);
const { library, catalogStatus, updateCatalogStatus } = React.useContext(LibrarySystemContext);
const [notifications, setNotifications] = React.useState([]);
const [messages, setILSMessages] = React.useState([]);
Expand Down Expand Up @@ -173,6 +173,15 @@ export const DrawerContent = () => {
placeholderData: [],
});

useQuery(['notification_history', user.id, library.baseUrl, language], () => fetchNotificationHistory(1, 20, false, library.baseUrl, language), {
initialData: notificationHistory,
refetchInterval: 60 * 1000 * 5,
refetchIntervalInBackground: true,
onSuccess: (data) => {
updateNotificationHistory(data);
},
});

useQuery(['pickup_locations', library.baseUrl, language], () => getPickupLocations(library.baseUrl), {
refetchInterval: 60 * 1000 * 30,
refetchIntervalInBackground: true,
Expand Down Expand Up @@ -398,6 +407,7 @@ export const DrawerContent = () => {
<SavedSearches />
<ReadingHistory />
<Fines />
<NotificationHistory />
<Events />
</VStack>

Expand Down Expand Up @@ -726,6 +736,29 @@ const UserProfile = () => {
);
};

const NotificationHistory = () => {
const { library } = React.useContext(LibrarySystemContext);
const { language } = React.useContext(LanguageContext);

if (library.displayIlsInbox === '1' || library.displayIlsInbox === 1 || library.displayIlsInbox === true) {
return (
<Pressable
px="2"
py="3"
onPress={() => {
navigateStack('AccountScreenTab', 'MyNotificationHistory', {
hasPendingChanges: false,
});
}}>
<HStack space="1" alignItems="center">
<Icon as={MaterialIcons} name="chevron-right" size="7" />
<Text fontWeight="500">{getTermFromDictionary(language, 'notification_history')}</Text>
</HStack>
</Pressable>
);
}
};

const LinkedAccounts = () => {
const { user } = React.useContext(UserContext);
const { library } = React.useContext(LibrarySystemContext);
Expand Down
41 changes: 41 additions & 0 deletions code/aspen_app/src/navigations/stack/AccountStackNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { MyCheckouts } from '../../screens/MyAccount/CheckedOutTitles/MyCheckout
import { MyEvents } from '../../screens/MyAccount/Events/Events';
import { MyList } from '../../screens/MyAccount/Lists/MyList';
import { MyLists } from '../../screens/MyAccount/Lists/MyLists';
import { MyNotificationHistoryMessage } from '../../screens/MyAccount/NotificationHistory/NotificationHistoryMessage';
import { MyNotificationHistory } from '../../screens/MyAccount/NotificationHistory/NotificationHistory';
import { MyProfile } from '../../screens/MyAccount/Profile/MyProfile';
import { MyReadingHistory } from '../../screens/MyAccount/ReadingHistory/ReadingHistory';
import { LoadSavedSearch } from '../../screens/MyAccount/SavedSearches/LoadSavedSearch';
Expand Down Expand Up @@ -187,6 +189,21 @@ const AccountStackNavigator = () => {
})}
/>
</Stack.Group>
<Stack.Screen
name="MyNotificationHistory"
component={MyNotificationHistory}
options={{
title: getTermFromDictionary(language, 'my_notification_history'),
}}
/>
<Stack.Screen
name="MyNotificationHistoryMessageModal"
component={MyNotificationHistoryMessageModal}
options={{
headerShown: false,
presentation: 'modal',
}}
/>
<Stack.Screen name="LoadSavedSearch" component={LoadSavedSearch} options={({ route }) => ({ title: route.params.name })} />
<Stack.Screen
name="CopyDetails"
Expand Down Expand Up @@ -265,4 +282,28 @@ export const PalaceProjectInstructionsModal = () => {
);
};

const MyNotificationHistoryMessageStack = createNativeStackNavigator();
export const MyNotificationHistoryMessageModal = () => {
const { language } = React.useContext(LanguageContext);
return (
<MyNotificationHistoryMessageStack.Navigator
id="MyNotificationHistoryMessageStack"
screenOptions={({ navigation, route }) => ({
headerShown: false,
animationTypeForReplace: 'push',
gestureEnabled: false,
})}>
<MyNotificationHistoryMessageStack.Screen
name="MyNotificationHistoryMessage"
component={MyNotificationHistoryMessage}
options={{
title: getTermFromDictionary(language, 'my_message'),
headerShown: true,
presentation: 'card',
}}
/>
</MyNotificationHistoryMessageStack.Navigator>
);
};

export default AccountStackNavigator;
43 changes: 39 additions & 4 deletions code/aspen_app/src/screens/Auth/Loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { createGlueTheme } from '../../themes/theme';
import { getLanguageDisplayName, getTermFromDictionary, getTranslatedTermsForUserPreferredLanguage, translationsLibrary } from '../../translations/TranslationService';
import { getCatalogStatus, getLibraryInfo, getLibraryLanguages, getLibraryLinks, getSystemMessages } from '../../util/api/library';
import { getLocationInfo, getSelfCheckSettings } from '../../util/api/location';
import { getAppPreferencesForUser, getLinkedAccounts, refreshProfile } from '../../util/api/user';
import { fetchNotificationHistory, getAppPreferencesForUser, getLinkedAccounts, refreshProfile } from '../../util/api/user';
import { GLOBALS } from '../../util/globals';
import { LIBRARY, reloadBrowseCategories } from '../../util/loadLibrary';
import { getBrowseCategoryListForUser, PATRON } from '../../util/loadPatron';
Expand Down Expand Up @@ -43,7 +43,7 @@ export const LoadingScreen = () => {
const [incomingUrl, setIncomingUrl] = React.useState('');
const [hasIncomingUrlChanged, setIncomingUrlChanged] = React.useState(false);

const { user, updateUser, accounts, updateLinkedAccounts, cards, updateLibraryCards, updateAppPreferences } = React.useContext(UserContext);
const { user, updateUser, accounts, updateLinkedAccounts, cards, updateLibraryCards, updateAppPreferences, notificationHistory, updateNotificationHistory, updateInbox } = React.useContext(UserContext);
const { library, updateLibrary, updateMenu, updateCatalogStatus, catalogStatus, catalogStatusMessage } = React.useContext(LibrarySystemContext);
const { location, updateLocation, updateScope, updateEnableSelfCheck, updateSelfCheckSettings } = React.useContext(LibraryBranchContext);
const { category, updateBrowseCategories, updateBrowseCategoryList, updateMaxCategories } = React.useContext(BrowseCategoryContext);
Expand Down Expand Up @@ -243,6 +243,15 @@ export const LoadingScreen = () => {
},
});

const { status: notificationHistoryQueryStatus, data: notificationHistoryQuery } = useQuery(['notification_history'], () => fetchNotificationHistory(1, 20, true, library.baseUrl, 'en'), {
enabled: hasError === false && !!appPreferencesQuery,
onSuccess: (data) => {
updateNotificationHistory(data);
updateInbox(data?.inbox ?? []);
setIsReloading(false);
},
});

if (hasError) {
return <ForceLogout />;
}
Expand All @@ -252,7 +261,20 @@ export const LoadingScreen = () => {
return <CatalogOffline />;
}

if ((isReloading && librarySystemQueryStatus === 'loading') || catalogStatusQueryStatus === 'loading' || userQueryStatus === 'loading' || browseCategoryQueryStatus === 'loading' || browseCategoryListQueryStatus === 'loading' || languagesQueryStatus === 'loading' || libraryBranchQueryStatus === 'loading' || linkedAccountQueryStatus === 'loading' || libraryCardsQueryStatus === 'loading' || systemMessagesQueryStatus === 'loading' || appPreferencesQueryStatus === 'loading') {
if (
(isReloading && librarySystemQueryStatus === 'loading') ||
catalogStatusQueryStatus === 'loading' ||
userQueryStatus === 'loading' ||
browseCategoryQueryStatus === 'loading' ||
browseCategoryListQueryStatus === 'loading' ||
languagesQueryStatus === 'loading' ||
libraryBranchQueryStatus === 'loading' ||
linkedAccountQueryStatus === 'loading' ||
libraryCardsQueryStatus === 'loading' ||
systemMessagesQueryStatus === 'loading' ||
appPreferencesQueryStatus === 'loading' ||
notificationHistoryQueryStatus === 'loading'
) {
return (
<Center flex={1} px="3" w="100%">
<Box w="90%" maxW="400">
Expand All @@ -267,7 +289,20 @@ export const LoadingScreen = () => {
);
}

if ((!isReloading && librarySystemQueryStatus === 'success') || catalogStatusQueryStatus === 'success' || userQueryStatus === 'success' || browseCategoryQueryStatus === 'success' || browseCategoryListQueryStatus === 'success' || languagesQueryStatus === 'success' || libraryBranchQueryStatus === 'success' || linkedAccountQueryStatus === 'success' || libraryCardsQueryStatus === 'success' || systemMessagesQueryStatus === 'success' || appPreferencesQueryStatus === 'success') {
if (
(!isReloading && librarySystemQueryStatus === 'success') ||
catalogStatusQueryStatus === 'success' ||
userQueryStatus === 'success' ||
browseCategoryQueryStatus === 'success' ||
browseCategoryListQueryStatus === 'success' ||
languagesQueryStatus === 'success' ||
libraryBranchQueryStatus === 'success' ||
linkedAccountQueryStatus === 'success' ||
libraryCardsQueryStatus === 'success' ||
systemMessagesQueryStatus === 'success' ||
appPreferencesQueryStatus === 'success' ||
notificationHistoryQueryStatus === 'success'
) {
if (hasIncomingUrlChanged) {
let url = decodeURIComponent(incomingUrl).replace(/\+/g, ' ');
url = url.replace('aspen-lida://', prefix);
Expand Down
Loading

0 comments on commit 317e983

Please sign in to comment.