user bin listing
This commit is contained in:
@@ -32,7 +32,7 @@ const new_bin_handler = function(state, dispatch){
|
||||
const id = nanoid();
|
||||
// change browser location in address bar:
|
||||
window.history.pushState(null,'','#'+id);
|
||||
dispatch('new-bin', {id});
|
||||
dispatch('new-bin', {id, name:id});
|
||||
};
|
||||
const username_change_handler = function(state, dispatch, e){
|
||||
dispatch('update-username', e.target.value);
|
||||
@@ -45,7 +45,8 @@ const login_request_handler = function(state, dispatch, e){
|
||||
api.post('/login', {username: state.login.username, password: state.login.password})
|
||||
.then(res=>{
|
||||
if(res.success===true){
|
||||
dispatch('login-succeeded', res.user, res.session_id);
|
||||
dispatch('login-succeeded', {user:res.user, session_id:res.session_id});
|
||||
dispatch('user-bin-list-loaded', res.bins);
|
||||
}
|
||||
else{
|
||||
dispatch('login-failed');
|
||||
@@ -54,8 +55,9 @@ const login_request_handler = function(state, dispatch, e){
|
||||
.catch(e=>{ dispatch('login-failed'); });
|
||||
};
|
||||
const logout_request_handler = function(state, dispatch, e){
|
||||
api.post('/logout', {});
|
||||
// we dispatch after the API call because the logout action clears the session_id, which is needed to logout
|
||||
dispatch('logout-requested');
|
||||
api.post('/logout', {session_id: state.login.session_id});
|
||||
};
|
||||
const bin_name_editing_toggle_button_handler = function(state, dispatch){
|
||||
dispatch('update-bin-name-editing', !state.is_editing_bin_name);
|
||||
@@ -64,6 +66,7 @@ const bin_name_change_handler = function(state, dispatch, e){
|
||||
dispatch('update-bin-name', e.target.value);
|
||||
};
|
||||
const bin_name_commit_handler = function(state, dispatch){
|
||||
api.post('/bin-rename', {bin_id:state.bin.id, name:state.temp_bin_name});
|
||||
dispatch('commit-bin-name');
|
||||
};
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import api from '../api.js';
|
||||
|
||||
const load_bin_handler = function(state, dispatch, bin_id){
|
||||
/*
|
||||
api.post('/load-bin', {id: bin_id})
|
||||
const initial_load_bin_handler = function(state, dispatch, bin_id){
|
||||
api.post('/load-bin', {bin_id})
|
||||
.then(res => {
|
||||
dispatch('bin-loaded', {bin:res.bin, _notes:res.notes});
|
||||
dispatch('bin-loaded', res.bin);
|
||||
});
|
||||
*/
|
||||
api.post('/load-notes', {bin_id})
|
||||
.then(res => {
|
||||
dispatch('notes-loaded', res.notes);
|
||||
@@ -22,6 +20,10 @@ const hash_change_handler = function(state, dispatch, e){
|
||||
}
|
||||
else{
|
||||
dispatch('bin-requested', bin_id);
|
||||
api.post('/load-bin', {bin_id})
|
||||
.then(res=>{
|
||||
dispatch('bin-loaded', res.bin);
|
||||
});
|
||||
api.post('/load-notes', {bin_id})
|
||||
.then(res => {
|
||||
dispatch('notes-loaded', res.notes);
|
||||
@@ -29,4 +31,4 @@ const hash_change_handler = function(state, dispatch, e){
|
||||
}
|
||||
};
|
||||
|
||||
export {load_bin_handler, hash_change_handler};
|
||||
export {initial_load_bin_handler, hash_change_handler};
|
||||
Reference in New Issue
Block a user