setMainImageByHash<DataT extends Data> method
sets an image specified by its hash as the new main image
Implementation
Future<String?> setMainImageByHash<DataT extends Data>(
DataT? data,
String mainhash, {
Data? caller,
bool forceUpdate = false,
}) async {
//offline procedure, needs some stuff changed and added..
if ((forceUpdate || caller != null) && data != null) {
try {
// remove new main image from list
data.imagehashes!.remove(mainhash);
//reinstert old main image to list
if (data.mainhash != null) data.imagehashes!.insert(0, data.mainhash!);
//set new main image
data.mainhash = mainhash;
debugPrint('set main image hash to $mainhash');
await storeData<DataT>(data, forId: caller?.id ?? await API().rootID);
// return 'successfully set main image offline';
} catch (e) {
debugPrint('failed to update main image locally');
}
}
return null;
}