Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change delete icon to archive #327

Merged
merged 1 commit into from
Jul 21, 2023
Merged

Conversation

imGok
Copy link
Contributor

@imGok imGok commented Jul 18, 2023

image

This Closes #326

@hoangdat
Copy link
Member

please also change the function from delete to archive also, Twake will not support delete

@imGok
Copy link
Contributor Author

imGok commented Jul 19, 2023

please also change the function from delete to archive also, Twake will not support delete

Current action is room.leave()

API call :

  /// This API stops a user participating in a particular room.
  ///
  /// If the user was already in the room, they will no longer be able to see
  /// new events in the room. If the room requires an invite to join, they
  /// will need to be re-invited before they can re-join.
  ///
  /// If the user was invited to the room, but had not joined, this call
  /// serves to reject the invite.
  ///
  /// The user will still be allowed to retrieve history from the room which
  /// they were previously allowed to see.
  ///
  /// [roomId] The room identifier to leave.
  ///
  /// [reason] Optional reason to be included as the `reason` on the subsequent
  /// membership event.
  Future<void> leaveRoom(String roomId, {String? reason}) async {
    final requestUri = Uri(
        path: '_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/leave');
    final request = Request('POST', baseUri!.resolveUri(requestUri));
    request.headers['authorization'] = 'Bearer ${bearerToken!}';
    request.headers['content-type'] = 'application/json';
    request.bodyBytes = utf8.encode(jsonEncode({
      if (reason != null) 'reason': reason,
    }));
    final response = await httpClient.send(request);
    final responseBody = await response.stream.toBytes();
    if (response.statusCode != 200) unexpectedResponse(response, responseBody);
    final responseString = utf8.decode(responseBody);
    final json = jsonDecode(responseString);
    return ignore(json);
  }

and archived is just a room you left

  /// Is the room archived
  bool get isArchived => membership == Membership.leave;

@hoangdat hoangdat merged commit efcbd1e into main Jul 21, 2023
2 checks passed
@hoangdat hoangdat deleted the tw_326_remove_delete_archive branch August 8, 2023 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Delete Chat button and Chagne it to Archive for chats
4 participants