Skip to content
This repository has been archived by the owner on Feb 8, 2025. It is now read-only.

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
Signed-off-by: nuclearfog <hatespirit666@gmail.com>
  • Loading branch information
nuclearfog committed Aug 29, 2021
1 parent e8618cf commit 2dbdd88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.nuclearfog.twidda.backend.model.Relation;
import org.nuclearfog.twidda.backend.model.User;
import org.nuclearfog.twidda.database.AppDatabase;
import org.nuclearfog.twidda.database.ExcludeDatabase;

import java.lang.ref.WeakReference;

Expand Down Expand Up @@ -61,7 +60,6 @@ public enum Action {
private EngineException twException;
private WeakReference<UserProfile> callback;
private TwitterEngine mTwitter;
private ExcludeDatabase excludeDb;
private AppDatabase db;
private long userId;

Expand All @@ -73,7 +71,6 @@ public UserAction(UserProfile callback, long userId) {
super();
this.callback = new WeakReference<>(callback);
mTwitter = TwitterEngine.getInstance(callback);
excludeDb = ExcludeDatabase.getInstance(callback);
db = new AppDatabase(callback);
this.userId = userId;
}
Expand Down Expand Up @@ -120,28 +117,24 @@ protected Relation doInBackground(Action[] action) {
user = mTwitter.blockUser(userId);
publishProgress(user);
db.muteUser(userId, true);
excludeDb.addUser(userId);
break;

case ACTION_UNBLOCK:
user = mTwitter.unblockUser(userId);
publishProgress(user);
db.muteUser(userId, false);
excludeDb.removeUser(userId);
break;

case ACTION_MUTE:
user = mTwitter.muteUser(userId);
publishProgress(user);
db.muteUser(userId, true);
excludeDb.addUser(userId);
break;

case ACTION_UNMUTE:
user = mTwitter.unmuteUser(userId);
publishProgress(user);
db.muteUser(userId, false);
excludeDb.removeUser(userId);
break;
}
return mTwitter.getConnection(userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ public void blockUser(String name) throws EngineException {
try {
if (!name.startsWith("@"))
name = '@' + name;
twitter.createBlock(name);
twitter4j.User user = twitter.createBlock(name);
excludeDB.addUser(user.getId());
} catch (Exception err) {
throw new EngineException(err);
}
Expand All @@ -513,7 +514,9 @@ public void blockUser(String name) throws EngineException {
*/
public User blockUser(long UserID) throws EngineException {
try {
return new User(twitter.createBlock(UserID), twitter.getId());
twitter4j.User user = twitter.createBlock(UserID);
excludeDB.addUser(UserID);
return new User(user, twitter.getId());
} catch (Exception err) {
throw new EngineException(err);
}
Expand All @@ -528,7 +531,9 @@ public User blockUser(long UserID) throws EngineException {
*/
public User unblockUser(long UserID) throws EngineException {
try {
return new User(twitter.destroyBlock(UserID), twitter.getId());
twitter4j.User user = twitter.destroyBlock(UserID);
excludeDB.removeUser(UserID);
return new User(user, twitter.getId());
} catch (Exception err) {
throw new EngineException(err);
}
Expand All @@ -544,7 +549,8 @@ public void muteUser(String name) throws EngineException {
try {
if (!name.startsWith("@"))
name = '@' + name;
twitter.createMute(name);
twitter4j.User user = twitter.createMute(name);
excludeDB.addUser(user.getId());
} catch (Exception err) {
throw new EngineException(err);
}
Expand All @@ -559,7 +565,9 @@ public void muteUser(String name) throws EngineException {
*/
public User muteUser(long UserID) throws EngineException {
try {
return new User(twitter.createMute(UserID), twitter.getId());
twitter4j.User user = twitter.createMute(UserID);
excludeDB.addUser(user.getId());
return new User(user, twitter.getId());
} catch (Exception err) {
throw new EngineException(err);
}
Expand All @@ -574,7 +582,9 @@ public User muteUser(long UserID) throws EngineException {
*/
public User unmuteUser(long UserID) throws EngineException {
try {
return new User(twitter.destroyMute(UserID), twitter.getId());
twitter4j.User user = twitter.destroyMute(UserID);
excludeDB.removeUser(user.getId());
return new User(user, twitter.getId());
} catch (Exception err) {
throw new EngineException(err);
}
Expand Down

0 comments on commit 2dbdd88

Please sign in to comment.