Add additional account restore logging, prevent double avatar fetch.
This commit is contained in:
parent
67a8ec0d39
commit
9d39db6428
2 changed files with 30 additions and 6 deletions
|
@ -1,11 +1,14 @@
|
|||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.app.job.JobScheduler;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobTracker;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
|
@ -67,6 +70,7 @@ public class StorageAccountRestoreJob extends BaseJob {
|
|||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
StorageKey storageServiceKey = SignalStore.storageServiceValues().getOrCreateStorageKey();
|
||||
|
||||
Log.i(TAG, "Retrieving manifest...");
|
||||
Optional<SignalStorageManifest> manifest = accountManager.getStorageManifest(storageServiceKey);
|
||||
|
||||
if (!manifest.isPresent()) {
|
||||
|
@ -82,6 +86,7 @@ public class StorageAccountRestoreJob extends BaseJob {
|
|||
return;
|
||||
}
|
||||
|
||||
Log.i(TAG, "Retrieving account record...");
|
||||
List<SignalStorageRecord> records = accountManager.readStorageRecords(storageServiceKey, Collections.singletonList(accountId.get()));
|
||||
SignalStorageRecord record = records.size() > 0 ? records.get(0) : null;
|
||||
|
||||
|
@ -96,16 +101,34 @@ public class StorageAccountRestoreJob extends BaseJob {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
Log.i(TAG, "Applying changes locally...");
|
||||
StorageId selfStorageId = StorageId.forAccount(Recipient.self().getStorageServiceId());
|
||||
StorageSyncHelper.applyAccountStorageSyncUpdates(context, selfStorageId, accountRecord);
|
||||
StorageSyncHelper.applyAccountStorageSyncUpdates(context, selfStorageId, accountRecord, false);
|
||||
|
||||
JobManager jobManager = ApplicationDependencies.getJobManager();
|
||||
|
||||
if (accountRecord.getAvatarUrlPath().isPresent()) {
|
||||
jobManager.runSynchronously(new RetrieveProfileAvatarJob(Recipient.self(), accountRecord.getAvatarUrlPath().get()), LIFESPAN/2);
|
||||
Log.i(TAG, "Fetching avatar...");
|
||||
Optional<JobTracker.JobState> state = jobManager.runSynchronously(new RetrieveProfileAvatarJob(Recipient.self(), accountRecord.getAvatarUrlPath().get()), LIFESPAN/2);
|
||||
|
||||
if (state.isPresent()) {
|
||||
Log.i(TAG, "Avatar retrieved successfully. " + state.get());
|
||||
} else {
|
||||
Log.w(TAG, "Avatar retrieval did not complete in time (or otherwise failed).");
|
||||
}
|
||||
} else {
|
||||
Log.i(TAG, "No avatar present. Not fetching.");
|
||||
}
|
||||
|
||||
jobManager.runSynchronously(new RefreshAttributesJob(), LIFESPAN/2);
|
||||
Log.i(TAG, "Refreshing attributes...");
|
||||
Optional<JobTracker.JobState> state = jobManager.runSynchronously(new RefreshAttributesJob(), LIFESPAN/2);
|
||||
|
||||
if (state.isPresent()) {
|
||||
Log.i(TAG, "Attributes refreshed successfully. " + state.get());
|
||||
} else {
|
||||
Log.w(TAG, "Attribute refresh did not complete in time (or otherwise failed).");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -404,10 +404,10 @@ public final class StorageSyncHelper {
|
|||
if (!update.isPresent()) {
|
||||
return;
|
||||
}
|
||||
applyAccountStorageSyncUpdates(context, update.get().getOld().getId(), update.get().getNew());
|
||||
applyAccountStorageSyncUpdates(context, update.get().getOld().getId(), update.get().getNew(), true);
|
||||
}
|
||||
|
||||
public static void applyAccountStorageSyncUpdates(@NonNull Context context, @NonNull StorageId storageId, @NonNull SignalAccountRecord update) {
|
||||
public static void applyAccountStorageSyncUpdates(@NonNull Context context, @NonNull StorageId storageId, @NonNull SignalAccountRecord update, boolean fetchProfile) {
|
||||
DatabaseFactory.getRecipientDatabase(context).applyStorageSyncUpdates(storageId, update);
|
||||
DatabaseFactory.getThreadDatabase(context).setArchived(Recipient.self().getId(), update.isNoteToSelfArchived());
|
||||
|
||||
|
@ -415,7 +415,8 @@ public final class StorageSyncHelper {
|
|||
TextSecurePreferences.setTypingIndicatorsEnabled(context, update.isTypingIndicatorsEnabled());
|
||||
TextSecurePreferences.setShowUnidentifiedDeliveryIndicatorsEnabled(context, update.isSealedSenderIndicatorsEnabled());
|
||||
TextSecurePreferences.setLinkPreviewsEnabled(context, update.isLinkPreviewsEnabled());
|
||||
if (update.getAvatarUrlPath().isPresent()) {
|
||||
|
||||
if (fetchProfile && update.getAvatarUrlPath().isPresent()) {
|
||||
ApplicationDependencies.getJobManager().add(new RetrieveProfileAvatarJob(Recipient.self(), update.getAvatarUrlPath().get()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue