mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 11:39:17 +00:00
Merge branch 'push' of https://github.com/balzack/databag into push
This commit is contained in:
commit
09827ea056
@ -17,6 +17,7 @@
|
|||||||
821572F657508372661B174B /* Pods_Databag.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B345113B5CABA2FED4B91FCF /* Pods_Databag.framework */; };
|
821572F657508372661B174B /* Pods_Databag.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B345113B5CABA2FED4B91FCF /* Pods_Databag.framework */; };
|
||||||
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */; };
|
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */; };
|
||||||
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; };
|
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; };
|
||||||
|
F0BE99122922C2FB007E89B0 /* avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = F0BE99112922C2FA007E89B0 /* avatar.png */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@ -37,6 +38,7 @@
|
|||||||
B345113B5CABA2FED4B91FCF /* Pods_Databag.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Databag.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
B345113B5CABA2FED4B91FCF /* Pods_Databag.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Databag.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
BB2F792C24A3F905000567C9 /* Expo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Expo.plist; sourceTree = "<group>"; };
|
BB2F792C24A3F905000567C9 /* Expo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Expo.plist; sourceTree = "<group>"; };
|
||||||
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
|
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
|
||||||
|
F0BE99112922C2FA007E89B0 /* avatar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = avatar.png; path = ../images/avatar.png; sourceTree = "<group>"; };
|
||||||
FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-Databag/ExpoModulesProvider.swift"; sourceTree = "<group>"; };
|
FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-Databag/ExpoModulesProvider.swift"; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
@ -55,6 +57,7 @@
|
|||||||
13B07FAE1A68108700A75B9A /* Databag */ = {
|
13B07FAE1A68108700A75B9A /* Databag */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
F0BE99112922C2FA007E89B0 /* avatar.png */,
|
||||||
7B2C51FE2918CC6E000E7B18 /* Databag.entitlements */,
|
7B2C51FE2918CC6E000E7B18 /* Databag.entitlements */,
|
||||||
7B0AD126291073C4002BB72A /* login.png */,
|
7B0AD126291073C4002BB72A /* login.png */,
|
||||||
BB2F792B24A3F905000567C9 /* Supporting */,
|
BB2F792B24A3F905000567C9 /* Supporting */,
|
||||||
@ -209,6 +212,7 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */,
|
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */,
|
||||||
|
F0BE99122922C2FB007E89B0 /* avatar.png in Resources */,
|
||||||
7B0AD127291073C4002BB72A /* login.png in Resources */,
|
7B0AD127291073C4002BB72A /* login.png in Resources */,
|
||||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
|
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
|
||||||
3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */,
|
3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */,
|
||||||
|
7
app/mobile/src/api/setAccountNotifications.js
Normal file
7
app/mobile/src/api/setAccountNotifications.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||||
|
|
||||||
|
export async function setAccountNotifications(server, token, flag) {
|
||||||
|
let res = await fetchWithTimeout(`https://${server}/account/notification?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) })
|
||||||
|
checkResponse(res);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
import { useState, useRef, useContext } from 'react';
|
import { useState, useRef, useContext } from 'react';
|
||||||
import { StoreContext } from 'context/StoreContext';
|
import { StoreContext } from 'context/StoreContext';
|
||||||
import { setAccountSearchable } from 'api/setAccountSearchable';
|
import { setAccountSearchable } from 'api/setAccountSearchable';
|
||||||
|
import { setAccountNotifications } from 'api/setAccountNotifications';
|
||||||
import { getAccountStatus } from 'api/getAccountStatus';
|
import { getAccountStatus } from 'api/getAccountStatus';
|
||||||
import { setAccountLogin } from 'api/setAccountLogin';
|
import { setAccountLogin } from 'api/setAccountLogin';
|
||||||
|
|
||||||
@ -61,6 +62,10 @@ export function useAccountContext() {
|
|||||||
curRevision.current = rev;
|
curRevision.current = rev;
|
||||||
sync();
|
sync();
|
||||||
},
|
},
|
||||||
|
setNotifications: async (flag) => {
|
||||||
|
const { server, appToken } = session.current;
|
||||||
|
await setAccountNotifications(server, appToken, flag);
|
||||||
|
},
|
||||||
setSearchable: async (flag) => {
|
setSearchable: async (flag) => {
|
||||||
const { server, appToken } = session.current;
|
const { server, appToken } = session.current;
|
||||||
await setAccountSearchable(server, appToken, flag);
|
await setAccountSearchable(server, appToken, flag);
|
||||||
|
@ -15,6 +15,19 @@ export function ProfileBody({ navigation }) {
|
|||||||
|
|
||||||
const { state, actions } = useProfileBody();
|
const { state, actions } = useProfileBody();
|
||||||
|
|
||||||
|
const setNotifications = async (notify) => {
|
||||||
|
try {
|
||||||
|
await actions.setNotifications(notify);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
Alert.alert(
|
||||||
|
'Account Update Failed',
|
||||||
|
'Please try again.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const setVisible = async (visible) => {
|
const setVisible = async (visible) => {
|
||||||
try {
|
try {
|
||||||
await actions.setVisible(visible);
|
await actions.setVisible(visible);
|
||||||
@ -124,6 +137,12 @@ export function ProfileBody({ navigation }) {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<Switch style={styles.visibleSwitch} value={state.searchable} onValueChange={setVisible} trackColor={styles.switch}/>
|
<Switch style={styles.visibleSwitch} value={state.searchable} onValueChange={setVisible} trackColor={styles.switch}/>
|
||||||
</View>
|
</View>
|
||||||
|
<View style={styles.notify}>
|
||||||
|
<TouchableOpacity onPress={() => setNotifications(!state.pushEnabled)} activeOpacity={1}>
|
||||||
|
<Text style={styles.notifyText}>Enable Notifications</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<Switch style={styles.visibleSwitch} value={state.pushEnabled} onValueChange={setNotifications} trackColor={styles.switch}/>
|
||||||
|
</View>
|
||||||
<TouchableOpacity style={styles.link} onPress={actions.showLoginEdit}>
|
<TouchableOpacity style={styles.link} onPress={actions.showLoginEdit}>
|
||||||
<Text style={styles.linkText}>Change Login</Text>
|
<Text style={styles.linkText}>Change Login</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
@ -122,6 +122,17 @@ export const styles = StyleSheet.create({
|
|||||||
paddingLeft: 8,
|
paddingLeft: 8,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
},
|
},
|
||||||
|
notify: {
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
paddingTop: 16,
|
||||||
|
},
|
||||||
|
notifyText: {
|
||||||
|
fontSize: 16,
|
||||||
|
color: Colors.text,
|
||||||
|
},
|
||||||
visible: {
|
visible: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
@ -16,6 +16,7 @@ export function useProfileBody() {
|
|||||||
node: null,
|
node: null,
|
||||||
imageSource: null,
|
imageSource: null,
|
||||||
searchable: null,
|
searchable: null,
|
||||||
|
notifications: null,
|
||||||
showDetailEdit: false,
|
showDetailEdit: false,
|
||||||
showLoginEdit: false,
|
showLoginEdit: false,
|
||||||
editName: null,
|
editName: null,
|
||||||
@ -63,7 +64,8 @@ export function useProfileBody() {
|
|||||||
}, [profile]);
|
}, [profile]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateState({ searchable: account.state.status.searchable });
|
const { searchable, pushEnabled } = account.state.status;
|
||||||
|
updateState({ searchable, pushEnabled });
|
||||||
}, [account]);
|
}, [account]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -85,6 +87,10 @@ export function useProfileBody() {
|
|||||||
updateState({ searchable });
|
updateState({ searchable });
|
||||||
await account.actions.setSearchable(searchable);
|
await account.actions.setSearchable(searchable);
|
||||||
},
|
},
|
||||||
|
setNotifications: async (pushEnabled) => {
|
||||||
|
updateState({ pushEnabled });
|
||||||
|
await account.actions.setNotifications(pushEnabled);
|
||||||
|
},
|
||||||
setProfileImage: async (data) => {
|
setProfileImage: async (data) => {
|
||||||
await profile.actions.setProfileImage(data);
|
await profile.actions.setProfileImage(data);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user