itemsDelete method

dynamic itemsDelete()

Implementation

itemsDelete() {
  DialogUtils.showAlert(
      dialogStyle: AppStyleConfig.dialogStyle,
      message: getTranslated("deleteSelectedChats")
          .replaceFirst("%d", "${selectedChatsPosition.length}"),
      actions: [
        TextButton(
            style: AppStyleConfig.dialogStyle.buttonStyle,
            onPressed: () {
              NavUtils.back();
            },
            child: Text(
              getTranslated("no"),
            )),
        TextButton(
            style: AppStyleConfig.dialogStyle.buttonStyle,
            onPressed: () async {
              NavUtils.back();
              Mirrorfly.deleteRecentChats(
                  jidList: selectedChats,
                  flyCallBack: (FlyResponse response) {
                    if (response.isSuccess) {
                      for (var chatItem in selectedChats) {
                        var chatIndex = recentChats
                            .indexWhere((element) => chatItem == element.jid);
                        recentChats.removeAt(chatIndex);
                      }
                      updateUnReadChatCount();
                      clearAllChatSelection();
                    }
                  });
            },
            child: Text(
              getTranslated("yes"),
            )),
      ]);
}