Skip to content

Commit

Permalink
Add started filter
Browse files Browse the repository at this point in the history
  • Loading branch information
0x16c3 committed Apr 22, 2022
1 parent 14c8c9a commit 9d4d4fd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
38 changes: 34 additions & 4 deletions cogs/api/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ async def channel_insert(self, items: List[Any]) -> None:
loop = asyncio.get_event_loop()

for item in items:
for status in ["progress", "completion", "planning", "dropped", "paused"]:
for status in [
"progress",
"started",
"completion",
"planning",
"dropped",
"paused",
]:
if not f"list_block_{status}" in item:
item[f"list_block_{status}"] = False

Expand All @@ -58,7 +65,14 @@ async def channel_insert(self, items: List[Any]) -> None:
async def channel_update(self, id, item: Any) -> None:
loop = asyncio.get_event_loop()

for status in ["progress", "completion", "planning", "dropped", "paused"]:
for status in [
"progress",
"started",
"completion",
"planning",
"dropped",
"paused",
]:
if not f"list_block_{status}" in item:
item[f"list_block_{status}"] = False

Expand All @@ -78,7 +92,14 @@ async def channel_repair(self, id) -> None:
loop = asyncio.get_event_loop()
channel = self.channels.get(where("channel") == int(id))

for status in ["progress", "completion", "planning", "dropped", "paused"]:
for status in [
"progress",
"started",
"completion",
"planning",
"dropped",
"paused",
]:
if not f"list_block_{status}" in channel:
channel[f"list_block_{status}"] = False

Expand All @@ -97,7 +118,14 @@ async def channel_repair(self, id) -> None:
async def _channel_remove(self, item: Any) -> bool:
loop = asyncio.get_event_loop()

for status in ["progress", "completion", "planning", "dropped", "paused"]:
for status in [
"progress",
"started",
"completion",
"planning",
"dropped",
"paused",
]:
if not f"list_block_{status}" in item:
item[f"list_block_{status}"] = False

Expand All @@ -108,6 +136,8 @@ async def _channel_remove(self, item: Any) -> bool:
(
(where("channel") == item["channel"])
& (where("list_block_progress") == item["list_block_progress"])
& (where("list_block_started") == item["list_block_started"])
& (where("list_block_completion") == item["list_block_completion"])
& (where("list_block_planning") == item["list_block_planning"])
& (where("list_block_dropped") == item["list_block_dropped"])
& (where("list_block_paused") == item["list_block_paused"])
Expand Down
4 changes: 3 additions & 1 deletion cogs/api/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ async def send_embed(
"CURRENT",
"REPEATING",
] or item.status in ["REWATCHED", "REREAD"]:
if ch["list_block_progress"]:
if listitem.progress <= 1 and ch["list_block_started"]:
return None
elif ch["list_block_progress"]:
return None
elif listitem.status in ["COMPLETED"]:
if ch["list_block_completion"]:
Expand Down
20 changes: 15 additions & 5 deletions cogs/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ async def _filter(self, ctx: SlashContext):
current = {
"channel": ctx.channel.id,
"list_block_progress": False,
"list_block_started": False,
"list_block_completion": False,
"list_block_planning": False,
"list_block_dropped": False,
Expand All @@ -1045,9 +1046,16 @@ async def _filter(self, ctx: SlashContext):
value=i,
default=not current[f"list_block_{i}"],
)
for i in ["progress", "completion", "planning", "dropped", "paused"]
for i in [
"progress",
"started",
"completion",
"planning",
"dropped",
"paused",
]
],
max_values=5,
max_values=6,
placeholder="Filter enabled list activities for this channel.",
)
actionrow = create_actionrow(select)
Expand All @@ -1071,7 +1079,7 @@ def check_author(cctx: ComponentContext):
selected: List[str] = [i for i in button_ctx.selected_options]
await button_ctx.defer(edit_origin=True)

for i in ["progress", "planning", "dropped", "paused"]:
for i in ["progress", "started", "planning", "dropped", "paused"]:
if i in selected and current[f"list_block_{i}"]:
current[f"list_block_{i}"] = False
elif i not in selected and not current[f"list_block_{i}"]:
Expand All @@ -1098,13 +1106,14 @@ def check_author(cctx: ComponentContext):
)
for i in [
"progress",
"started",
"completion",
"planning",
"dropped",
"paused",
]
],
max_values=5,
max_values=6,
placeholder="Filter enabled list activities for this channel.",
)
actionrow = create_actionrow(select)
Expand All @@ -1123,13 +1132,14 @@ def check_author(cctx: ComponentContext):
)
for i in [
"progress",
"started",
"completion",
"planning",
"dropped",
"paused",
]
],
max_values=5,
max_values=6,
placeholder="Filter enabled list activities for this channel.",
disabled=True,
)
Expand Down

0 comments on commit 9d4d4fd

Please sign in to comment.