A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
add new announcement
ammarahm-eda4afe2249b81
diff --git a/apps/mobile/babel.config.js b/apps/mobile/babel.config.jsindex fe43b23c6..db56e779c 100644--- a/apps/mobile/babel.config.js+++ b/apps/mobile/babel.config.js@@ -1,6 +1,6 @@module.exports = {presets: ['module:metro-react-native-babel-preset'],plugins: [- "transform-remove-console"+ // "transform-remove-console"]};diff --git a/apps/mobile/patches/react-native-actions-sheet+0.4.9.patch b/apps/mobile/patches/react-native-actions-sheet+0.4.9.patchindex f13b3802d..7d0d67dff 100644--- a/apps/mobile/patches/react-native-actions-sheet+0.4.9.patch+++ b/apps/mobile/patches/react-native-actions-sheet+0.4.9.patch@@ -1,5 +1,5 @@diff --git a/node_modules/react-native-actions-sheet/src/index.js b/node_modules/react-native-actions-sheet/src/index.js-index dfa8fad..0ada3ca 100644+index dfa8fad..d243c06 100644--- a/node_modules/react-native-actions-sheet/src/index.js+++ b/node_modules/react-native-actions-sheet/src/index.js@@ -72,7 +72,7 @@ export default class ActionSheet extends Component {@@ -37,7 +37,18 @@ index dfa8fad..0ada3ca 100644if (this.isRecoiling) return;if (this.prevScroll < verticalOffset) {-@@ -330,7 +329,7 @@ export default class ActionSheet extends Component {+@@ -321,16 +320,17 @@ export default class ActionSheet extends Component {+ };++ updateActionSheetPosition(scrollPosition) {+- if (!this.props.drawUnderStatusBar) return;+ if (scrollPosition > this.state.deviceHeight) {++ if (!this.props.drawUnderStatusBar) return;+ this.indicatorTranslateY.setValue(0);+ } else {++ console.log(this.state.paddingTop);+ this.indicatorTranslateY.setValue(-this.state.paddingTop);+ }}_returnToPrevScrollPosition(height) {@@ -46,7 +57,7 @@ index dfa8fad..0ada3ca 100644let scrollOffset =height * this.currentOffsetFromBottom +correction +-@@ -380,7 +379,7 @@ export default class ActionSheet extends Component {+@@ -380,7 +380,7 @@ export default class ActionSheet extends Component {this.targetId = event.nativeEvent.target;this.offsetY = event.nativeEvent.contentOffset.y;@@ -55,10 +66,11 @@ index dfa8fad..0ada3ca 100644let distanceFromTop = this.actionSheetHeight + correction - this.offsetY;if (distanceFromTop < 3) {-@@ -396,15 +395,6 @@ export default class ActionSheet extends Component {+@@ -395,21 +395,13 @@ export default class ActionSheet extends Component {+ }}if (this.actionSheetHeight >= this.state.deviceHeight) {- if (!this.props.drawUnderStatusBar) return;+- if (!this.props.drawUnderStatusBar) return;- /* if (- distanceFromTop < StatusBar.currentHeight &&- Platform.OS === "android" &&@@ -69,18 +81,30 @@ index dfa8fad..0ada3ca 100644- );- } */if (distanceFromTop < this.state.paddingTop) {++ if (!this.props.drawUnderStatusBar) return;this.indicatorTranslateY.setValue(-this.state.paddingTop + (this.state.paddingTop - distanceFromTop)-@@ -541,7 +531,7 @@ export default class ActionSheet extends Component {+ );+ } else {++ console.log('setting',this.state.paddingTop)+ this.indicatorTranslateY.setValue(-this.state.paddingTop);+ }+ }+@@ -541,10 +533,11 @@ export default class ActionSheet extends Component {let event = { ..._event };let safeMarginFromTop = 0;-- if (!this.props.drawUnderStatusBar) {-+ if (this.props.drawUnderStatusBar) {++ let measuredPadding = Platform.OS === "ios" ? await this.measure() : StatusBar.currentHeight;+ if (!this.props.drawUnderStatusBar) {if (Platform.OS === "android" && !this.props.statusBarTranslucent) return;- safeMarginFromTop =- Platform.OS === "ios" ? await this.measure() : StatusBar.currentHeight;-@@ -562,16 +552,13 @@ export default class ActionSheet extends Component {+- safeMarginFromTop =+- Platform.OS === "ios" ? await this.measure() : StatusBar.currentHeight;++ safeMarginFromTop = measuredPadding;++ this.indicatorTranslateY.setValue(-measuredPadding)+ }++ let height = event.nativeEvent.layout.height - safeMarginFromTop;+@@ -562,16 +555,13 @@ export default class ActionSheet extends Component {deviceHeight: height,deviceWidth: width,portrait: height > width,@@ -88,7 +112,7 @@ index dfa8fad..0ada3ca 100644- Platform.OS === "android"- ? StatusBar.currentHeight- : await this.measure(),-+ paddingTop:safeMarginFromTop,++ paddingTop:measuredPadding,});};@@ -99,7 +123,7 @@ index dfa8fad..0ada3ca 100644let scrollPosition = this.props.gestureEnabled? this.actionSheetHeight * this.props.initialOffsetFromBottom +correction +-@@ -626,7 +613,7 @@ export default class ActionSheet extends Component {+@@ -626,7 +616,7 @@ export default class ActionSheet extends Component {<SafeAreaView ref={this.safeAreaViewRef} style={styles.safearea}><View /></SafeAreaView>diff --git a/apps/mobile/src/components/SimpleList/announcement.js b/apps/mobile/src/components/SimpleList/announcement.jsindex b5475c2f7..e8a990b3d 100644--- a/apps/mobile/src/components/SimpleList/announcement.js+++ b/apps/mobile/src/components/SimpleList/announcement.js@@ -17,10 +17,10 @@ export const Announcement = () => {const announcements = useMessageStore(state => state.announcements);const remove = useMessageStore(state => state.remove);let announcement = announcements.length > 0 ? announcements[0] : null;-+ console.log(announcements, 'ann');const selectionMode = useSelectionStore(state => state.selectionMode);- return announcement || selectionMode ? null : (+ return !announcement || selectionMode ? null : (<Viewstyle={{backgroundColor: colors.bg,@@ -83,30 +83,42 @@ export const Announcement = () => {<Paragraph color={colors.pri}>{announcement.description}</Paragraph>)}<Seperator />-- {announcement?.cta && (- <Button- type="accent"- title={announcement.cta.text}- fontSize={SIZE.md}- onPress={async () => {- if (announcement.cta.type === 'link') {- try {- await openLinkInBrowser(- announcement.cta.action,- state.colors,- );- } catch (e) {}- } else if (announcement.cta.type === 'promo') {- eSendEvent(eOpenPremiumDialog, {- promoCode: announcement.cta.action,- text: announcement.cta.text,- });- }- }}- width="100%"- />- )}+ <View+ style={{+ flexDirection: 'row',+ justifyContent: 'space-between',+ flexWrap: 'wrap',+ }}>+ {announcement?.callToActions &&+ announcement.callToActions.map((item, index) => (+ <>+ <Button+ type={index === 0 ? 'accent' : 'shade'}+ title={item.title}+ fontSize={SIZE.md}+ onPress={async () => {+ if (announcement.type === 'link') {+ try {+ await openLinkInBrowser(+ announcement.cta.action,+ state.colors,+ );+ } catch (e) {}+ } else if (announcement.type === 'promo') {+ eSendEvent(eOpenPremiumDialog, {+ promoCode: announcement.cta.action,+ text: announcement.cta.text,+ });+ }+ }}+ width="48%"+ style={{+ marginBottom: 10,+ }}+ />+ </>+ ))}+ </View></View></View>);diff --git a/apps/mobile/src/components/SimpleList/header.js b/apps/mobile/src/components/SimpleList/header.jsindex 0cbdd79af..86a102736 100644--- a/apps/mobile/src/components/SimpleList/header.js+++ b/apps/mobile/src/components/SimpleList/header.js@@ -28,9 +28,11 @@ export const Header = React.memo(}) => {const [state] = useTracked();const {colors} = state;- const announcement = useMessageStore(state => state.announcement)+ const announcements = useMessageStore(state => state.announcements)const deviceMode = useSettingStore(state => state.deviceMode)- return announcement && !noAnnouncement ? (+++ return announcements.length > 0 && !noAnnouncement ? (<Announcement color={color || colors.accent} />) : type === 'search' ? null : deviceMode !== "mobile" && !shouldShow ? (<Viewdiff --git a/apps/mobile/src/provider/interfaces.ts b/apps/mobile/src/provider/interfaces.tsindex 2eb095f66..71d36289f 100644--- a/apps/mobile/src/provider/interfaces.ts+++ b/apps/mobile/src/provider/interfaces.ts@@ -91,13 +91,12 @@ export interface SettingStore extends State {setDimensions: (dimensions: Dimensions) => void}--export interface MenuStore extends State {menuPins: object[],colorNotes: object[],setMenuPins: () => void,setColorNotes: () => void+ clearAll: () => void}@@ -125,8 +124,6 @@ export interface SelectionStore extends State {clearSelection: () => void,}--export type Message = {visible: booleanmessage: string | null@@ -137,15 +134,21 @@ export type Message = {}export type Action = {- type:string- title:string- action:string+ type: string+ platforms: string[]+ title: string+ data: string}export type Announcement = {title: stringdescription: string- ctas:Action[]+ id: string+ callToActions: Action[]+ timestamp: number+ platforms: string[]+ isActive: boolean+ userTypes: string[]}export interface MessageStore extends State {diff --git a/apps/mobile/src/provider/stores.ts b/apps/mobile/src/provider/stores.tsindex 007d82c76..0f62fe55f 100644--- a/apps/mobile/src/provider/stores.ts+++ b/apps/mobile/src/provider/stores.ts@@ -21,6 +21,7 @@ import {EditorStore,FavoriteStore,UserStore,+ Announcement,} from './interfaces';@@ -181,6 +182,7 @@ export const useMenuStore = create<MenuStore>((set, get) => ({colorNotes: [],setMenuPins: () => set({ menuPins: db.settings.pins }),setColorNotes: () => set({ colorNotes: db.colors.all }),+ clearAll: () => set({ menuPins: [], colorNotes: [] })}));export const useEditorStore = create<EditorStore>((set, get) => ({@@ -254,17 +256,12 @@ export const useMessageStore = create<MessageStore>((set, get) => ({set({ announcements: copy });},setAnnouncement: async function () {- let announcements = [];+ let announcements: Announcement[] = [];try {- let announcement = await db.announcement()- let shouldShow = await shouldShowAnnouncement(announcement)- if (- shouldShow- ) {+ announcements = await db.announcements()+ if (!announcements) {announcements = [];- return;}- set({ announcements: announcement })} catch (e) {set({ announcements: [] })} finally {@@ -300,10 +297,9 @@ export function clearAllStores() {useTagStore.getState().clearTags();useFavoriteStore.getState().clearFavorites();useNoteStore.getState().clearNotes();+ useMenuStore.getState().clearAll();}--export const allowedPlatforms = ['all', 'mobile', Platform.OS];async function shouldShowAnnouncement(announcement) {diff --git a/apps/mobile/src/services/Sync.js b/apps/mobile/src/services/Sync.jsindex f3287654b..0197eaef9 100644--- a/apps/mobile/src/services/Sync.js+++ b/apps/mobile/src/services/Sync.js@@ -29,6 +29,7 @@ const run = async (context = 'global', forced) => {context: context,});} catch (e) {+ console.log(e);if (e.message === 'You need to login to sync.') {ToastEvent.show({heading: 'Enable sync',