better async handling for flag unflag
This commit is contained in:
		
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -224,37 +224,44 @@ export default {
 | 
			
		||||
    },
 | 
			
		||||
    flag({ dispatch, commit, state }, args) {
 | 
			
		||||
      console.log("user flag", args.uuid, args.collid);
 | 
			
		||||
      const params = {
 | 
			
		||||
        flagid: state.flagcolls[args.collid].flag_id,
 | 
			
		||||
        uuid: args.uuid,
 | 
			
		||||
        flagcollid: args.collid
 | 
			
		||||
      };
 | 
			
		||||
      return MA.post(`materio_flag/flag`, params)
 | 
			
		||||
        .then(({ data }) => {
 | 
			
		||||
          console.log("user MA flag", data);
 | 
			
		||||
          dispatch('getUserFlagColls')
 | 
			
		||||
        })
 | 
			
		||||
        .catch(error => {
 | 
			
		||||
          console.warn("Issue USER MA flag", error);
 | 
			
		||||
        });
 | 
			
		||||
      return new Promise((resolve, reject) => {
 | 
			
		||||
        const params = {
 | 
			
		||||
          flagid: state.flagcolls[args.collid].flag_id,
 | 
			
		||||
          uuid: args.uuid,
 | 
			
		||||
          flagcollid: args.collid
 | 
			
		||||
        };
 | 
			
		||||
        return MA.post(`materio_flag/flag`, params)
 | 
			
		||||
          .then(({ data }) => {
 | 
			
		||||
            console.log("user MA flag", data);
 | 
			
		||||
            dispatch('getUserFlagColls').then(() =>{
 | 
			
		||||
              resolve();
 | 
			
		||||
            });
 | 
			
		||||
          })
 | 
			
		||||
          .catch(error => {
 | 
			
		||||
            console.warn("Issue USER MA flag", error);
 | 
			
		||||
          });
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    unFlag({ dispatch, commit, state }, args) {
 | 
			
		||||
      console.log("user unFlag", args.uuid, args.collid);
 | 
			
		||||
      const params = {
 | 
			
		||||
        flagid: state.flagcolls[args.collid].flag_id,
 | 
			
		||||
        uuid: args.uuid,
 | 
			
		||||
        flagcollid: args.collid
 | 
			
		||||
      };
 | 
			
		||||
      return MA.post(`materio_flag/unflag`, params)
 | 
			
		||||
        .then(({ data }) => {
 | 
			
		||||
          console.log("user MA unFlag", data);
 | 
			
		||||
          dispatch('getUserFlagColls')
 | 
			
		||||
        })
 | 
			
		||||
        .catch(error => {
 | 
			
		||||
          console.warn("Issue USER MA unFlag", error);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
      return new Promise((resolve, reject) => {
 | 
			
		||||
        const params = {
 | 
			
		||||
          flagid: state.flagcolls[args.collid].flag_id,
 | 
			
		||||
          uuid: args.uuid,
 | 
			
		||||
          flagcollid: args.collid
 | 
			
		||||
        };
 | 
			
		||||
        return MA.post(`materio_flag/unflag`, params)
 | 
			
		||||
          .then(({ data }) => {
 | 
			
		||||
            console.log("user MA unFlag", data);
 | 
			
		||||
            dispatch('getUserFlagColls').then(() =>{
 | 
			
		||||
              resolve();
 | 
			
		||||
            });
 | 
			
		||||
          })
 | 
			
		||||
          .catch(error => {
 | 
			
		||||
            console.warn("Issue USER MA unFlag", error);
 | 
			
		||||
          });
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    userLogout({ commit, state }) {
 | 
			
		||||
      const credentials = qs.stringify({
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user