import FileManager from "./base/file-manager";

// export default class ImageManager extends FileManager {
//     constructor(page) {
//         super(page);
//         this._page.imageClickEvent = function (e) {
//             wx.previewImage({
//                 current: e.currentTarget.dataset.url, // 当前显示图片的http链接
//                 urls: [e.currentTarget.dataset.url] // 需要预览的图片http链接列表
//             })
//         }
//     }
// }

export default class ImageManager {
  constructor(page) {
    this._page = page;
    // super(page);
    this._page.imageClickEvent = function (e) {
      wx.previewImage({
        current: e.currentTarget.dataset.url, // 当前显示图片的http链接
        urls: [e.currentTarget.dataset.url] // 需要预览的图片http链接列表
      })
    }
  }

  /**
   * 发送文件类型消息
   * @param type 消息类型
   * @param content 由输入组件接收到的临时文件路径
   * @param duration 由输入组件接收到的录音时间
   */
  sendOneMsg({ type, content, duration }) {
    const temp = this._page.imOperator.createNormalChatItem({
      type,
      content,
      duration
    });
    this._page.UI.showItemForMoment(temp, (itemIndex) => {
      this._page.sendMsg({
        content: this._page.imOperator.createChatItemContent({ type, content, duration }),
        itemIndex,
        success: (msg) => {
          // FileSaveManager.set(msg, content);
        }
      });
      // this.uploadFileAndSend({ content, duration, itemIndex, type })
    });
  }
}