Commit 116f5a01 authored by Thomas's avatar Thomas
Browse files

Fix message that remain in drafts

parent eea7e83f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ public class StatusCache {
     * @return int - 0 if updated 1 if inserted
     * @throws DBException exception with database
     */
    public int insertOrUpdate(StatusCache statusCache, String slug) throws DBException {
    public synchronized int insertOrUpdate(StatusCache statusCache, String slug) throws DBException {
        if (db == null) {
            throw new DBException("db is null. Wrong initialization.");
        }
+19 −14
Original line number Diff line number Diff line
@@ -234,8 +234,11 @@ public class ComposeWorker extends Worker {
                            if (statusReply != null) {
                                in_reply_to_status = statusReply.id;
                                dataPost.statusDraft.state.posts_successfully_sent = i;
                                dataPost.statusDraft.state.posts.get(i).id = statusReply.id;
                                dataPost.statusDraft.state.posts.get(i).in_reply_to_id = statusReply.in_reply_to_id;
                                if (dataPost.statusDraft.state.posts.size() > i + 1) {
                                    dataPost.statusDraft.state.posts.get(i + 1).id = statusReply.id;
                                    dataPost.statusDraft.state.posts.get(i + 1).in_reply_to_id = statusReply.in_reply_to_id;
                                }

                                try {
                                    new StatusDraft(context.getApplicationContext()).updatePostState(dataPost.statusDraft);
                                } catch (DBException e) {
@@ -284,23 +287,15 @@ public class ComposeWorker extends Worker {
                            if (statusReply != null) {
                                in_reply_to_status = statusReply.id;
                                dataPost.statusDraft.state.posts_successfully_sent = i;
                                dataPost.statusDraft.state.posts.get(i).id = statusReply.id;
                                dataPost.statusDraft.state.posts.get(i).in_reply_to_id = statusReply.params.in_reply_to_id;
                                try {
                                    new StatusDraft(context.getApplicationContext()).updatePostState(dataPost.statusDraft);
                                } catch (DBException e) {
                                    e.printStackTrace();
                                if (dataPost.statusDraft.state.posts.size() > i + 1) {
                                    dataPost.statusDraft.state.posts.get(i + 1).id = statusReply.id;
                                    dataPost.statusDraft.state.posts.get(i + 1).in_reply_to_id = statusReply.params.in_reply_to_id;
                                }
                                if (i >= dataPost.statusDraft.statusDraftList.size()) {
                                try {
                                        new StatusDraft(context).removeDraft(dataPost.statusDraft);
                                    new StatusDraft(context.getApplicationContext()).updatePostState(dataPost.statusDraft);
                                } catch (DBException e) {
                                    e.printStackTrace();
                                }
                                    if (dataPost.service != null) {
                                        dataPost.service.stopSelf();
                                    }
                                }
                            }
                        }
                    } catch (IOException e) {
@@ -312,6 +307,16 @@ public class ComposeWorker extends Worker {
                if (dataPost.messageSent > dataPost.messageToSend) {
                    dataPost.messageSent = dataPost.messageToSend;
                }
                if (i >= (statuses.size() - 1)) {
                    try {
                        new StatusDraft(context).removeDraft(dataPost.statusDraft);
                    } catch (DBException e) {
                        e.printStackTrace();
                    }
                    if (dataPost.service != null) {
                        dataPost.service.stopSelf();
                    }
                }
            }
        }