Skip to content

Commit

Permalink
Make remaining public methods synchronized.
Browse files Browse the repository at this point in the history
  • Loading branch information
leopoldsedev authored and jmattheis committed Feb 18, 2020
1 parent 48c2806 commit 10b6741
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ public MessageFacade(MessageApi api, ApplicationHolder applicationHolder) {
this.state = new MessageStateHolder();
}

public List<MessageWithImage> get(Integer appId) {
public synchronized List<MessageWithImage> get(Integer appId) {
return combiner.combine(state.state(appId).messages, applicationHolder.get());
}

public void addMessages(List<Message> messages) {
public synchronized void addMessages(List<Message> messages) {
for (Message message : messages) {
state.newMessage(message);
}
}

public List<MessageWithImage> loadMore(Integer appId) {
public synchronized List<MessageWithImage> loadMore(Integer appId) {
MessageState state = this.state.state(appId);
if (state.hasNext || !state.loaded) {
PagedMessages pagedMessages = requester.loadMore(state);
Expand All @@ -37,14 +37,14 @@ public List<MessageWithImage> loadMore(Integer appId) {
return get(appId);
}

public void loadMoreIfNotPresent(Integer appId) {
public synchronized void loadMoreIfNotPresent(Integer appId) {
MessageState state = this.state.state(appId);
if (!state.loaded) {
loadMore(appId);
}
}

public void clear() {
public synchronized void clear() {
this.state.clear();
}

Expand All @@ -70,13 +70,13 @@ public synchronized MessageDeletion undoDeleteLocal() {
return this.state.undoPendingDeletion();
}

public boolean deleteAll(Integer appId) {
public synchronized boolean deleteAll(Integer appId) {
boolean success = this.requester.deleteAll(appId);
this.state.deleteAll(appId);
return success;
}

public boolean canLoadMore(Integer appId) {
public synchronized boolean canLoadMore(Integer appId) {
return state.state(appId).hasNext;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ synchronized MessageState state(Integer appId) {
return state;
}

void deleteAll(Integer appId) {
synchronized void deleteAll(Integer appId) {
clear();
MessageState state = state(appId);
state.loaded = true;
Expand Down Expand Up @@ -115,7 +115,7 @@ synchronized MessageDeletion purgePendingDeletion() {
return result;
}

boolean deletionPending() {
synchronized boolean deletionPending() {
return pendingDeletion != null;
}

Expand Down

0 comments on commit 10b6741

Please sign in to comment.