Refactor things to store information about the current user as data attributes on the <body> tag rather than as <meta> tags. These <meta> tags are now deprecated and will be eventually removed. * Store all of the current user's API attributes as data attributes on the <body> tag. * Add `CurrentUser.data` for getting data from the <body> tag, and use it instead of `Utility.meta`. * Add `CurrentUser.update` for updating the current user's settings. * Fix a bug with the user named "Anonymous" not being able to edit notes.
15 lines
289 B
JavaScript
15 lines
289 B
JavaScript
let CurrentUser = {};
|
|
|
|
CurrentUser.data = function(key) {
|
|
return $("body").data(`user-${key}`);
|
|
};
|
|
|
|
CurrentUser.update = function(settings) {
|
|
return $.ajax(`/users/${CurrentUser.data("id")}.json`, {
|
|
method: "PUT",
|
|
data: { user: settings }
|
|
});
|
|
};
|
|
|
|
export default CurrentUser;
|