Some fixes to handling of task list metadata

pull/14/head
Sam Bosley 12 years ago
parent 8717d6c8b7
commit c7e0b81dd7

@ -18,15 +18,19 @@ import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmInvoker;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.dao.HistoryDao;
import com.todoroo.astrid.dao.RemoteModelDao;
import com.todoroo.astrid.dao.TagMetadataDao;
import com.todoroo.astrid.dao.TaskListMetadataDao;
import com.todoroo.astrid.dao.UserActivityDao;
import com.todoroo.astrid.data.History;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.MetadataApiDao.MetadataCriteria;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.TagMetadata;
import com.todoroo.astrid.data.TaskListMetadata;
import com.todoroo.astrid.data.UserActivity;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.tags.TagService;
@ -258,6 +262,11 @@ public class MakeChanges<TYPE extends RemoteModel> extends ServerToClientMessage
taskToTagTemplate.setValue(TaskToTagMetadata.TASK_UUID, toUuid);
taskToTagTemplate.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
metadataService.update(Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY), TaskToTagMetadata.TASK_UUID.eq(fromUuid)), taskToTagTemplate);
HistoryDao historyDao = PluginServices.getHistoryDao();
History histTemplate = new History();
histTemplate.setValue(History.TARGET_ID, toUuid);
historyDao.update(Criterion.and(History.TABLE_ID.eq(NameMaps.TABLE_ID_TAGS), History.TARGET_ID.eq(oldUuid)), histTemplate);
}
}
@ -345,6 +354,17 @@ public class MakeChanges<TYPE extends RemoteModel> extends ServerToClientMessage
memberMetadataTemplate.setValue(TagMetadata.TAG_UUID, toUuid);
memberMetadataTemplate.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
tagMetadataDao.update(TagMetadata.TAG_UUID.eq(fromUuid), memberMetadataTemplate);
HistoryDao historyDao = PluginServices.getHistoryDao();
History histTemplate = new History();
histTemplate.setValue(History.TARGET_ID, toUuid);
historyDao.update(Criterion.and(History.TABLE_ID.eq(NameMaps.TABLE_ID_TAGS), History.TARGET_ID.eq(oldUuid)), histTemplate);
TaskListMetadataDao taskListMetadataDao = PluginServices.getTaskListMetadataDao();
TaskListMetadata tlm = new TaskListMetadata();
tlm.setValue(TaskListMetadata.TAG_UUID, toUuid);
tlm.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
taskListMetadataDao.update(TaskListMetadata.TAG_UUID.eq(fromUuid), tlm);
}
}

@ -53,10 +53,7 @@ public class SubtasksListFragment extends TaskListFragment {
@Override
public void setUpTaskList() {
if (helper instanceof AstridOrderedListFragmentHelper) {
if (isTodayFilter)
((AstridOrderedListFragmentHelper<String>) helper).setList(SubtasksUpdater.TODAY_TASKS_ORDER);
else if (isInbox)
((AstridOrderedListFragmentHelper<String>) helper).setList(SubtasksUpdater.ACTIVE_TASKS_ORDER);
((AstridOrderedListFragmentHelper<TaskListMetadata>) helper).setList(taskListMetadata);
}
helper.beforeSetUpTaskList(filter);

@ -414,10 +414,19 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
TagData td = getActiveTagData();
String tdId;
if (td == null) {
String filterId = null;
if (isInbox)
taskListMetadata = taskListMetadataDao.fetchByTagId(TaskListMetadata.FILTER_ID_ALL, TaskListMetadata.PROPERTIES);
filterId = TaskListMetadata.FILTER_ID_ALL;
else if (isTodayFilter)
taskListMetadata = taskListMetadataDao.fetchByTagId(TaskListMetadata.FILTER_ID_TODAY, TaskListMetadata.PROPERTIES);
filterId = TaskListMetadata.FILTER_ID_TODAY;
if (!TextUtils.isEmpty(filterId)) {
taskListMetadata = taskListMetadataDao.fetchByTagId(filterId, TaskListMetadata.PROPERTIES);
if (taskListMetadata == null) {
taskListMetadata = new TaskListMetadata();
taskListMetadata.setValue(TaskListMetadata.FILTER, filterId);
taskListMetadataDao.createNew(taskListMetadata);
}
}
} else {
tdId = td.getUuid();
taskListMetadata = taskListMetadataDao.fetchByTagId(td.getUuid(), TaskListMetadata.PROPERTIES);

@ -40,6 +40,7 @@ public class TaskListMetadataDao extends RemoteModelDao<TaskListMetadata> {
public TaskListMetadata fetchByTagId(String tagUuid, Property<?>...properties) {
TodorooCursor<TaskListMetadata> taskListMetadata = query(Query.select(properties).where(Criterion.or(TaskListMetadata.TAG_UUID.eq(tagUuid),
TaskListMetadata.FILTER.eq(tagUuid))));
taskListMetadata.moveToFirst();
return returnFetchResult(taskListMetadata);
}

Loading…
Cancel
Save