-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
65 lines (61 loc) · 1.76 KB
/
utils.js
File metadata and controls
65 lines (61 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { showMessage, hideMessage } from "react-native-flash-message";
import {Alert} from 'react-native';
import { Storage, Auth } from 'aws-amplify';
import {my_i18n} from './styleConst'
export async function login(){
try{
const user = await Auth.signIn('wanghp000@gmail.com', '123456789');
if (user.challengeName === 'NEW_PASSWORD_REQUIRED'){
const loggedUser = await Auth.completeNewPassword(
user, '123456789'
)
};
info = await Auth.currentUserInfo();
showMessage({
message: "Login Success",
description: "Login as "+ info.attributes.email,
type: "success"})
// console.log(info);
}catch{
console.log(err);
}
}
export async function process_upload_json(json_res){
if (json_res.message){
showMessage({
message: my_i18n.t('failed'),
description: json_res.message,
type: "danger"}
)
console.log(json_res)
return null;
}
if (json_res.success){
showMessage({
message: my_i18n.t('success'),
description: my_i18n.t('utils_ds', {song: res_json.download}),
type: "success"})
console.log(res_json.download + " is downloaded to cloud")
}else{
if (json_res.error_code == 1){
Alert.alert(
my_i18n.t('utils_df'),
my_i18n.t('utils_df_mes1', {song: res_json.download})
)
}else if (json_res.error_code == 2){
Alert.alert(
my_i18n.t('utils_df'),
my_i18n.t('utils_df_mes2', {song: res_json.download})
)
}else if (json_res.error_code == 3){
Alert.alert(
my_i18n.t('utils_df'),
my_i18n.t('utils_df_mes3', {song: res_json.download})
)
}
}
}
export function displayTitle(title){
// return title.match(/(.*)(-\w*.mp3$)/)[1]
return title.substring(0, title.length - 16)
}