Default lastUpdated to created; extra error messaging
This commit is contained in:
parent
1369fb0fdb
commit
6aef828f42
|
@ -49,7 +49,7 @@ export const DEFAULT_DICTIONARY = {
|
||||||
isComplete: false,
|
isComplete: false,
|
||||||
isPublic: false,
|
isPublic: false,
|
||||||
},
|
},
|
||||||
lastUpdated: null,
|
lastUpdated: getTimestampInSeconds(),
|
||||||
createdOn: getTimestampInSeconds(),
|
createdOn: getTimestampInSeconds(),
|
||||||
version: MIGRATE_VERSION,
|
version: MIGRATE_VERSION,
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,7 +91,7 @@ VALUES ($new_id, ?, ?, ?, ?)";
|
||||||
'name' => $result['name'],
|
'name' => $result['name'],
|
||||||
'specification' => $result['specification'],
|
'specification' => $result['specification'],
|
||||||
'description' => $result['description'],
|
'description' => $result['description'],
|
||||||
'partsOfSpeech' => $partsOfSpeech,
|
'partsOfSpeech' => explode(',', $partsOfSpeech),
|
||||||
'details' => array(
|
'details' => array(
|
||||||
'phonology' => array(
|
'phonology' => array(
|
||||||
'consonants' => $result['consonants'] !== '' ? explode(' ', $result['consonants']) : array(),
|
'consonants' => $result['consonants'] !== '' ? explode(' ', $result['consonants']) : array(),
|
||||||
|
@ -118,7 +118,7 @@ VALUES ($new_id, ?, ?, ?, ?)";
|
||||||
'isComplete' => $result['is_complete'] === '1' ? true : false,
|
'isComplete' => $result['is_complete'] === '1' ? true : false,
|
||||||
'isPublic' => $result['is_public'] === '1' ? true : false,
|
'isPublic' => $result['is_public'] === '1' ? true : false,
|
||||||
),
|
),
|
||||||
'lastUpdated' => is_null($result['last_updated']) ? null : $result['last_updated'],
|
'lastUpdated' => is_null($result['last_updated']) ? $results['created_on'] : $result['last_updated'],
|
||||||
'createdOn' => $result['created_on'],
|
'createdOn' => $result['created_on'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,13 @@ VALUES (?, ?, ?, ?, ?)';
|
||||||
if ($user_data !== false) {
|
if ($user_data !== false) {
|
||||||
$user = $user_data->id;
|
$user = $user_data->id;
|
||||||
$dictionary = $user_data->dictionary;
|
$dictionary = $user_data->dictionary;
|
||||||
return $this->dictionary->setDetails($user, $dictionary, $dictionary_details);
|
$details_updated = $this->dictionary->setDetails($user, $dictionary, $dictionary_details);
|
||||||
|
if ($details_updated === true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return array(
|
||||||
|
'error' => $details_updated,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,13 +222,19 @@ switch ($action) {
|
||||||
if ($token !== false && isset($request['details'])) {
|
if ($token !== false && isset($request['details'])) {
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$update_details_success = $user->updateCurrentDictionaryDetails($token, $request['details']);
|
$update_details_success = $user->updateCurrentDictionaryDetails($token, $request['details']);
|
||||||
if ($update_details_success !== false) {
|
if ($update_details_success === true) {
|
||||||
return Response::json(array(
|
return Response::json(array(
|
||||||
// 'data' => 'Updated successfully',
|
// 'data' => 'Updated successfully',
|
||||||
'data' => $update_details_success,
|
'data' => $update_details_success,
|
||||||
'error' => false,
|
'error' => false,
|
||||||
), 200);
|
), 200);
|
||||||
}
|
}
|
||||||
|
if (isset($update_details_success['error'])) {
|
||||||
|
return Response::json(array(
|
||||||
|
'data' => $update_details_success['error'],
|
||||||
|
'error' => true,
|
||||||
|
), 500);
|
||||||
|
}
|
||||||
return Response::json(array(
|
return Response::json(array(
|
||||||
'data' => 'Could not set dictionary: invalid token',
|
'data' => 'Could not set dictionary: invalid token',
|
||||||
'error' => true,
|
'error' => true,
|
||||||
|
|
Loading…
Reference in New Issue