def get_similar(data=None, error=None): if data is not None and not error: cmd = Command(data) cmd.poll_until_complete(1000) cmd.poll_progress(callback=this.get_similar_progress) cmd.set_callback(this.get_similar_value) elif error: state.app.notif("Failed to fetch similar galleries ({})".format( this.state.id), level="error")
def thumbnail_get_thumb(data=None, error=None): if not this.mounted: return if data is not None and not error: cmd_id = data[str(this.props.item_id)] if cmd_id: cmd = Command(cmd_id) this.setState({'active_cmd': cmd}) cmd.set_callback(this.set_thumb) cmd.poll_until_complete(500) elif error: pass else: if this.state.active_cmd: this.state.active_cmd.stop() this.setState({'active_cmd': None}) if this.props.item_id and this.props.size_type and this.props.item_type: client.call_func("get_image", this.get_thumb, item_ids=[this.props.item_id], size=this.props.size_type, url=True, uri=True, item_type=this.props.item_type) s = {'loading': True} if this.state.placeholder: s['img'] = this.state.placeholder this.setState(s)
def submit_view(data=None, error=None): if data is not None and not error: this.view_cmd = Command(data, daemon=False) this.view_cmd.poll_progress(interval=200, callback=this.on_view_progress) elif error: state.app.notif("Failed to submit temporary view", level="error") else: if this.state.view_id: this.setState({'view_loading': True, 'view_data': {}}) client.call_func( "submit_temporary_view", this.submit_view, view_type=TemporaryViewType.GalleryAddition, view_id=this.state.view_id, )
def submit_gallery(data=None, error=None): if data is not None and not error: this.submit_txt = tr(this, "ui.t-new-gallery-added", "A new gallery was added"), Command(data, daemon=False).poll_progress(interval=200, callback=this.on_submitted) elif error: state.app.notif("Failed to submit new gallery", level="error") this.setState({'submitting': False}) else: if this.state.data.gallery: this.setState({'submitting': True}) client.call_func( "new_item", this.submit_gallery, item_type=ItemType.Gallery, item=this.state.data.gallery, options=this.state.options, )
def get_thumbs(data=None, error=None, other=None): if data is not None and not error: this.cmd_data = data cmd = Command(list(dict(data).values())) cmd.set_callback(this.set_thumbs) cmd.poll_until_complete(500) elif error: pass else: if other: item_ids = [x.id for x in other] client.call_func("get_image", this.get_thumbs, item_ids=item_ids, size=this.state.image_size, url=True, uri=True, item_type=this.state.item_type)
def scan_galleries(data=None, error=None): if data is not None and not error: utils.session_storage.set("scan_view_id", data['view_id']) this.setState({'view_id': data['view_id']}) this.scan_cmd = Command(data['command_id'], daemon=False) this.scan_cmd.poll_progress(interval=200, callback=this.on_scan_progress) elif error: state.app.notif("Failed to scan for galleries", level="error") else: this.setState({'view_progress_data': None}) if this.state.path: utils.session_storage.set("scan_view_id", None) client.call_func("scan_galleries", this.scan_galleries, path=this.state.path) this.setState({ 'submitted_path': this.state.path, 'loading': True, 'view_id': None })