-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧹 Post-Migration Code Cleanup #1124
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
31d472e
unify function declarations: `const` vs `function`
JGreenlee adc6620
use 'const' and 'let' instead of 'var'
JGreenlee 0a8ed76
cleanup all console/log statements
JGreenlee 03fc69a
Merge branch 'master' of https://github.com/e-mission/e-mission-phone…
JGreenlee a26d039
use PascalCase for all type defs
JGreenlee 069a72e
use LocalDt in MetricsTypes
JGreenlee 633db15
use 'i18n.resolvedLanguage', not 'language'
JGreenlee 125d009
LabelTab: guard clause for pipelineRange, both start_ts and end_ts
JGreenlee 2453e9a
use Boolean() instead of !!
JGreenlee c483322
use AppConfig type def on the useAppConfig hook and in inputMatcher
JGreenlee a4eb833
remove 'ch' unit from MetricsDateSelect
JGreenlee 260f213
bump 'react-native-paper' to ^5.11.0
JGreenlee 1ed9e57
use the new Icon component from RN Paper 5.11
JGreenlee a717560
in useAppConfig, check config contents safely
JGreenlee ed49146
AddedNotesList: adjust UI
JGreenlee b076910
EnketoModal: allow appConfig to be initially null
JGreenlee 8101388
use theme colors for logout button
JGreenlee 8047221
fix OverallTripDescriptives not showing for multimodal unlabeled trips
JGreenlee 72608de
make <NavBar> a reusable component
JGreenlee 09a0408
aria: make NavBar + NavBarButton taller
JGreenlee d647f33
add AlertManager for global alerts
JGreenlee 76f4d5d
remove weird comma
JGreenlee c6a9777
move AlertBar to /components
JGreenlee 9592107
revert "remove weird comma"
JGreenlee b573e06
make push notifications warning an AlertBar
JGreenlee 524eb71
make Log Out button a NavBarButton; tweak NavBarButton
JGreenlee 5f8bb77
explanation comment in dynamicStyleSheet.d.ts
JGreenlee f9c3c57
AddedNotesList: safer guard clauses in deleteEntry
JGreenlee 9178685
aria: use 'touch' style for Enketo forms
JGreenlee 9174545
fix inputMatcher logging test
JGreenlee 2bf2e3e
fix uploadService arrow functions 'this'
JGreenlee 0ce1e7d
add "inverse" colors to appTheme for AlertBars
JGreenlee 658f00f
finish adding typings for LabelTabContext
JGreenlee 0e50c8b
simplify alert creation in ProfileSettings
JGreenlee 2796702
SettingRow: remove unused variable 'descriptionText'
JGreenlee b62861e
use blue instead of orange for enketo surveys
JGreenlee 9062055
UI touch up on the EnketoModal footer
JGreenlee 14f72de
Merge branch 'master' into code-cleanup-jan2024
JGreenlee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* Provides a global context for alerts to show as SnackBars ('toasts') at the bottom of the screen. | ||
Alerts can be added to the queue from anywhere by calling AlertManager.addMessage. */ | ||
|
||
import React, { useState, useEffect } from 'react'; | ||
import { Snackbar } from 'react-native-paper'; | ||
import { Modal } from 'react-native'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { ParseKeys } from 'i18next'; | ||
|
||
type AlertMessage = { | ||
msgKey?: ParseKeys<'translation'>; | ||
text?: string; | ||
duration?: number; | ||
}; | ||
|
||
// public static AlertManager that can add messages from a global context | ||
export class AlertManager { | ||
private static listener?: (msg: AlertMessage) => void; | ||
static setListener(listener?: (msg: AlertMessage) => void) { | ||
AlertManager.listener = listener; | ||
} | ||
static addMessage(msg: AlertMessage) { | ||
AlertManager.listener?.(msg); | ||
} | ||
} | ||
|
||
const AlertBar = () => { | ||
const { t } = useTranslation(); | ||
const [messages, setMessages] = useState<AlertMessage[]>([]); | ||
const onDismissSnackBar = () => setMessages(messages.slice(1)); | ||
|
||
// on init, attach a listener to AlertManager so messages can be added from a global context | ||
useEffect(() => { | ||
AlertManager.setListener((msg) => { | ||
setMessages([...messages, msg]); | ||
}); | ||
return () => AlertManager.setListener(undefined); | ||
}, []); | ||
|
||
if (!messages.length) return null; | ||
const { msgKey, text } = messages[0]; | ||
const alertText = [msgKey && t(msgKey), text].filter((x) => x).join(' '); | ||
return ( | ||
<Modal visible={true} onDismiss={onDismissSnackBar} transparent={true}> | ||
<Snackbar | ||
visible={true} | ||
onDismiss={onDismissSnackBar} | ||
duration={messages[0].duration} | ||
action={{ | ||
label: t('join.close'), | ||
onPress: onDismissSnackBar, | ||
}}> | ||
{alertText} | ||
</Snackbar> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default AlertBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not going to hold up the release for this, but it looks like we need to add some additional tests for this functionality. For example, there is no test for
setListener
oraddMessage
(or that is what `codecov tells me)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO