~tardypad/wee-most

a8efc60db2fb93a7959091269fa29cc5d90515d1 — Damien Tardy-Panis 3 months ago 01ae7c6
Remove buffer argument from add/remove reaction functions

Buffer can be accessed from post object
2 files changed, 6 insertions(+), 8 deletions(-)

M wee_most/post.py
M wee_most/websocket.py
M wee_most/post.py => wee_most/post.py +4 -2
@@ 381,7 381,8 @@ def find_buffer_first_post_line_data(buffer, post_id):
            break
        line_data = weechat.hdata_pointer(weechat.hdata_get("line"), line, "data")

def add_reaction_to_post(buffer, reaction):
def add_reaction_to_post(reaction):
    buffer = reaction.post.channel.buffer
    line_data = find_buffer_last_post_line_data(buffer, reaction.post.id)

    tags = get_line_data_tags(line_data)


@@ 402,7 403,8 @@ def add_reaction_to_post(buffer, reaction):
        }
    )

def remove_reaction_from_post(buffer, reaction):
def remove_reaction_from_post(reaction):
    buffer = reaction.post.channel.buffer
    line_data = find_buffer_last_post_line_data(buffer, reaction.post.id)

    tags = get_line_data_tags(line_data)

M wee_most/websocket.py => wee_most/websocket.py +2 -6
@@ 136,10 136,8 @@ def handle_reaction_added_message(server, message):
    reaction_data = json.loads(data["reaction"])

    reaction = wee_most.post.Reaction(server, **reaction_data)
    post = server.get_post(reaction_data["post_id"])
    buffer = post.channel.buffer

    wee_most.post.add_reaction_to_post(buffer, reaction)
    wee_most.post.add_reaction_to_post(reaction)

def handle_reaction_removed_message(server, message):
    data = message["data"]


@@ 147,10 145,8 @@ def handle_reaction_removed_message(server, message):
    reaction_data = json.loads(data["reaction"])

    reaction = wee_most.post.Reaction(server, **reaction_data)
    post = server.get_post(reaction_data["post_id"])
    buffer = post.channel.buffer

    wee_most.post.remove_reaction_from_post(buffer, reaction)
    wee_most.post.remove_reaction_from_post(reaction)

def handle_post_edited_message(server, message):
    data = message["data"]