Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feat offline support refactor#135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
stnguyen90 wants to merge1 commit intofeat-offline-support
base:feat-offline-support
Choose a base branch
Loading
fromfeat-offline-support-refactor

Conversation

stnguyen90
Copy link
Contributor

What does this PR do?

Refactor ClientOfflineMixin and add offline filters

Test Plan

Manual

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read theContributing Guidelines on issues?

Yes

dkbast reacted with eyes emoji
Split out offline DB related operations into separate classes.
@stnguyen90stnguyen90 changed the base branch frommaster tofeat-offline-supportMarch 22, 2023 18:22
@stnguyen90
Copy link
ContributorAuthor

@lohanidamodar, I tried to move a lot of logic out of ClientOfflineMixin. What do you think?

lohanidamodar reacted with thumbs up emoji

Comment on lines +40 to +114
if (params.containsKey('queries')) {
final queries = params['queries'] as List<dynamic>;
queries.forEach((query) {
final q = Query.parse(query as String);

switch (q.method) {
case 'equal':
final value = q.params[1];
if (value is List) {
value.forEach((v) {
final List<Filter> equalFilters = [];
value.forEach((v) {
equalFilters.add(Filter.equals(q.params[0], v));
});
filters.add(Filter.or(equalFilters));
});
} else {
filters.add(Filter.equals(q.params[0], q.params[1]));
}
break;

case 'notEqual':
filters.add(Filter.notEquals(q.params[0], q.params[1]));
break;

case 'lessThan':
filters.add(Filter.lessThan(q.params[0], q.params[1]));
break;

case 'lessThanEqual':
filters.add(Filter.lessThanOrEquals(q.params[0], q.params[1]));
break;

case 'greaterThan':
filters.add(Filter.greaterThan(q.params[0], q.params[1]));
break;

case 'greaterThanEqual':
filters.add(Filter.greaterThanOrEquals(q.params[0], q.params[1]));
break;

case 'search':
filters.add(Filter.matches(q.params[0], r'${q.params[1]}+'));
break;

case 'orderAsc':
sortOrders.add(SortOrder(q.params[0] as String));
break;

case 'orderDesc':
sortOrders.add(SortOrder(q.params[0] as String, false));
break;

case 'cursorBefore':
// TODO: Handle this case.
break;

case 'cursorAfter':
// TODO: Handle this case.
break;

case 'limit':
finder.limit = q.params[0] as int;
break;
case 'offset':
finder.offset = q.params[0] as int;
break;
}
});

if (filters.isNotEmpty) {
filter = Filter.and(filters);
finder.filter = filter;
}
}
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@abnegate, here's an attempt at client-side filters of offline data.

Copy link
Member

@lohanidamodarlohanidamodar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good. However I still suggest refactoring it in a middleware approach for final release. LMK WYT.

Comment on lines +50 to +51
String method;
List<dynamic> params;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
String method;
List<dynamic> params;
finalString method;
finalList<dynamic> params;

I think these can be final

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@lohanidamodarlohanidamodarlohanidamodar left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@stnguyen90@lohanidamodar

[8]ページ先頭

©2009-2025 Movatter.jp