mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	unify get_user event via socketio
This commit is contained in:
		@@ -8,19 +8,19 @@ class App {
 | 
			
		||||
    this.socket.on('PATCH', (patch) => {this.onPatch(patch);});
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getUser(userId, backrefs=true, relationships=true) {
 | 
			
		||||
  getUser(userId) {
 | 
			
		||||
    if (userId in this.data.promises.getUser) {
 | 
			
		||||
      return this.data.promises.getUser[userId];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.data.promises.getUser[userId] = new Promise((resolve, reject) => {
 | 
			
		||||
      this.socket.emit('GET /users/<user_id>', userId, backrefs, relationships, (response) => {
 | 
			
		||||
        if (response.status !== 200) {
 | 
			
		||||
          reject(response);
 | 
			
		||||
          return;
 | 
			
		||||
      this.socket.emit('GET /users/<user_id>', userId, (response) => {
 | 
			
		||||
        if (response.status === 200) {
 | 
			
		||||
          this.data.users[userId] = response.body;
 | 
			
		||||
          resolve(this.data.users[userId]);
 | 
			
		||||
        } else {
 | 
			
		||||
          reject(`[${response.status}] ${response.statusText}`);
 | 
			
		||||
        }
 | 
			
		||||
        this.data.users[userId] = response.body;
 | 
			
		||||
        resolve(this.data.users[userId]);
 | 
			
		||||
      });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user